summaryrefslogtreecommitdiffstats
path: root/src/wireguard.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-06-12 00:40:05 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-06-12 00:40:05 +1000
commita4a4036a40d24ecf556b8b686c657119881831c3 (patch)
treebd527b94c119df7587cc811139a55ff33c637076 /src/wireguard.h
parentstaging (diff)
downloadwireguard-openbsd-a4a4036a40d24ecf556b8b686c657119881831c3.tar.xz
wireguard-openbsd-a4a4036a40d24ecf556b8b686c657119881831c3.zip
staging2
Diffstat (limited to 'src/wireguard.h')
-rw-r--r--src/wireguard.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/wireguard.h b/src/wireguard.h
index d2af218b8ad..992ccc69305 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -39,6 +39,12 @@ enum wg_role {
WG_ROLE_RESPONDER,
};
+enum wg_keytype {
+ WG_KEY_PSK,
+ WG_KEY_LOCAL,
+ WG_KEY_REMOTE,
+};
+
enum wg_pkt_type {
WG_PKT_UNKNOWN = 0,
WG_PKT_INITIATION,
@@ -47,7 +53,12 @@ enum wg_pkt_type {
WG_PKT_TRANSPORT,
};
-struct wg_state {
+struct wg_conn {
+ struct rwlock c_lock;
+ uint8_t c_psk[WG_KEY_SIZE];
+ uint8_t c_pubkey[WG_KEY_SIZE];
+ uint8_t c_local_pubkey[WG_KEY_SIZE], c_local_privkey[WG_KEY_SIZE];
+
struct wg_handshake {
enum wg_role hs_role;
uint32_t hs_local_id;
@@ -124,6 +135,16 @@ struct wg_msg_transport {
uint8_t data [];
} __packed;
+struct wg_msg_initiation_helper {
+ void *ih_arg;
+ struct wg_conn *(*ih_keylookup)(void *, uint8_t *);
+ uint8_t *ih_pubkey, *ih_privkey;
+};
+
+void wg_conn_init(struct wg_conn *);
+void wg_conn_reset(struct wg_conn *);
+void wg_conn_setkey(struct wg_conn *, enum wg_keytype, uint8_t *);
+
void wg_conn_make_initiation(struct wg_conn *, struct wg_msg_initiation *);
int wg_conn_make_response(struct wg_conn *, struct wg_msg_response *);
int wg_conn_make_cookie(struct wg_conn *, struct wg_msg_cookie *);
@@ -136,4 +157,9 @@ int wg_conn_decrypt(struct wg_conn *, struct wg_msg_transport *, size_t);
int wg_conn_promote_handshake(struct wg_conn *);
+int wg_conn_reject_tx(struct wg_conn *);
+
+void wg_util_key_privtopub(uint8_t [WG_KEY_SIZE], const uint8_t [WG_KEY_SIZE]);
+enum wg_pkt_type wg_util_pkt_type(uint8_t *, size_t);
+
#endif /* _LIBWG_H_ */