ssh.h 42 KB

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