2 * Dropbear - a SSH2 server
4 * Copyright (c) 2002,2003 Matt Johnston
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 extern int sessinitdone;
40 void session_cleanup();
41 void child_session(int sock, runopts *opts, int childpipe,
42 struct sockaddr *remoteaddr);
46 const struct dropbear_cipher *recv_algo_crypt; /* NULL for none */
47 const struct dropbear_cipher *trans_algo_crypt; /* NULL for none */
48 const struct dropbear_hash *recv_algo_mac; /* NULL for none */
49 const struct dropbear_hash *trans_algo_mac; /* NULL for none */
53 char recv_algo_comp; /* compression */
56 z_streamp recv_zstream;
57 z_streamp trans_zstream;
61 symmetric_CBC recv_symmetric_struct;
62 symmetric_CBC trans_symmetric_struct;
63 unsigned char recvmackey[MAX_MAC_KEY];
64 unsigned char transmackey[MAX_MAC_KEY];
70 runopts * opts; /* runtime options, incl hostkey, banner etc */
72 int childpipe; /* kept open until we successfully authenticate */
73 long connecttime; /* time of initial connection */
75 struct sockaddr *remoteaddr; /* the host and port of the client */
76 unsigned char *addrstring; /* the text version of remoteaddr */
77 unsigned char *hostname; /* the remote hostname */
79 int maxfd; /* the maximum file descriptor to check with select() */
80 unsigned char *remoteident;
82 struct KEXState kexstate;
85 unsigned dataallowed : 1; /* whether we can send data packets or we are in
86 the middle of a KEX or something */
88 unsigned char expecting; /* byte indicating what packet we expect next,
91 /* unencrypted write payload */
92 buffer *writepayload; /* this will actually refer to within clearwritebuf */
93 unsigned int transseq; /* sequence number */
94 /* encrypted write packet buffer queue */
95 struct Queue writequeue;
97 /* read packet buffer */
99 /* decrypted read buffer */
100 buffer *decryptreadbuf;
101 buffer *payload; /* this actually refers to within decryptreadbuf */
102 unsigned int recvseq; /* sequence number */
104 struct key_context *keys;
105 struct key_context *newkeys;
107 unsigned char *session_id; /*this is the hash from the first kex*/
109 /* the following are for key exchange */
110 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/
111 /* these are used temorarily during kex, are freed after use */
112 mp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */
113 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/
114 buffer* transkexinit; /* the kexinit payload we send */
117 struct AuthState authstate;
120 struct Channel ** channels; /* these pointers may be null */
121 unsigned int chansize; /* the number of Channel*s allocated for channels */
123 struct ChildPid * childpids; /* array of mappings childpid<->channel */
124 unsigned int childpidsize;
128 /* global struct storing the state */
129 extern struct sshsession ses;
131 #endif /* _SESSION_H_ */