TF-M Services

As explained in the Configurable build section, TF-M is built from a set of services that are isolated from each other. Services can be enabled or disabled based on the application requirements. Following sections describe the available TF-M services and their purpose.

Platform service

The platform service is the mandatory implementation of the Platform RoT Services. It provides platform-specific services to other TF-M partitions and to a non-secure application. To enable the platform service, set the CONFIG_TFM_PARTITION_PLATFORM Kconfig option.

For user applications placed in the Non-Secure Processing Environment, you can set the CONFIG_TFM_ALLOW_NON_SECURE_FAULT_HANDLING Kconfig option, which enables more detailed error descriptions of faults from the application with the Zephyr fault handler.

The platform service also exposes the following nRF Connect SDK specific APIs for the non-secure application:

/* Search for the fw_info structure in firmware image located at address. */
int tfm_platform_firmware_info(uint32_t fw_address, struct fw_info *info);

/* Check if S0 is the active B1 slot. */
int tfm_platform_s0_active(uint32_t s0_address, uint32_t s1_address, bool *s0_active);

/* Writes a word to the secure memory as long as the address permissions allow it. */
enum tfm_platform_err_t tfm_platform_mem_write32(uint32_t addr, uint32_t value, uint32_t mask, uint32_t *result);

/* Reads data from the secure memory as long as the address range permissions allow it. */
enum tfm_platform_err_t tfm_platform_mem_read(void *destination, uint32_t addr, size_t len, uint32_t *result);

See TF-M input/output control (IOCTL) for more information about APIs available for the non-secure application.

For more information about the general features of the TF-M Platform partition, see TF-M Platform.

System Reset service

The System Reset service is one of the default TF-M platform services that has a specific implementation for the nRF Connect SDK. It allows to perform a system reset through the TF-M platform service using the tfm_hal_system_reset() function.

This service is enabled when you enable the CONFIG_TFM_PARTITION_PLATFORM Kconfig option.

System OFF service

The System OFF service is one of the TF-M platform services specific to the nRF Connect SDK. It allows the non-secure application to request the system to enter the System OFF mode using a secure service call.

The System OFF mode is part of the power and clock management system and is available on selected Nordic Semiconductor devices, including the nRF54L Series devices that support TF-M. For more details about the System OFF mode, see the device datasheet, for example the nRF54L15 Power and clock management page.

To enable the System OFF service in the nRF Connect SDK, enable the CONFIG_TFM_NRF_SYSTEM_OFF_SERVICE Kconfig option.

Zephyr’s System Off sample demonstrates how to use the System OFF service.

Internal Trusted Storage service

The Internal Trusted Storage (ITS) service is one of Platform RoT Services. It implements the PSA Internal Trusted Storage APIs (PSA Certified Secure Storage API 1.0) to achieve confidentiality, authenticity and encryption in rest (optional).

To enable the ITS service, set the CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE Kconfig option.

ITS is meant to be used by other TF-M partitions. It has specific sizing requirements and must not be accessed directly by a user application placed in the Non-Secure Processing Environment. If you want the user application to access the contents of the partition, use the Protected Storage service.

This service is enabled as the default storage mechanism when you enable the Crypto service service. If you are using a device with the Key Management Unit (KMU), you can disable the Internal Trusted Storage service and start using KMU instead to save memory.

For more information about the general features of the TF-M ITS service, see TF-M ITS.

Encrypted ITS

TF-M ITS encryption is a data protection mechanism in Internal Trusted Storage. It provides transparent encryption using a Master Key Encryption Key (MKEK) stored in hardware, with unique encryption keys derived for each file.

To enable TF-M ITS encryption, set the CONFIG_TFM_ITS_ENCRYPTED Kconfig option.

On Nordic Semiconductor devices, the hardware-accelerated AEAD scheme ChaChaPoly1305 is used with a 256-bit key. This key is derived with a key derivation function (KDF) based on NIST SP 800-108 CMAC. The input key of the KDF is the MKEK, a symmetric key stored in the Key Management Unit (KMU) of Nordic Semiconductor devices. The MKEK is protected by the KMU peripheral and its key material cannot be read by the software. It can only be used by reference.

The file ID is used as a derivation label for the KDF. This means that each file ID uses a different AEAD key. As long as each file has a unique file ID, the key used for encryption and authentication is unique.

To strengthen data integrity, the metadata of the ITS file (creation flags or size, or both) is used as authenticated data in the encryption process.

The nonce for the AEAD operation is generated by concatenating a random 8-byte seed and an increasing 4-byte counter. The random seed is generated once in the boot process and stays the same until reset.

Crypto service

The TF-M Crypto Service is one of Platform RoT Services. It implements the PSA Crypto APIs (PSA Certified Crypto API 1.4.0) and provides cryptographic services to other TF-M partitions and to the non-secure application.

To enable the crypto service, set the CONFIG_TFM_PARTITION_CRYPTO Kconfig option.

You can configure the service directly using the CONFIG_TFM_CRYPTO_* Kconfig options found in the zephyr/modules/trusted-firmware-m/Kconfig.tfm.crypto file. However, it is recommended to use the CONFIG_PSA_WANT_* Kconfig options to enable the required algorithms and key types. These will enable the required CONFIG_TFM_CRYPTO_* Kconfig options.

TF-M uses hardware unique keys when the PSA Crypto key derivation APIs are used, and psa_key_derivation_setup is called with the algorithm TFM_CRYPTO_ALG_HUK_DERIVATION.

When enabled, the Crypto service by default uses the Internal Trusted Storage service to store the keys and other sensitive data. If you are using a device with the Key Management Unit (KMU), you can disable the Internal Trusted Storage service and start using KMU instead to save memory.

For more information about the general features of the Crypto partition, see TF-M Crypto.

Protected Storage service

The Protected Storage (PS) service is one of possible Application RoT Services. It implements the PSA Protected Storage APIs (PSA Certified Secure Storage API 1.0).

To enable the PS service, set the CONFIG_TFM_PARTITION_PROTECTED_STORAGE Kconfig option.

The PS service uses the ITS service to achieve confidentiality and authenticity. In addition, it provides encryption, authentication, and rollback protection.

A user application placed in the Non-Secure Processing Environment should use the PS partition for storing sensitive data.

The PS service partition has specific sizing requirements.

For more information about the general features of the TF-M PS service, see TF-M PS.

Initial Attestation service

The Initial Attestation service implements the PSA Initial Attestation APIs (PSA Certified Attestation API 1.0). The service allows the device to prove its identity to a remote entity.

To enable the Initial Attestation service, set the CONFIG_TFM_PARTITION_INITIAL_ATTESTATION Kconfig option.

The TF-M: PSA template sample demonstrates how to use the Initial Attestation service.

The Initial Attestation service is not enabled by default. Keep it disabled unless you need attestation.

For more information about the general features of the TF-M Initial Attestation service, see TF-M Attestation.