]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - ssh.h
Initial 'merge -s ours' from 0.66 release branch.
[PuTTY.git] / ssh.h
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "puttymem.h"
5 #include "tree234.h"
6 #include "network.h"
7 #include "int64.h"
8 #include "misc.h"
9
10 struct ssh_channel;
11 typedef struct ssh_tag *Ssh;
12
13 extern int sshfwd_write(struct ssh_channel *c, char *, int);
14 extern void sshfwd_write_eof(struct ssh_channel *c);
15 extern void sshfwd_unclean_close(struct ssh_channel *c, const char *err);
16 extern void sshfwd_unthrottle(struct ssh_channel *c, int bufsize);
17 Conf *sshfwd_get_conf(struct ssh_channel *c);
18 void sshfwd_x11_sharing_handover(struct ssh_channel *c,
19                                  void *share_cs, void *share_chan,
20                                  const char *peer_addr, int peer_port,
21                                  int endian, int protomajor, int protominor,
22                                  const void *initial_data, int initial_len);
23 void sshfwd_x11_is_local(struct ssh_channel *c);
24
25 extern Socket ssh_connection_sharing_init(const char *host, int port,
26                                           Conf *conf, Ssh ssh, void **state);
27 int ssh_share_test_for_upstream(const char *host, int port, Conf *conf);
28 void share_got_pkt_from_server(void *ctx, int type,
29                                unsigned char *pkt, int pktlen);
30 void share_activate(void *state, const char *server_verstring);
31 void sharestate_free(void *state);
32 int share_ndownstreams(void *state);
33
34 void ssh_connshare_log(Ssh ssh, int event, const char *logtext,
35                        const char *ds_err, const char *us_err);
36 unsigned ssh_alloc_sharing_channel(Ssh ssh, void *sharing_ctx);
37 void ssh_delete_sharing_channel(Ssh ssh, unsigned localid);
38 int ssh_alloc_sharing_rportfwd(Ssh ssh, const char *shost, int sport,
39                                void *share_ctx);
40 void ssh_sharing_queue_global_request(Ssh ssh, void *share_ctx);
41 struct X11FakeAuth *ssh_sharing_add_x11_display(Ssh ssh, int authtype,
42                                                 void *share_cs,
43                                                 void *share_chan);
44 void ssh_sharing_remove_x11_display(Ssh ssh, struct X11FakeAuth *auth);
45 void ssh_send_packet_from_downstream(Ssh ssh, unsigned id, int type,
46                                      const void *pkt, int pktlen,
47                                      const char *additional_log_text);
48 void ssh_sharing_downstream_connected(Ssh ssh, unsigned id,
49                                       const char *peerinfo);
50 void ssh_sharing_downstream_disconnected(Ssh ssh, unsigned id);
51 void ssh_sharing_logf(Ssh ssh, unsigned id, const char *logfmt, ...);
52 int ssh_agent_forwarding_permitted(Ssh ssh);
53 void share_setup_x11_channel(void *csv, void *chanv,
54                              unsigned upstream_id, unsigned server_id,
55                              unsigned server_currwin, unsigned server_maxpkt,
56                              unsigned client_adjusted_window,
57                              const char *peer_addr, int peer_port, int endian,
58                              int protomajor, int protominor,
59                              const void *initial_data, int initial_len);
60
61 /*
62  * Useful thing.
63  */
64 #ifndef lenof
65 #define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
66 #endif
67
68 #define SSH_CIPHER_IDEA         1
69 #define SSH_CIPHER_DES          2
70 #define SSH_CIPHER_3DES         3
71 #define SSH_CIPHER_BLOWFISH     6
72
73 #ifdef MSCRYPTOAPI
74 #define APIEXTRA 8
75 #else
76 #define APIEXTRA 0
77 #endif
78
79 #ifndef BIGNUM_INTERNAL
80 typedef void *Bignum;
81 #endif
82
83 struct RSAKey {
84     int bits;
85     int bytes;
86 #ifdef MSCRYPTOAPI
87     unsigned long exponent;
88     unsigned char *modulus;
89 #else
90     Bignum modulus;
91     Bignum exponent;
92     Bignum private_exponent;
93     Bignum p;
94     Bignum q;
95     Bignum iqmp;
96 #endif
97     char *comment;
98 };
99
100 struct dss_key {
101     Bignum p, q, g, y, x;
102 };
103
104 struct ec_curve;
105
106 struct ec_point {
107     const struct ec_curve *curve;
108     Bignum x, y;
109     Bignum z;  /* Jacobian denominator */
110     unsigned char infinity;
111 };
112
113 void ec_point_free(struct ec_point *point);
114
115 /* Weierstrass form curve */
116 struct ec_wcurve
117 {
118     Bignum a, b, n;
119     struct ec_point G;
120 };
121
122 /* Montgomery form curve */
123 struct ec_mcurve
124 {
125     Bignum a, b;
126     struct ec_point G;
127 };
128
129 /* Edwards form curve */
130 struct ec_ecurve
131 {
132     Bignum l, d;
133     struct ec_point B;
134 };
135
136 struct ec_curve {
137     enum { EC_WEIERSTRASS, EC_MONTGOMERY, EC_EDWARDS } type;
138     /* 'name' is the identifier of the curve when it has to appear in
139      * wire protocol encodings, as it does in e.g. the public key and
140      * signature formats for NIST curves. Curves which do not format
141      * their keys or signatures in this way just have name==NULL.
142      *
143      * 'textname' is non-NULL for all curves, and is a human-readable
144      * identification suitable for putting in log messages. */
145     const char *name, *textname;
146     unsigned int fieldBits;
147     Bignum p;
148     union {
149         struct ec_wcurve w;
150         struct ec_mcurve m;
151         struct ec_ecurve e;
152     };
153 };
154
155 const struct ssh_signkey *ec_alg_by_oid(int len, const void *oid,
156                                         const struct ec_curve **curve);
157 const unsigned char *ec_alg_oid(const struct ssh_signkey *alg, int *oidlen);
158 const int ec_nist_alg_and_curve_by_bits(int bits,
159                                         const struct ec_curve **curve,
160                                         const struct ssh_signkey **alg);
161 const int ec_ed_alg_and_curve_by_bits(int bits,
162                                       const struct ec_curve **curve,
163                                       const struct ssh_signkey **alg);
164
165 struct ssh_signkey;
166
167 struct ec_key {
168     const struct ssh_signkey *signalg;
169     struct ec_point publicKey;
170     Bignum privateKey;
171 };
172
173 struct ec_point *ec_public(const Bignum privateKey, const struct ec_curve *curve);
174
175 int makekey(const unsigned char *data, int len, struct RSAKey *result,
176             const unsigned char **keystr, int order);
177 int makeprivate(const unsigned char *data, int len, struct RSAKey *result);
178 int rsaencrypt(unsigned char *data, int length, struct RSAKey *key);
179 Bignum rsadecrypt(Bignum input, struct RSAKey *key);
180 void rsasign(unsigned char *data, int length, struct RSAKey *key);
181 void rsasanitise(struct RSAKey *key);
182 int rsastr_len(struct RSAKey *key);
183 void rsastr_fmt(char *str, struct RSAKey *key);
184 void rsa_fingerprint(char *str, int len, struct RSAKey *key);
185 int rsa_verify(struct RSAKey *key);
186 unsigned char *rsa_public_blob(struct RSAKey *key, int *len);
187 int rsa_public_blob_len(void *data, int maxlen);
188 void freersakey(struct RSAKey *key);
189
190 #ifndef PUTTY_UINT32_DEFINED
191 /* This makes assumptions about the int type. */
192 typedef unsigned int uint32;
193 #define PUTTY_UINT32_DEFINED
194 #endif
195 typedef uint32 word32;
196
197 unsigned long crc32_compute(const void *s, size_t len);
198 unsigned long crc32_update(unsigned long crc_input, const void *s, size_t len);
199
200 /* SSH CRC compensation attack detector */
201 void *crcda_make_context(void);
202 void crcda_free_context(void *handle);
203 int detect_attack(void *handle, unsigned char *buf, uint32 len,
204                   unsigned char *IV);
205
206 /*
207  * SSH2 RSA key exchange functions
208  */
209 struct ssh_hash;
210 void *ssh_rsakex_newkey(char *data, int len);
211 void ssh_rsakex_freekey(void *key);
212 int ssh_rsakex_klen(void *key);
213 void ssh_rsakex_encrypt(const struct ssh_hash *h, unsigned char *in, int inlen,
214                         unsigned char *out, int outlen,
215                         void *key);
216
217 /*
218  * SSH2 ECDH key exchange functions
219  */
220 struct ssh_kex;
221 const char *ssh_ecdhkex_curve_textname(const struct ssh_kex *kex);
222 void *ssh_ecdhkex_newkey(const struct ssh_kex *kex);
223 void ssh_ecdhkex_freekey(void *key);
224 char *ssh_ecdhkex_getpublic(void *key, int *len);
225 Bignum ssh_ecdhkex_getkey(void *key, char *remoteKey, int remoteKeyLen);
226
227 /*
228  * Helper function for k generation in DSA, reused in ECDSA
229  */
230 Bignum *dss_gen_k(const char *id_string, Bignum modulus, Bignum private_key,
231                   unsigned char *digest, int digest_len);
232
233 typedef struct {
234     uint32 h[4];
235 } MD5_Core_State;
236
237 struct MD5Context {
238 #ifdef MSCRYPTOAPI
239     unsigned long hHash;
240 #else
241     MD5_Core_State core;
242     unsigned char block[64];
243     int blkused;
244     uint32 lenhi, lenlo;
245 #endif
246 };
247
248 void MD5Init(struct MD5Context *context);
249 void MD5Update(struct MD5Context *context, unsigned char const *buf,
250                unsigned len);
251 void MD5Final(unsigned char digest[16], struct MD5Context *context);
252 void MD5Simple(void const *p, unsigned len, unsigned char output[16]);
253
254 void *hmacmd5_make_context(void *);
255 void hmacmd5_free_context(void *handle);
256 void hmacmd5_key(void *handle, void const *key, int len);
257 void hmacmd5_do_hmac(void *handle, unsigned char const *blk, int len,
258                      unsigned char *hmac);
259
260 typedef struct {
261     uint32 h[5];
262     unsigned char block[64];
263     int blkused;
264     uint32 lenhi, lenlo;
265 } SHA_State;
266 void SHA_Init(SHA_State * s);
267 void SHA_Bytes(SHA_State * s, const void *p, int len);
268 void SHA_Final(SHA_State * s, unsigned char *output);
269 void SHA_Simple(const void *p, int len, unsigned char *output);
270
271 void hmac_sha1_simple(void *key, int keylen, void *data, int datalen,
272                       unsigned char *output);
273 typedef struct {
274     uint32 h[8];
275     unsigned char block[64];
276     int blkused;
277     uint32 lenhi, lenlo;
278 } SHA256_State;
279 void SHA256_Init(SHA256_State * s);
280 void SHA256_Bytes(SHA256_State * s, const void *p, int len);
281 void SHA256_Final(SHA256_State * s, unsigned char *output);
282 void SHA256_Simple(const void *p, int len, unsigned char *output);
283
284 typedef struct {
285     uint64 h[8];
286     unsigned char block[128];
287     int blkused;
288     uint32 len[4];
289 } SHA512_State;
290 #define SHA384_State SHA512_State
291 void SHA512_Init(SHA512_State * s);
292 void SHA512_Bytes(SHA512_State * s, const void *p, int len);
293 void SHA512_Final(SHA512_State * s, unsigned char *output);
294 void SHA512_Simple(const void *p, int len, unsigned char *output);
295 void SHA384_Init(SHA384_State * s);
296 #define SHA384_Bytes(s, p, len) SHA512_Bytes(s, p, len)
297 void SHA384_Final(SHA384_State * s, unsigned char *output);
298 void SHA384_Simple(const void *p, int len, unsigned char *output);
299
300 struct ssh_mac;
301 struct ssh_cipher {
302     void *(*make_context)(void);
303     void (*free_context)(void *);
304     void (*sesskey) (void *, unsigned char *key);       /* for SSH-1 */
305     void (*encrypt) (void *, unsigned char *blk, int len);
306     void (*decrypt) (void *, unsigned char *blk, int len);
307     int blksize;
308     const char *text_name;
309 };
310
311 struct ssh2_cipher {
312     void *(*make_context)(void);
313     void (*free_context)(void *);
314     void (*setiv) (void *, unsigned char *key); /* for SSH-2 */
315     void (*setkey) (void *, unsigned char *key);/* for SSH-2 */
316     void (*encrypt) (void *, unsigned char *blk, int len);
317     void (*decrypt) (void *, unsigned char *blk, int len);
318     /* Ignored unless SSH_CIPHER_SEPARATE_LENGTH flag set */
319     void (*encrypt_length) (void *, unsigned char *blk, int len, unsigned long seq);
320     void (*decrypt_length) (void *, unsigned char *blk, int len, unsigned long seq);
321     const char *name;
322     int blksize;
323     /* real_keybits is the number of bits of entropy genuinely used by
324      * the cipher scheme; it's used for deciding how big a
325      * Diffie-Hellman group is needed to exchange a key for the
326      * cipher. */
327     int real_keybits;
328     /* padded_keybytes is the number of bytes of key data expected as
329      * input to the setkey function; it's used for deciding how much
330      * data needs to be generated from the post-kex generation of key
331      * material. In a sensible cipher which uses all its key bytes for
332      * real work, this will just be real_keybits/8, but in DES-type
333      * ciphers which ignore one bit in each byte, it'll be slightly
334      * different. */
335     int padded_keybytes;
336     unsigned int flags;
337 #define SSH_CIPHER_IS_CBC       1
338 #define SSH_CIPHER_SEPARATE_LENGTH      2
339     const char *text_name;
340     /* If set, this takes priority over other MAC. */
341     const struct ssh_mac *required_mac;
342 };
343
344 struct ssh2_ciphers {
345     int nciphers;
346     const struct ssh2_cipher *const *list;
347 };
348
349 struct ssh_mac {
350     /* Passes in the cipher context */
351     void *(*make_context)(void *);
352     void (*free_context)(void *);
353     void (*setkey) (void *, unsigned char *key);
354     /* whole-packet operations */
355     void (*generate) (void *, unsigned char *blk, int len, unsigned long seq);
356     int (*verify) (void *, unsigned char *blk, int len, unsigned long seq);
357     /* partial-packet operations */
358     void (*start) (void *);
359     void (*bytes) (void *, unsigned char const *, int);
360     void (*genresult) (void *, unsigned char *);
361     int (*verresult) (void *, unsigned char const *);
362     const char *name, *etm_name;
363     int len, keylen;
364     const char *text_name;
365 };
366
367 struct ssh_hash {
368     void *(*init)(void); /* also allocates context */
369     void *(*copy)(const void *);
370     void (*bytes)(void *, const void *, int);
371     void (*final)(void *, unsigned char *); /* also frees context */
372     void (*free)(void *);
373     int hlen; /* output length in bytes */
374     const char *text_name;
375 };   
376
377 struct ssh_kex {
378     const char *name, *groupname;
379     enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type;
380     const struct ssh_hash *hash;
381     const void *extra;                 /* private to the kex methods */
382 };
383
384 struct ssh_kexes {
385     int nkexes;
386     const struct ssh_kex *const *list;
387 };
388
389 struct ssh_signkey {
390     void *(*newkey) (const struct ssh_signkey *self,
391                      const char *data, int len);
392     void (*freekey) (void *key);
393     char *(*fmtkey) (void *key);
394     unsigned char *(*public_blob) (void *key, int *len);
395     unsigned char *(*private_blob) (void *key, int *len);
396     void *(*createkey) (const struct ssh_signkey *self,
397                         const unsigned char *pub_blob, int pub_len,
398                         const unsigned char *priv_blob, int priv_len);
399     void *(*openssh_createkey) (const struct ssh_signkey *self,
400                                 const unsigned char **blob, int *len);
401     int (*openssh_fmtkey) (void *key, unsigned char *blob, int len);
402     /* OpenSSH private key blobs, as created by openssh_fmtkey and
403      * consumed by openssh_createkey, always (at least so far...) take
404      * the form of a number of SSH-2 strings / mpints concatenated
405      * end-to-end. Because the new-style OpenSSH private key format
406      * stores those blobs without a containing string wrapper, we need
407      * to know how many strings each one consists of, so that we can
408      * skip over the right number to find the next key in the file.
409      * openssh_private_npieces gives that information. */
410     int openssh_private_npieces;
411     int (*pubkey_bits) (const struct ssh_signkey *self,
412                         const void *blob, int len);
413     int (*verifysig) (void *key, const char *sig, int siglen,
414                       const char *data, int datalen);
415     unsigned char *(*sign) (void *key, const char *data, int datalen,
416                             int *siglen);
417     const char *name;
418     const char *keytype;               /* for host key cache */
419     const void *extra;                 /* private to the public key methods */
420 };
421
422 struct ssh_compress {
423     const char *name;
424     /* For zlib@openssh.com: if non-NULL, this name will be considered once
425      * userauth has completed successfully. */
426     const char *delayed_name;
427     void *(*compress_init) (void);
428     void (*compress_cleanup) (void *);
429     int (*compress) (void *, unsigned char *block, int len,
430                      unsigned char **outblock, int *outlen);
431     void *(*decompress_init) (void);
432     void (*decompress_cleanup) (void *);
433     int (*decompress) (void *, unsigned char *block, int len,
434                        unsigned char **outblock, int *outlen);
435     int (*disable_compression) (void *);
436     const char *text_name;
437 };
438
439 struct ssh2_userkey {
440     const struct ssh_signkey *alg;     /* the key algorithm */
441     void *data;                        /* the key data */
442     char *comment;                     /* the key comment */
443 };
444
445 /* The maximum length of any hash algorithm used in kex. (bytes) */
446 #define SSH2_KEX_MAX_HASH_LEN (64) /* SHA-512 */
447
448 extern const struct ssh_cipher ssh_3des;
449 extern const struct ssh_cipher ssh_des;
450 extern const struct ssh_cipher ssh_blowfish_ssh1;
451 extern const struct ssh2_ciphers ssh2_3des;
452 extern const struct ssh2_ciphers ssh2_des;
453 extern const struct ssh2_ciphers ssh2_aes;
454 extern const struct ssh2_ciphers ssh2_blowfish;
455 extern const struct ssh2_ciphers ssh2_arcfour;
456 extern const struct ssh2_ciphers ssh2_ccp;
457 extern const struct ssh_hash ssh_sha1;
458 extern const struct ssh_hash ssh_sha256;
459 extern const struct ssh_hash ssh_sha384;
460 extern const struct ssh_hash ssh_sha512;
461 extern const struct ssh_kexes ssh_diffiehellman_group1;
462 extern const struct ssh_kexes ssh_diffiehellman_group14;
463 extern const struct ssh_kexes ssh_diffiehellman_gex;
464 extern const struct ssh_kexes ssh_rsa_kex;
465 extern const struct ssh_kexes ssh_ecdh_kex;
466 extern const struct ssh_signkey ssh_dss;
467 extern const struct ssh_signkey ssh_rsa;
468 extern const struct ssh_signkey ssh_ecdsa_ed25519;
469 extern const struct ssh_signkey ssh_ecdsa_nistp256;
470 extern const struct ssh_signkey ssh_ecdsa_nistp384;
471 extern const struct ssh_signkey ssh_ecdsa_nistp521;
472 extern const struct ssh_mac ssh_hmac_md5;
473 extern const struct ssh_mac ssh_hmac_sha1;
474 extern const struct ssh_mac ssh_hmac_sha1_buggy;
475 extern const struct ssh_mac ssh_hmac_sha1_96;
476 extern const struct ssh_mac ssh_hmac_sha1_96_buggy;
477 extern const struct ssh_mac ssh_hmac_sha256;
478
479 void *aes_make_context(void);
480 void aes_free_context(void *handle);
481 void aes128_key(void *handle, unsigned char *key);
482 void aes192_key(void *handle, unsigned char *key);
483 void aes256_key(void *handle, unsigned char *key);
484 void aes_iv(void *handle, unsigned char *iv);
485 void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len);
486 void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len);
487
488 /*
489  * PuTTY version number formatted as an SSH version string. 
490  */
491 extern char sshver[];
492
493 /*
494  * Gross hack: pscp will try to start SFTP but fall back to scp1 if
495  * that fails. This variable is the means by which scp.c can reach
496  * into the SSH code and find out which one it got.
497  */
498 extern int ssh_fallback_cmd(void *handle);
499
500 #ifndef MSCRYPTOAPI
501 void SHATransform(word32 * digest, word32 * data);
502 #endif
503
504 int random_byte(void);
505 void random_add_noise(void *noise, int length);
506 void random_add_heavynoise(void *noise, int length);
507
508 void logevent(void *, const char *);
509
510 struct PortForwarding;
511
512 /* Allocate and register a new channel for port forwarding */
513 void *new_sock_channel(void *handle, struct PortForwarding *pf);
514 void ssh_send_port_open(void *channel, const char *hostname, int port,
515                         const char *org);
516
517 /* Exports from portfwd.c */
518 extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port,
519                          void *c, Conf *conf, int addressfamily);
520 extern void pfd_close(struct PortForwarding *);
521 extern int pfd_send(struct PortForwarding *, char *data, int len);
522 extern void pfd_send_eof(struct PortForwarding *);
523 extern void pfd_confirm(struct PortForwarding *);
524 extern void pfd_unthrottle(struct PortForwarding *);
525 extern void pfd_override_throttle(struct PortForwarding *, int enable);
526 struct PortListener;
527 /* desthost == NULL indicates dynamic (SOCKS) port forwarding */
528 extern char *pfl_listen(char *desthost, int destport, char *srcaddr,
529                         int port, void *backhandle, Conf *conf,
530                         struct PortListener **pl, int address_family);
531 extern void pfl_terminate(struct PortListener *);
532
533 /* Exports from x11fwd.c */
534 enum {
535     X11_TRANS_IPV4 = 0, X11_TRANS_IPV6 = 6, X11_TRANS_UNIX = 256
536 };
537 struct X11Display {
538     /* Broken-down components of the display name itself */
539     int unixdomain;
540     char *hostname;
541     int displaynum;
542     int screennum;
543     /* OSX sometimes replaces all the above with a full Unix-socket pathname */
544     char *unixsocketpath;
545
546     /* PuTTY networking SockAddr to connect to the display, and associated
547      * gubbins */
548     SockAddr addr;
549     int port;
550     char *realhost;
551
552     /* Our local auth details for talking to the real X display. */
553     int localauthproto;
554     unsigned char *localauthdata;
555     int localauthdatalen;
556 };
557 struct X11FakeAuth {
558     /* Auth details we invented for a virtual display on the SSH server. */
559     int proto;
560     unsigned char *data;
561     int datalen;
562     char *protoname;
563     char *datastring;
564
565     /* The encrypted form of the first block, in XDM-AUTHORIZATION-1.
566      * Used as part of the key when these structures are organised
567      * into a tree. See x11_invent_fake_auth for explanation. */
568     unsigned char *xa1_firstblock;
569
570     /*
571      * Used inside x11fwd.c to remember recently seen
572      * XDM-AUTHORIZATION-1 strings, to avoid replay attacks.
573      */
574     tree234 *xdmseen;
575
576     /*
577      * What to do with an X connection matching this auth data.
578      */
579     struct X11Display *disp;
580     void *share_cs, *share_chan;
581 };
582 void *x11_make_greeting(int endian, int protomajor, int protominor,
583                         int auth_proto, const void *auth_data, int auth_len,
584                         const char *peer_ip, int peer_port,
585                         int *outlen);
586 int x11_authcmp(void *av, void *bv); /* for putting X11FakeAuth in a tree234 */
587 /*
588  * x11_setup_display() parses the display variable and fills in an
589  * X11Display structure. Some remote auth details are invented;
590  * the supplied authtype parameter configures the preferred
591  * authorisation protocol to use at the remote end. The local auth
592  * details are looked up by calling platform_get_x11_auth.
593  */
594 extern struct X11Display *x11_setup_display(const char *display, Conf *);
595 void x11_free_display(struct X11Display *disp);
596 struct X11FakeAuth *x11_invent_fake_auth(tree234 *t, int authtype);
597 void x11_free_fake_auth(struct X11FakeAuth *auth);
598 struct X11Connection;                  /* opaque outside x11fwd.c */
599 struct X11Connection *x11_init(tree234 *authtree, void *, const char *, int);
600 extern void x11_close(struct X11Connection *);
601 extern int x11_send(struct X11Connection *, char *, int);
602 extern void x11_send_eof(struct X11Connection *s);
603 extern void x11_unthrottle(struct X11Connection *s);
604 extern void x11_override_throttle(struct X11Connection *s, int enable);
605 char *x11_display(const char *display);
606 /* Platform-dependent X11 functions */
607 extern void platform_get_x11_auth(struct X11Display *display, Conf *);
608     /* examine a mostly-filled-in X11Display and fill in localauth* */
609 extern const int platform_uses_x11_unix_by_default;
610     /* choose default X transport in the absence of a specified one */
611 SockAddr platform_get_x11_unix_address(const char *path, int displaynum);
612     /* make up a SockAddr naming the address for displaynum */
613 char *platform_get_x_display(void);
614     /* allocated local X display string, if any */
615 /* Callbacks in x11.c usable _by_ platform X11 functions */
616 /*
617  * This function does the job of platform_get_x11_auth, provided
618  * it is told where to find a normally formatted .Xauthority file:
619  * it opens that file, parses it to find an auth record which
620  * matches the display details in "display", and fills in the
621  * localauth fields.
622  *
623  * It is expected that most implementations of
624  * platform_get_x11_auth() will work by finding their system's
625  * .Xauthority file, adjusting the display details if necessary
626  * for local oddities like Unix-domain socket transport, and
627  * calling this function to do the rest of the work.
628  */
629 void x11_get_auth_from_authfile(struct X11Display *display,
630                                 const char *authfilename);
631 int x11_identify_auth_proto(const char *proto);
632 void *x11_dehexify(const char *hex, int *outlen);
633
634 Bignum copybn(Bignum b);
635 Bignum bn_power_2(int n);
636 void bn_restore_invariant(Bignum b);
637 Bignum bignum_from_long(unsigned long n);
638 void freebn(Bignum b);
639 Bignum modpow(Bignum base, Bignum exp, Bignum mod);
640 Bignum modmul(Bignum a, Bignum b, Bignum mod);
641 Bignum modsub(const Bignum a, const Bignum b, const Bignum n);
642 void decbn(Bignum n);
643 extern Bignum Zero, One;
644 Bignum bignum_from_bytes(const unsigned char *data, int nbytes);
645 Bignum bignum_from_bytes_le(const unsigned char *data, int nbytes);
646 Bignum bignum_random_in_range(const Bignum lower, const Bignum upper);
647 int ssh1_read_bignum(const unsigned char *data, int len, Bignum * result);
648 int bignum_bitcount(Bignum bn);
649 int ssh1_bignum_length(Bignum bn);
650 int ssh2_bignum_length(Bignum bn);
651 int bignum_byte(Bignum bn, int i);
652 int bignum_bit(Bignum bn, int i);
653 void bignum_set_bit(Bignum bn, int i, int value);
654 int ssh1_write_bignum(void *data, Bignum bn);
655 Bignum biggcd(Bignum a, Bignum b);
656 unsigned short bignum_mod_short(Bignum number, unsigned short modulus);
657 Bignum bignum_add_long(Bignum number, unsigned long addend);
658 Bignum bigadd(Bignum a, Bignum b);
659 Bignum bigsub(Bignum a, Bignum b);
660 Bignum bigmul(Bignum a, Bignum b);
661 Bignum bigmuladd(Bignum a, Bignum b, Bignum addend);
662 Bignum bigdiv(Bignum a, Bignum b);
663 Bignum bigmod(Bignum a, Bignum b);
664 Bignum modinv(Bignum number, Bignum modulus);
665 Bignum bignum_bitmask(Bignum number);
666 Bignum bignum_rshift(Bignum number, int shift);
667 Bignum bignum_lshift(Bignum number, int shift);
668 int bignum_cmp(Bignum a, Bignum b);
669 char *bignum_decimal(Bignum x);
670 Bignum bignum_from_decimal(const char *decimal);
671
672 #ifdef DEBUG
673 void diagbn(char *prefix, Bignum md);
674 #endif
675
676 int dh_is_gex(const struct ssh_kex *kex);
677 void *dh_setup_group(const struct ssh_kex *kex);
678 void *dh_setup_gex(Bignum pval, Bignum gval);
679 void dh_cleanup(void *);
680 Bignum dh_create_e(void *, int nbits);
681 const char *dh_validate_f(void *handle, Bignum f);
682 Bignum dh_find_K(void *, Bignum f);
683
684 int loadrsakey(const Filename *filename, struct RSAKey *key,
685                const char *passphrase, const char **errorstr);
686 int rsakey_encrypted(const Filename *filename, char **comment);
687 int rsakey_pubblob(const Filename *filename, void **blob, int *bloblen,
688                    char **commentptr, const char **errorstr);
689
690 int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase);
691
692 extern int base64_decode_atom(const char *atom, unsigned char *out);
693 extern int base64_lines(int datalen);
694 extern void base64_encode_atom(const unsigned char *data, int n, char *out);
695 extern void base64_encode(FILE *fp, const unsigned char *data, int datalen,
696                           int cpl);
697
698 /* ssh2_load_userkey can return this as an error */
699 extern struct ssh2_userkey ssh2_wrong_passphrase;
700 #define SSH2_WRONG_PASSPHRASE (&ssh2_wrong_passphrase)
701
702 int ssh2_userkey_encrypted(const Filename *filename, char **comment);
703 struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
704                                        const char *passphrase,
705                                        const char **errorstr);
706 unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
707                                     int *pub_blob_len, char **commentptr,
708                                     const char **errorstr);
709 int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
710                       char *passphrase);
711 const struct ssh_signkey *find_pubkey_alg(const char *name);
712 const struct ssh_signkey *find_pubkey_alg_len(int namelen, const char *name);
713
714 enum {
715     SSH_KEYTYPE_UNOPENABLE,
716     SSH_KEYTYPE_UNKNOWN,
717     SSH_KEYTYPE_SSH1, SSH_KEYTYPE_SSH2,
718     /*
719      * The OpenSSH key types deserve a little explanation. OpenSSH has
720      * two physical formats for private key storage: an old PEM-based
721      * one largely dictated by their use of OpenSSL and full of ASN.1,
722      * and a new one using the same private key formats used over the
723      * wire for talking to ssh-agent. The old format can only support
724      * a subset of the key types, because it needs redesign for each
725      * key type, and after a while they decided to move to the new
726      * format so as not to have to do that.
727      *
728      * On input, key files are identified as either
729      * SSH_KEYTYPE_OPENSSH_PEM or SSH_KEYTYPE_OPENSSH_NEW, describing
730      * accurately which actual format the keys are stored in.
731      *
732      * On output, however, we default to following OpenSSH's own
733      * policy of writing out PEM-style keys for maximum backwards
734      * compatibility if the key type supports it, and otherwise
735      * switching to the new format. So the formats you can select for
736      * output are SSH_KEYTYPE_OPENSSH_NEW (forcing the new format for
737      * any key type), and SSH_KEYTYPE_OPENSSH_AUTO to use the oldest
738      * format supported by whatever key type you're writing out.
739      *
740      * So we have three type codes, but only two of them usable in any
741      * given circumstance. An input key file will never be identified
742      * as AUTO, only PEM or NEW; key export UIs should not be able to
743      * select PEM, only AUTO or NEW.
744      */
745     SSH_KEYTYPE_OPENSSH_AUTO,
746     SSH_KEYTYPE_OPENSSH_PEM,
747     SSH_KEYTYPE_OPENSSH_NEW,
748     SSH_KEYTYPE_SSHCOM,
749     /*
750      * Public-key-only formats, which we still want to be able to read
751      * for various purposes.
752      */
753     SSH_KEYTYPE_SSH1_PUBLIC,
754     SSH_KEYTYPE_SSH2_PUBLIC_RFC4716,
755     SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH
756 };
757 char *ssh1_pubkey_str(struct RSAKey *ssh1key);
758 void ssh1_write_pubkey(FILE *fp, struct RSAKey *ssh1key);
759 char *ssh2_pubkey_openssh_str(struct ssh2_userkey *key);
760 void ssh2_write_pubkey(FILE *fp, const char *comment,
761                        const void *v_pub_blob, int pub_len,
762                        int keytype);
763 char *ssh2_fingerprint_blob(const void *blob, int bloblen);
764 char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data);
765 int key_type(const Filename *filename);
766 const char *key_type_to_str(int type);
767
768 int import_possible(int type);
769 int import_target_type(int type);
770 int import_encrypted(const Filename *filename, int type, char **comment);
771 int import_ssh1(const Filename *filename, int type,
772                 struct RSAKey *key, char *passphrase, const char **errmsg_p);
773 struct ssh2_userkey *import_ssh2(const Filename *filename, int type,
774                                  char *passphrase, const char **errmsg_p);
775 int export_ssh1(const Filename *filename, int type,
776                 struct RSAKey *key, char *passphrase);
777 int export_ssh2(const Filename *filename, int type,
778                 struct ssh2_userkey *key, char *passphrase);
779
780 void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len);
781 void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len);
782 void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
783                               unsigned char *blk, int len);
784 void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
785                               unsigned char *blk, int len);
786 void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk,
787                            int len);
788 void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk,
789                            int len);
790
791 void des_encrypt_xdmauth(const unsigned char *key,
792                          unsigned char *blk, int len);
793 void des_decrypt_xdmauth(const unsigned char *key,
794                          unsigned char *blk, int len);
795
796 void openssh_bcrypt(const char *passphrase,
797                     const unsigned char *salt, int saltbytes,
798                     int rounds, unsigned char *out, int outbytes);
799
800 /*
801  * For progress updates in the key generation utility.
802  */
803 #define PROGFN_INITIALISE 1
804 #define PROGFN_LIN_PHASE 2
805 #define PROGFN_EXP_PHASE 3
806 #define PROGFN_PHASE_EXTENT 4
807 #define PROGFN_READY 5
808 #define PROGFN_PROGRESS 6
809 typedef void (*progfn_t) (void *param, int action, int phase, int progress);
810
811 int rsa_generate(struct RSAKey *key, int bits, progfn_t pfn,
812                  void *pfnparam);
813 int dsa_generate(struct dss_key *key, int bits, progfn_t pfn,
814                  void *pfnparam);
815 int ec_generate(struct ec_key *key, int bits, progfn_t pfn,
816                 void *pfnparam);
817 int ec_edgenerate(struct ec_key *key, int bits, progfn_t pfn,
818                   void *pfnparam);
819 Bignum primegen(int bits, int modulus, int residue, Bignum factor,
820                 int phase, progfn_t pfn, void *pfnparam, unsigned firstbits);
821 void invent_firstbits(unsigned *one, unsigned *two);
822
823
824 /*
825  * zlib compression.
826  */
827 void *zlib_compress_init(void);
828 void zlib_compress_cleanup(void *);
829 void *zlib_decompress_init(void);
830 void zlib_decompress_cleanup(void *);
831 int zlib_compress_block(void *, unsigned char *block, int len,
832                         unsigned char **outblock, int *outlen);
833 int zlib_decompress_block(void *, unsigned char *block, int len,
834                           unsigned char **outblock, int *outlen);
835
836 /*
837  * Connection-sharing API provided by platforms. This function must
838  * either:
839  *  - return SHARE_NONE and do nothing
840  *  - return SHARE_DOWNSTREAM and set *sock to a Socket connected to
841  *    downplug
842  *  - return SHARE_UPSTREAM and set *sock to a Socket connected to
843  *    upplug.
844  */
845 enum { SHARE_NONE, SHARE_DOWNSTREAM, SHARE_UPSTREAM };
846 int platform_ssh_share(const char *name, Conf *conf,
847                        Plug downplug, Plug upplug, Socket *sock,
848                        char **logtext, char **ds_err, char **us_err,
849                        int can_upstream, int can_downstream);
850 void platform_ssh_share_cleanup(const char *name);
851
852 /*
853  * SSH-1 message type codes.
854  */
855 #define SSH1_MSG_DISCONNECT                       1     /* 0x1 */
856 #define SSH1_SMSG_PUBLIC_KEY                      2     /* 0x2 */
857 #define SSH1_CMSG_SESSION_KEY                     3     /* 0x3 */
858 #define SSH1_CMSG_USER                            4     /* 0x4 */
859 #define SSH1_CMSG_AUTH_RSA                        6     /* 0x6 */
860 #define SSH1_SMSG_AUTH_RSA_CHALLENGE              7     /* 0x7 */
861 #define SSH1_CMSG_AUTH_RSA_RESPONSE               8     /* 0x8 */
862 #define SSH1_CMSG_AUTH_PASSWORD                   9     /* 0x9 */
863 #define SSH1_CMSG_REQUEST_PTY                     10    /* 0xa */
864 #define SSH1_CMSG_WINDOW_SIZE                     11    /* 0xb */
865 #define SSH1_CMSG_EXEC_SHELL                      12    /* 0xc */
866 #define SSH1_CMSG_EXEC_CMD                        13    /* 0xd */
867 #define SSH1_SMSG_SUCCESS                         14    /* 0xe */
868 #define SSH1_SMSG_FAILURE                         15    /* 0xf */
869 #define SSH1_CMSG_STDIN_DATA                      16    /* 0x10 */
870 #define SSH1_SMSG_STDOUT_DATA                     17    /* 0x11 */
871 #define SSH1_SMSG_STDERR_DATA                     18    /* 0x12 */
872 #define SSH1_CMSG_EOF                             19    /* 0x13 */
873 #define SSH1_SMSG_EXIT_STATUS                     20    /* 0x14 */
874 #define SSH1_MSG_CHANNEL_OPEN_CONFIRMATION        21    /* 0x15 */
875 #define SSH1_MSG_CHANNEL_OPEN_FAILURE             22    /* 0x16 */
876 #define SSH1_MSG_CHANNEL_DATA                     23    /* 0x17 */
877 #define SSH1_MSG_CHANNEL_CLOSE                    24    /* 0x18 */
878 #define SSH1_MSG_CHANNEL_CLOSE_CONFIRMATION       25    /* 0x19 */
879 #define SSH1_SMSG_X11_OPEN                        27    /* 0x1b */
880 #define SSH1_CMSG_PORT_FORWARD_REQUEST            28    /* 0x1c */
881 #define SSH1_MSG_PORT_OPEN                        29    /* 0x1d */
882 #define SSH1_CMSG_AGENT_REQUEST_FORWARDING        30    /* 0x1e */
883 #define SSH1_SMSG_AGENT_OPEN                      31    /* 0x1f */
884 #define SSH1_MSG_IGNORE                           32    /* 0x20 */
885 #define SSH1_CMSG_EXIT_CONFIRMATION               33    /* 0x21 */
886 #define SSH1_CMSG_X11_REQUEST_FORWARDING          34    /* 0x22 */
887 #define SSH1_CMSG_AUTH_RHOSTS_RSA                 35    /* 0x23 */
888 #define SSH1_MSG_DEBUG                            36    /* 0x24 */
889 #define SSH1_CMSG_REQUEST_COMPRESSION             37    /* 0x25 */
890 #define SSH1_CMSG_AUTH_TIS                        39    /* 0x27 */
891 #define SSH1_SMSG_AUTH_TIS_CHALLENGE              40    /* 0x28 */
892 #define SSH1_CMSG_AUTH_TIS_RESPONSE               41    /* 0x29 */
893 #define SSH1_CMSG_AUTH_CCARD                      70    /* 0x46 */
894 #define SSH1_SMSG_AUTH_CCARD_CHALLENGE            71    /* 0x47 */
895 #define SSH1_CMSG_AUTH_CCARD_RESPONSE             72    /* 0x48 */
896
897 #define SSH1_AUTH_RHOSTS                          1     /* 0x1 */
898 #define SSH1_AUTH_RSA                             2     /* 0x2 */
899 #define SSH1_AUTH_PASSWORD                        3     /* 0x3 */
900 #define SSH1_AUTH_RHOSTS_RSA                      4     /* 0x4 */
901 #define SSH1_AUTH_TIS                             5     /* 0x5 */
902 #define SSH1_AUTH_CCARD                           16    /* 0x10 */
903
904 #define SSH1_PROTOFLAG_SCREEN_NUMBER              1     /* 0x1 */
905 /* Mask for protoflags we will echo back to server if seen */
906 #define SSH1_PROTOFLAGS_SUPPORTED                 0     /* 0x1 */
907
908 /*
909  * SSH-2 message type codes.
910  */
911 #define SSH2_MSG_DISCONNECT                       1     /* 0x1 */
912 #define SSH2_MSG_IGNORE                           2     /* 0x2 */
913 #define SSH2_MSG_UNIMPLEMENTED                    3     /* 0x3 */
914 #define SSH2_MSG_DEBUG                            4     /* 0x4 */
915 #define SSH2_MSG_SERVICE_REQUEST                  5     /* 0x5 */
916 #define SSH2_MSG_SERVICE_ACCEPT                   6     /* 0x6 */
917 #define SSH2_MSG_KEXINIT                          20    /* 0x14 */
918 #define SSH2_MSG_NEWKEYS                          21    /* 0x15 */
919 #define SSH2_MSG_KEXDH_INIT                       30    /* 0x1e */
920 #define SSH2_MSG_KEXDH_REPLY                      31    /* 0x1f */
921 #define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD           30    /* 0x1e */
922 #define SSH2_MSG_KEX_DH_GEX_REQUEST               34    /* 0x22 */
923 #define SSH2_MSG_KEX_DH_GEX_GROUP                 31    /* 0x1f */
924 #define SSH2_MSG_KEX_DH_GEX_INIT                  32    /* 0x20 */
925 #define SSH2_MSG_KEX_DH_GEX_REPLY                 33    /* 0x21 */
926 #define SSH2_MSG_KEXRSA_PUBKEY                    30    /* 0x1e */
927 #define SSH2_MSG_KEXRSA_SECRET                    31    /* 0x1f */
928 #define SSH2_MSG_KEXRSA_DONE                      32    /* 0x20 */
929 #define SSH2_MSG_KEX_ECDH_INIT                    30    /* 0x1e */
930 #define SSH2_MSG_KEX_ECDH_REPLY                   31    /* 0x1f */
931 #define SSH2_MSG_KEX_ECMQV_INIT                   30    /* 0x1e */
932 #define SSH2_MSG_KEX_ECMQV_REPLY                  31    /* 0x1f */
933 #define SSH2_MSG_USERAUTH_REQUEST                 50    /* 0x32 */
934 #define SSH2_MSG_USERAUTH_FAILURE                 51    /* 0x33 */
935 #define SSH2_MSG_USERAUTH_SUCCESS                 52    /* 0x34 */
936 #define SSH2_MSG_USERAUTH_BANNER                  53    /* 0x35 */
937 #define SSH2_MSG_USERAUTH_PK_OK                   60    /* 0x3c */
938 #define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ        60    /* 0x3c */
939 #define SSH2_MSG_USERAUTH_INFO_REQUEST            60    /* 0x3c */
940 #define SSH2_MSG_USERAUTH_INFO_RESPONSE           61    /* 0x3d */
941 #define SSH2_MSG_GLOBAL_REQUEST                   80    /* 0x50 */
942 #define SSH2_MSG_REQUEST_SUCCESS                  81    /* 0x51 */
943 #define SSH2_MSG_REQUEST_FAILURE                  82    /* 0x52 */
944 #define SSH2_MSG_CHANNEL_OPEN                     90    /* 0x5a */
945 #define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION        91    /* 0x5b */
946 #define SSH2_MSG_CHANNEL_OPEN_FAILURE             92    /* 0x5c */
947 #define SSH2_MSG_CHANNEL_WINDOW_ADJUST            93    /* 0x5d */
948 #define SSH2_MSG_CHANNEL_DATA                     94    /* 0x5e */
949 #define SSH2_MSG_CHANNEL_EXTENDED_DATA            95    /* 0x5f */
950 #define SSH2_MSG_CHANNEL_EOF                      96    /* 0x60 */
951 #define SSH2_MSG_CHANNEL_CLOSE                    97    /* 0x61 */
952 #define SSH2_MSG_CHANNEL_REQUEST                  98    /* 0x62 */
953 #define SSH2_MSG_CHANNEL_SUCCESS                  99    /* 0x63 */
954 #define SSH2_MSG_CHANNEL_FAILURE                  100   /* 0x64 */
955 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE               60
956 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN                  61
957 #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE      63
958 #define SSH2_MSG_USERAUTH_GSSAPI_ERROR                  64
959 #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK                 65
960 #define SSH2_MSG_USERAUTH_GSSAPI_MIC                    66
961
962 /*
963  * SSH-1 agent messages.
964  */
965 #define SSH1_AGENTC_REQUEST_RSA_IDENTITIES    1
966 #define SSH1_AGENT_RSA_IDENTITIES_ANSWER      2
967 #define SSH1_AGENTC_RSA_CHALLENGE             3
968 #define SSH1_AGENT_RSA_RESPONSE               4
969 #define SSH1_AGENTC_ADD_RSA_IDENTITY          7
970 #define SSH1_AGENTC_REMOVE_RSA_IDENTITY       8
971 #define SSH1_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9 /* openssh private? */
972
973 /*
974  * Messages common to SSH-1 and OpenSSH's SSH-2.
975  */
976 #define SSH_AGENT_FAILURE                    5
977 #define SSH_AGENT_SUCCESS                    6
978
979 /*
980  * OpenSSH's SSH-2 agent messages.
981  */
982 #define SSH2_AGENTC_REQUEST_IDENTITIES          11
983 #define SSH2_AGENT_IDENTITIES_ANSWER            12
984 #define SSH2_AGENTC_SIGN_REQUEST                13
985 #define SSH2_AGENT_SIGN_RESPONSE                14
986 #define SSH2_AGENTC_ADD_IDENTITY                17
987 #define SSH2_AGENTC_REMOVE_IDENTITY             18
988 #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES       19
989
990 /*
991  * Assorted other SSH-related enumerations.
992  */
993 #define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1   /* 0x1 */
994 #define SSH2_DISCONNECT_PROTOCOL_ERROR            2     /* 0x2 */
995 #define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED       3     /* 0x3 */
996 #define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED 4    /* 0x4 */
997 #define SSH2_DISCONNECT_MAC_ERROR                 5     /* 0x5 */
998 #define SSH2_DISCONNECT_COMPRESSION_ERROR         6     /* 0x6 */
999 #define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE     7     /* 0x7 */
1000 #define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8        /* 0x8 */
1001 #define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE   9     /* 0x9 */
1002 #define SSH2_DISCONNECT_CONNECTION_LOST           10    /* 0xa */
1003 #define SSH2_DISCONNECT_BY_APPLICATION            11    /* 0xb */
1004 #define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS      12    /* 0xc */
1005 #define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER    13    /* 0xd */
1006 #define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14       /* 0xe */
1007 #define SSH2_DISCONNECT_ILLEGAL_USER_NAME         15    /* 0xf */
1008
1009 #define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED     1     /* 0x1 */
1010 #define SSH2_OPEN_CONNECT_FAILED                  2     /* 0x2 */
1011 #define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE            3     /* 0x3 */
1012 #define SSH2_OPEN_RESOURCE_SHORTAGE               4     /* 0x4 */
1013
1014 #define SSH2_EXTENDED_DATA_STDERR                 1     /* 0x1 */
1015
1016 /*
1017  * Need this to warn about support for the original SSH-2 keyfile
1018  * format.
1019  */
1020 void old_keyfile_warning(void);