7 enum /* internal debugging flags */
19 enum /* protocol packet types */
29 SSH_SMSG_AUTH_RSA_CHALLENGE,
30 SSH_CMSG_AUTH_RSA_RESPONSE,
31 SSH_CMSG_AUTH_PASSWORD,
47 SSH_MSG_CHANNEL_OPEN_CONFIRMATION,
48 SSH_MSG_CHANNEL_OPEN_FAILURE,
50 SSH_MSG_CHANNEL_INPUT_EOF,
51 SSH_MSG_CHANNEL_OUTPUT_CLOSED,
52 SSH_MSG_UNIX_DOMAIN_X11_FORWARDING, /* obsolete */
54 SSH_CMSG_PORT_FORWARD_REQUEST,
58 SSH_CMSG_AGENT_REQUEST_FORWARDING,
61 SSH_CMSG_EXIT_CONFIRMATION,
62 SSH_CMSG_X11_REQUEST_FORWARDING,
63 SSH_CMSG_AUTH_RHOSTS_RSA,
65 SSH_CMSG_REQUEST_COMPRESSION,
66 SSH_CMSG_MAX_PACKET_SIZE,
70 SSH_SMSG_AUTH_TIS_CHALLENGE,
71 SSH_CMSG_AUTH_TIS_RESPONSE,
72 SSH_CMSG_AUTH_KERBEROS,
73 SSH_SMSG_AUTH_KERBEROS_RESPONSE,
74 SSH_CMSG_HAVE_KERBEROS_TGT,
77 enum /* protocol flags */
79 SSH_PROTOFLAG_SCREEN_NUMBER=1<<0,
80 SSH_PROTOFLAG_HOST_IN_FWD_OPEN=1<<1,
83 enum /* agent protocol packet types */
86 SSH_AGENTC_REQUEST_RSA_IDENTITIES,
87 SSH_AGENT_RSA_IDENTITIES_ANSWER,
88 SSH_AGENTC_RSA_CHALLENGE,
89 SSH_AGENT_RSA_RESPONSE,
92 SSH_AGENTC_ADD_RSA_IDENTITY,
93 SSH_AGENTC_REMOVE_RSA_IDENTITY,
96 enum /* protocol constants */
98 SSH_MAX_DATA = 256*1024,
99 SSH_MAX_MSG = SSH_MAX_DATA+4,
107 enum /* crypto ids */
116 SSH_CIPHER_TWIDDLE, /* for debugging */
119 enum /* auth method ids */
123 SSH_AUTH_PASSWORD = 3,
124 SSH_AUTH_RHOSTS_RSA = 4,
126 SSH_AUTH_USER_RSA = 6,
129 typedef struct Auth Auth;
130 typedef struct Authsrv Authsrv;
131 typedef struct Cipher Cipher;
132 typedef struct CipherState CipherState;
133 typedef struct Conn Conn;
134 typedef struct Msg Msg;
136 #pragma incomplete CipherState
150 AuthInfo *(*fn)(Conn*, Msg*);
157 CipherState *(*init)(Conn*, int isserver);
158 void (*encrypt)(CipherState*, uchar*, int);
159 void (*decrypt)(CipherState*, uchar*, int);
167 uchar cookie[COOKIELEN];
168 uchar sessid[SESSIDLEN];
169 uchar sesskey[SESSKEYLEN];
174 Cipher *cipher; /* chosen cipher */
175 Cipher **okcipher; /* list of acceptable ciphers */
186 RSApriv *serverpriv; /* server only */
196 ulong len; /* output: #bytes before pos, input: #bytes after pos */
197 uchar *bp; /* beginning of allocated space */
198 uchar *rp; /* read pointer */
199 uchar *wp; /* write pointer */
200 uchar *ep; /* end of allocated space */
201 Msg *link; /* for sshnet */
204 #define LONG(p) (((p)[0]<<24)|((p)[1]<<16)|((p)[2]<<8)|((p)[3]))
205 #define PLONG(p, l) \
206 (((p)[0]=(l)>>24),((p)[1]=(l)>>16),\
207 ((p)[2]=(l)>>8),((p)[3]=(l)))
208 #define SHORT(p) (((p)[0]<<8)|(p)[1])
209 #define PSHORT(p,l) \
210 (((p)[0]=(l)>>8),((p)[1]=(l)))
212 extern char Edecode[];
213 extern char Eencode[];
214 extern char Ememory[];
215 extern char Ehangup[];
217 extern int debuglevel;
219 extern Auth authpassword;
223 extern Authsrv authsrvpassword;
224 extern Authsrv authsrvtis;
226 extern Cipher cipher3des;
227 extern Cipher cipherblowfish;
228 extern Cipher cipherdes;
229 extern Cipher cipherrc4;
230 extern Cipher ciphernone;
231 extern Cipher ciphertwiddle;
234 Msg* allocmsg(Conn*, int, int);
235 void badmsg(Msg*, int);
236 Msg* recvmsg(Conn*, int);
237 void unrecvmsg(Conn*, Msg*);
240 ushort getshort(Msg*);
242 char* getstring(Msg*);
243 void* getbytes(Msg*, int);
244 mpint* getmpint(Msg*);
245 RSApub* getRSApub(Msg*);
246 void putbyte(Msg*, uchar);
247 void putshort(Msg*, ushort);
248 void putlong(Msg*, ulong);
249 void putstring(Msg*, char*);
250 void putbytes(Msg*, void*, long);
251 void putmpint(Msg*, mpint*);
252 void putRSApub(Msg*, RSApub*);
253 mpint* rsapad(mpint*, int);
254 mpint* rsaunpad(mpint*);
255 void mptoberjust(mpint*, uchar*, int);
256 mpint* rsaencryptbuf(RSApub*, uchar*, int);
259 void sshclienthandshake(Conn*);
260 void requestpty(Conn*);
261 int readgeom(int*, int*, int*, int*);
262 void sendwindowsize(Conn*, int, int, int, int);
266 void sshserverhandshake(Conn*);
276 int appendkey(char*, char*, RSApub*);
277 int findkey(char*, char*, RSApub*);
278 int replacekey(char*, char*, RSApub*);
281 int startagent(Conn*);
282 void handleagentmsg(Msg*);
283 void handleagentopen(Msg*);
284 void handleagentieof(Msg*);
285 void handleagentoclose(Msg*);
288 void debug(int, char*, ...);
290 void* erealloc(void*, long);
291 void error(char*, ...);
292 RSApriv* readsecretkey(char*);
293 int readstrnl(int, char*, int);
294 void atexitkill(int);
295 void atexitkiller(void);
296 void calcsessid(Conn*);
297 void sshlog(char*, ...);
298 void setaliases(Conn*, char*);
299 void privatefactotum(void);
301 #pragma varargck argpos debug 2
302 #pragma varargck argpos error 1
303 #pragma varargck argpos sshlog 2