From 71690fc73abef7598ecef9b2dbf566fa498c25e3 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 20 Nov 2019 13:29:16 -0800 Subject: [PATCH] Maintenance: DTLS 1. Updated the window scrolling. There was a couple off-by-one errors in the DTLS window handling. They canceled each other out, but there was a rare case where they would shift too much. --- src/internal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal.c b/src/internal.c index cd4954713..5e834bc7d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -12102,7 +12102,7 @@ static WC_INLINE int DtlsCheckWindow(WOLFSSL* ssl) return 0; } - if (window[idx] & (1 << (newDiff - 1))) { + if (window[idx] & (1 << newDiff)) { WOLFSSL_MSG("Current record sequence number already received."); return 0; } @@ -12209,7 +12209,7 @@ static WC_INLINE int DtlsUpdateWindow(WOLFSSL* ssl) word32 newDiff = diff % DTLS_WORD_BITS; if (idx < WOLFSSL_DTLS_WINDOW_WORDS) - window[idx] |= (1 << (newDiff - 1)); + window[idx] |= (1 << newDiff); } else { if (diff >= DTLS_SEQ_BITS) @@ -12231,7 +12231,7 @@ static WC_INLINE int DtlsUpdateWindow(WOLFSSL* ssl) else { temp |= (oldWindow[i-idx] << newDiff); window[i] = temp; - temp = oldWindow[i-idx] >> (DTLS_WORD_BITS - newDiff); + temp = oldWindow[i-idx] >> (DTLS_WORD_BITS - newDiff - 1); } } }