summaryrefslogtreecommitdiffstats
path: root/src/wireguard.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-20 22:32:43 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-20 22:35:35 +1000
commit1621c152fd62a66f6b454e9000caa7d1f38a59e1 (patch)
tree27bd801be081fc1759363b422844ba536b75f2e1 /src/wireguard.h
parentAdd docs to clean_patch.sh (diff)
downloadwireguard-openbsd-1621c152fd62a66f6b454e9000caa7d1f38a59e1.tar.xz
wireguard-openbsd-1621c152fd62a66f6b454e9000caa7d1f38a59e1.zip
Simplify handshake and session structs
Diffstat (limited to 'src/wireguard.h')
-rw-r--r--src/wireguard.h81
1 files changed, 53 insertions, 28 deletions
diff --git a/src/wireguard.h b/src/wireguard.h
index c3e6f3e4203..b3ecd51bb89 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -86,42 +86,67 @@ struct wg_cookie_maker {
struct wg_handshake {
struct rwlock hs_lock;
- enum wg_state hs_state;
- uint32_t hs_local_id;
- uint32_t hs_remote_id;
- uint8_t hs_mac[WG_MAC_SIZE];
- uint8_t hs_hash[WG_HASH_SIZE];
- uint8_t hs_ck[WG_HASH_SIZE];
- uint8_t hs_k[WG_HASH_SIZE];
- uint8_t hs_timestamp[WG_TIMESTAMP_SIZE];
-
- uint8_t hs_epub[WG_KEY_SIZE];
- struct wg_keypair hs_ekey;
- struct wg_cookie hs_cookie;
-
- uint8_t hs_shared[WG_KEY_SIZE];
uint8_t hs_spub[WG_KEY_SIZE];
+ uint8_t hs_shared[WG_KEY_SIZE];
+ struct wg_cookie hs_cookie;
struct wg_keypair *hs_skey;
+
+ struct {
+ enum wg_state ss_state;
+ uint32_t ss_local_id;
+ uint32_t ss_remote_id;
+ uint8_t ss_mac[WG_MAC_SIZE];
+ uint8_t ss_hash[WG_HASH_SIZE];
+ uint8_t ss_ck[WG_HASH_SIZE];
+ uint8_t ss_k[WG_HASH_SIZE];
+ uint8_t ss_timestamp[WG_TIMESTAMP_SIZE];
+
+ uint8_t ss_epub[WG_KEY_SIZE];
+ struct wg_keypair ss_ekey;
+ } hs_ss;
};
+#define hs_state hs_ss.ss_state
+#define hs_local_id hs_ss.ss_local_id
+#define hs_remote_id hs_ss.ss_remote_id
+#define hs_mac hs_ss.ss_mac
+#define hs_hash hs_ss.ss_hash
+#define hs_ck hs_ss.ss_ck
+#define hs_k hs_ss.ss_k
+#define hs_timestamp hs_ss.ss_timestamp
+#define hs_epub hs_ss.ss_epub
+#define hs_ekey hs_ss.ss_ekey
+
struct wg_session {
struct rwlock s_lock;
- enum wg_state s_state;
- uint64_t s_txcounter;
- uint64_t s_rxcounter;
- uint32_t s_local_id;
- uint32_t s_remote_id;
- struct timespec s_created;
-
- uint8_t s_txkey[WG_KEY_SIZE];
- uint8_t s_rxkey[WG_KEY_SIZE];
-
- struct wg_antireplay {
- uint64_t ar_head;
- uint64_t ar_bitmap[WG_ARB_BITS / WG_ARI_BITS];
- } s_ar;
+ struct {
+ enum wg_state ss_state;
+ uint64_t ss_txcounter;
+ uint64_t ss_rxcounter;
+ uint32_t ss_local_id;
+ uint32_t ss_remote_id;
+ struct timespec ss_created;
+
+ uint8_t ss_txkey[WG_KEY_SIZE];
+ uint8_t ss_rxkey[WG_KEY_SIZE];
+
+ struct wg_antireplay {
+ uint64_t ar_head;
+ uint64_t ar_bitmap[WG_ARB_BITS / WG_ARI_BITS];
+ } ss_ar;
+ } s_ss;
};
+#define s_state s_ss.ss_state
+#define s_txcounter s_ss.ss_txcounter
+#define s_rxcounter s_ss.ss_rxcounter
+#define s_local_id s_ss.ss_local_id
+#define s_remote_id s_ss.ss_remote_id
+#define s_created s_ss.ss_created
+#define s_txkey s_ss.ss_txkey
+#define s_rxkey s_ss.ss_rxkey
+#define s_ar s_ss.ss_ar
+
struct wg_timers {
struct timeout t_ka;
struct timeout t_pka;