Skip to content

Commit

Permalink
Merge pull request #35 from trombik/bugfix-upstream
Browse files Browse the repository at this point in the history
bugfix: merge fixes in upstream
  • Loading branch information
trombik authored Nov 13, 2022
2 parents b3d4493 + 3cd8506 commit 0687400
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/wireguard.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#include "crypto.h"
#include <esp_log.h>
Expand Down Expand Up @@ -322,7 +323,10 @@ bool wireguard_check_replay(struct wireguard_keypair *keypair, uint64_t seq) {
// Adapted from code in Appendix C at https://tools.ietf.org/html/rfc2401
uint32_t diff;
bool result = false;
size_t ReplayWindowSize = sizeof(keypair->replay_bitmap); // 32 bits
size_t ReplayWindowSize = sizeof(keypair->replay_bitmap) * CHAR_BIT; // 32 bits

// WireGuard data packet counter starts from 0 but algorithm expects packet numbers to start from 1
seq++;

if (seq != 0) {
if (seq > keypair->replay_counter) {
Expand Down

0 comments on commit 0687400

Please sign in to comment.