From afdf1a31c8ec7e1478d297f3316ba22882489077 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Tue, 29 Apr 2025 15:04:51 +0530 Subject: [PATCH] feat(soc): Update ESP32-C5 ECO2 to support SHA512 --- .../esp_rom/esp32c5/include/esp32c5/rom/sha.h | 7 ++++++- components/hal/esp32c5/include/hal/sha_ll.h | 21 ++++++++++++++++++- .../esp32c5/include/soc/Kconfig.soc_caps.in | 20 ++++++++++++++++++ components/soc/esp32c5/include/soc/soc_caps.h | 5 +++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/components/esp_rom/esp32c5/include/esp32c5/rom/sha.h b/components/esp_rom/esp32c5/include/esp32c5/rom/sha.h index d96cac8448..be03f8ab10 100644 --- a/components/esp_rom/esp32c5/include/esp32c5/rom/sha.h +++ b/components/esp_rom/esp32c5/include/esp32c5/rom/sha.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,11 @@ typedef enum { SHA1 = 0, SHA2_224, SHA2_256, + SHA2_384, + SHA2_512, + SHA2_512224, + SHA2_512256, + SHA2_512T, SHA_TYPE_MAX } SHA_TYPE; diff --git a/components/hal/esp32c5/include/hal/sha_ll.h b/components/hal/esp32c5/include/hal/sha_ll.h index 807391731e..05c8ac445e 100644 --- a/components/hal/esp32c5/include/hal/sha_ll.h +++ b/components/hal/esp32c5/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -168,6 +168,25 @@ static inline void sha_ll_write_digest(esp_sha_type sha_type, void *digest_state } } +/** + * @brief Sets SHA512_t T_string parameter + * + * @param t_string T_string parameter + */ +static inline void sha_ll_t_string_set(uint32_t t_string) +{ + REG_WRITE(SHA_T_STRING_REG, t_string); +} + +/** + * @brief Sets SHA512_t T_string parameter's length + * + * @param t_len T_string parameter length + */ +static inline void sha_ll_t_len_set(uint8_t t_len) +{ + REG_WRITE(SHA_T_LENGTH_REG, t_len); +} #ifdef __cplusplus } diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 8d4f1df11e..fe1d7c472a 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1071,6 +1071,26 @@ config SOC_SHA_SUPPORT_SHA256 bool default y +config SOC_SHA_SUPPORT_SHA384 + bool + default y + +config SOC_SHA_SUPPORT_SHA512 + bool + default y + +config SOC_SHA_SUPPORT_SHA512_224 + bool + default y + +config SOC_SHA_SUPPORT_SHA512_256 + bool + default y + +config SOC_SHA_SUPPORT_SHA512_T + bool + default y + config SOC_ECC_CONSTANT_TIME_POINT_MUL bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index e10357be40..b8249a287a 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -422,6 +422,11 @@ #define SOC_SHA_SUPPORT_SHA1 (1) #define SOC_SHA_SUPPORT_SHA224 (1) #define SOC_SHA_SUPPORT_SHA256 (1) +#define SOC_SHA_SUPPORT_SHA384 (1) +#define SOC_SHA_SUPPORT_SHA512 (1) +#define SOC_SHA_SUPPORT_SHA512_224 (1) +#define SOC_SHA_SUPPORT_SHA512_256 (1) +#define SOC_SHA_SUPPORT_SHA512_T (1) /*--------------------------- ECC CAPS ---------------------------------------*/ #define SOC_ECC_CONSTANT_TIME_POINT_MUL 1