From ecd649205db1d886ac4021f37fb7bd583c720c0f Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Thu, 16 Mar 2023 12:00:24 +0000 Subject: [PATCH] Add tests that cover msan explicit_bzero issue Signed-off-by: Dave Rodgman --- tests/suites/test_suite_platform_util.data | 24 +++++++++++++++++++ .../suites/test_suite_platform_util.function | 10 ++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/suites/test_suite_platform_util.data b/tests/suites/test_suite_platform_util.data index 948543a6f..b820293b9 100644 --- a/tests/suites/test_suite_platform_util.data +++ b/tests/suites/test_suite_platform_util.data @@ -21,3 +21,27 @@ mbedtls_platform_zeroize:127:0 Zeroize len 128 mbedtls_platform_zeroize:128:0 + +Zeroize uninitialised 1 0 +mbedtls_platform_zeroize_uninitialised:1:0 + +Zeroize uninitialised 16 0 +mbedtls_platform_zeroize_uninitialised:16:0 + +Zeroize uninitialised 16 1 +mbedtls_platform_zeroize_uninitialised:16:1 + +Zeroize uninitialised 16 10 +mbedtls_platform_zeroize_uninitialised:16:10 + +Zeroize uninitialised 16 15 +mbedtls_platform_zeroize_uninitialised:16:15 + +Zeroize uninitialised 128 0 +mbedtls_platform_zeroize_uninitialised:128:0 + +Zeroize uninitialised 128 64 +mbedtls_platform_zeroize_uninitialised:128:64 + +Zeroize uninitialised 128 127 +mbedtls_platform_zeroize_uninitialised:128:127 diff --git a/tests/suites/test_suite_platform_util.function b/tests/suites/test_suite_platform_util.function index e5464e0ec..8f131dfa7 100644 --- a/tests/suites/test_suite_platform_util.function +++ b/tests/suites/test_suite_platform_util.function @@ -39,3 +39,13 @@ void mbedtls_platform_zeroize(int len, int null) TEST_EQUAL(buf[len + 1], 2); } /* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_platform_zeroize_uninitialised(int len, int p) +{ + char buf[128]; + mbedtls_platform_zeroize(buf, len); + + TEST_EQUAL(buf[p], 0); +} +/* END_CASE */ \ No newline at end of file