Skip to content

Commit

Permalink
modules: mbedtls: enable persistent keys when CONFIG_SECURE_STORAGE
Browse files Browse the repository at this point in the history
With the secure storage subsystem now providing an implementation of
the PSA ITS API, let Mbed TLS use it when it's enabled.
This allows the use of persistent keys in the PSA Crypto API.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
  • Loading branch information
tomi-font authored and carlescufi committed Oct 7, 2024
1 parent bf0e6d7 commit 4b47901
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion modules/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ zephyr_interface_library_named(mbedTLS)

zephyr_library_named(mbedTLSCrypto)

if (CONFIG_MBEDTLS_PSA_CRYPTO_C AND NOT CONFIG_BUILD_WITH_TFM)
if (CONFIG_MBEDTLS_PSA_CRYPTO_C)
list(APPEND crypto_source
${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_aead.c
${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_cipher.c
Expand Down Expand Up @@ -176,6 +176,9 @@ zephyr_interface_library_named(mbedTLS)

zephyr_library_sources(${crypto_source})

# Custom macro to tell that an mbedTLSCrypto source file is being compiled.
zephyr_library_compile_definitions(BUILDING_MBEDTLS_CRYPTO)

zephyr_library_link_libraries(mbedTLS)

zephyr_library_link_libraries_ifdef(CONFIG_BUILD_WITH_TFM tfm_api)
Expand Down
10 changes: 5 additions & 5 deletions modules/mbedtls/configs/config-tls-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,12 @@
#define MBEDTLS_PSA_P256M_DRIVER_ENABLED
#endif

#if defined(CONFIG_ARCH_POSIX) && !defined(CONFIG_PICOLIBC)
#define MBEDTLS_PSA_KEY_SLOT_COUNT 64
#if defined(CONFIG_ARCH_POSIX)
#define MBEDTLS_PSA_KEY_SLOT_COUNT 64 /* for BLE Mesh tests */
#endif

#if defined(CONFIG_SECURE_STORAGE)
#define MBEDTLS_PSA_CRYPTO_STORAGE_C
#define MBEDTLS_PSA_ITS_FILE_C
#define MBEDTLS_FS_IO
#endif

#endif /* CONFIG_MBEDTLS_PSA_CRYPTO_C */
Expand All @@ -499,7 +500,6 @@
#define MBEDTLS_PSA_CRYPTO_CLIENT
#define MBEDTLS_PSA_CRYPTO_CONFIG
#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "config-psa.h"

#endif

#if defined(CONFIG_MBEDTLS_TLS_VERSION_1_2) && defined(CONFIG_MBEDTLS_PSA_CRYPTO_C)
Expand Down

0 comments on commit 4b47901

Please sign in to comment.