diff --git a/components/hal/ecc_hal.c b/components/hal/ecc_hal.c index 18ca952f8e..3de372cdf5 100644 --- a/components/hal/ecc_hal.c +++ b/components/hal/ecc_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -177,3 +177,10 @@ int ecc_hal_read_mod_op_result(uint8_t *r, uint16_t len) } #endif /* SOC_ECC_EXTENDED_MODES_SUPPORTED */ + +#ifdef SOC_ECC_CONSTANT_TIME_POINT_MUL +void ecc_hal_enable_constant_time_point_mul(bool enable) +{ + ecc_ll_enable_constant_time_point_mul(enable); +} +#endif /* SOC_ECC_CONSTANT_TIME_POINT_MUL */ diff --git a/components/hal/esp32c5/include/hal/ecc_ll.h b/components/hal/esp32c5/include/hal/ecc_ll.h index b9f04d7a8a..9e56f188b8 100644 --- a/components/hal/esp32c5/include/hal/ecc_ll.h +++ b/components/hal/esp32c5/include/hal/ecc_ll.h @@ -148,6 +148,15 @@ static inline void ecc_ll_set_mod_base(ecc_mod_base_t base) } } +static inline void ecc_ll_enable_constant_time_point_mul(bool enable) +{ + if (enable) { + REG_SET_BIT(ECC_MULT_CONF_REG, ECC_MULT_SECURITY_MODE); + } else { + REG_CLR_BIT(ECC_MULT_CONF_REG, ECC_MULT_SECURITY_MODE); + } +} + static inline void ecc_ll_write_param(ecc_ll_param_t param, const uint8_t *buf, uint16_t len) { uint32_t reg; diff --git a/components/hal/esp32c61/include/hal/ecc_ll.h b/components/hal/esp32c61/include/hal/ecc_ll.h index b9f04d7a8a..9e56f188b8 100644 --- a/components/hal/esp32c61/include/hal/ecc_ll.h +++ b/components/hal/esp32c61/include/hal/ecc_ll.h @@ -148,6 +148,15 @@ static inline void ecc_ll_set_mod_base(ecc_mod_base_t base) } } +static inline void ecc_ll_enable_constant_time_point_mul(bool enable) +{ + if (enable) { + REG_SET_BIT(ECC_MULT_CONF_REG, ECC_MULT_SECURITY_MODE); + } else { + REG_CLR_BIT(ECC_MULT_CONF_REG, ECC_MULT_SECURITY_MODE); + } +} + static inline void ecc_ll_write_param(ecc_ll_param_t param, const uint8_t *buf, uint16_t len) { uint32_t reg; diff --git a/components/hal/include/hal/ecc_hal.h b/components/hal/include/hal/ecc_hal.h index 23cfbbbda1..4d9916e251 100644 --- a/components/hal/include/hal/ecc_hal.h +++ b/components/hal/include/hal/ecc_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -195,6 +195,15 @@ int ecc_hal_read_mod_op_result(uint8_t *r, uint16_t len); #endif /* SOC_ECC_EXTENDED_MODES_SUPPORTED */ +#ifdef SOC_ECC_CONSTANT_TIME_POINT_MUL +/** + * @brief Enable constant time multiplication operations + * + * @param true: enable; false: disable + */ +void ecc_hal_enable_constant_time_point_mul(bool enable); +#endif /* SOC_ECC_CONSTANT_TIME_POINT_MUL */ + #ifdef __cplusplus } #endif diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 0ac05a0ce3..d3ffe65191 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -935,6 +935,10 @@ config SOC_SHA_SUPPORT_SHA256 bool default y +config SOC_ECC_CONSTANT_TIME_POINT_MUL + bool + default y + config SOC_ECDSA_SUPPORT_EXPORT_PUBKEY bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 2cad5a7f94..4924ed158d 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -395,6 +395,9 @@ #define SOC_SHA_SUPPORT_SHA224 (1) #define SOC_SHA_SUPPORT_SHA256 (1) +/*--------------------------- ECC CAPS ---------------------------------------*/ +#define SOC_ECC_CONSTANT_TIME_POINT_MUL 1 + /*--------------------------- ECDSA CAPS ---------------------------------------*/ #define SOC_ECDSA_SUPPORT_EXPORT_PUBKEY (1) diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index 4a904e190f..02a66ec774 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -515,6 +515,10 @@ config SOC_SHA_SUPPORT_SHA256 bool default y +config SOC_ECC_CONSTANT_TIME_POINT_MUL + bool + default y + config SOC_ECDSA_SUPPORT_EXPORT_PUBKEY bool default y diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 62086ac264..d529db4a62 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -289,6 +289,9 @@ #define SOC_SHA_SUPPORT_SHA224 (1) #define SOC_SHA_SUPPORT_SHA256 (1) +/*--------------------------- ECC CAPS ---------------------------------------*/ +#define SOC_ECC_CONSTANT_TIME_POINT_MUL 1 + /*--------------------------- ECDSA CAPS ---------------------------------------*/ #define SOC_ECDSA_SUPPORT_EXPORT_PUBKEY (1) #define SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE (1)