Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/ssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4304 - (show annotations) (download) (as text)
Mon Feb 14 09:09:07 2011 UTC (13 years, 1 month ago) by maya
Original Path: trunk/ttssh2/ttxssh/ssh.h
File MIME type: text/x-chdr
File size: 19920 byte(s)
ssh.c から key.c, kex.c を分割
1 /*
2 Copyright (c) 1998-2001, Robert O'Callahan
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this list
12 of conditions and the following disclaimer in the documentation and/or other materials
13 provided with the distribution.
14
15 The name of Robert O'Callahan may not be used to endorse or promote products derived from
16 this software without specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 This code is copyright (C) 1998-1999 Robert O'Callahan.
31 See LICENSE.TXT for the license.
32 */
33
34 #ifndef __SSH_H
35 #define __SSH_H
36
37 #include "zlib.h"
38 #include <openssl/evp.h>
39
40 #include "buffer.h"
41
42 #define DEBUG_PRINT_TO_FILE(base, msg, len) { \
43 static int count = 0; \
44 debug_print(count + base, msg, len); \
45 count++; \
46 }
47
48 // from OpenSSH
49 extern const EVP_CIPHER *evp_aes_128_ctr(void);
50 extern const EVP_CIPHER *evp_des3_ctr(void);
51 extern const EVP_CIPHER *evp_bf_ctr(void);
52 extern const EVP_CIPHER *evp_cast5_ctr(void);
53
54 // yutaka
55 #define SSH2_USE
56
57
58 /* Some of this code has been adapted from Ian Goldberg's Pilot SSH */
59
60 typedef enum {
61 SSH_MSG_NONE, SSH_MSG_DISCONNECT, SSH_SMSG_PUBLIC_KEY, //2
62 SSH_CMSG_SESSION_KEY, SSH_CMSG_USER, SSH_CMSG_AUTH_RHOSTS, // 5
63 SSH_CMSG_AUTH_RSA, SSH_SMSG_AUTH_RSA_CHALLENGE,
64 SSH_CMSG_AUTH_RSA_RESPONSE, SSH_CMSG_AUTH_PASSWORD,
65 SSH_CMSG_REQUEST_PTY, // 10
66 SSH_CMSG_WINDOW_SIZE, SSH_CMSG_EXEC_SHELL,
67 SSH_CMSG_EXEC_CMD, SSH_SMSG_SUCCESS, SSH_SMSG_FAILURE,
68 SSH_CMSG_STDIN_DATA, SSH_SMSG_STDOUT_DATA, SSH_SMSG_STDERR_DATA,
69 SSH_CMSG_EOF, SSH_SMSG_EXITSTATUS,
70 SSH_MSG_CHANNEL_OPEN_CONFIRMATION, SSH_MSG_CHANNEL_OPEN_FAILURE,
71 SSH_MSG_CHANNEL_DATA, SSH_MSG_CHANNEL_INPUT_EOF,
72 SSH_MSG_CHANNEL_OUTPUT_CLOSED, SSH_MSG_OBSOLETED0,
73 SSH_SMSG_X11_OPEN, SSH_CMSG_PORT_FORWARD_REQUEST, SSH_MSG_PORT_OPEN,
74 SSH_CMSG_AGENT_REQUEST_FORWARDING, SSH_SMSG_AGENT_OPEN,
75 SSH_MSG_IGNORE, SSH_CMSG_EXIT_CONFIRMATION,
76 SSH_CMSG_X11_REQUEST_FORWARDING, SSH_CMSG_AUTH_RHOSTS_RSA,
77 SSH_MSG_DEBUG, SSH_CMSG_REQUEST_COMPRESSION,
78 SSH_CMSG_MAX_PACKET_SIZE, SSH_CMSG_AUTH_TIS,
79 SSH_SMSG_AUTH_TIS_CHALLENGE, SSH_CMSG_AUTH_TIS_RESPONSE,
80 SSH_CMSG_AUTH_KERBEROS, SSH_SMSG_AUTH_KERBEROS_RESPONSE
81 } SSHMessage;
82
83 typedef enum {
84 SSH_CIPHER_NONE, SSH_CIPHER_IDEA, SSH_CIPHER_DES, SSH_CIPHER_3DES,
85 SSH_CIPHER_TSS, SSH_CIPHER_RC4, SSH_CIPHER_BLOWFISH,
86 // for SSH2
87 SSH2_CIPHER_3DES_CBC, SSH2_CIPHER_AES128_CBC,
88 SSH2_CIPHER_AES192_CBC, SSH2_CIPHER_AES256_CBC,
89 SSH2_CIPHER_BLOWFISH_CBC, SSH2_CIPHER_AES128_CTR,
90 SSH2_CIPHER_AES192_CTR, SSH2_CIPHER_AES256_CTR,
91 SSH2_CIPHER_ARCFOUR, SSH2_CIPHER_ARCFOUR128, SSH2_CIPHER_ARCFOUR256,
92 SSH2_CIPHER_CAST128_CBC,
93 SSH2_CIPHER_3DES_CTR, SSH2_CIPHER_BLOWFISH_CTR, SSH2_CIPHER_CAST128_CTR,
94 } SSHCipher;
95
96 #define SSH_CIPHER_MAX SSH2_CIPHER_CAST128_CTR
97
98 typedef enum {
99 SSH_AUTH_NONE, SSH_AUTH_RHOSTS, SSH_AUTH_RSA, SSH_AUTH_PASSWORD,
100 SSH_AUTH_RHOSTS_RSA, SSH_AUTH_TIS, SSH_AUTH_KERBEROS,
101 SSH_AUTH_PAGEANT = 16,
102 } SSHAuthMethod;
103
104 #define SSH_AUTH_MAX SSH_AUTH_PAGEANT
105
106 typedef enum {
107 SSH_GENERIC_AUTHENTICATION, SSH_TIS_AUTHENTICATION
108 } SSHAuthMode;
109
110 #define SSH_PROTOFLAG_SCREEN_NUMBER 1
111 #define SSH_PROTOFLAG_HOST_IN_FWD_OPEN 2
112
113 enum channel_type {
114 TYPE_SHELL, TYPE_PORTFWD, TYPE_SCP, TYPE_SFTP, TYPE_AGENT,
115 };
116
117 // for SSH1
118 #define SSH_MAX_SEND_PACKET_SIZE 250000
119
120 // for SSH2
121 /* default window/packet sizes for tcp/x11-fwd-channel */
122 // changed CHAN_SES_WINDOW_DEFAULT from 32KB to 128KB. (2007.10.29 maya)
123 #define CHAN_SES_PACKET_DEFAULT (32*1024)
124 #define CHAN_SES_WINDOW_DEFAULT (4*CHAN_SES_PACKET_DEFAULT)
125 #define CHAN_TCP_PACKET_DEFAULT (32*1024)
126 #define CHAN_TCP_WINDOW_DEFAULT (4*CHAN_TCP_PACKET_DEFAULT)
127 #if 0 // unused
128 #define CHAN_X11_PACKET_DEFAULT (16*1024)
129 #define CHAN_X11_WINDOW_DEFAULT (4*CHAN_X11_PACKET_DEFAULT)
130 #endif
131
132
133 /* SSH2 constants */
134
135 /* SSH2 messages */
136 #define SSH2_MSG_DISCONNECT 1
137 #define SSH2_MSG_IGNORE 2
138 #define SSH2_MSG_UNIMPLEMENTED 3
139 #define SSH2_MSG_DEBUG 4
140 #define SSH2_MSG_SERVICE_REQUEST 5
141 #define SSH2_MSG_SERVICE_ACCEPT 6
142
143 #define SSH2_MSG_KEXINIT 20
144 #define SSH2_MSG_NEWKEYS 21
145
146 #define SSH2_MSG_KEXDH_INIT 30
147 #define SSH2_MSG_KEXDH_REPLY 31
148
149 #define SSH2_MSG_KEX_DH_GEX_GROUP 31
150 #define SSH2_MSG_KEX_DH_GEX_INIT 32
151 #define SSH2_MSG_KEX_DH_GEX_REPLY 33
152 #define SSH2_MSG_KEX_DH_GEX_REQUEST 34
153
154 #define SSH2_MSG_USERAUTH_REQUEST 50
155 #define SSH2_MSG_USERAUTH_FAILURE 51
156 #define SSH2_MSG_USERAUTH_SUCCESS 52
157 #define SSH2_MSG_USERAUTH_BANNER 53
158
159 #define SSH2_MSG_USERAUTH_PK_OK 60
160 #define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60
161 #define SSH2_MSG_USERAUTH_INFO_REQUEST 60
162 #define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
163
164 #define SSH2_MSG_GLOBAL_REQUEST 80
165 #define SSH2_MSG_REQUEST_SUCCESS 81
166 #define SSH2_MSG_REQUEST_FAILURE 82
167 #define SSH2_MSG_CHANNEL_OPEN 90
168 #define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91
169 #define SSH2_MSG_CHANNEL_OPEN_FAILURE 92
170 #define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93
171 #define SSH2_MSG_CHANNEL_DATA 94
172 #define SSH2_MSG_CHANNEL_EXTENDED_DATA 95
173 #define SSH2_MSG_CHANNEL_EOF 96
174 #define SSH2_MSG_CHANNEL_CLOSE 97
175 #define SSH2_MSG_CHANNEL_REQUEST 98
176 #define SSH2_MSG_CHANNEL_SUCCESS 99
177 #define SSH2_MSG_CHANNEL_FAILURE 100
178
179 /* SSH2 miscellaneous constants */
180 #define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1
181 #define SSH2_DISCONNECT_PROTOCOL_ERROR 2
182 #define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED 3
183 #define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED 4
184 #define SSH2_DISCONNECT_MAC_ERROR 5
185 #define SSH2_DISCONNECT_COMPRESSION_ERROR 6
186 #define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE 7
187 #define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8
188 #define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9
189 #define SSH2_DISCONNECT_CONNECTION_LOST 10
190 #define SSH2_DISCONNECT_BY_APPLICATION 11
191
192 #define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED 1
193 #define SSH2_OPEN_CONNECT_FAILED 2
194 #define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE 3
195 #define SSH2_OPEN_RESOURCE_SHORTAGE 4
196
197 enum hostkey_type {
198 KEY_RSA1,
199 KEY_RSA,
200 KEY_DSA,
201 KEY_UNSPEC,
202 };
203
204 #define KEX_DEFAULT_KEX "diffie-hellman-group-exchange-sha256," \
205 "diffie-hellman-group-exchange-sha1," \
206 "diffie-hellman-group14-sha1," \
207 "diffie-hellman-group1-sha1"
208 #define KEX_DEFAULT_PK_ALG "ssh-rsa,ssh-dss"
209 // use the setting of pvar.CipherOrder.
210 #define KEX_DEFAULT_ENCRYPT ""
211 #define KEX_DEFAULT_MAC "hmac-sha1,hmac-md5"
212 // support of "Compression delayed" (2006.6.23 maya)
213 #define KEX_DEFAULT_COMP "none,zlib@openssh.com,zlib"
214 #define KEX_DEFAULT_LANG ""
215
216 /* Minimum modulus size (n) for RSA keys. */
217 #define SSH_RSA_MINIMUM_MODULUS_SIZE 768
218
219 #define SSH_KEYGEN_DEFAULT_BITS 2048
220 #define SSH_RSA_MINIMUM_KEY_SIZE 768
221 #define SSH_DSA_MINIMUM_KEY_SIZE 1024
222
223 enum kex_init_proposals {
224 PROPOSAL_KEX_ALGS,
225 PROPOSAL_SERVER_HOST_KEY_ALGS,
226 PROPOSAL_ENC_ALGS_CTOS,
227 PROPOSAL_ENC_ALGS_STOC,
228 PROPOSAL_MAC_ALGS_CTOS,
229 PROPOSAL_MAC_ALGS_STOC,
230 PROPOSAL_COMP_ALGS_CTOS,
231 PROPOSAL_COMP_ALGS_STOC,
232 PROPOSAL_LANG_CTOS,
233 PROPOSAL_LANG_STOC,
234 PROPOSAL_MAX
235 };
236
237
238 // �N���C�A���g�����T�[�o������������
239 #ifdef SSH2_DEBUG
240 static char *myproposal[PROPOSAL_MAX] = {
241 // KEX_DEFAULT_KEX,
242 "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256",
243 KEX_DEFAULT_PK_ALG,
244 // "ssh-dss,ssh-rsa",
245 KEX_DEFAULT_ENCRYPT,
246 KEX_DEFAULT_ENCRYPT,
247 "hmac-md5,hmac-sha1",
248 "hmac-md5,hmac-sha1",
249 // "hmac-sha1",
250 // "hmac-sha1",
251 // KEX_DEFAULT_MAC,
252 // KEX_DEFAULT_MAC,
253 KEX_DEFAULT_COMP,
254 KEX_DEFAULT_COMP,
255 KEX_DEFAULT_LANG,
256 KEX_DEFAULT_LANG,
257 };
258 #else
259 static char *myproposal[PROPOSAL_MAX] = {
260 KEX_DEFAULT_KEX,
261 KEX_DEFAULT_PK_ALG,
262 KEX_DEFAULT_ENCRYPT,
263 KEX_DEFAULT_ENCRYPT,
264 KEX_DEFAULT_MAC,
265 KEX_DEFAULT_MAC,
266 KEX_DEFAULT_COMP,
267 KEX_DEFAULT_COMP,
268 KEX_DEFAULT_LANG,
269 KEX_DEFAULT_LANG,
270 };
271 #endif
272
273
274 typedef struct ssh2_cipher {
275 SSHCipher cipher;
276 char *name;
277 int block_size;
278 int key_len;
279 int discard_len;
280 const EVP_CIPHER *(*func)(void);
281 } ssh2_cipher_t;
282
283 static ssh2_cipher_t ssh2_ciphers[] = {
284 {SSH2_CIPHER_3DES_CBC, "3des-cbc", 8, 24, 0, EVP_des_ede3_cbc},
285 {SSH2_CIPHER_AES128_CBC, "aes128-cbc", 16, 16, 0, EVP_aes_128_cbc},
286 {SSH2_CIPHER_AES192_CBC, "aes192-cbc", 16, 24, 0, EVP_aes_192_cbc},
287 {SSH2_CIPHER_AES256_CBC, "aes256-cbc", 16, 32, 0, EVP_aes_256_cbc},
288 {SSH2_CIPHER_BLOWFISH_CBC, "blowfish-cbc", 8, 16, 0, EVP_bf_cbc},
289 {SSH2_CIPHER_AES128_CTR, "aes128-ctr", 16, 16, 0, evp_aes_128_ctr},
290 {SSH2_CIPHER_AES192_CTR, "aes192-ctr", 16, 24, 0, evp_aes_128_ctr},
291 {SSH2_CIPHER_AES256_CTR, "aes256-ctr", 16, 32, 0, evp_aes_128_ctr},
292 {SSH2_CIPHER_ARCFOUR, "arcfour", 8, 16, 0, EVP_rc4},
293 {SSH2_CIPHER_ARCFOUR128, "arcfour128", 8, 16, 1536, EVP_rc4},
294 {SSH2_CIPHER_ARCFOUR256, "arcfour256", 8, 32, 1536, EVP_rc4},
295 {SSH2_CIPHER_CAST128_CBC, "cast128-cbc", 8, 16, 0, EVP_cast5_cbc},
296 {SSH2_CIPHER_3DES_CTR, "3des-ctr", 8, 24, 0, evp_des3_ctr},
297 {SSH2_CIPHER_BLOWFISH_CTR, "blowfish-ctr", 8, 16, 0, evp_bf_ctr},
298 {SSH2_CIPHER_CAST128_CTR, "cast128-ctr", 8, 16, 0, evp_cast5_ctr},
299 {SSH_CIPHER_NONE, NULL, 0, 0, 0, NULL},
300 };
301
302
303 // ���L���C���f�b�N�X�� ssh2_kex_algorithms[] ���������������B
304 enum kex_algorithm {
305 KEX_DH_GRP1_SHA1,
306 KEX_DH_GRP14_SHA1,
307 KEX_DH_GEX_SHA1,
308 KEX_DH_GEX_SHA256,
309 KEX_DH_UNKNOWN,
310 };
311
312 typedef struct ssh2_kex_algorithm {
313 enum kex_algorithm kextype;
314 char *name;
315 const EVP_MD *(*evp_md)(void);
316 } ssh2_kex_algorithm_t;
317
318 static ssh2_kex_algorithm_t ssh2_kex_algorithms[] = {
319 {KEX_DH_GRP1_SHA1, "diffie-hellman-group1-sha1", EVP_sha1},
320 {KEX_DH_GRP14_SHA1, "diffie-hellman-group14-sha1", EVP_sha1},
321 {KEX_DH_GEX_SHA1, "diffie-hellman-group-exchange-sha1", EVP_sha1},
322 {KEX_DH_GEX_SHA256, "diffie-hellman-group-exchange-sha256", EVP_sha256},
323 {KEX_DH_UNKNOWN , NULL , NULL},
324 };
325
326
327 // ���L���C���f�b�N�X�� ssh2_macs[] ���������������B
328 enum hmac_type {
329 HMAC_SHA1,
330 HMAC_MD5,
331 HMAC_UNKNOWN
332 };
333
334 typedef struct ssh2_mac {
335 enum hmac_type type;
336 char *name;
337 const EVP_MD *(*func)(void);
338 int truncatebits;
339 } ssh2_mac_t;
340
341 static ssh2_mac_t ssh2_macs[] = {
342 {HMAC_SHA1, "hmac-sha1", EVP_sha1, 0},
343 {HMAC_MD5, "hmac-md5", EVP_md5, 0},
344 {HMAC_UNKNOWN, NULL, NULL, 0},
345 };
346
347
348 // ���L���C���f�b�N�X�� ssh_comps[] ���������������B
349 enum compression_type {
350 COMP_NONE,
351 COMP_ZLIB,
352 COMP_DELAYED,
353 COMP_UNKNOWN
354 };
355
356 typedef struct ssh_comp {
357 enum compression_type type;
358 char *name;
359 } ssh_comp_t;
360
361 static ssh_comp_t ssh_comps[] = {
362 {COMP_NONE, "none"},
363 {COMP_ZLIB, "zlib"},
364 {COMP_DELAYED, "zlib@openssh.com"},
365 {COMP_UNKNOWN, NULL},
366 };
367
368
369 struct Enc {
370 u_char *key;
371 u_char *iv;
372 unsigned int key_len;
373 unsigned int block_size;
374 };
375
376 struct Mac {
377 char *name;
378 int enabled;
379 const EVP_MD *md;
380 int mac_len;
381 u_char *key;
382 int key_len;
383 };
384
385 struct Comp {
386 int type;
387 int enabled;
388 char *name;
389 };
390
391 typedef struct {
392 struct Enc enc;
393 struct Mac mac;
394 struct Comp comp;
395 } Newkeys;
396
397 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
398
399 enum kex_modes {
400 MODE_IN,
401 MODE_OUT,
402 MODE_MAX
403 };
404
405
406 // �z�X�g�L�[(SSH1, SSH2����)���f�[�^�\�� (2006.3.21 yutaka)
407 typedef struct Key {
408 // host key type
409 enum hostkey_type type;
410 // SSH2 RSA
411 RSA *rsa;
412 // SSH2 DSA
413 DSA *dsa;
414 // SSH1 RSA
415 int bits;
416 unsigned char *exp;
417 unsigned char *mod;
418 } Key;
419
420 // fingerprint������
421 enum fp_rep {
422 SSH_FP_HEX,
423 SSH_FP_BUBBLEBABBLE,
424 SSH_FP_RANDOMART
425 };
426
427 enum scp_dir {
428 TOREMOTE, FROMREMOTE,
429 };
430
431 /* The packet handler returns TRUE to keep the handler in place,
432 FALSE to remove the handler. */
433 typedef BOOL (* SSHPacketHandler)(PTInstVar pvar);
434
435 typedef struct _SSHPacketHandlerItem SSHPacketHandlerItem;
436 struct _SSHPacketHandlerItem {
437 SSHPacketHandler handler;
438 /* Circular list of handlers for given message */
439 SSHPacketHandlerItem FAR * next_for_message;
440 SSHPacketHandlerItem FAR * last_for_message;
441 /* Circular list of handlers in set */
442 SSHPacketHandlerItem FAR * next_in_set;
443 int active_for_message;
444 };
445
446 typedef struct {
447 char FAR * hostname;
448
449 int server_protocol_flags;
450 char FAR * server_ID;
451
452 /* This buffer is used to hold the outgoing data, and encrypted in-place
453 here if necessary. */
454 unsigned char FAR * outbuf;
455 long outbuflen;
456 /* This buffer is used by the SSH protocol processing to store uncompressed
457 packet data for compression. User data is never streamed through here;
458 it is compressed directly from the user's buffer. */
459 unsigned char FAR * precompress_outbuf;
460 long precompress_outbuflen;
461 /* this is the length of the packet data, including the type header */
462 long outgoing_packet_len;
463
464 /* This buffer is used by the SSH protocol processing to store decompressed
465 packet data. User data is never streamed through here; it is decompressed
466 directly to the user's buffer. */
467 unsigned char FAR * postdecompress_inbuf;
468 long postdecompress_inbuflen;
469
470 unsigned char FAR * payload;
471 long payload_grabbed;
472 long payloadlen;
473 long payload_datastart;
474 long payload_datalen;
475
476 uint32 receiver_sequence_number;
477 uint32 sender_sequence_number;
478
479 z_stream compress_stream;
480 z_stream decompress_stream;
481 BOOL compressing;
482 BOOL decompressing;
483 int compression_level;
484
485 SSHPacketHandlerItem FAR * packet_handlers[256];
486 int status_flags;
487
488 int win_cols;
489 int win_rows;
490
491 unsigned short tcpport;
492 } SSHState;
493
494 #define STATUS_DONT_SEND_USER_NAME 0x01
495 #define STATUS_EXPECTING_COMPRESSION_RESPONSE 0x02
496 #define STATUS_DONT_SEND_CREDENTIALS 0x04
497 #define STATUS_HOST_OK 0x08
498 #define STATUS_INTERACTIVE 0x10
499 #define STATUS_IN_PARTIAL_ID_STRING 0x20
500
501 void SSH_init(PTInstVar pvar);
502 void SSH_open(PTInstVar pvar);
503 void SSH_notify_disconnecting(PTInstVar pvar, char FAR * reason);
504 /* SSH_handle_server_ID returns TRUE iff a valid ID string has been
505 received. If it returns FALSE, we need to keep looking for another
506 ID string. */
507 BOOL SSH_handle_server_ID(PTInstVar pvar, char FAR * ID, int ID_len);
508 /* SSH_handle_packet requires NO PAYLOAD on entry.
509 'len' is the size of the packet: payload + padding (+ CRC for SSHv1)
510 'padding' is the size of the padding.
511 'data' points to the start of the packet data (the length field)
512 */
513 void SSH_handle_packet(PTInstVar pvar, char FAR * data, int len, int padding);
514 void SSH_notify_win_size(PTInstVar pvar, int cols, int rows);
515 void SSH_notify_user_name(PTInstVar pvar);
516 void SSH_notify_cred(PTInstVar pvar);
517 void SSH_notify_host_OK(PTInstVar pvar);
518 void SSH_send(PTInstVar pvar, unsigned char const FAR * buf, unsigned int buflen);
519 /* SSH_extract_payload returns number of bytes extracted */
520 int SSH_extract_payload(PTInstVar pvar, unsigned char FAR * dest, int len);
521 void SSH_end(PTInstVar pvar);
522
523 void SSH_get_server_ID_info(PTInstVar pvar, char FAR * dest, int len);
524 void SSH_get_protocol_version_info(PTInstVar pvar, char FAR * dest, int len);
525 void SSH_get_compression_info(PTInstVar pvar, char FAR * dest, int len);
526
527 /* len must be <= SSH_MAX_SEND_PACKET_SIZE */
528 void SSH_channel_send(PTInstVar pvar, int channel_num,
529 uint32 remote_channel_num,
530 unsigned char FAR * buf, int len);
531 void SSH_fail_channel_open(PTInstVar pvar, uint32 remote_channel_num);
532 void SSH_confirm_channel_open(PTInstVar pvar, uint32 remote_channel_num, uint32 local_channel_num);
533 void SSH_channel_output_eof(PTInstVar pvar, uint32 remote_channel_num);
534 void SSH_channel_input_eof(PTInstVar pvar, uint32 remote_channel_num, uint32 local_channel_num);
535 void SSH_request_forwarding(PTInstVar pvar, char FAR * bind_address, int from_server_port,
536 char FAR * to_local_host, int to_local_port);
537 void SSH_request_X11_forwarding(PTInstVar pvar,
538 char FAR * auth_protocol, unsigned char FAR * auth_data, int auth_data_len, int screen_num);
539 void SSH_open_channel(PTInstVar pvar, uint32 local_channel_num,
540 char FAR * to_remote_host, int to_remote_port,
541 char FAR * originator, unsigned short originator_port);
542
543 int SSH_start_scp(PTInstVar pvar, char *sendfile, char *dstfile);
544 int SSH_start_scp_receive(PTInstVar pvar, char *filename);
545 int SSH_scp_transaction(PTInstVar pvar, char *sendfile, char *dstfile, enum scp_dir direction);
546 int SSH_sftp_transaction(PTInstVar pvar);
547
548 /* auxiliary SSH2 interfaces for pkt.c */
549 int SSH_get_min_packet_size(PTInstVar pvar);
550 /* data is guaranteed to be at least SSH_get_min_packet_size bytes long
551 at least 5 bytes must be decrypted */
552 void SSH_predecrpyt_packet(PTInstVar pvar, char FAR * data);
553 int SSH_get_clear_MAC_size(PTInstVar pvar);
554
555 #define SSH_is_any_payload(pvar) ((pvar)->ssh_state.payload_datalen > 0)
556 #define SSH_get_host_name(pvar) ((pvar)->ssh_state.hostname)
557 #define SSH_get_compression_level(pvar) ((pvar)->ssh_state.compressing ? (pvar)->ts_SSH_CompressionLevel : 0)
558
559 void SSH2_send_kexinit(PTInstVar pvar);
560 BOOL do_SSH2_userauth(PTInstVar pvar);
561 BOOL do_SSH2_authrequest(PTInstVar pvar);
562 void debug_print(int no, char *msg, int len);
563 int get_cipher_block_size(SSHCipher cipher);
564 int get_cipher_key_len(SSHCipher cipher);
565 const EVP_CIPHER* get_cipher_EVP_CIPHER(SSHCipher cipher);
566 int get_cipher_discard_len(SSHCipher cipher);
567 void ssh_heartbeat_lock_initialize(void);
568 void ssh_heartbeat_lock_finalize(void);
569 void ssh_heartbeat_lock(void);
570 void ssh_heartbeat_unlock(void);
571 void halt_ssh_heartbeat_thread(PTInstVar pvar);
572 void ssh2_channel_free(void);
573 BOOL handle_SSH2_userauth_inforeq(PTInstVar pvar);
574 BOOL handle_SSH2_userauth_passwd_changereq(PTInstVar pvar);
575 void SSH2_update_compression_myproposal(PTInstVar pvar);
576 void SSH2_update_cipher_myproposal(PTInstVar pvar);
577 int SSH_notify_break_signal(PTInstVar pvar);
578
579 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26