mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-12-24 17:41:01 +03:00
Change mpi_core_exp_mod() constant time testing to be clearer
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
@@ -1302,18 +1302,16 @@ void mpi_core_exp_mod(char *input_N, char *input_A,
|
||||
working_limbs);
|
||||
|
||||
TEST_CALLOC(T, working_limbs);
|
||||
|
||||
/* Temporary because MEMSAN doesn't support assembly implementation see #1243 */
|
||||
#if !defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
|
||||
TEST_CF_SECRET(A, A_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_CF_SECRET(N, N_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_CF_SECRET(E, E_limbs * sizeof(mbedtls_mpi_uint));
|
||||
#endif
|
||||
mbedtls_mpi_core_exp_mod(Y, A, N, N_limbs, E, E_limbs, R2, T);
|
||||
#if !defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
|
||||
|
||||
TEST_CF_PUBLIC(Y, N_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_CF_PUBLIC(A, A_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_CF_PUBLIC(N, N_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_CF_PUBLIC(E, E_limbs * sizeof(mbedtls_mpi_uint));
|
||||
#endif
|
||||
|
||||
TEST_EQUAL(0, memcmp(X, Y, N_limbs * sizeof(mbedtls_mpi_uint)));
|
||||
|
||||
@@ -1324,10 +1322,8 @@ void mpi_core_exp_mod(char *input_N, char *input_A,
|
||||
#endif
|
||||
/* Check when output aliased to input */
|
||||
mbedtls_mpi_core_exp_mod(A, A, N, N_limbs, E, E_limbs, R2, T);
|
||||
#if !defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
|
||||
TEST_CF_PUBLIC(A, A_limbs * sizeof(mbedtls_mpi_uint));
|
||||
#endif
|
||||
|
||||
TEST_CF_PUBLIC(A, A_limbs * sizeof(mbedtls_mpi_uint));
|
||||
TEST_EQUAL(0, memcmp(X, A, N_limbs * sizeof(mbedtls_mpi_uint)));
|
||||
|
||||
exit:
|
||||
|
||||
Reference in New Issue
Block a user