Skip to content

Commit 7a0899d

Browse files
FrancescoSernordicjm
authored andcommitted
doc: Added ISE Counter Service doc
Added IronSide SE Counter Service doc. Signed-off-by: Francesco Domenico Servidio <[email protected]>
1 parent 1169ceb commit 7a0899d

File tree

1 file changed

+141
-16
lines changed

1 file changed

+141
-16
lines changed

doc/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_ironside.rst

Lines changed: 141 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ UICR.SECURESTORAGE
705705

706706
:kconfig:option:`CONFIG_GEN_UICR_SECURESTORAGE` enables the secure storage system used by |ISE| for persistent storage of cryptographic keys and trusted data.
707707
The secure storage is divided into separate partitions for different services and processor domains.
708-
The total size of all configurations specified in ``UICR.SECURESTORAGE.*`` must be aligned to a 4 KB boundary.
708+
The total size of all configurations specified in UICR.SECURESTORAGE.\* must be aligned to a 4 KB boundary.
709709
For more information, see :ref:`ug_nrf54h20_ironside_se_secure_storage`.
710710

711711
The UICR.SECURESTORAGE configuration consists of the following sub-registers:
@@ -769,10 +769,10 @@ For information on how to configure these UICR settings, see :ref:`ug_nrf54h20_i
769769

770770
.. _ug_nrf54h20_ironside_se_boot_report:
771771

772-
IronSide boot report
773-
********************
772+
|ISE| boot report
773+
*****************
774774

775-
The IronSide boot report contains device state information communicated from |ISE| to the local domains.
775+
The |ISE| boot report contains device state information communicated from |ISE| to the local domains.
776776
It is written to a reserved region in RAM20, which is accessible to the local domain in the default system configuration.
777777
There is one boot report per processor that is booted, either directly by |ISE| or via the CPUCONF service.
778778

@@ -954,7 +954,7 @@ Setting bit 5 in ``CTRLAP.BOOTMODE`` will also trigger secondary firmware.
954954
|ISE| automatically triggers the secondary firmware in any of the following situations:
955955

956956
* The integrity check of the memory specified in :kconfig:option:`CONFIG_GEN_UICR_PROTECTEDMEM` fails.
957-
* Any boot failure occurs, such as missing primary firmware or failure to apply ``UICR.PERIPHCONF`` configurations.
957+
* Any boot failure occurs, such as missing primary firmware or failure to apply UICR.PERIPHCONF configurations.
958958
* If :kconfig:option:`CONFIG_GEN_UICR_SECONDARY_TRIGGER` is enabled, and a UICR-configurable trigger occurs.
959959
See the following table for UICR-configurable triggers.
960960

@@ -1067,21 +1067,21 @@ To leverage this secure storage functionality, applications must set the key loc
10671067

10681068
The secure storage configuration includes two separate storage regions:
10691069

1070-
* **UICR.SECURESTORAGE.CRYPTO** - Used for PSA Crypto API operations when storing cryptographic keys
1071-
* **UICR.SECURESTORAGE.ITS** - Used for PSA Internal Trusted Storage (ITS) API operations when storing general secure data
1070+
* UICR.SECURESTORAGE.CRYPTO - Used for PSA Crypto API operations when storing cryptographic keys
1071+
* UICR.SECURESTORAGE.ITS - Used for PSA Internal Trusted Storage (ITS) API operations when storing general secure data
10721072

10731073

10741074
Secure Storage through PSA Crypto API
10751075
=====================================
10761076

1077-
When using the PSA Crypto API to operate on keys, the storage region specified by ``UICR.SECURESTORAGE.CRYPTO`` is automatically used if the key attributes are configured with **key location** set to ``PSA_KEY_LOCATION_LOCAL_STORAGE``.
1077+
When using the PSA Crypto API to operate on keys, the storage region specified by UICR.SECURESTORAGE.CRYPTO is automatically used if the key attributes are configured with ``key location`` set to ``PSA_KEY_LOCATION_LOCAL_STORAGE``.
10781078

10791079
This ensures that cryptographic keys are stored in the dedicated secure storage region rather than in regular application memory.
10801080

10811081
Secure storage through PSA ITS API
10821082
==================================
10831083

1084-
When using the PSA ITS API for storing general secure data, the storage region specified by ``UICR.SECURESTORAGE.ITS`` is used automatically.
1084+
When using the PSA ITS API for storing general secure data, the storage region specified by UICR.SECURESTORAGE.ITS is used automatically.
10851085
No special configuration is required for PSA ITS operations, as they inherently use the secure storage when available.
10861086

10871087
Security Properties
@@ -1092,16 +1092,16 @@ The secure storage provided by |ISE| has the following security characteristics:
10921092
Access Control
10931093
--------------
10941094

1095-
* **Domain Isolation**: Secure storage regions are not accessible by local domains directly.
1096-
* **Ironside Exclusive Access**: Only the Ironside Secure Element can access the secure storage regions.
1097-
* **Domain Separation**: Each local domain can only access its own secure storage data, ensuring isolation between different domains.
1095+
* *Domain Isolation*: Secure storage regions are not accessible by local domains directly.
1096+
* *Ironside Exclusive Access*: Only the |ISE| can access the secure storage regions.
1097+
* *Domain Separation*: Each local domain can only access its own secure storage data, ensuring isolation between different domains.
10981098

10991099
Data Protection
11001100
---------------
11011101

1102-
* **Encryption**: All data stored in the secure storage regions is encrypted using device-unique keys.
1103-
* **Integrity**: The stored data is protected against tampering through cryptographic integrity checks.
1104-
* **Confidentiality**: The encryption ensures that stored data remains confidential even if the storage medium is physically accessed.
1102+
* *Encryption*: All data stored in the secure storage regions is encrypted using device-unique keys.
1103+
* *Integrity*: The stored data is protected against tampering through cryptographic integrity checks.
1104+
* *Confidentiality*: The encryption ensures that stored data remains confidential even if the storage medium is physically accessed.
11051105

11061106
.. note::
11071107
The device-unique encryption keys are managed entirely by |ISE| and are not accessible to application code.
@@ -1112,7 +1112,7 @@ Configuration Considerations
11121112

11131113
When configuring secure storage, consider the following:
11141114

1115-
* Ensure sufficient storage space is allocated in both ``UICR.SECURESTORAGE.CRYPTO`` and ``UICR.SECURESTORAGE.ITS`` regions based on your application's requirements
1115+
* Ensure sufficient storage space is allocated in both UICR.SECURESTORAGE.CRYPTO and UICR.SECURESTORAGE.ITS regions based on your application's requirements
11161116
* The sum of these two regions must be 4kB aligned.
11171117
* The secure storage regions should be properly sized to accommodate the expected number of keys and data items
11181118
* Access to secure storage is only available when the key location is explicitly set to ``PSA_KEY_LOCATION_LOCAL_STORAGE``
@@ -1292,3 +1292,128 @@ This prevents the CPU from executing any instructions until the CPUWAIT register
12921292
Use this command to begin debugging at the very first instruction or to program flash memory safely without concurrent CPU access.
12931293

12941294
The ``DEBUGWAIT`` command does not define any command-specific values for the CTRLAP.BOOTSTATUS.CMDERROR field.
1295+
1296+
.. _ug_nrf54h20_ironside_se_spu_mramc_feature_configuration:
1297+
1298+
|ISE| SPU MRAMC feature configuration
1299+
*************************************
1300+
1301+
|ISE| configures the SPU.FEATURES.MRAMC registers with default settings for both MRAMC110 and MRAMC111.
1302+
Local domains have access to the READY/READYNEXT status registers for monitoring the status of the MRAM controller.
1303+
All other MRAMC features (like WAITSTATES and AUTODPOWERDOWN) are managed by |ISE|, with all configurations locked at boot time.
1304+
1305+
.. _ug_nrf54h20_ironside_se_counter_service:
1306+
1307+
|ISE| Counter service
1308+
*********************
1309+
1310+
The |ISE| Counter service provides secure monotonic counters for rollback protection, version tracking, and other security-critical applications that require strictly increasing values.
1311+
1312+
The header file for this service is :file:`sdk-zephyr/soc/nordic/ironside/include/nrf_ironside/counter.h`.
1313+
1314+
It provides four independent 32-bit monotonic counters (``IRONSIDE_COUNTER_0`` through ``IRONSIDE_COUNTER_3``).
1315+
Each counter can only be set to a value greater than or equal to its current value, which ensures that counter values never decrease.
1316+
1317+
The counters have the following properties:
1318+
1319+
.. list-table::
1320+
:header-rows: 1
1321+
1322+
* - Property
1323+
- Description
1324+
* - Monotonic
1325+
- Counter values can only increase or stay the same; they cannot decrease.
1326+
* - Persistent
1327+
- Counter values are stored in secure storage and survive reboots.
1328+
* - Per-boot locking
1329+
- Counters can be locked for the current boot session to prevent further modifications.
1330+
* - Automatic initialization
1331+
- Counters are initialized to 0 during the first boot with an unlocked UICR.
1332+
1333+
Operations
1334+
==========
1335+
1336+
The Counter service provides three primary operations applicable to the counters: ``set``, ``get``, and ``lock``.
1337+
1338+
Set
1339+
---
1340+
1341+
The ``ironside_counter_set()`` function sets a counter to a specified value.
1342+
The new value must be greater than or equal to the current counter value.
1343+
1344+
The function takes the following parameters:
1345+
1346+
* ``counter_id`` - Counter identifier (``IRONSIDE_COUNTER_0`` through ``IRONSIDE_COUNTER_3``).
1347+
* ``value`` - New counter value.
1348+
It must be greater than or equal to the current value.
1349+
1350+
The function returns the following values:
1351+
1352+
* ``0`` on success.
1353+
* ``-IRONSIDE_COUNTER_ERROR_INVALID_ID`` if the counter ID is invalid.
1354+
* ``-IRONSIDE_COUNTER_ERROR_TOO_LOW`` if the specified value is lower than the current value.
1355+
* ``-IRONSIDE_COUNTER_ERROR_LOCKED`` if the counter is locked for this boot session.
1356+
* ``-IRONSIDE_COUNTER_ERROR_STORAGE_FAILURE`` if the storage operation failed.
1357+
1358+
Get
1359+
---
1360+
1361+
The ``ironside_counter_get()`` function retrieves the current value of a counter.
1362+
1363+
The function takes the following parameters:
1364+
1365+
* ``counter_id`` - Counter identifier (``IRONSIDE_COUNTER_0`` through ``IRONSIDE_COUNTER_3``).
1366+
* ``value`` - Pointer to store the retrieved counter value.
1367+
1368+
The function returns the following values:
1369+
1370+
* ``0`` on success.
1371+
* ``-IRONSIDE_COUNTER_ERROR_INVALID_ID`` if the counter ID is invalid.
1372+
* ``-IRONSIDE_COUNTER_ERROR_STORAGE_FAILURE`` if the storage operation failed or the counter is not initialized.
1373+
1374+
Lock
1375+
----
1376+
1377+
The ``ironside_counter_lock()`` function locks a counter for the current boot session, which prevents any further modifications until the next reboot.
1378+
Lock states are non-persistent and are cleared on reboot.
1379+
1380+
The function takes the following parameter:
1381+
1382+
* ``counter_id`` - Counter identifier (``IRONSIDE_COUNTER_0`` through ``IRONSIDE_COUNTER_3``).
1383+
1384+
The function returns the following values:
1385+
1386+
* ``0`` on success.
1387+
* ``-IRONSIDE_COUNTER_ERROR_INVALID_ID`` if the counter ID is invalid.
1388+
1389+
Usage
1390+
=====
1391+
1392+
The Counter service is typically used for the following purposes:
1393+
1394+
* *Firmware version tracking* - Store the current firmware version and prevent rollback to older versions.
1395+
* *Anti-rollback protection* - Ensure that security-critical updates cannot be reverted.
1396+
* *Nonce generation* - Generate unique, strictly increasing values for cryptographic operations.
1397+
1398+
The following example demonstrates how to use the Counter service to track firmware versions and prevent rollback:
1399+
1400+
.. code-block:: c
1401+
1402+
#include <nrf_ironside/counter.h>
1403+
1404+
/* Read the current firmware version counter */
1405+
uint32_t current_version;
1406+
int err = ironside_counter_get(IRONSIDE_COUNTER_0, &current_version);
1407+
if (err != 0) {
1408+
/* Handle error */
1409+
}
1410+
1411+
/* Update to the new firmware version */
1412+
uint32_t new_version = 42;
1413+
err = ironside_counter_set(IRONSIDE_COUNTER_0, new_version);
1414+
if (err == -IRONSIDE_COUNTER_ERROR_TOO_LOW) {
1415+
/* Firmware rollback detected - reject update */
1416+
}
1417+
1418+
/* Lock the counter to prevent tampering during this boot session */
1419+
ironside_counter_lock(IRONSIDE_COUNTER_0);

0 commit comments

Comments
 (0)