From 658f4fd6d8dbfab6f13c943ae12af2695f8b8c1f Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 26 May 2021 14:26:48 +0200 Subject: [PATCH] Cover multiple calls to mbedtls_gcm_update_ad in gcm test suite. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_gcm.function | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_gcm.function b/tests/suites/test_suite_gcm.function index a6b0a4c119..c7942f81a7 100644 --- a/tests/suites/test_suite_gcm.function +++ b/tests/suites/test_suite_gcm.function @@ -16,15 +16,19 @@ static int check_multipart( mbedtls_gcm_context *ctx, int ok = 0; uint8_t *output = NULL; size_t n2 = input->len - n1; + size_t n1_add = n1 < add->len ? add->len - n1 : add->len; + size_t n2_add = add->len - n1_add; size_t olen; /* Sanity checks on the test data */ TEST_ASSERT( n1 <= input->len ); + TEST_ASSERT( n1_add <= add->len ); TEST_EQUAL( input->len, expected_output->len ); TEST_EQUAL( 0, mbedtls_gcm_starts( ctx, mode, iv->x, iv->len ) ); - TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x, add->len ) ); + TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x, n1_add ) ); + TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x + n1_add, n2_add ) ); /* Allocate a tight buffer for each update call. This way, if the function * tries to write beyond the advertised required buffer size, this will