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.
pull/862/head
Daniele Lacamera 2026-08-18 05:03:00 +02:00
parent 3a3f66e1b4
commit b9c32027bc
1 changed files with 11 additions and 3 deletions

View File

@ -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)