Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/wireguard.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ bool wireguard_check_mac2(struct wireguard_device *device, const uint8_t *data,
return result;
}

void handshake_destroy(struct wireguard_handshake *handshake) {
crypto_zero(handshake->ephemeral_private, WIREGUARD_PUBLIC_KEY_LEN);
crypto_zero(handshake->remote_ephemeral, WIREGUARD_PUBLIC_KEY_LEN);
crypto_zero(handshake->hash, WIREGUARD_HASH_LEN);
crypto_zero(handshake->chaining_key, WIREGUARD_HASH_LEN);
handshake->remote_index = 0;
handshake->local_index = 0;
handshake->valid = false;
}

void keypair_destroy(struct wireguard_keypair *keypair) {
crypto_zero(keypair, sizeof(struct wireguard_keypair));
keypair->valid = false;
Expand Down
2 changes: 1 addition & 1 deletion src/wireguardif.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ static void wireguardif_tmr(void *arg) {
keypair_destroy(&peer->next_keypair);
keypair_destroy(&peer->curr_keypair);
keypair_destroy(&peer->prev_keypair);
// TODO: Also destroy handshake?
handshake_destroy(&peer->handshake);

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