Skip to content

Commit 694e751

Browse files
committed
modules/mbedtls: Stop copying private headers into build tree
CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS no longer mirrors TF-PSA-Crypto builtin private headers into CMAKE_BINARY_DIR without the private/ segment. Consumers must include mbedtls/private/... explicitly; the mbedtls library INTERFACE already exposes drivers/builtin/include. When building the MCUboot image, add drivers/builtin/src to the mbedTLS INTERFACE include path so bootutil can include rsa_alt_helpers.h by basename. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no> Assisted-by: Cursor: Auto
1 parent 52fb3b9 commit 694e751

2 files changed

Lines changed: 16 additions & 34 deletions

File tree

modules/mbedtls/Kconfig.tf-psa-crypto

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,13 @@ config MBEDTLS_NIST_KW_C
374374
config MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
375375
bool "Legacy crypto support (private)"
376376
help
377-
Legacy crypto is now private inside TF-PSA-Crypto and they should
378-
no more be directly accessed. However there might be code that still
379-
needs to be transitioned and in this case enabling this Kconfig
380-
allows internal headers related to legacy crypto to be made public.
381-
The long term goal is to get rid of this support so all the code
382-
should be transitioned to the PSA Crypto API as soon as possible.
377+
Legacy crypto is now private inside TF-PSA-Crypto and should not be
378+
used from new code. Enable this only while transitioning callers that
379+
still need legacy declarations: with MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
380+
defined, those APIs are reachable via mbedtls/private/*.h (under the
381+
TF-PSA-Crypto builtin include path exported by the mbedtls target).
382+
The long term goal is to remove this option once all users are on the
383+
PSA Crypto API.
383384

384385
config TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED
385386
bool "mldsa-native from the PQCP (post-quantum code package) driver [EXPERIMENTAL]"

modules/mbedtls/legacy_support.cmake

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,24 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
# Copy header files related to legacy crypto to the build folder in a path
6-
# that does not contain "private" in the name. This allows legacy includes
7-
# like "#include <mbedtls/ecp.h>" to still work. This is a temporary
8-
# fix in order not to break external modules (ex: hostap) which are
9-
# still referencing legacy includes. However these files are private now
10-
# and all the users of legacy Mbed TLS should transition to PSA API as soon
11-
# as possible!
5+
# When CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS is enabled, legacy crypto
6+
# declarations live under mbedtls/private/*.h in TF-PSA-Crypto builtin
7+
# includes. The mbedtls CMake target already exports
8+
# tf-psa-crypto/drivers/builtin/include on its INTERFACE, so consumers must
9+
# include the private paths explicitly (no flattened header copy).
1210
if(CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
1311
message(WARNING "
1412
Enabling CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS is discouraged as it
1513
gives access to Mbed TLS crypto functions which are internal and may be removed
1614
or modified at any time. Please transition to the PSA Crypto API."
1715
)
18-
set(MBEDTLS_PRIVATE_INCLUDE_PATH "${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/mbedtls/private")
19-
set(legacy_headers
20-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/aes.h
21-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/bignum.h
22-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/cipher.h
23-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/cmac.h
24-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/ecdsa.h
25-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/ecp.h
26-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/pkcs5.h
27-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/error_common.h
28-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/sha256.h
29-
${MBEDTLS_PRIVATE_INCLUDE_PATH}/rsa.h
30-
)
31-
file(COPY ${legacy_headers} DESTINATION ${CMAKE_BINARY_DIR}/legacy-mbedtls-headers/mbedtls/)
16+
# MCUBoot bootutil includes rsa_alt_helpers.h by basename; the header lives
17+
# next to builtin RSA sources under drivers/builtin/src.
3218
if(CONFIG_MCUBOOT)
33-
set(MBEDTLS_BUILTIN_SRC_PATH "${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/src")
34-
set(legacy_headers
35-
${MBEDTLS_BUILTIN_SRC_PATH}/rsa_alt_helpers.h
19+
target_include_directories(mbedTLS INTERFACE
20+
${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/src
3621
)
37-
file(COPY ${legacy_headers} DESTINATION ${CMAKE_BINARY_DIR}/legacy-mbedtls-headers/)
3822
endif()
39-
target_include_directories(mbedTLS INTERFACE
40-
${CMAKE_BINARY_DIR}/legacy-mbedtls-headers/
41-
)
4223
endif()
4324

4425
set(MBEDTLS_EXPORT_REMOVED_HEADERS OFF)

0 commit comments

Comments
 (0)