From 30f49f19cca6f8e30c470c7f84dce98a8c6438d2 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Fri, 8 Mar 2024 16:29:54 +0000 Subject: [PATCH] Hinder unwanted optimisations We want this function to be constant time. Make it less likely that the compiler optimises it. Signed-off-by: Janos Follath --- library/bignum_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/bignum_core.c b/library/bignum_core.c index f66739df92..8374f3ae60 100644 --- a/library/bignum_core.c +++ b/library/bignum_core.c @@ -859,7 +859,7 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub_int(mbedtls_mpi_uint *X, mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(const mbedtls_mpi_uint *A, size_t limbs) { - mbedtls_mpi_uint bits = 0; + volatile mbedtls_mpi_uint bits = 0; for (size_t i = 0; i < limbs; i++) { bits |= A[i];