From 3af2d152161fbf28497f69fbd016dcd667126d39 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Mon, 21 Mar 2022 15:15:14 +0530 Subject: [PATCH] mbedtls: Fix build failures for ESP32-C2 with hardware SHA Clean support for SHA peripheral will appear with IDF-3830 --- components/mbedtls/CMakeLists.txt | 12 ++++++------ components/mbedtls/Kconfig | 2 +- .../soc/esp32c2/include/soc/Kconfig.soc_caps.in | 2 +- components/soc/esp32c2/include/soc/soc_caps.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index b2c79d46c2..59dd98879a 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -133,8 +133,8 @@ if(SHA_PERIPHERAL_TYPE STREQUAL "dma") if(NOT CONFIG_SOC_SHA_GDMA) set(SHA_DMA_SRCS "${COMPONENT_DIR}/port/sha/dma/esp_sha_crypto_dma_impl.c") else() - set(SHA_DMA_SRCS "${COMPONENT_DIR}/port/sha/dma/esp_sha_gdma_impl.c" - "${COMPONENT_DIR}/port/crypto_shared_gdma/esp_crypto_shared_gdma.c") + set(SHA_DMA_SRCS "${COMPONENT_DIR}/port/sha/dma/esp_sha_gdma_impl.c") + endif() target_sources(mbedcrypto PRIVATE "${SHA_DMA_SRCS}") endif() @@ -144,7 +144,8 @@ if(AES_PERIPHERAL_TYPE STREQUAL "dma") if(NOT CONFIG_SOC_AES_GDMA) set(AES_DMA_SRCS "${COMPONENT_DIR}/port/aes/dma/esp_aes_crypto_dma_impl.c") else() - set(AES_DMA_SRCS "${COMPONENT_DIR}/port/aes/dma/esp_aes_gdma_impl.c") + set(AES_DMA_SRCS "${COMPONENT_DIR}/port/aes/dma/esp_aes_gdma_impl.c" + "${COMPONENT_DIR}/port/crypto_shared_gdma/esp_crypto_shared_gdma.c") endif() target_include_directories(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/aes/dma/include") @@ -154,6 +155,7 @@ endif() target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c" "${COMPONENT_DIR}/port/esp_mem.c" "${COMPONENT_DIR}/port/esp_timing.c" + "${COMPONENT_DIR}/port/sha/esp_sha.c" ) if(CONFIG_SOC_AES_SUPPORTED) @@ -164,9 +166,7 @@ if(CONFIG_SOC_AES_SUPPORTED) endif() if(CONFIG_SOC_SHA_SUPPORTED) - target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/sha/esp_sha.c" - "${COMPONENT_DIR}/port/sha/${SHA_PERIPHERAL_TYPE}/sha.c" - ) + target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/sha/${SHA_PERIPHERAL_TYPE}/sha.c") endif() # CONFIG_ESP_TLS_USE_DS_PERIPHERAL can be enabled only for the supported targets. diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index c060d45d72..4800211f43 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -401,7 +401,7 @@ menu "mbedTLS" config MBEDTLS_HARDWARE_SHA bool "Enable hardware SHA acceleration" default y - depends on !SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST + depends on !SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST && SOC_SHA_SUPPORTED help Enable hardware accelerated SHA1, SHA256, SHA384 & SHA512 in mbedTLS. diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index 8e6d8e6c56..0343113898 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -69,7 +69,7 @@ config SOC_FLASH_ENCRYPTION_XTS_AES config SOC_SHA_SUPPORTED bool - default y + default n config SOC_ECC_SUPPORTED bool diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index aac652dadd..f59ed617f0 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -41,7 +41,7 @@ #define SOC_RTC_SLOW_MEM_SUPPORTED 0 #define SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY 0 #define SOC_FLASH_ENCRYPTION_XTS_AES 1 -#define SOC_SHA_SUPPORTED 1 +#define SOC_SHA_SUPPORTED 0 // This will be enabled with IDF-3830 #define SOC_ECC_SUPPORTED 1 /*-------------------------- ADC CAPS -------------------------------*/