comparison session.h @ 801:7dcb46da72d9 ecc

merge in HEAD
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 May 2013 12:09:35 +0800
parents ac2158e3e403 2f1c199b6e4b
children 6c69e7df3621
comparison
equal deleted inserted replaced
799:c344607b7341 801:7dcb46da72d9
42 extern int sessinitdone; /* Is set to 0 somewhere */ 42 extern int sessinitdone; /* Is set to 0 somewhere */
43 extern int exitflag; 43 extern int exitflag;
44 44
45 void common_session_init(int sock_in, int sock_out); 45 void common_session_init(int sock_in, int sock_out);
46 void session_loop(void(*loophandler)()); 46 void session_loop(void(*loophandler)());
47 void common_session_cleanup(); 47 void session_cleanup();
48 void session_identification(); 48 void send_session_identification();
49 void send_msg_ignore(); 49 void send_msg_ignore();
50 50
51 const char* get_user_shell(); 51 const char* get_user_shell();
52 void fill_passwd(const char* username); 52 void fill_passwd(const char* username);
53 53
56 void svr_dropbear_exit(int exitcode, const char* format, va_list param) ATTRIB_NORETURN; 56 void svr_dropbear_exit(int exitcode, const char* format, va_list param) ATTRIB_NORETURN;
57 void svr_dropbear_log(int priority, const char* format, va_list param); 57 void svr_dropbear_log(int priority, const char* format, va_list param);
58 58
59 /* Client */ 59 /* Client */
60 void cli_session(int sock_in, int sock_out); 60 void cli_session(int sock_in, int sock_out);
61 void cli_session_cleanup();
62 void cleantext(unsigned char* dirtytext); 61 void cleantext(unsigned char* dirtytext);
63 62
64 /* crypto parameters that are stored individually for transmit and receive */ 63 /* crypto parameters that are stored individually for transmit and receive */
65 struct key_context_directional { 64 struct key_context_directional {
66 const struct dropbear_cipher *algo_crypt; 65 const struct dropbear_cipher *algo_crypt;
77 #ifdef DROPBEAR_ENABLE_CTR_MODE 76 #ifdef DROPBEAR_ENABLE_CTR_MODE
78 symmetric_CTR ctr; 77 symmetric_CTR ctr;
79 #endif 78 #endif
80 } cipher_state; 79 } cipher_state;
81 unsigned char mackey[MAX_MAC_LEN]; 80 unsigned char mackey[MAX_MAC_LEN];
81 int valid;
82 }; 82 };
83 83
84 struct key_context { 84 struct key_context {
85 85
86 struct key_context_directional recv; 86 struct key_context_directional recv;
109 respecting AUTH_TIMEOUT any more) */ 109 respecting AUTH_TIMEOUT any more) */
110 110
111 int sock_in; 111 int sock_in;
112 int sock_out; 112 int sock_out;
113 113
114 unsigned char *remoteident; 114 /* remotehost will be initially NULL as we delay
115 * reading the remote version string. it will be set
116 * by the time any recv_() packet methods are called */
117 unsigned char *remoteident;
115 118
116 int maxfd; /* the maximum file descriptor to check with select() */ 119 int maxfd; /* the maximum file descriptor to check with select() */
117 120
118 121
119 /* Packet buffers/values etc */ 122 /* Packet buffers/values etc */
130 session, see process-packet.c */ 133 session, see process-packet.c */
131 134
132 unsigned dataallowed : 1; /* whether we can send data packets or we are in 135 unsigned dataallowed : 1; /* whether we can send data packets or we are in
133 the middle of a KEX or something */ 136 the middle of a KEX or something */
134 137
135 unsigned char requirenext; /* byte indicating what packet we require next, 138 unsigned char requirenext[2]; /* bytes indicating what packets we require next,
136 or 0x00 for any */ 139 or 0x00 for any. Second option can only be
140 used if the first byte is also set */
137 141
138 unsigned char ignorenext; /* whether to ignore the next packet, 142 unsigned char ignorenext; /* whether to ignore the next packet,
139 used for kex_follows stuff */ 143 used for kex_follows stuff */
140 144
141 unsigned char lastpacket; /* What the last received packet type was */ 145 unsigned char lastpacket; /* What the last received packet type was */
167 171
168 /* a list of queued replies that should be sent after a KEX has 172 /* a list of queued replies that should be sent after a KEX has
169 concluded (ie, while dataallowed was unset)*/ 173 concluded (ie, while dataallowed was unset)*/
170 struct packetlist *reply_queue_head, *reply_queue_tail; 174 struct packetlist *reply_queue_head, *reply_queue_tail;
171 175
172 algo_type*(*buf_match_algo)(buffer*buf, algo_type localalgos[],
173 int *goodguess); /* The function to use to choose which algorithm
174 to use from the ones presented by the remote
175 side. Is specific to the client/server mode,
176 hence the function-pointer callback.*/
177
178 void(*remoteclosed)(); /* A callback to handle closure of the 176 void(*remoteclosed)(); /* A callback to handle closure of the
179 remote connection */ 177 remote connection */
180 178
179 void(*extra_session_cleanup)(); /* client or server specific cleanup */
180 void(*send_kex_first_guess)();
181 181
182 struct AuthState authstate; /* Common amongst client and server, since most 182 struct AuthState authstate; /* Common amongst client and server, since most
183 struct elements are common */ 183 struct elements are common */
184 184
185 /* Channel related */ 185 /* Channel related */
231 KEXDONE 231 KEXDONE
232 } cli_kex_state; 232 } cli_kex_state;
233 233
234 typedef enum { 234 typedef enum {
235 STATE_NOTHING, 235 STATE_NOTHING,
236 SERVICE_AUTH_REQ_SENT,
237 SERVICE_AUTH_ACCEPT_RCVD,
238 SERVICE_CONN_REQ_SENT,
239 SERVICE_CONN_ACCEPT_RCVD,
240 USERAUTH_REQ_SENT, 236 USERAUTH_REQ_SENT,
241 USERAUTH_FAIL_RCVD, 237 USERAUTH_FAIL_RCVD,
242 USERAUTH_SUCCESS_RCVD, 238 USERAUTH_SUCCESS_RCVD,
243 SESSION_RUNNING 239 SESSION_RUNNING
244 } cli_state; 240 } cli_state;
245 241
246 struct clientsession { 242 struct clientsession {
243
244 // XXX - move these to kexstate?
247 struct kex_dh_param *dh_param; 245 struct kex_dh_param *dh_param;
248 struct kex_ecdh_param *ecdh_param; 246 struct kex_ecdh_param *ecdh_param;
247 const struct dropbear_kex *param_kex_algo; /* KEX algorithm corresponding to current dh_e and dh_x */
248
249 cli_kex_state kex_state; /* Used for progressing KEX */ 249 cli_kex_state kex_state; /* Used for progressing KEX */
250 cli_state state; /* Used to progress auth/channelsession etc */ 250 cli_state state; /* Used to progress auth/channelsession etc */
251 unsigned donefirstkex : 1; /* Set when we set sentnewkeys, never reset */ 251 unsigned donefirstkex : 1; /* Set when we set sentnewkeys, never reset */
252 252
253 int tty_raw_mode; /* Whether we're in raw mode (and have to clean up) */ 253 int tty_raw_mode; /* Whether we're in raw mode (and have to clean up) */