From f2878c8c0d554409d2001a9471153646a1fe0e5e Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 5 Dec 2023 11:39:40 +0000 Subject: [PATCH 1/2] Reduce variations tested in constant_time_hmac Signed-off-by: Dave Rodgman --- tests/suites/test_suite_constant_time_hmac.function | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_constant_time_hmac.function b/tests/suites/test_suite_constant_time_hmac.function index 9d9aa3c778..c311c2bcdd 100644 --- a/tests/suites/test_suite_constant_time_hmac.function +++ b/tests/suites/test_suite_constant_time_hmac.function @@ -78,11 +78,20 @@ void ssl_cf_hmac(int hash) #endif /* - * Test all possible lengths up to a point. The difference between + * Test various possible lengths up to a point. The difference between * max_in_len and min_in_len is at most 255, and make sure they both vary * by at least one block size. + * + * It is quite expensive to test all possible lengths, so we test values + * which are within 1 of a multiple of 64, plus loop end values. */ for (max_in_len = 0; max_in_len <= 255 + block_size; max_in_len++) { + int no_skip = (((max_in_len + 65) % 64) < 3) || + (max_in_len >= ((255 + block_size) - 1)); + if (!no_skip) { + continue; + } + mbedtls_test_set_step(max_in_len * 10000); /* Use allocated in buffer to catch overreads */ From 48652f081125130a0dda11ae5ed3e7d215585273 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Thu, 7 Dec 2023 08:41:08 +0000 Subject: [PATCH 2/2] Adjust test iterations Signed-off-by: Dave Rodgman --- tests/suites/test_suite_constant_time_hmac.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_constant_time_hmac.function b/tests/suites/test_suite_constant_time_hmac.function index c311c2bcdd..109cbce0a0 100644 --- a/tests/suites/test_suite_constant_time_hmac.function +++ b/tests/suites/test_suite_constant_time_hmac.function @@ -83,10 +83,10 @@ void ssl_cf_hmac(int hash) * by at least one block size. * * It is quite expensive to test all possible lengths, so we test values - * which are within 1 of a multiple of 64, plus loop end values. + * which are within 1 of a multiple of block_size, plus loop end values. */ for (max_in_len = 0; max_in_len <= 255 + block_size; max_in_len++) { - int no_skip = (((max_in_len + 65) % 64) < 3) || + int no_skip = (((max_in_len + block_size + 1) % block_size) < 3) || (max_in_len >= ((255 + block_size) - 1)); if (!no_skip) { continue;