Mercurial > dropbear
comparison session.h @ 641:2b1bb792cd4d dropbear-tfm
- Update tfm changes to current default tip
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 21 Nov 2011 19:52:28 +0800 |
parents | 76097ec1a29a 00eca37e47e8 |
children |
comparison
equal
deleted
inserted
replaced
640:76097ec1a29a | 641:2b1bb792cd4d |
---|---|
35 #include "queue.h" | 35 #include "queue.h" |
36 #include "listener.h" | 36 #include "listener.h" |
37 #include "packet.h" | 37 #include "packet.h" |
38 #include "tcpfwd.h" | 38 #include "tcpfwd.h" |
39 #include "chansession.h" | 39 #include "chansession.h" |
40 #include "dbutil.h" | |
40 | 41 |
41 extern int sessinitdone; /* Is set to 0 somewhere */ | 42 extern int sessinitdone; /* Is set to 0 somewhere */ |
42 extern int exitflag; | 43 extern int exitflag; |
43 | 44 |
44 void common_session_init(int sock_in, int sock_out, char* remotehost); | 45 void common_session_init(int sock_in, int sock_out); |
45 void session_loop(void(*loophandler)()); | 46 void session_loop(void(*loophandler)()); |
46 void common_session_cleanup(); | 47 void common_session_cleanup(); |
47 void session_identification(); | 48 void session_identification(); |
48 void send_msg_ignore(); | 49 void send_msg_ignore(); |
49 | 50 |
50 const char* get_user_shell(); | 51 const char* get_user_shell(); |
51 void fill_passwd(const char* username); | 52 void fill_passwd(const char* username); |
52 | 53 |
53 /* Server */ | 54 /* Server */ |
54 void svr_session(int sock, int childpipe, char *remotehost, char *addrstring); | 55 void svr_session(int sock, int childpipe); |
55 void svr_dropbear_exit(int exitcode, const char* format, va_list param); | 56 void svr_dropbear_exit(int exitcode, const char* format, va_list param) ATTRIB_NORETURN; |
56 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); |
57 | 58 |
58 /* Client */ | 59 /* Client */ |
59 void cli_session(int sock_in, int sock_out, char *remotehost); | 60 void cli_session(int sock_in, int sock_out); |
60 void cli_session_cleanup(); | 61 void cli_session_cleanup(); |
61 void cleantext(unsigned char* dirtytext); | 62 void cleantext(unsigned char* dirtytext); |
62 | 63 |
63 struct key_context { | 64 /* crypto parameters that are stored individually for transmit and receive */ |
64 | 65 struct key_context_directional { |
65 const struct dropbear_cipher *recv_algo_crypt; /* NULL for none */ | 66 const struct dropbear_cipher *algo_crypt; /* NULL for none */ |
66 const struct dropbear_cipher *trans_algo_crypt; /* NULL for none */ | 67 const struct dropbear_cipher_mode *crypt_mode; |
67 const struct dropbear_cipher_mode *recv_crypt_mode; | 68 const struct dropbear_hash *algo_mac; /* NULL for none */ |
68 const struct dropbear_cipher_mode *trans_crypt_mode; | 69 int hash_index; /* lookup for libtomcrypt */ |
69 const struct dropbear_hash *recv_algo_mac; /* NULL for none */ | 70 char algo_comp; /* compression */ |
70 const struct dropbear_hash *trans_algo_mac; /* NULL for none */ | |
71 char algo_kex; | |
72 char algo_hostkey; | |
73 | |
74 char recv_algo_comp; /* compression */ | |
75 char trans_algo_comp; | |
76 int allow_compress; /* whether compression has started (useful in | |
77 [email protected] delayed compression case) */ | |
78 #ifndef DISABLE_ZLIB | 71 #ifndef DISABLE_ZLIB |
79 z_streamp recv_zstream; | 72 z_streamp zstream; |
80 z_streamp trans_zstream; | 73 #endif |
81 #endif | |
82 | |
83 /* actual keys */ | 74 /* actual keys */ |
84 union { | 75 union { |
85 symmetric_CBC cbc; | 76 symmetric_CBC cbc; |
86 #ifdef DROPBEAR_ENABLE_CTR_MODE | 77 #ifdef DROPBEAR_ENABLE_CTR_MODE |
87 symmetric_CTR ctr; | 78 symmetric_CTR ctr; |
88 #endif | 79 #endif |
89 } recv_cipher_state; | 80 } cipher_state; |
90 union { | 81 unsigned char mackey[MAX_MAC_KEY]; |
91 symmetric_CBC cbc; | 82 }; |
92 #ifdef DROPBEAR_ENABLE_CTR_MODE | 83 |
93 symmetric_CTR ctr; | 84 struct key_context { |
94 #endif | 85 |
95 } trans_cipher_state; | 86 struct key_context_directional recv; |
96 unsigned char recvmackey[MAX_MAC_KEY]; | 87 struct key_context_directional trans; |
97 unsigned char transmackey[MAX_MAC_KEY]; | 88 |
98 | 89 char algo_kex; |
90 char algo_hostkey; | |
91 | |
92 int allow_compress; /* whether compression has started (useful in | |
93 [email protected] delayed compression case) */ | |
99 }; | 94 }; |
100 | 95 |
101 struct packetlist; | 96 struct packetlist; |
102 struct packetlist { | 97 struct packetlist { |
103 struct packetlist *next; | 98 struct packetlist *next; |
113 (cleared after auth once we're not | 108 (cleared after auth once we're not |
114 respecting AUTH_TIMEOUT any more) */ | 109 respecting AUTH_TIMEOUT any more) */ |
115 | 110 |
116 int sock_in; | 111 int sock_in; |
117 int sock_out; | 112 int sock_out; |
118 | |
119 unsigned char *remotehost; /* the peer hostname */ | |
120 | 113 |
121 unsigned char *remoteident; | 114 unsigned char *remoteident; |
122 | 115 |
123 int maxfd; /* the maximum file descriptor to check with select() */ | 116 int maxfd; /* the maximum file descriptor to check with select() */ |
124 | 117 |
126 /* Packet buffers/values etc */ | 119 /* Packet buffers/values etc */ |
127 buffer *writepayload; /* Unencrypted payload to write - this is used | 120 buffer *writepayload; /* Unencrypted payload to write - this is used |
128 throughout the code, as handlers fill out this | 121 throughout the code, as handlers fill out this |
129 buffer with the packet to send. */ | 122 buffer with the packet to send. */ |
130 struct Queue writequeue; /* A queue of encrypted packets to send */ | 123 struct Queue writequeue; /* A queue of encrypted packets to send */ |
131 buffer *readbuf; /* Encrypted */ | 124 buffer *readbuf; /* From the wire, decrypted in-place */ |
132 buffer *decryptreadbuf; /* Post-decryption */ | |
133 buffer *payload; /* Post-decompression, the actual SSH packet */ | 125 buffer *payload; /* Post-decompression, the actual SSH packet */ |
134 unsigned int transseq, recvseq; /* Sequence IDs */ | 126 unsigned int transseq, recvseq; /* Sequence IDs */ |
135 | 127 |
136 /* Packet-handling flags */ | 128 /* Packet-handling flags */ |
137 const packettype * packettypes; /* Packet handler mappings for this | 129 const packettype * packettypes; /* Packet handler mappings for this |
167 fp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */ | 159 fp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */ |
168 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/ | 160 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/ |
169 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/ | 161 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/ |
170 buffer* transkexinit; /* the kexinit packet we send should be kept so we | 162 buffer* transkexinit; /* the kexinit packet we send should be kept so we |
171 can add it to the hash when generating keys */ | 163 can add it to the hash when generating keys */ |
164 | |
165 /* Enables/disables compression */ | |
166 algo_type *compress_algos; | |
172 | 167 |
173 /* a list of queued replies that should be sent after a KEX has | 168 /* a list of queued replies that should be sent after a KEX has |
174 concluded (ie, while dataallowed was unset)*/ | 169 concluded (ie, while dataallowed was unset)*/ |
175 struct packetlist *reply_queue_head, *reply_queue_tail; | 170 struct packetlist *reply_queue_head, *reply_queue_tail; |
176 | 171 |
217 * svr-chansession.c for details */ | 212 * svr-chansession.c for details */ |
218 struct exitinfo lastexit; | 213 struct exitinfo lastexit; |
219 | 214 |
220 /* The numeric address they connected from, used for logging */ | 215 /* The numeric address they connected from, used for logging */ |
221 char * addrstring; | 216 char * addrstring; |
217 | |
218 /* The resolved remote address, used for lastlog etc */ | |
219 char *remotehost; | |
220 | |
221 #ifdef __uClinux__ | |
222 pid_t server_pid; | |
223 #endif | |
222 | 224 |
223 }; | 225 }; |
224 | 226 |
225 typedef enum { | 227 typedef enum { |
226 KEX_NOTHING, | 228 KEX_NOTHING, |
266 be used */ | 268 be used */ |
267 int interact_request_received; /* flag whether we've received an | 269 int interact_request_received; /* flag whether we've received an |
268 info request from the server for | 270 info request from the server for |
269 interactive auth.*/ | 271 interactive auth.*/ |
270 #endif | 272 #endif |
271 struct SignKeyList *lastprivkey; | 273 sign_key *lastprivkey; |
272 | 274 |
273 int retval; /* What the command exit status was - we emulate it */ | 275 int retval; /* What the command exit status was - we emulate it */ |
274 #if 0 | 276 #if 0 |
275 TODO | 277 TODO |
276 struct AgentkeyList *agentkeys; /* Keys to use for public-key auth */ | 278 struct AgentkeyList *agentkeys; /* Keys to use for public-key auth */ |