ssh.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include <string.h>
  2. #define SSH_CIPHER_NONE 0
  3. #define SSH_CIPHER_IDEA 1
  4. #define SSH_CIPHER_DES 2
  5. #define SSH_CIPHER_3DES 3
  6. #define SSH_CIPHER_RC4 5
  7. #define SSH_CIPHER_BLOWFISH 6
  8. #define SSH_AUTH_RHOSTS 1
  9. #define SSH_AUTH_RSA 2
  10. #define SSH_AUTH_PASSWORD 3
  11. #define SSH_AUTH_RHOSTS_RSA 4
  12. #define SSH_PROTOFLAG_SCREEN_NUMBER 0x00000001
  13. #define SSH_PROTOFLAG_HOST_IN_FWD_OPEN 0x00000002
  14. #define SSH_MSG_NONE 0
  15. #define SSH_MSG_DISCONNECT 1
  16. #define SSH_SMSG_PUBLIC_KEY 2
  17. #define SSH_CMSG_SESSION_KEY 3
  18. #define SSH_CMSG_USER 4
  19. #define SSH_CMSG_AUTH_RHOSTS 5
  20. #define SSH_CMSG_AUTH_RSA 6
  21. #define SSH_SMSG_RSA_CHALLENGE 7
  22. #define SSH_CMSG_AUTH_RSA_RESPONSE 8
  23. #define SSH_CMSG_AUTH_PASSWORD 9
  24. #define SSH_CMSG_REQUEST_PTY 10
  25. #define SSH_CMSG_WINDOW_SIZE 11
  26. #define SSH_CMSG_EXEC_SHELL 12
  27. #define SSH_CMSG_EXEC_CMD 13
  28. #define SSH_SMSG_SUCCESS 14
  29. #define SSH_SMSG_FAILURE 15
  30. #define SSH_CMSG_STDIN_DATA 16
  31. #define SSH_SMSG_STDOUT_DATA 17
  32. #define SSH_SMSG_STDERR_DATA 18
  33. #define SSH_CMSG_EOF 19
  34. #define SSH_SMSG_EXITSTATUS 20
  35. #define SSH_MSG_CHANNEL_OPEN_CONFIRMATION 21
  36. #define SSH_MSG_CHANNEL_OPEN_FAILURE 22
  37. #define SSH_MSG_CHANNEL_DATA 23
  38. #define SSH_MSG_CHANNEL_CLOSE 24
  39. #define SSH_MSG_CHANNEL_CLOSE_CONFIRMATION 25
  40. /* 26 was unix-domain X11 forwarding */
  41. #define SSH_SMSG_X11_OPEN 27
  42. #define SSH_CMSG_PORT_FORWARD_REQUEST 28
  43. #define SSH_MSG_PORT_OPEN 29
  44. #define SSH_CMSG_AGENT_REQUEST_FORWARDING 30
  45. #define SSH_SMSG_AGENT_OPEN 31
  46. #define SSH_MSG_IGNORE 32
  47. #define SSH_CMSG_EXIT_CONFIRMATION 33
  48. #define SSH_CMSG_X11_REQUEST_FARWARDING 34
  49. #define SSH_CMSG_AUTH_RHOSTS_RSA 35
  50. #define SSH_MSG_DEBUG 36
  51. #define SSH_CMSG_REQUEST_COMPRESSION 37
  52. #define SSH_CMSG_MAX_PACKET_SIZE 38
  53. #define SSH_CMSG_AUTH_TIS 39
  54. #define SSH_SMSG_AUTH_TIS_CHALLENGE 40
  55. #define SSH_CMSG_AUTH_TIS_RESPONSE 41
  56. #define SSH_CMSG_AUTH_KERBEROS 42
  57. #define SSH_SMSG_AUTH_KERBEROS_RESPONSE 43
  58. #define SSH_CMSG_HAVE_KERBEROS_TGT 44
  59. struct RSAKey {
  60. int bits;
  61. int bytes;
  62. void *modulus;
  63. void *exponent;
  64. };
  65. int makekey(unsigned char *data, struct RSAKey *result,
  66. unsigned char **keystr);
  67. void rsaencrypt(unsigned char *data, int length, struct RSAKey *key);
  68. int rsastr_len(struct RSAKey *key);
  69. void rsastr_fmt(char *str, struct RSAKey *key);
  70. typedef unsigned int word32;
  71. typedef unsigned int uint32;
  72. unsigned long crc32(const unsigned char *s, unsigned int len);
  73. struct MD5Context {
  74. uint32 buf[4];
  75. uint32 bits[2];
  76. unsigned char in[64];
  77. };
  78. void MD5Init(struct MD5Context *context);
  79. void MD5Update(struct MD5Context *context, unsigned char const *buf,
  80. unsigned len);
  81. void MD5Final(unsigned char digest[16], struct MD5Context *context);
  82. struct ssh_cipher {
  83. void (*sesskey)(unsigned char *key);
  84. void (*encrypt)(unsigned char *blk, int len);
  85. void (*decrypt)(unsigned char *blk, int len);
  86. };
  87. void SHATransform(word32 *digest, word32 *data);
  88. int random_byte(void);
  89. void random_add_noise(void *noise, int length);