From d6df0a5dacc0dd1cef11b5232eb546124bfe9f18 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Mon, 11 Mar 2024 09:40:03 +0000 Subject: [PATCH] Fix use of volatile We need the pointer, A, to be volatile, to ensure the reads happen. bits does not need to be volatile. Signed-off-by: Janos Follath --- library/bignum_core.c | 4 ++-- library/bignum_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/bignum_core.c b/library/bignum_core.c index 8374f3ae60..db6e231703 100644 --- a/library/bignum_core.c +++ b/library/bignum_core.c @@ -856,10 +856,10 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub_int(mbedtls_mpi_uint *X, return c; } -mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(const mbedtls_mpi_uint *A, +mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(volatile const mbedtls_mpi_uint *A, size_t limbs) { - volatile mbedtls_mpi_uint bits = 0; + mbedtls_mpi_uint bits = 0; for (size_t i = 0; i < limbs; i++) { bits |= A[i]; diff --git a/library/bignum_core.h b/library/bignum_core.h index 92c8d47db5..00c557b816 100644 --- a/library/bignum_core.h +++ b/library/bignum_core.h @@ -665,7 +665,7 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub_int(mbedtls_mpi_uint *X, * \return MBEDTLS_CT_FALSE if `A == 0` * MBEDTLS_CT_TRUE if `A != 0`. */ -mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(const mbedtls_mpi_uint *A, +mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(volatile const mbedtls_mpi_uint *A, size_t limbs); /**