Skip to content

Commit 32d6742

Browse files
mia-kojfischer-no
authored andcommitted
doc: Add trusted storage library
Adding info on trusted storage/secure storage library Signed-off-by: Mia Koen <mia.koen@nordicsemi.no>
1 parent 84e717d commit 32d6742

16 files changed

+2442
-10
lines changed

doc/nrf/libraries/security/images/trusted_storage.svg

+1,711
Loading

doc/nrf/libraries/security/index.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _lib_security:
2+
3+
Security libraries
4+
##################
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
:glob:
9+
:caption: Subpages:
10+
11+
nrf_security/index
12+
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
.. _trusted_storage_readme:
2+
3+
Trusted storage
4+
###############
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The trusted storage library enables its users to provide integrity, confidentiality and authenticity of stored data using Authenticated Encryption with Associated Data (AEAD) algorithms or cryptographic hash, without the use of TF-M Platform Root of Trust (PRoT).
11+
The library implements the PSA Certified Secure Storage API.
12+
13+
Overview
14+
********
15+
16+
The following subsections give an overview of the library architecture, its interfaces, choices and backends.
17+
18+
Architecture
19+
============
20+
21+
The trusted storage library is designed and implemented in a modular way, which allows and simplifies customization.
22+
This is realized by using backends for the different tasks performed within the trusted storage.
23+
24+
The library provides users two choices that are interfacing backends: ``TRUSTED_STORAGE_BACKEND`` and ``TRUSTED_STORAGE_STORAGE_BACKEND``.
25+
The backends are also modular, allowing customization of what crypto implementation and the key nonce are provided.
26+
27+
The following image gives an overview of the default architecture of the trusted storage library.
28+
29+
.. figure:: images/trusted_storage.svg
30+
:alt: Diagram showing the trusted storage library architecture
31+
32+
Overview of the trusted storage library architecture
33+
34+
External storage is not supported by the trusted storage library by default.
35+
To add support for external storage, implement a custom storage backend.
36+
37+
Interfaces
38+
==========
39+
40+
The trusted storage library provides two storage interfaces for use with device-protected storage:
41+
42+
* PSA internal trusted storage, designed to store critical data that must be placed inside internal non-volatile memory.
43+
The size of the storage available by the internal trusted storage API is expected to be limited, and therefore should be used for small, security-critical values.
44+
Examples of assets that require this kind of storage are replay protection values for external storage and keys for use by components of the PSA Root of Trust.
45+
* PSA protected storage, designed to store all other critical data that do not need to be stored inside internal non-volatile memory.
46+
47+
The two interfaces provide a consistent way for applications to access the storage types, through PSA Internal Trusted Storage API and PSA Protected Storage API.
48+
49+
Choices and backends
50+
====================
51+
52+
The trusted storage library comes with two choices:
53+
54+
* ``TRUSTED_STORAGE_BACKEND`` that defines a backend for handling of encryption, authentication or other means of validation of the stored data.
55+
It is responsible for what is happening with the data before and after they are read from or written to non-volatile storage.
56+
* ``TRUSTED_STORAGE_STORAGE_BACKEND`` that defines a backend that handles how the data are written to non-volatile storage.
57+
58+
In other words, ``TRUSTED_STORAGE_BACKEND`` is responsible for modifying the assets before they are forwarded to the ``TRUSTED_STORAGE_STORAGE_BACKEND``, which again handles storing of data in the non-volatile storage.
59+
60+
The following backends are used in the trusted storage library:
61+
62+
``TRUSTED_STORAGE_BACKEND_AEAD``
63+
Uses an AEAD scheme to provide integrity, confidentiality and authenticity.
64+
The trusted storage library provides the ``TRUSTED_STORAGE_BACKEND_AEAD`` backend, but it has support for adding other secure implementation backends to provide various levels of trust, depending on the device security features.
65+
66+
Uses a separate backend to perform the AEAD operation, set by the Kconfig option :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_CRYPTO`.
67+
The nonce and the key for the AEAD operation are provided by separate backends, allowing a custom implementation.
68+
69+
For the key, the default choice is to use the :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_KEY_DERIVE_FROM_HUK` Kconfig option.
70+
With this option, a :ref:`lib_hw_unique_key` and the UID are used to derive an AEAD key.
71+
72+
``TRUSTED_STORAGE_STORAGE_BACKEND_SETTINGS``
73+
Stores the given assets by using :ref:`Zephyr's settings subsystem <zephyr:settings_api>`.
74+
The backend requires that Zephyr's settings subsystem is enabled for use (Kconfig option :kconfig:option:`CONFIG_SETTINGS` has to be set).
75+
76+
The trusted storage library provides the ``TRUSTED_STORAGE_STORAGE_BACKEND_SETTINGS`` as a storage backend, but it has support for adding other memory types for storage.
77+
78+
Requirements
79+
************
80+
81+
Before using the trusted storage library with its default settings and options, make sure to meet the following requirements:
82+
83+
* The hardware unique key (HUK) :ref:`library <lib_hw_unique_key>` and :ref:`sample <hw_unique_key_usage>` are enabled and ready for use to derive an AEAD key.
84+
* Zephyr's settings subsystem has to be enabled for use by setting the Kconfig option :kconfig:option:`CONFIG_SETTINGS`.
85+
86+
* The settings subsystem uses the :ref:`zephyr:nvs_api` file system by default.
87+
This file system has to be mounted to a mount point at application startup. For more information about this, see :ref:`zephyr:file_system_api`.
88+
89+
Configuration
90+
*************
91+
92+
Set the Kconfig option :kconfig:option:`CONFIG_TRUSTED_STORAGE` to enable the trusted storage library.
93+
94+
Use the Kconfig option :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND` to define the backend that handles encryption and authentication.
95+
If this Kconfig option is set, the configuration defaults to the only currently available option :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD` to use an AEAD scheme for encryption and authentication of stored data.
96+
97+
Use the Kconfig option :kconfig:option:`CONFIG_TRUSTED_STORAGE_STORAGE_BACKEND` to define the backend that handles how the data are written to and from the non-volatile storage.
98+
If this Kconfig option is set, the configuration defaults to the only currently available option :kconfig:option:`CONFIG_TRUSTED_STORAGE_STORAGE_BACKEND_SETTINGS` to use Zephyr's settings subsystem.
99+
100+
The following options are used to configure the AEAD backend and its behavior:
101+
102+
:kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_MAX_DATA_SIZE`
103+
Defines the maximum data storage size for the AEAD backend (256 as default value).
104+
105+
:kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_CRYPTO`
106+
Selects what implementation is used to perform the AEAD cryptographic operations.
107+
This option defaults to :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_CRYPTO_PSA_CHACHAPOLY` using the ChaCha20Poly1305 AEAD scheme via PSA APIs.
108+
109+
:kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_NONCE`
110+
Selects what implementation provides AEAD nonce.
111+
You can choose one of the following values when this configuration option is set:
112+
113+
* :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_NONCE_PSA_SEED_COUNTER` - Selects the PSA Crypto for nonce initial random seed and a counter incrementing nonce for each AEAD encryption.
114+
This is the default option for the AEAD nonce.
115+
* :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_NONCE_CUSTOM` - Selects a custom implementation for AEAD nonce provider.
116+
117+
:kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_KEY`
118+
Selects what implementation provides the AEAD keys.
119+
You can choose one of the following values when this configuration option is set:
120+
121+
* :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_KEY_DERIVE_FROM_HUK` - Selects HUK to derive a key based on the UID file.
122+
This is the default selection for the AEAD key provider, and also the only really secure option.
123+
* :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_KEY_HASH_UID` - Selects the use of SHA-256 of the UID file as the key.
124+
This option is not as secure as when using HUKs for key derivation as it will only provide integrity of the data.
125+
Use this option only when HUK is not possible to use.
126+
* :kconfig:option:`CONFIG_TRUSTED_STORAGE_BACKEND_AEAD_KEY_CUSTOM` - Selects a custom implementation for the AEAD key provider.
127+
128+
Usage
129+
*****
130+
131+
The trusted storage library can only be used on a build using a build target with :ref:`CMSE disabled <app_boards_spe_nspe_cpuapp>` (``_cpuapp``).
132+
When you build for ``_cpuapp``, you build the firmware for the application core without CMSE and thus no TF-M.
133+
The library can be used directly on such a build to store important assets.
134+
However, for cryptographic keys we suggest to use the `PSA functions for key management`_.
135+
These APIs will internally use this library to store persistent keys.
136+
137+
Dependencies
138+
************
139+
140+
This library has dependencies to following libraries:
141+
142+
* :ref:`lib_hw_unique_key`
143+
* :ref:`Zephyr's settings subsystem <zephyr:settings_api>`
144+
145+
146+
API documentation
147+
*****************
148+
149+
Protected storage
150+
=================
151+
152+
| Header file: :file:`include/protected_storage.h`
153+
| Source files: :file:`subsys/secure_storage/src/protected_storage/backend_interface.c`
154+
155+
.. doxygengroup:: protected_storage
156+
:project: nrf
157+
:members:
158+
159+
Internal trusted storage
160+
========================
161+
162+
| Header file: :file:`include/internal_trusted_storage.h`
163+
| Source files: :file:`subsys/secure_storage/src/internal_trusted_storage/backend_interface.c`
164+
165+
.. doxygengroup:: internal_trusted_storage
166+
:project: nrf
167+
:members:

doc/nrf/links.txt

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
.. _`Memfault WebBluetooth Client`: https://memfault.github.io/web-ble-example/
235235

236236
.. _`PSA Cryptography API 1.0.1`: https://armmbed.github.io/mbed-crypto/1.0.1/html/index.html
237+
.. _`PSA functions for key management`: https://arm-software.github.io/psa-api/crypto/1.1/api/keys/management.html
237238

238239
.. ### Source: developer.nordicsemi.com
239240

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

+13-10
Original file line numberDiff line numberDiff line change
@@ -1206,20 +1206,21 @@ Libraries for NFC
12061206

12071207
* Fixed an issue with handling zero size data (when receiving empty I-blocks from poller) in the :file:`platform_internal_thread` file.
12081208

1209-
nRF Security
1210-
------------
1209+
Security libraries
1210+
------------------
12111211

1212-
* PSA crypto is now supported on nRF54L Series devices.
1213-
Enable PSA crypto support with a CRACEN driver as the backend by setting the Kconfig option :kconfig:option:`CONFIG_NRF_SECURITY`.
1212+
* Added the :ref:`trusted_storage_readme` library.
12141213

1215-
* Updated the library to no longer enable RSA keys by default.
1216-
This reduces the code size by 30 kB for those that are not using RSA keys.
1217-
This will also break the configuration for those using the RSA keys without explicitly enabling an RSA key size.
1218-
Enable the required key size to fix the configuration, for example by setting the Kconfig option :kconfig:option:`CONFIG_PSA_WANT_RSA_KEY_SIZE_2048` if 2048-bit RSA keys are required.
1214+
* :ref:`nrf_security` library:
12191215

1220-
* The PSA config is now validated by the :file:`ncs/nrf/ext/oberon/psa/core/library/check_crypto_config.h` file.
1221-
Users with invalid configurations must update their PSA configuration according to the error messages that the :file:`check_crypto_config.h` file provides.
1216+
* Updated:
12221217

1218+
* The library no longer enables RSA keys by default, which reduces the code size by 30 kB for those that are not using RSA keys.
1219+
The RSA key size must be explicitly enabled to avoid breaking the configuration when using the RSA keys, for example by setting the Kconfig option :kconfig:option:`CONFIG_PSA_WANT_RSA_KEY_SIZE_2048` if 2048-bit RSA keys are required.
1220+
* The PSA config is now validated by the file :file:`ncs/nrf/ext/oberon/psa/core/library/check_crypto_config.h`.
1221+
Users with invalid configurations must update their PSA configuration according to the error messages that the file :file:`check_crypto_config.h` provides.
1222+
* PSA crypto is now supported on nRF54L Series devices.
1223+
Enable PSA crypto support with a CRACEN driver as the backend by setting the Kconfig option :kconfig:option:`CONFIG_NRF_SECURITY`.
12231224

12241225
Other libraries
12251226
---------------
@@ -1368,6 +1369,7 @@ Documentation
13681369

13691370
* :ref:`qspi_xip` user guide under :ref:`ug_nrf53`.
13701371
* A section on :ref:`tfm_enable_share_uart` in :ref:`ug_nrf9160`.
1372+
* :ref:`lib_security` where libraries :ref:`trusted_storage_readme` and :ref:`nrf_security` are added.
13711373

13721374
* Updated:
13731375

@@ -1404,6 +1406,7 @@ Documentation
14041406
* The Getting started with nRF70 Series user guide is split into three user guides, :ref:`ug_nrf7002_gs`, :ref:`ug_nrf7002ek_gs` and :ref:`ug_nrf7002eb_gs`.
14051407
* The Operating with a resource constrained host user guide by renaming it to :ref:`nRF70_nRF5340_constrained_host`.
14061408
Additionally, the information about stack configuration and performance is placed into its own separate page, :ref:`ug_wifi_stack_configuration`, under :ref:`ug_wifi`.
1409+
* The :ref:`security` page with information about the trusted storage.
14071410

14081411
* Removed the Welcome to the |NCS| page.
14091412
This page is replaced with existing :ref:`ncs_introduction` page.

doc/nrf/security/security.rst

+69
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,75 @@ To enable the HUK in an application, enable the :kconfig:option:`CONFIG_HW_UNIQU
4545

4646
For more information, see the hardware unique key :ref:`library <lib_hw_unique_key>` and :ref:`sample <hw_unique_key_usage>`.
4747

48+
Trusted storage in the |NCS|
49+
****************************
50+
51+
There are several options for storing keys and other important data persistently when developing applications with the |NCS|.
52+
Different storage options have different features.
53+
One of the options is to use the :ref:`trusted_storage_readme` library.
54+
55+
The trusted storage library enables the users to provide features like integrity, confidentiality and authenticity of the stored data, without using the TF-M Platform Root of Trust (PRoT).
56+
The library implements the PSA Cerified Secure Storage API.
57+
It consists of PSA Internal Trusted Storage API and PSA Protected Storage API.
58+
59+
The Internal Trusted Storage and the Protected Storage are designed to work in :ref:`environments both with and without security by separation <app_boards_spe_nspe>`.
60+
The two APIs used in the trusted storage library are also offered as secure services by TF-M.
61+
While TF-M enables security by separation, building and isolating security-critical functions in SPE and applications in NSPE, the trusted storage can be used in environments with no TF-M and separation of firmware.
62+
63+
The table below gives an overview of the trusted storage support for the products and their features.
64+
65+
.. list-table:: Trusted storage product support
66+
:widths: auto
67+
:header-rows: 1
68+
69+
* - Product
70+
- Backend
71+
- Confidentiality
72+
- Integrity
73+
- Authenticity
74+
- Isolation
75+
* - nRF52840
76+
- Library
77+
- ?
78+
- Yes
79+
- Yes
80+
- No
81+
* - | nRF5340 ``cpuapp`` builds
82+
| (no TF-M)
83+
- Library
84+
- ?
85+
- Yes
86+
- Yes
87+
- No
88+
* - | nRF5340 ``ns`` builds
89+
| (with TF-M)
90+
- TF-M service
91+
- Yes
92+
- Yes
93+
- Yes
94+
- Yes
95+
* - | nRF9160 ``cpuapp`` builds
96+
| (no TF-M)
97+
- Library
98+
- ?
99+
- Yes
100+
- Yes
101+
- No
102+
* - | nRF9160 ``ns`` builds
103+
| (with TF-M)
104+
- TF-M service
105+
- Yes
106+
- Yes
107+
- Yes
108+
- Yes
109+
110+
The trusted storage library addresses two of the PSA Certified Level 2 and Level 3 optional security functional requirements (SFRs):
111+
112+
* Secure Encrypted Storage (internal storage)
113+
* Secure Storage (internal storage)
114+
115+
The Secure External Storage SFR is not covered by the trusted storage library by default, but this can be realized by implementing a custom storage backend.
116+
48117
Device firmware upgrade (DFU)
49118
*****************************
50119

0 commit comments

Comments
 (0)