From b9c32027bc7b27f370b7c84b8fd9f0e94d28311f Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 18 Aug 2026 05:03:00 +0200 Subject: [PATCH] F-9722: keep WC_NO_HARDEN out of software-DICE fast-math builds The comment justified WC_NO_HARDEN on the grounds that 'wolfBoot only does public asymmetric operations'. That is not true for software DICE: with WOLFCRYPT_TZ_PSA and no WOLFBOOT_DICE_HW, src/dice/dice.c retrieves the private IAK (wolfboot_attest_get_private_key) and signs the attestation claims with wc_CoseSign1_Sign_ex(), and arch.mk still selects USE_FAST_MATH for those builds. A configuration maintainer trusting the comment would have left the private-key signing path without timing hardening. Gate the definition to verify-only configurations: WC_NO_HARDEN is now defined only when WOLFCRYPT_TZ_PSA is absent or WOLFBOOT_DICE_HW is set (hardware DICE keeps signing in the crypto engine), and the comment states the actual rationale. Verified with a preprocessor probe: plain fast-math and hardware DICE still get WC_NO_HARDEN; software DICE no longer does. --- include/user_settings.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/user_settings.h b/include/user_settings.h index 791a6754..37c554e7 100644 --- a/include/user_settings.h +++ b/include/user_settings.h @@ -58,9 +58,17 @@ extern int tolower(int c); #endif #ifdef USE_FAST_MATH - /* wolfBoot only does public asymmetric operations, - * so timing resistance and hardening is not required */ -# define WC_NO_HARDEN + /* WC_NO_HARDEN is intended only for verify-only builds: the image + * verification path performs public-key operations only, so timing + * resistance and hardening are not required there. Software DICE + * (WOLFCRYPT_TZ_PSA without WOLFBOOT_DICE_HW) is not verify-only: + * it signs the attestation claims with the private IAK via + * wc_CoseSign1_Sign_ex() and must keep the timing hardening, so + * exclude it. Hardware DICE (WOLFBOOT_DICE_HW) keeps the signing + * in the crypto engine and stays verify-only in fast math. */ +# if !defined(WOLFCRYPT_TZ_PSA) || defined(WOLFBOOT_DICE_HW) +# define WC_NO_HARDEN +# endif #endif #if defined(WOLFBOOT_TPM_KEYSTORE) || defined(WOLFBOOT_TPM_SEAL)