2019-06-05 22:57:29 -04:00
|
|
|
idf_build_get_property(idf_target IDF_TARGET)
|
|
|
|
|
2019-06-25 00:13:12 -04:00
|
|
|
idf_component_register(INCLUDE_DIRS "port/include" "mbedtls/include"
|
2019-08-07 23:44:24 -04:00
|
|
|
REQUIRES lwip
|
2019-11-07 23:50:28 -05:00
|
|
|
PRIV_REQUIRES soc
|
2019-08-07 23:44:24 -04:00
|
|
|
)
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2018-11-11 02:44:54 -05:00
|
|
|
# Only build mbedtls libraries
|
|
|
|
set(ENABLE_TESTING CACHE BOOL OFF)
|
|
|
|
set(ENABLE_PROGRAMS CACHE BOOL OFF)
|
|
|
|
|
|
|
|
# Needed to for include_next includes to work from within mbedtls
|
2019-05-09 22:53:08 -04:00
|
|
|
include_directories("${COMPONENT_DIR}/port/include")
|
2018-11-11 02:44:54 -05:00
|
|
|
|
|
|
|
# Import mbedtls library targets
|
|
|
|
add_subdirectory(mbedtls)
|
|
|
|
|
2018-11-08 00:56:33 -05:00
|
|
|
# Use port specific implementation of net_socket.c instead of one from mbedtls
|
|
|
|
get_target_property(src_tls mbedtls SOURCES)
|
|
|
|
list(REMOVE_ITEM src_tls net_sockets.c)
|
|
|
|
set_property(TARGET mbedtls PROPERTY SOURCES ${src_tls})
|
|
|
|
|
2018-11-11 02:44:54 -05:00
|
|
|
set(mbedtls_targets mbedtls mbedcrypto mbedx509)
|
|
|
|
|
|
|
|
# Add port files to mbedtls targets
|
2019-08-12 08:32:14 -04:00
|
|
|
target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/mbedtls_debug.c"
|
|
|
|
"${COMPONENT_DIR}/port/net_sockets.c")
|
|
|
|
|
2019-08-16 05:06:34 -04:00
|
|
|
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c"
|
2020-05-19 22:18:04 -04:00
|
|
|
"${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()
|
2018-11-11 02:44:54 -05:00
|
|
|
|
|
|
|
foreach(target ${mbedtls_targets})
|
|
|
|
target_compile_definitions(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h")
|
|
|
|
endforeach()
|
|
|
|
|
2019-08-18 01:28:52 -04:00
|
|
|
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls)
|
|
|
|
|
2018-11-11 02:44:54 -05:00
|
|
|
# Link mbedtls libraries to component library
|
2019-10-30 22:39:17 -04:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets})
|
|
|
|
|