Fix asm Memsan workaround
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/constant_time_impl.h b/library/constant_time_impl.h
index c9e6a83..191769b 100644
--- a/library/constant_time_impl.h
+++ b/library/constant_time_impl.h
@@ -73,17 +73,18 @@
#if defined(MBEDTLS_CT_ASM)
/* Prevent false positives from Memsan - otherwise it will report the asm as
* accessing secret data. */
- TEST_CF_PUBLIC(&x, sizeof(x));
+ TEST_CF_SAVE_SECRET(x);
asm volatile ("" : [x] "+r" (x) :);
- /* Mark the return value as secret. This is needed so that code of the form:
+ /* Mark the return value as secret (if it was previously marked secret).
+ * This is needed so that code of the form:
*
* if (mbedtls_ct_compiler_opaque(secret)) { ... }
*
* will fail const-flow tests.
*/
- TEST_CF_SECRET(&x, sizeof(x));
+ TEST_CF_RESTORE_SECRET(x);
return x;
#else
return x ^ mbedtls_ct_zero;