From adb9d2d8221755ea7d3a2fc75ad918dd23639161 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Mon, 11 Mar 2024 10:03:05 +0000 Subject: [PATCH] Remove volatile from declaration Use of volatile is more an internal implementation detail (ensuring const-time) than part of the contract (the caller doesn't care about volatile as such). Signed-off-by: Janos Follath --- library/bignum_core.c | 5 +++-- library/bignum_core.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/bignum_core.c b/library/bignum_core.c index db6e231703..54b519509b 100644 --- a/library/bignum_core.c +++ b/library/bignum_core.c @@ -856,13 +856,14 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub_int(mbedtls_mpi_uint *X, return c; } -mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(volatile const mbedtls_mpi_uint *A, +mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(const mbedtls_mpi_uint *A, size_t limbs) { + volatile const mbedtls_mpi_uint* force_read_A = A; mbedtls_mpi_uint bits = 0; for (size_t i = 0; i < limbs; i++) { - bits |= A[i]; + bits |= force_read_A[i]; } return mbedtls_ct_bool(bits); diff --git a/library/bignum_core.h b/library/bignum_core.h index 00c557b816..92c8d47db5 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(volatile const mbedtls_mpi_uint *A, +mbedtls_ct_condition_t mbedtls_mpi_core_check_zero_ct(const mbedtls_mpi_uint *A, size_t limbs); /**