From 4ee90fe0e626c5d7ed06f803ff3a4470172659ac Mon Sep 17 00:00:00 2001 From: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com> Date: Wed, 10 Jun 2026 07:48:55 +0100 Subject: [PATCH] Correct logic for keystream_bytes_used Co-authored-by: minosgalanakis <30719586+minosgalanakis@users.noreply.github.com> Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com> (cherry picked from commit 8de9f6aa776d5e92d77b10dfca6666f83f542ab2) --- library/chacha20.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/chacha20.c b/library/chacha20.c index 53bf4900b6..41383c44b2 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -210,7 +210,7 @@ int mbedtls_chacha20_check_counter_wrap(const mbedtls_chacha20_context *ctx, size_t available_keystream = 0; uint64_t needed_blocks = 0; - if (ctx->keystream_bytes_used == CHACHA20_COUNTER_EXHAUSTED) { + if (ctx->keystream_bytes_used >= CHACHA20_COUNTER_EXHAUSTED) { return size == 0U ? 0 : MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA; }