From da04b3b972eabb6985a4067a149585361aad3561 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 28 Jan 2019 15:18:15 +0200 Subject: [PATCH] Increase okm_hex buffer to contain null character Add an additional byte for the `okm_hex` buffer, to assure it is null-terminated in case `okm` is 128 bytes long. --- tests/suites/test_suite_hkdf.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_hkdf.function b/tests/suites/test_suite_hkdf.function index d2d66596f..3e8720734 100644 --- a/tests/suites/test_suite_hkdf.function +++ b/tests/suites/test_suite_hkdf.function @@ -21,9 +21,9 @@ void test_hkdf( int md_alg, char *hex_ikm_string, char *hex_salt_string, unsigned char okm[128] = { '\0' }; /* * okm_hex is the string representation of okm, - * so its size is twice the size of okm. + * so its size is twice the size of okm, and an extra null-termination. */ - unsigned char okm_hex[256] = { '\0' }; + unsigned char okm_hex[257] = { '\0' }; const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg ); TEST_ASSERT( md != NULL );