Skip to content

Commit a43167e

Browse files
valeriosettinordicjm
authored andcommitted
zephyr: fix Mbed TLS configuration header file selection
Mbed TLS already provides MBEDTLS_CFG_FILE Kconfig when it's builtin. So we only need to override that config when not using the builtin Mbed TLS version. This commit also fixes some hardcoding of "mcuboot-mbedtls-cfg.h" in Kconfig and prj.conf. Signed-off-by: Valerio Setti <[email protected]>
1 parent fbd2267 commit a43167e

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ if(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 OR CONFIG_BOOT_ENCRYPT_EC256)
220220
# to set MBEDTLS_CONFIG_FILE ourselves. When using Zephyr's copy, this
221221
# variable is set by its Kconfig in the Zephyr codebase.
222222
zephyr_library_compile_definitions(
223-
MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h"
223+
MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}"
224224
)
225225
elseif(CONFIG_BOOT_SIGNATURE_TYPE_NONE)
226226
zephyr_library_include_directories(
@@ -266,7 +266,7 @@ elseif(CONFIG_BOOT_SIGNATURE_TYPE_ED25519 OR CONFIG_BOOT_ENCRYPT_X25519)
266266
${TINYCRYPT_SHA512_DIR}/source/sha512.c
267267
)
268268
zephyr_library_compile_definitions(
269-
MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h"
269+
MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}"
270270
)
271271
else()
272272
zephyr_include_directories(include)

boot/zephyr/Kconfig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,12 @@ config MCUBOOT_CLEANUP_RAM
360360
help
361361
Sets contents of memory to 0 before jumping to application.
362362

363-
if MBEDTLS
364-
365363
config MBEDTLS_CFG_FILE
366-
default "config-tls-generic.h" if MBEDTLS_BUILTIN || BOOT_USE_PSA_CRYPTO
367-
default "mcuboot-mbedtls-cfg.h" if BOOT_USE_MBEDTLS
368-
369-
endif
364+
# It might be awkward to define an Mbed TLS header file when TinyCrypt
365+
# is used, but the fact is that Mbed TLS' ASN1 parse module is used
366+
# also when TinyCrypt is used as crypto backend.
367+
default "mcuboot-mbedtls-cfg.h" if BOOT_USE_TINYCRYPT
368+
default "mcuboot-mbedtls-cfg.h" if BOOT_USE_MBEDTLS && !MBEDTLS_BUILTIN
370369

371370
config BOOT_HW_KEY
372371
bool "Use HW key for image verification"

boot/zephyr/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CONFIG_PM=n
22

33
CONFIG_MAIN_STACK_SIZE=10240
4-
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"
54

65
CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
76
CONFIG_BOOT_ENCRYPT_IMAGE=n

0 commit comments

Comments
 (0)