Skip to content

Commit ab89408

Browse files
authored
Merge pull request #1 from ErikDoell/main
The handshake must also be destroyed during a timer reset. Compare wg_q…
2 parents b984818 + 2520c24 commit ab89408

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/wireguard.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,16 @@ bool wireguard_check_mac2(struct wireguard_device *device, const uint8_t *data,
444444
return result;
445445
}
446446

447+
void handshake_destroy(struct wireguard_handshake *handshake) {
448+
crypto_zero(handshake->ephemeral_private, WIREGUARD_PUBLIC_KEY_LEN);
449+
crypto_zero(handshake->remote_ephemeral, WIREGUARD_PUBLIC_KEY_LEN);
450+
crypto_zero(handshake->hash, WIREGUARD_HASH_LEN);
451+
crypto_zero(handshake->chaining_key, WIREGUARD_HASH_LEN);
452+
handshake->remote_index = 0;
453+
handshake->local_index = 0;
454+
handshake->valid = false;
455+
}
456+
447457
void keypair_destroy(struct wireguard_keypair *keypair) {
448458
crypto_zero(keypair, sizeof(struct wireguard_keypair));
449459
keypair->valid = false;

src/wireguardif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static void wireguardif_tmr(void *arg) {
863863
keypair_destroy(&peer->next_keypair);
864864
keypair_destroy(&peer->curr_keypair);
865865
keypair_destroy(&peer->prev_keypair);
866-
// TODO: Also destroy handshake?
866+
handshake_destroy(&peer->handshake);
867867

868868
// Revert back to default IP/port if these were altered
869869
peer->ip = peer->connect_ip;

0 commit comments

Comments
 (0)