feat(ecc): enable ECC constant time mode for ESP32-H2 ECO5

This commit is contained in:
Mahavir Jain
2025-02-20 21:03:10 +08:00
committed by BOT
parent 2fe702e8f7
commit 748d29b5ad
15 changed files with 58 additions and 23 deletions
+1 -2
View File
@@ -586,11 +586,10 @@ menu "mbedTLS"
menu "Enable Software Countermeasure for ECDSA signing using on-chip ECDSA peripheral"
depends on MBEDTLS_HARDWARE_ECDSA_SIGN
depends on IDF_TARGET_ESP32H2
depends on IDF_TARGET_ESP32H2 && ESP32H2_REV_MIN_FULL < 102
config MBEDTLS_HARDWARE_ECDSA_SIGN_MASKING_CM
bool "Mask original ECDSA sign operation under dummy sign operations"
select HAL_ECDSA_GEN_SIG_CM
# ToDo: IDF-11051
default y
help
The ECDSA peripheral before ECO5 does not offer constant time ECDSA sign operation.
+6 -7
View File
@@ -45,14 +45,13 @@ int esp_ecc_point_multiply(const ecc_point_t *point, const uint8_t *scalar, ecc_
ecc_hal_write_mul_param(scalar, point->x, point->y, len);
ecc_hal_set_mode(work_mode);
#ifdef SOC_ECC_CONSTANT_TIME_POINT_MUL
/* Enable constant-time point multiplication operations for the ECC hardware accelerator
This protects the ECC multiplication operation from timing attacks.
This increases the time taken (by almost 50%) for some point multiplication
operations performed by the ECC hardware accelerator.
*/
/*
* Enable constant-time point multiplication operations for the ECC hardware accelerator,
* if supported for the given target. This protects the ECC multiplication operation from
* timing attacks. This increases the time taken (by almost 50%) for some point
* multiplication operations performed by the ECC hardware accelerator.
*/
ecc_hal_enable_constant_time_point_mul(true);
#endif /* SOC_ECC_CONSTANT_TIME_POINT_MUL */
ecc_hal_start_calc();
memset(result, 0, sizeof(ecc_point_t));