mbedtls: Don't compile hardware MPI & SHA files if disabled in config

Fixes bug where hardware accelerated mbedtls_mpi API was always used, even when
disabled in config.
This commit is contained in:
Angus Gratton
2020-05-20 12:18:04 +10:00
committed by Angus Gratton
parent 6cbc7dc2cd
commit 40c9f0599c
2 changed files with 25 additions and 9 deletions

View File

@ -27,15 +27,24 @@ target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/mbedtls_debug.c"
"${COMPONENT_DIR}/port/net_sockets.c")
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c"
"${COMPONENT_DIR}/port/esp_mem.c"
"${COMPONENT_DIR}/port/esp_sha.c"
"${COMPONENT_DIR}/port/esp_sha1.c"
"${COMPONENT_DIR}/port/esp_sha256.c"
"${COMPONENT_DIR}/port/esp_sha512.c"
"${COMPONENT_DIR}/port/esp_timing.c"
"${COMPONENT_DIR}/port/${idf_target}/esp_bignum.c"
"${COMPONENT_DIR}/port/${idf_target}/aes.c"
"${COMPONENT_DIR}/port/${idf_target}/sha.c")
"${COMPONENT_DIR}/port/esp_mem.c"
"${COMPONENT_DIR}/port/esp_timing.c"
"${COMPONENT_DIR}/port/esp_sha.c"
"${COMPONENT_DIR}/port/${idf_target}/aes.c"
)
if(CONFIG_MBEDTLS_HARDWARE_MPI)
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/${idf_target}/esp_bignum.c"
)
endif()
if(CONFIG_MBEDTLS_HARDWARE_SHA)
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_sha1.c"
"${COMPONENT_DIR}/port/esp_sha256.c"
"${COMPONENT_DIR}/port/esp_sha512.c"
"${COMPONENT_DIR}/port/${idf_target}/sha.c"
)
endif()
foreach(target ${mbedtls_targets})
target_compile_definitions(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h")

View File

@ -10,3 +10,10 @@ COMPONENT_OBJEXCLUDE := mbedtls/library/net_sockets.o
COMPONENT_SUBMODULES += mbedtls
ifndef CONFIG_MBEDTLS_HARDWARE_MPI
COMPONENT_OBJEXCLUDE += port/$(IDF_TARGET)/esp_bignum.o
endif
ifndef CONFIG_MBEDTLS_HARDWARE_SHA
COMPONENT_OBJEXCLUDE += port/esp_sha1.o port/esp_sha256.o port/esp_sha512.o port/$(IDF_TARGET)/sha.o
endif