From 58c80f4d9208aa75aa5cb60585c1af176918d9e1 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Mon, 12 Jun 2023 18:19:46 +0100 Subject: [PATCH] Make mbedtls_ct_zero non-static Signed-off-by: Dave Rodgman --- library/constant_time.c | 9 +++++++++ library/constant_time_impl.h | 7 +------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/library/constant_time.c b/library/constant_time.c index 90fbcf2d27..40a7f0dba1 100644 --- a/library/constant_time.c +++ b/library/constant_time.c @@ -37,6 +37,15 @@ psa_generic_status_to_mbedtls) #endif +#if !defined(MBEDTLS_CT_ASM) +/* +* Define an object with the value zero, such that the compiler cannot prove that it +* has the value zero (because it is volatile, it "may be modified in ways unknown to +* the implementation"). +*/ +volatile mbedtls_ct_uint_t mbedtls_ct_zero = 0; +#endif + /* * Define MBEDTLS_EFFICIENT_UNALIGNED_VOLATILE_ACCESS where assembly is present to * perform fast unaligned access to volatile data. diff --git a/library/constant_time_impl.h b/library/constant_time_impl.h index c490d8229d..91418e58ff 100644 --- a/library/constant_time_impl.h +++ b/library/constant_time_impl.h @@ -73,12 +73,7 @@ */ #if !defined(MBEDTLS_CT_ASM) -/* -* Define an object with the value zero, such that the compiler cannot prove that it -* has the value zero (because it is volatile, it "may be modified in ways unknown to -* the implementation"). -*/ -static volatile mbedtls_ct_uint_t mbedtls_ct_zero = 0; +extern volatile mbedtls_ct_uint_t mbedtls_ct_zero; #endif static inline mbedtls_ct_uint_t mbedtls_ct_compiler_opaque(mbedtls_ct_uint_t x)