Mercurial > dropbear
comparison session.h @ 534:0431915df79f
- Get rid of decryptreadbuf, just decrypt in-place with readbuf
- Share make_mac function for both packet creation and validation
- Split recv/trans parts of key_context into their own structures
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 01 Mar 2009 16:15:57 +0000 |
parents | a3748e54273c |
children | cf376c696dfc 8711f20b89ab |
comparison
equal
deleted
inserted
replaced
533:805ae74ec024 | 534:0431915df79f |
---|---|
58 /* Client */ | 58 /* Client */ |
59 void cli_session(int sock_in, int sock_out, char *remotehost); | 59 void cli_session(int sock_in, int sock_out, char *remotehost); |
60 void cli_session_cleanup(); | 60 void cli_session_cleanup(); |
61 void cleantext(unsigned char* dirtytext); | 61 void cleantext(unsigned char* dirtytext); |
62 | 62 |
63 struct key_context { | 63 /* crypto parameters that are stored individually for transmit and receive */ |
64 | 64 struct key_context_directional { |
65 const struct dropbear_cipher *recv_algo_crypt; /* NULL for none */ | 65 const struct dropbear_cipher *algo_crypt; /* NULL for none */ |
66 const struct dropbear_cipher *trans_algo_crypt; /* NULL for none */ | 66 const struct dropbear_cipher_mode *crypt_mode; |
67 const struct dropbear_cipher_mode *recv_crypt_mode; | 67 const struct dropbear_hash *algo_mac; /* NULL for none */ |
68 const struct dropbear_cipher_mode *trans_crypt_mode; | 68 int hash_index; /* lookup for libtomcrypt */ |
69 const struct dropbear_hash *recv_algo_mac; /* NULL for none */ | 69 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 | 70 #ifndef DISABLE_ZLIB |
79 z_streamp recv_zstream; | 71 z_streamp zstream; |
80 z_streamp trans_zstream; | 72 #endif |
81 #endif | |
82 | |
83 /* actual keys */ | 73 /* actual keys */ |
84 union { | 74 union { |
85 symmetric_CBC cbc; | 75 symmetric_CBC cbc; |
86 #ifdef DROPBEAR_ENABLE_CTR_MODE | 76 #ifdef DROPBEAR_ENABLE_CTR_MODE |
87 symmetric_CTR ctr; | 77 symmetric_CTR ctr; |
88 #endif | 78 #endif |
89 } recv_cipher_state; | 79 } cipher_state; |
90 union { | 80 unsigned char mackey[MAX_MAC_KEY]; |
91 symmetric_CBC cbc; | 81 }; |
92 #ifdef DROPBEAR_ENABLE_CTR_MODE | 82 |
93 symmetric_CTR ctr; | 83 struct key_context { |
94 #endif | 84 |
95 } trans_cipher_state; | 85 struct key_context_directional recv; |
96 unsigned char recvmackey[MAX_MAC_KEY]; | 86 struct key_context_directional trans; |
97 unsigned char transmackey[MAX_MAC_KEY]; | 87 |
98 | 88 char algo_kex; |
89 char algo_hostkey; | |
90 | |
91 int allow_compress; /* whether compression has started (useful in | |
92 [email protected] delayed compression case) */ | |
99 }; | 93 }; |
100 | 94 |
101 struct packetlist; | 95 struct packetlist; |
102 struct packetlist { | 96 struct packetlist { |
103 struct packetlist *next; | 97 struct packetlist *next; |
126 /* Packet buffers/values etc */ | 120 /* Packet buffers/values etc */ |
127 buffer *writepayload; /* Unencrypted payload to write - this is used | 121 buffer *writepayload; /* Unencrypted payload to write - this is used |
128 throughout the code, as handlers fill out this | 122 throughout the code, as handlers fill out this |
129 buffer with the packet to send. */ | 123 buffer with the packet to send. */ |
130 struct Queue writequeue; /* A queue of encrypted packets to send */ | 124 struct Queue writequeue; /* A queue of encrypted packets to send */ |
131 buffer *readbuf; /* Encrypted */ | 125 buffer *readbuf; /* From the wire, decrypted in-place */ |
132 buffer *decryptreadbuf; /* Post-decryption */ | |
133 buffer *payload; /* Post-decompression, the actual SSH packet */ | 126 buffer *payload; /* Post-decompression, the actual SSH packet */ |
134 unsigned int transseq, recvseq; /* Sequence IDs */ | 127 unsigned int transseq, recvseq; /* Sequence IDs */ |
135 | 128 |
136 /* Packet-handling flags */ | 129 /* Packet-handling flags */ |
137 const packettype * packettypes; /* Packet handler mappings for this | 130 const packettype * packettypes; /* Packet handler mappings for this |