From 3221798c67884619c8bd4104f7f2adc6a3284c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 14 Apr 2026 12:24:53 +0200 Subject: [PATCH] ecp: improve test function in case of failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_ecp.function | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function index e0ced66eff..ddeda55e6f 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -1671,7 +1671,12 @@ void ecp_mod_p_generic_raw(int curve_id, mbedtls_mpi_uint c = mbedtls_mpi_core_sub(X, X, N, limbs_N); (void) mbedtls_mpi_core_add_if(X, N, limbs_N, (unsigned) c); #endif + /* Checking that the result is equal to the expected value is enough, + * but in case of failures, it's useful to know if the incorrect result + * had the correct bitlength or not / was in the correct range or not. */ TEST_LE_U(mbedtls_mpi_core_bitlen(X, limbs_X), curve_bits); + /* This only works because we know from above the top limbs of X are 0. */ + TEST_EQUAL(MBEDTLS_CT_TRUE, mbedtls_mpi_core_lt_ct(X, N, limbs_N)); TEST_MEMORY_COMPARE(X, bytes, res, bytes); exit: