From 58c8b942d2b04fd4db58bd4b27b79cb23b960067 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 16 Aug 2023 17:51:04 +0100 Subject: [PATCH] Eliminate redundant version of mbedtls_ct_memcmp Signed-off-by: Dave Rodgman --- library/psa_crypto_core.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h index 8bc1b647c0..6d44768443 100644 --- a/library/psa_crypto_core.h +++ b/library/psa_crypto_core.h @@ -21,6 +21,8 @@ #ifndef PSA_CRYPTO_CORE_H #define PSA_CRYPTO_CORE_H +#include "mbedtls/constant_time.h" + #include "mbedtls/build_info.h" #include "psa/crypto.h" @@ -49,14 +51,7 @@ int psa_can_do_hash(psa_algorithm_t hash_alg); static inline int mbedtls_psa_safer_memcmp( const uint8_t *a, const uint8_t *b, size_t n) { - size_t i; - unsigned char diff = 0; - - for (i = 0; i < n; i++) { - diff |= a[i] ^ b[i]; - } - - return diff; + return mbedtls_ct_memcmp(a, b, n); } /** The data structure representing a key slot, containing key material