ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/connection.h
(Generate patch)

Comparing gvpe/src/connection.h (file contents):
Revision 1.37 by root, Tue Jul 16 16:44:36 2013 UTC vs.
Revision 1.40 by root, Fri Oct 11 04:07:24 2013 UTC

38#include "conf.h" 38#include "conf.h"
39#include "sockinfo.h" 39#include "sockinfo.h"
40#include "util.h" 40#include "util.h"
41#include "device.h" 41#include "device.h"
42#include "curve25519.h" 42#include "curve25519.h"
43#include "iv_gen.h"
43 44
44struct vpn; 45struct vpn;
45 46
46// called after HUP etc. to (re-)initialize global data structures 47// called after HUP etc. to (re-)initialize global data structures
47void connection_init (); 48void connection_init ();
48 49
49typedef curve25519_key ecdh_key; 50typedef curve25519_key ecdh_key;
50 51
51struct rsa_data 52struct rsa_data
52{ 53{
53 u32 seqno; 54 u32 seqno; // (ictx) initial sequence nr (31 bits)
54 u8 auth_key[AUTH_SIZE];
55 u8 mac_key[MAC_KEYSIZE]; // used to generate hmac key 55 u8 mac_key[MAC_IKMSIZE]; // (ictx) used to generate hmac key
56 u8 cipher_key[CIPHER_KEYSIZE]; // used to generate cipher key 56 u8 cipher_key[CIPHER_IKMSIZE]; // (ictx) used to generate cipher key
57 u8 hkdf_salt[HKDF_SALT]; // used as hkdf salt 57 u8 hkdf_salt[HKDF_SALT]; // (octx) used as hkdf salt
58 u8 ikm[IKM_SIZE]; // used as additional keying material for both sides 58 u8 extra_auth[ // (ictx) additional auth randomness
59 u8 pad[
60 (RSABITS >> 3) 59 (RSABITS >> 3)
61 - 41 // OAEP 60 - RSA_OAEP_SIZE
62 - sizeof (u32) // seqno 61 - sizeof (u32) // seqno
63 - AUTH_SIZE
64 - MAC_KEYSIZE 62 - MAC_IKMSIZE
65 - CIPHER_KEYSIZE 63 - CIPHER_IKMSIZE
66 - HKDF_SALT 64 - HKDF_SALT
67 - IKM_SIZE
68 - 3 // struct alignment... 65 - 3 // struct alignment...
69 ]; 66 ];
70}; 67};
71 68
72struct auth_data 69struct auth_data
101 98
102 void hmac_set (crypto_ctx * ctx); 99 void hmac_set (crypto_ctx * ctx);
103 bool hmac_chk (crypto_ctx * ctx); 100 bool hmac_chk (crypto_ctx * ctx);
104 101
105private: 102private:
106 static unsigned char hmac_digest[EVP_MAX_MD_SIZE];
107
108 void hmac_gen (crypto_ctx * ctx); 103 void hmac_gen (crypto_ctx * ctx, u8 *hmac_digest);
109}; 104};
110 105
111struct vpn_packet : hmac_packet 106struct vpn_packet : hmac_packet
112{ 107{
113 enum ptype 108 enum ptype
197 u32 oseqno; 192 u32 oseqno;
198 sliding_window iseqno; 193 sliding_window iseqno;
199 194
200 u8 protocol; 195 u8 protocol;
201 u8 features; 196 u8 features;
202 bool is_direct; // current connection (si) is direct?
203 197
204 pkt_queue data_queue, vpn_queue; 198 pkt_queue data_queue, vpn_queue;
205 199
206 crypto_ctx *octx, *ictx; 200 crypto_ctx *octx, *ictx;
201 iv_gen oiv; // generator for random byte prefix
207 202
208 void generate_auth_data (); 203 void generate_auth_data ();
209 204
210 ev_tstamp auth_expire; // when the snd_* and *_ecdh values expire 205 ev_tstamp auth_expire; // when the snd_* and *_ecdh values expire
206 ev_tstamp hmac_error; // time of first hmac error in a series
211 207
212 // send auth data - used for octx 208 // send auth data - used for octx
213 auth_data snd_auth; 209 auth_data snd_auth;
214 auth_mac snd_auth_mac; // expected response mac
215 ecdh_key snd_ecdh_a; // the secret ecdh key we used for our request 210 ecdh_key snd_ecdh_a; // the secret ecdh key we used for our request
216 ecdh_key snd_ecdh_b; // the public ecdh key we received in the response 211 ecdh_key snd_ecdh_b; // the public ecdh key we received in the response
217 bool have_snd_auth; // received response for our req 212 bool have_snd_auth; // received response for our req
218 213
219 // receive auth data - used for ictx 214 // receive auth data - used for ictx
232 void reset_si (); 227 void reset_si ();
233 const sockinfo &forward_si (const sockinfo &si) const; 228 const sockinfo &forward_si (const sockinfo &si) const;
234 229
235 void shutdown (); 230 void shutdown ();
236 void connection_established (const sockinfo &rsi); 231 void connection_established (const sockinfo &rsi);
237 void reset_connection (); 232 void reset_connection (const char *reason);
238 233
239 void establish_connection_cb (ev::timer &w, int revents); ev::timer establish_connection; 234 void establish_connection_cb (ev::timer &w, int revents); ev::timer establish_connection;
240 void rekey_cb (ev::timer &w, int revents); ev::timer rekey; // next rekying (actually current reset + reestablishing) 235 void rekey_cb (ev::timer &w, int revents); ev::timer rekey; // next rekeying (actually current reset + reestablishing)
241 void keepalive_cb (ev::timer &w, int revents); ev::timer keepalive; // next keepalive probe 236 void keepalive_cb (ev::timer &w, int revents); ev::timer keepalive; // next keepalive probe
242 237
243 void send_connect_request (int id); 238 void send_connect_request (int id);
244 void send_auth_request (const sockinfo &si, bool initiate); 239 void send_auth_request (const sockinfo &si, bool initiate);
245 void send_auth_response (const sockinfo &si); 240 void send_auth_response (const sockinfo &si);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines