From 8b7fca9ede7bdf1672ec06793a56f07fb4375b9f Mon Sep 17 00:00:00 2001 From: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:55:23 +0100 Subject: [PATCH] Add improvement to chacha20 tests 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 9d6a54795c96f7f0d7dfc230071dc16c5f47f94a) --- tests/suites/test_suite_chacha20.function | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_chacha20.function b/tests/suites/test_suite_chacha20.function index d8cc8a0eb3..2b8e086d1b 100644 --- a/tests/suites/test_suite_chacha20.function +++ b/tests/suites/test_suite_chacha20.function @@ -97,7 +97,9 @@ void chacha20_input_len_too_long(void) /* Consume the rest of the final counter block, then reject more input. */ TEST_EQUAL(mbedtls_chacha20_update(&ctx, 63, input, output), 0); TEST_EQUAL(mbedtls_chacha20_update(&ctx, 0, NULL, NULL), 0); - TEST_EQUAL(mbedtls_chacha20_update(&ctx, 1, input, output), +/*Test that zero length update does not break an exhausted context */ +TEST_EQUAL(mbedtls_chacha20_update(&ctx, 0, NULL, NULL), 0); +TEST_EQUAL(mbedtls_chacha20_update(&ctx, 1, input, output), MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA); /* The final counter block is valid, but generating another block is not. */