ssh.h 42 KB

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