From ea9848e14afac46c9ac0343b7cb1c1d97fc268cc Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Fri, 29 May 2026 13:09:39 +0100 Subject: [PATCH] Adapt ChaCha20 counter helper for 3.6 Signed-off-by: Ben Taylor --- library/chacha20.c | 6 +++--- library/chachapoly.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/library/chacha20.c b/library/chacha20.c index 0f97116f0c..b67e7ef40e 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -202,8 +202,8 @@ int mbedtls_chacha20_starts(mbedtls_chacha20_context *ctx, return 0; } -static int chacha20_check_counter_wrap(const mbedtls_chacha20_context *ctx, - size_t size) +int mbedtls_chacha20_check_counter_wrap(const mbedtls_chacha20_context *ctx, + size_t size) { size_t available_keystream = 0; uint64_t needed_blocks = 0; @@ -255,7 +255,7 @@ int mbedtls_chacha20_update(mbedtls_chacha20_context *ctx, size_t offset = 0U; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ret = chacha20_check_counter_wrap(ctx, size); + ret = mbedtls_chacha20_check_counter_wrap(ctx, size); if (ret != 0) { return ret; } diff --git a/library/chachapoly.c b/library/chachapoly.c index a6fbebe10e..3580a36367 100644 --- a/library/chachapoly.c +++ b/library/chachapoly.c @@ -21,6 +21,9 @@ #if !defined(MBEDTLS_CHACHAPOLY_ALT) +int mbedtls_chacha20_check_counter_wrap(const mbedtls_chacha20_context *ctx, + size_t size); + #define CHACHAPOLY_STATE_INIT (0) #define CHACHAPOLY_STATE_AAD (1) #define CHACHAPOLY_STATE_CIPHERTEXT (2) /* Encrypting or decrypting */