Commit 69c61d0e authored by Carles Cufi's avatar Carles Cufi Committed by Carles Cufí
Browse files

zephyr: Properly use the same mbedTLS header macros

For both RSA (which uses Zephyr's mbedTLS copy) and ECDSA (which uses
our own for ASN1 parsing) use the common "mcuboot-mbedtls-cfg.h" header
file instead of relying on the default config.h bundled with mbedTLS.
Additionally issue a descriptive error when CONFIG_MBEDTLS is set and we
are building with our own copy.

Signed-off-by: default avatarCarles Cufi <carles.cufi@nordicsemi.no>
parent 519285fa
Loading
Loading
Loading
Loading
+13 −1
Changes for boot/zephyr/CMakeLists.txt: 13 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -104,8 +104,20 @@ if(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
  target_sources(app PRIVATE "${TINYCRYPT_DIR}/source/sha256.c")
  target_sources(app PRIVATE "${TINYCRYPT_DIR}/source/utils.c")

  # When building for ECDSA, we use our own copy of mbedTLS, so the Zephyr
  # one must not be enabled or the MBEDTLS_CONFIG_FILE macros will collide.
  if(DEFINED CONFIG_MBEDTLS)
	  message(FATAL_ERROR "\

CONFIG_MBEDTLS should not be enabled. \
Try adding CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y to your prj.conf, \
delete the build folder and build from scratch.")
  endif()
  # Since here we are not using Zephyr's mbedTLS bur rather our own, we need
  # to set MBEDTLS_CONFIG_FILE ourselves. When using Zephyr's copy, this
  # variable is set by its Kconfig in the Zephyr codebase.
  target_compile_definitions(app PRIVATE MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h")
  # Additionally pull in just the ASN.1 parser from mbedTLS.
  target_compile_definitions(app PRIVATE MBEDTLS_CFG_FILE=config-asn1.h)
  target_sources(app PRIVATE "${MBEDTLS_ASN1_DIR}/src/asn1parse.c")
elseif(CONFIG_BOOT_SIGNATURE_TYPE_RSA)
  # Use mbedTLS provided by Zephyr for RSA signatures. (Its config file