Adapt ChaCha20 counter helper for 3.6

Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
This commit is contained in:
Ben Taylor 2026-05-29 13:09:39 +01:00
parent 96cb584a5e
commit ea9848e14a
2 changed files with 6 additions and 3 deletions

View File

@ -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;
}

View File

@ -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 */