… | |
… | |
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 | |
44 | struct vpn; |
45 | struct 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 |
47 | void connection_init (); |
48 | void connection_init (); |
… | |
… | |
53 | u32 seqno; |
54 | u32 seqno; |
54 | u8 auth_key[AUTH_SIZE]; |
55 | u8 auth_key[AUTH_SIZE]; |
55 | u8 mac_key[MAC_KEYSIZE]; // used to generate hmac key |
56 | u8 mac_key[MAC_KEYSIZE]; // used to generate hmac key |
56 | u8 cipher_key[CIPHER_KEYSIZE]; // used to generate cipher key |
57 | u8 cipher_key[CIPHER_KEYSIZE]; // used to generate cipher key |
57 | u8 hkdf_salt[HKDF_SALT]; // used as hkdf salt |
58 | u8 hkdf_salt[HKDF_SALT]; // used as hkdf salt |
58 | u8 ikm[IKM_SIZE]; // used as additional keying material for both sides |
|
|
59 | u8 pad[ |
59 | u8 pad[ |
60 | (RSABITS >> 3) |
60 | (RSABITS >> 3) |
61 | - 41 // OAEP |
61 | - 41 // OAEP |
62 | - sizeof (u32) // seqno |
62 | - sizeof (u32) // seqno |
63 | - AUTH_SIZE |
63 | - AUTH_SIZE |
64 | - MAC_KEYSIZE |
64 | - MAC_KEYSIZE |
65 | - CIPHER_KEYSIZE |
65 | - CIPHER_KEYSIZE |
66 | - HKDF_SALT |
66 | - HKDF_SALT |
67 | - IKM_SIZE |
|
|
68 | - 3 // struct alignment... |
67 | - 3 // struct alignment... |
69 | ]; |
68 | ]; |
70 | }; |
69 | }; |
71 | |
70 | |
72 | struct auth_data |
71 | struct auth_data |
… | |
… | |
202 | bool is_direct; // current connection (si) is direct? |
201 | bool is_direct; // current connection (si) is direct? |
203 | |
202 | |
204 | pkt_queue data_queue, vpn_queue; |
203 | pkt_queue data_queue, vpn_queue; |
205 | |
204 | |
206 | crypto_ctx *octx, *ictx; |
205 | crypto_ctx *octx, *ictx; |
|
|
206 | iv_gen oiv; // generator for random byte prefix |
207 | |
207 | |
208 | void generate_auth_data (); |
208 | void generate_auth_data (); |
209 | |
209 | |
210 | ev_tstamp auth_expire; // when the snd_* and *_ecdh values expire |
210 | ev_tstamp auth_expire; // when the snd_* and *_ecdh values expire |
211 | |
211 | |