Skip to content

Commit 71c27ab

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 c34a6a7 commit 71c27ab

2 files changed

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

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

modules/mbedtls/legacy_support.cmake

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,19 @@
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!
125
if(CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
136
message(WARNING "
147
Enabling CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS is discouraged as it
158
gives access to Mbed TLS crypto functions which are internal and may be removed
169
or modified at any time. Please transition to the PSA Crypto API."
1710
)
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/)
3211
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
12+
# MCUBoot bootutil includes rsa_alt_helpers.h by basename; the header lives
13+
# next to builtin RSA sources under drivers/builtin/src.
14+
target_include_directories(mbedTLS INTERFACE
15+
${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/src
3616
)
37-
file(COPY ${legacy_headers} DESTINATION ${CMAKE_BINARY_DIR}/legacy-mbedtls-headers/)
3817
endif()
39-
target_include_directories(mbedTLS INTERFACE
40-
${CMAKE_BINARY_DIR}/legacy-mbedtls-headers/
41-
)
4218
endif()
4319

4420
set(MBEDTLS_EXPORT_REMOVED_HEADERS OFF)

0 commit comments

Comments
 (0)