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