Skip to content

Commit 74ba0ac

Browse files
committed
nrf_security: remove mbedtls/platform.h
We have been duplicating this file from Mbed TLS, and I don't like duplication. Instead define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS when building the crypto library so that it doesn't link against problematic libc functions. If it turns out to be too much then we can individually replace the calloc and free functions with the appropriate macros. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent 9c545e6 commit 74ba0ac

4 files changed

Lines changed: 6 additions & 398 deletions

File tree

subsys/nrf_security/Kconfig.tf-psa-crypto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ configdefault TF_PSA_CRYPTO_CONFIG_FILE
1010
configdefault TF_PSA_CRYPTO_USER_CONFIG_FILE
1111
default "nrf-psa-crypto-user-config.h"
1212

13+
# Prevent TF-PSA-Crypto from linking against calloc() and free().
14+
config MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
15+
default y
16+
1317
# Make sure that MBEDTLS_PSA_CRYPTO_RNG_SOURCE is available even when !MBEDTLS_PSA_CRYPTO_C
1418
# (when building TF-M) so that MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is always enabled.
1519
# This is needed because without this symbol the Oberon PSA core defaults to legacy RNG.

subsys/nrf_security/cmake/psa_crypto_config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ kconfig_check_and_set_base_int(MBEDTLS_PSA_KEY_SLOT_COUNT)
1717
# Platform
1818
kconfig_check_and_set_base(MBEDTLS_PLATFORM_C)
1919
kconfig_check_and_set_base(MBEDTLS_PLATFORM_MEMORY)
20+
kconfig_check_and_set_base(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
2021
kconfig_check_and_set_base(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
2122

2223
# TF-M

subsys/nrf_security/configs/psa_crypto_config.h.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/* Platform */
2121
#cmakedefine MBEDTLS_PLATFORM_C
2222
#cmakedefine MBEDTLS_PLATFORM_MEMORY
23+
#cmakedefine MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
2324
#cmakedefine MBEDTLS_MEMORY_BUFFER_ALLOC_C
2425

2526
/* TF-M */

0 commit comments

Comments
 (0)