Skip to content

Commit 900df03

Browse files
tomi-fontrlubos
authored andcommitted
samples: crypto: persistent_key_usage: support secure storage subsystem
Make secure storage the default option on non-TF-M board targets. Have test scenarios for both secure storage and trusted storage to test both. Reduce a bit the number of board targets in integration_platforms to reduce CI load as some don't bring extra value when others are already in there. Signed-off-by: Tomi Fontanilles <[email protected]>
1 parent 652b40f commit 900df03

17 files changed

+124
-115
lines changed

samples/crypto/persistent_key_usage/CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1111
project(persistent_key)
1212

1313
target_sources(app PRIVATE
14-
src/main.c
15-
)
16-
17-
target_sources_ifdef(CONFIG_TRUSTED_STORAGE app PRIVATE
18-
src/trusted_storage_init.c
19-
)
14+
src/main.c
15+
src/init.c
16+
)

samples/crypto/persistent_key_usage/README.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
.. _crypto_persistent_key:
22

3-
Crypto: Persistent key storage
4-
##############################
3+
Crypto: Persistent key usage
4+
############################
55

66
.. contents::
77
:local:
88
:depth: 2
99

1010
The persistent key sample shows how to generate a persistent key using the Platform Security Architecture (PSA) APIs.
1111
Persistent keys are stored in the Internal Trusted Storage (ITS) of the device and retain their value between resets.
12-
The ITS backend is either provided by TF-M, or the :ref:`trusted_storage_readme` library when building applications without TF-M.
12+
The implementation of the PSA ITS API is provided in one of the following ways, depending on your configuration:
13+
14+
* Through TF-M using Internal Trusted Storage and Protected Storage services.
15+
* When building without TF-M: using either Zephyr's :ref:`secure_storage` subsystem or the :ref:`trusted_storage_readme` library.
16+
1317
A persistent key becomes unusable when the ``psa_destroy_key`` function is called.
1418

1519
Requirements
@@ -72,6 +76,7 @@ Dependencies
7276

7377
* :file:`psa/crypto.h`
7478

75-
* Builds without TF-M use the :ref:`trusted_storage_readme` library
79+
* Builds without TF-M use the :ref:`secure_storage` subsystem as the PSA Secure Storage API
80+
provider.
7681

7782
* The :ref:`lib_hw_unique_key` is used to encrypt the key before storing it.

samples/crypto/persistent_key_usage/boards/nrf52840dk_nrf52840.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CC3XX=y
99

10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
12+
1013
CONFIG_FLASH=y
1114
CONFIG_FLASH_PAGE_LAYOUT=y
1215
CONFIG_FLASH_MAP=y
1316
CONFIG_NVS=y
1417
CONFIG_SETTINGS=y
15-
CONFIG_SETTINGS_NVS=y
16-
CONFIG_TRUSTED_STORAGE=y
1718

18-
# Mbedtls configuration
1919
CONFIG_MBEDTLS_ENABLE_HEAP=y
2020
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf5340dk_nrf5340_cpuapp.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CC3XX=y
99

10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
12+
1013
CONFIG_FLASH=y
1114
CONFIG_FLASH_PAGE_LAYOUT=y
1215
CONFIG_FLASH_MAP=y
1316
CONFIG_NVS=y
1417
CONFIG_SETTINGS=y
15-
CONFIG_SETTINGS_NVS=y
16-
CONFIG_TRUSTED_STORAGE=y
1718

18-
# Mbedtls configuration
1919
CONFIG_MBEDTLS_ENABLE_HEAP=y
2020
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf54l15dk_nrf54l05_cpuapp.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CRACEN=y
99

10-
# Use TRUSTED_STORAGE because this is a non-TF-M board target.
11-
CONFIG_TRUSTED_STORAGE=y
10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
1212

1313
CONFIG_FLASH=y
1414
CONFIG_FLASH_PAGE_LAYOUT=y
1515
CONFIG_FLASH_MAP=y
1616
CONFIG_ZMS=y
1717
CONFIG_SETTINGS=y
1818

19-
# Mbedtls configuration
2019
CONFIG_MBEDTLS_ENABLE_HEAP=y
2120
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf54l15dk_nrf54l10_cpuapp.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CRACEN=y
99

10-
# Use TRUSTED_STORAGE because this is a non-TF-M board target.
11-
CONFIG_TRUSTED_STORAGE=y
10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
1212

1313
CONFIG_FLASH=y
1414
CONFIG_FLASH_PAGE_LAYOUT=y
1515
CONFIG_FLASH_MAP=y
1616
CONFIG_ZMS=y
1717
CONFIG_SETTINGS=y
1818

19-
# Mbedtls configuration
2019
CONFIG_MBEDTLS_ENABLE_HEAP=y
2120
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf54l15dk_nrf54l15_cpuapp.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CRACEN=y
99

10-
# Use TRUSTED_STORAGE because this is a non-TF-M board target.
11-
CONFIG_TRUSTED_STORAGE=y
10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
1212

1313
CONFIG_FLASH=y
1414
CONFIG_FLASH_PAGE_LAYOUT=y
1515
CONFIG_FLASH_MAP=y
1616
CONFIG_ZMS=y
1717
CONFIG_SETTINGS=y
1818

19-
# Mbedtls configuration
2019
CONFIG_MBEDTLS_ENABLE_HEAP=y
2120
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf54lm20pdk_nrf54lm20a_cpuapp.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55

6+
# Using hardware crypto accelerator
67
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
78
CONFIG_PSA_CRYPTO_DRIVER_CRACEN=y
89

9-
# Use TRUSTED_STORAGE because this is a non-TF-M board target.
10-
CONFIG_TRUSTED_STORAGE=y
10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
1112

1213
CONFIG_FLASH=y
1314
CONFIG_FLASH_PAGE_LAYOUT=y

samples/crypto/persistent_key_usage/boards/nrf54lv10dk_nrf5454lv10a_cpuapp.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CRACEN=y
99

10-
# Use TRUSTED_STORAGE because this is a non-TF-M board target.
11-
CONFIG_TRUSTED_STORAGE=y
10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
1212

1313
CONFIG_FLASH=y
1414
CONFIG_FLASH_PAGE_LAYOUT=y
1515
CONFIG_FLASH_MAP=y
1616
CONFIG_ZMS=y
1717
CONFIG_SETTINGS=y
1818

19-
# Mbedtls configuration
2019
CONFIG_MBEDTLS_ENABLE_HEAP=y
2120
CONFIG_MBEDTLS_HEAP_SIZE=8192

samples/crypto/persistent_key_usage/boards/nrf9151dk_nrf9151.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# Copyright (c) 2024 Nordic Semiconductor ASA
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5-
#
5+
66
# Using hardware crypto accelerator
77
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
88
CONFIG_PSA_CRYPTO_DRIVER_CC3XX=y
99

10+
# When TF-M is not in use, the Secure storage subsystem provides the PSA Secure Storage API.
11+
CONFIG_SECURE_STORAGE=y
12+
1013
CONFIG_FLASH=y
1114
CONFIG_FLASH_PAGE_LAYOUT=y
1215
CONFIG_FLASH_MAP=y
1316
CONFIG_NVS=y
1417
CONFIG_SETTINGS=y
15-
CONFIG_SETTINGS_NVS=y
16-
CONFIG_TRUSTED_STORAGE=y
1718

18-
# Mbedtls configuration
1919
CONFIG_MBEDTLS_ENABLE_HEAP=y
2020
CONFIG_MBEDTLS_HEAP_SIZE=8192

0 commit comments

Comments
 (0)