3. System security

The STM32U5 series devices are designed with a comprehensive set of security features, some of which being based on the standard Arm TrustZone technology.

These security features simplify the process of evaluating IoT devices against security standards. They also significantly reduce the cost and complexity of software development for OEM and third-party developers, by facilitating the reuse, improving the interoperability, and minimizing the API fragmentation.

This section explains the different security features available on STM32U5 series devices.

3.1 Key security features

3.2 Secure install

The secure firmware install (SFI) is an STMicroelectronics secure service authenticated and decrypted by the immutable RSS code stored in the device. The SFI allows secure and counted installation of OEM firmware in the untrusted production environment (such as the OEM contract manufacturer).

The confidentiality of the installed images written either in the internal flash memory or encrypted in an external flash memory, is also protected, using the AES.

The SFI native service leverages the following hardware security features:

Further information can be found in the application note: “STM32 MCUs secure firmware install (SFI) overview ” (AN4992).

3.3 Secure boot

Secure boot is an immutable code that is always executed after a system reset. As a root of trust, this code checks the device static protections and activates available device runtime protections, reducing the risk that invalid or malicious code runs on the platform. As root of trust, the secure boot also checks the integrity and authenticity of the next level firmware before executing it.

The actual functions of the secure boot depend on the availability of TrustZone features, and on the firmware stored in the device. However, the secure boot typically initializes the secure storage, and installs on-the-fly decryption keys in the OTFDEC, to be able to use encrypted firmware stored in an external flash memory.

The device trusted firmware-M (TFM) application, supported by the STM32 ecosystem, provides a root of trust solution including secure boot functions. For more information, refer to the user manual Getting started with STM32CubeU5 TFM application (UM2851).

In the devices, the secure boot takes benefit of hardware security features such as:

This section describes the features specifically designed for secure boot.

3.3.1 Unique boot entry and BOOT_LOCK

When TrustZone is activated (TZEN = 1) and the BOOT_LOCK secure option bit is cleared, the application selects a boot entry point located either in the system flash memory (see the next section), or in the secure user flash memory, at the address defined by SECBOOTADD0 option bytes.

When TrustZone is activated (TZEN = 1) and the BOOT_LOCK secure option bit is set, the device unique boot entry is the unmodifiable secure address defined by SECBOOTADD0 option bytes. All these option bytes cannot be modified by the application anymore when BOOT_LOCK is set.

Note: As long as it is cleared, the BOOT_LOCK option bit can be set without any constraint. But once set, the BOOT_LOCK option bit cannot be cleared when RDP level > 0.

For more information on the boot mechanisms, refer to Section 4: Boot modes .

3.3.2 Immutable root of trust in system flash memory

The immutable root-of-trust code stored in the system flash memory is first used to initiate the SFI, allowing secure and counted installation of OEM firmware in the untrusted production environment (such as the OEM contract manufacturer).

The STMicroelectronics immutable code also includes secure runtime services that can be called at runtime when a secure application sets the SYSCFG_RSSCMR register to a non-null value before triggering a system reset. This runtime feature is deactivated when the BOOT_LOCK secure option bit is set, and the secure address defined by SECBOOTADD0 is set on the secure user flash memory.

3.4 Secure update

The secure firmware update is a secure service that runs after a secure boot. Its actual functions depend on the availability of the TrustZone features, and on the firmware stored in the device.

The device trusted firmware-M (TFM) application, supported by the STM32 ecosystem, allows the update of the microcontroller built-in program with new firmware versions, adding new features and correcting potential issues. The update process is performed in a secure way to prevent unauthorized updates and access to confidential on-device data.

A firmware update can be done either on a single firmware image including both secure and nonsecure parts, or on the secure (respectively nonsecure) part of the firmware image, independently.

In the devices, the secure update application leverages the same hardware security as the firmware install described in Section 3.2 . For more information, refer to the user manual: Getting started with STM32CubeU5 TFM application (UM2851) .

3.5 Resource isolation using TrustZone

In the STM32U5 series devices, the hardware and software resources can be partitioned so that they exist either in the secure world or in the nonsecure world, as shown in the figure below.

Figure 7. Secure/nonsecure partitioning using TrustZone technology

Diagram illustrating secure/nonsecure partitioning using TrustZone technology. The diagram shows two worlds: Nonsecure world and Secure world. The Nonsecure world contains Applications and Privileged system services. The Secure world contains Application RoT and Root of trust services. Both worlds share Peripherals and I/Os, Memory (internal, external), and CPU time. The Secure world is initialized by Init. A legend indicates that white boxes represent the Nonsecure world and blue hatched boxes represent the Secure world.

The diagram illustrates the secure/nonsecure partitioning using TrustZone technology. It shows two main worlds: the Nonsecure world and the Secure world. The Nonsecure world contains Applications and Privileged system services. The Secure world contains Application RoT and Root of trust services. Both worlds share Peripherals and I/Os, Memory (internal, external), and CPU time. The Secure world is initialized by Init. A legend indicates that white boxes represent the Nonsecure world and blue hatched boxes represent the Secure world.

Diagram illustrating secure/nonsecure partitioning using TrustZone technology. The diagram shows two worlds: Nonsecure world and Secure world. The Nonsecure world contains Applications and Privileged system services. The Secure world contains Application RoT and Root of trust services. Both worlds share Peripherals and I/Os, Memory (internal, external), and CPU time. The Secure world is initialized by Init. A legend indicates that white boxes represent the Nonsecure world and blue hatched boxes represent the Secure world.

Note: The initial partitioning of the platform is under the responsibility of the secure firmware executed after the reset of the device.

Thanks to this resource isolation technology, the secure world can be used to protect critical code against intentional or unintentional tampering from the more exposed code running in the nonsecure world.

Note: The secure code is typically small and rarely modified, while nonsecure code is more exposed, and prone to firmware updates.

3.5.1 TrustZone security architecture

The Armv8-M TrustZone technology is a comprehensive hardware architecture that proposes to developers a comprehensive, holistic protection across the entire processor and system. The device TrustZone hardware features include:

Note: The TrustZone security is activated by the TZEN option bit in the FLASH_OPTR register.

3.5.2 Armv8-M security extension of Cortex-M33

The Arm security extension of the Cortex-M33 is an evolution, not a revolution. It uses the programmer model from earlier Cortex-M subfamilies like Cortex-M4. Indeed, Armv8-M is architecturally similar to Armv7-M, using the same 32-bit architecture, the same memory mapped resources protected with an MPU. Armv8-M also uses the nested vectored interrupt controller (NVIC).

The Armv8-M TrustZone implementation in STM32U5 series devices is composed of the following features:

For more information, refer to STM32 Cortex-M33 MCUs programming manual (PM0264).

3.5.3 Memory and peripheral allocation using IDAU/SAU

Security attributes

As illustrated on Figure 8 , the Armv8-M nonsecure memory view is similar to Armv7-M (that can be found in Cortex-M4), with the difference that the secure memory is hidden. The secure memory view shows the flash memory, SRAM, and peripherals that are only accessible while the Cortex processor executes in Secure state.

The figure below shows the 32-bit address space viewed after the SAU configuration by the secure code.

Figure 8. Sharing memory map between CPU in secure and nonsecure state

Figure 8: Sharing memory map between CPU in secure and nonsecure state. This diagram shows two memory views of the 32-bit address space (0x0000 0000 to 0xFFFF FFFF). The 'Nonsecure memory view' lists regions like System region, System control and debug, External peripherals, External memories, Periph-NS, hidden (Periph-S), SRAM-NS, hidden (SRAM-S), Flash-NS, and hidden (Flash-S). The 'Secure memory view' lists regions like MPU-NS*, SCB-NS*, SysTick-NS*, DEBUG, hidden (SAU), MPU-NS, MPU-S, SCB-NS, SCB-S, NVIC, SysTick-NS, SysTick-S, and ITM / DWT / FBP. A dotted line connects the 'System control and debug' region in the nonsecure view to the 'hidden' block in the secure view. A note at the bottom right indicates '(*) Aliased addresses' and the code 'MSv64440V1'.
Figure 8: Sharing memory map between CPU in secure and nonsecure state. This diagram shows two memory views of the 32-bit address space (0x0000 0000 to 0xFFFF FFFF). The 'Nonsecure memory view' lists regions like System region, System control and debug, External peripherals, External memories, Periph-NS, hidden (Periph-S), SRAM-NS, hidden (SRAM-S), Flash-NS, and hidden (Flash-S). The 'Secure memory view' lists regions like MPU-NS*, SCB-NS*, SysTick-NS*, DEBUG, hidden (SAU), MPU-NS, MPU-S, SCB-NS, SCB-S, NVIC, SysTick-NS, SysTick-S, and ITM / DWT / FBP. A dotted line connects the 'System control and debug' region in the nonsecure view to the 'hidden' block in the secure view. A note at the bottom right indicates '(*) Aliased addresses' and the code 'MSv64440V1'.

The Cortex processor state (and associated rights) depends on the security attribute assigned to the memory region where it is executed:

In order to manage transitions to the secure world, developers must create nonsecure callable (NSC) regions that contain valid entry points to the secure libraries. The first instruction in these entry points must be the new secure gate (SG) instruction, used by the nonsecure code to call a secure function (see the figure below).

Figure 9. Secure world transition and memory partitioning

Figure 9: Secure world transition and memory partitioning. This diagram illustrates the interaction between a 'Nonsecure application' in 'Nonsecure memory' and a 'Secure library' in 'Secure memory'. The Nonsecure application makes a 'call' to a 'Secure entry point' located within a 'Nonsecure callable' region of the Secure memory. The Secure entry point then makes a 'call / branch' to the Secure library. The Secure library returns control to the Secure entry point, which in turn returns control to the Nonsecure application. The code 'MSv64441V1' is noted at the bottom right.
Figure 9: Secure world transition and memory partitioning. This diagram illustrates the interaction between a 'Nonsecure application' in 'Nonsecure memory' and a 'Secure library' in 'Secure memory'. The Nonsecure application makes a 'call' to a 'Secure entry point' located within a 'Nonsecure callable' region of the Secure memory. The Secure entry point then makes a 'call / branch' to the Secure library. The Secure library returns control to the Secure entry point, which in turn returns control to the Nonsecure application. The code 'MSv64441V1' is noted at the bottom right.

Programming security attributes

In Cortex-M33, the static implementation defined attribution unit (IDAU) works in conjunction with the programmable security attribution unit (SAU) to assign a specific security attribute (S, NS, or NSC) to a specific address, as shown in the table below.

Table 8. Configuring security attributes with IDAU and SAU

IDAU security attributionSAU security attribution (1)Final security attribution
NonsecureSecureSecure
Secure-NSCSecure-NSC
NonsecureNonsecure
Secure-NSCSecureSecure
NonsecureSecure-NSC

1. Defined regions are aligned to 32-byte boundaries.

The SAU can only be configured by the Cortex-M33 in the secure-privilege state. When the TrustZone is enabled, the SAU defaults all addresses as secure (S). A secure boot application can then program the SAU to create NSC or NS regions, as shown in the previous table.

Note: The SAU/IDAU settings are applicable only to the Cortex-M33. The other masters like DMA are not affected by these policies.

A memory space not covered by an SAU region is fixed as secure.

For more information on memory security attribution using IDAU/SAU, refer to the application note TrustZone features on STM32L5 and STM32U5 Series (AN5347) .

3.5.4 Memory and peripheral allocation using GTZC

Global TrustZone framework architecture

On top of the Armv8-M TrustZone security extension in Cortex-M33, the devices embed complementary security features that reinforce, in a flexible way, the isolation between the secure and the nonsecure worlds. Unlike the SAU/IDAU, the GTZC can protect legacy memories and peripherals against nonsecure transactions coming from other masters than the Cortex-M33.

Figure 10. Global TrustZone framework and TrustZone awareness

Diagram of the Global TrustZone framework and TrustZone awareness. The diagram shows a device boundary containing various components: 'Other bus master' (white), 'CPU' (blue hatched, containing SAU+IDAU and MPU), 'DMA' (blue hatched), 'Flash memory' (blue hatched), 'SRAM' (white), 'OTFDEC' (blue hatched), 'External Flash memory' (white), 'External SRAM' (white), and four 'Peripheral' blocks (three white, one blue hatched). A thick blue line represents the 'Global TrustZone framework' interconnect. A legend at the bottom left indicates that solid blue represents the 'Global TrustZone framework' and blue hatched represents 'TrustZone-aware peripherals'. The reference 'MSv64450V1' is in the bottom right corner.
Diagram of the Global TrustZone framework and TrustZone awareness. The diagram shows a device boundary containing various components: 'Other bus master' (white), 'CPU' (blue hatched, containing SAU+IDAU and MPU), 'DMA' (blue hatched), 'Flash memory' (blue hatched), 'SRAM' (white), 'OTFDEC' (blue hatched), 'External Flash memory' (white), 'External SRAM' (white), and four 'Peripheral' blocks (three white, one blue hatched). A thick blue line represents the 'Global TrustZone framework' interconnect. A legend at the bottom left indicates that solid blue represents the 'Global TrustZone framework' and blue hatched represents 'TrustZone-aware peripherals'. The reference 'MSv64450V1' is in the bottom right corner.

Securing peripherals with TZSC

When the TrustZone security is active, a peripheral is either securable through the TZSC in GTZC, or is natively TrustZone-aware, as shown in the previous figure:

When a securable peripheral is made secure-only with the GTZC, if this peripheral is master on the interconnect (such as SDMMC), it automatically issues secure transactions. The SDMMC is an example of securable master. TrustZone-aware AHB masters like Cortex-M33 or DMAs, drive a secure signal in the AHB interconnect, according to their security mode, independently to the GTZC.

Note: Like with TrustZone, a peripheral can be made privileged-only with TZSC (see Section 3.6.3 ). In this case, if this peripheral is master on the interconnect, it automatically issues privileged transactions.

Securing memories with TZSC and MPCBB

The TZSC block in GTZC provides the capability to manage the security and privilege for all securable external memories, programming the MPCWM resources.

The table below shows an implementation example. For all other implementations on the STM32U5 Series devices, refer to Section 5.3: GTZC implementation .

Table 9. MPCWMx resources

MemoryMPC resourceType of filteringNumber of regionsDefault securityOn-the-fly decryption (1)
OCTOSPI1MPCWM1Nonsecure privileged or unprivileged region (watermarks)2Secure privileged (2)Yes
FMC_NOR bankMPCWM22No
FMC_NAND bankMPCWM31
Backup SRAM (BKPSRAM)MPCWM41
OCTOSPI2MPCWM52Yes
HSPI1MPCWM62No

1. Using the OTFDEC.

2. Assuming TrustZone is activated on the device, nonsecure unprivileged otherwise.

The MPCBB resources in GTZC provide the capability to configure the security and privilege of embedded SRAM blocks.

The table below shows an implementation example. For all other implementations on the STM32U5 Series devices, refer to Section 5.3: GTZC implementation .

Table 10. MPCBBx resources

MemoryMPC resourceType of filteringMemory size (Kbytes)Block size (Bytes)Number of super-blocksDefault security
SRAM1GTZC1_MPCBB1Block based, managing security and privilege768512 (1)48Secure privileged (2)
SRAM2GTZC1_MPCBB2644
SRAM3GTZC1_MPCBB383252
SRAM4GTZC2_MPCBB4161
SRAM5GTZC1_MPCBB583252
SRAM6GTZC1_MPCBB651232

1. Blocks are grouped in super-blocks of 32 consecutive blocks, to manage the configuration locking.

2. Assuming TrustZone is activated on the device, nonsecure unprivileged otherwise.

Applying GTZC configurations

The TZSC and MPCBB blocks can be used in one of the following ways:

When the dynamic option is selected and the configuration is not locked:

Securing peripherals with TZSC

The TZSC block in GTZC provides the capability to manage the security and the privilege for all securable peripherals. The list of these peripherals can be found in Section 5: Global TrustZone controller (GTZC) .

Note: When the TrustZone is deactivated, the resource isolation hardware GTZC can still be used to isolate peripherals to privileged code only (see Section 3.6.3 ).

When the TrustZone is activated, peripherals are set as nonsecure and unprivileged after reset.

TrustZone-aware peripherals

The devices include the following TrustZone-aware peripherals:

The way illegal accesses to these peripherals are monitored through the TZIC registers is described in Section 5: Global TrustZone controller (GTZC) .

For more details, refer to Section 3.5.5 .

TrustZone illegal access controller (TZIC)

The TZIC block in GTZC gathers all illegal access events originated from sources either protected by GTZC or TrustZone-aware peripherals, generating one global secure interrupt towards the NVIC.

TZIC is available only when the system is TrustZone enabled (TZEN = 1). All accesses to TZIC registers must be secured and privileged.

For each illegal event source, a status flag and a clear bit exist. Each illegal event can be masked, not generating an interrupt toward the NVIC.

Note: By default, all events are masked.

3.5.5 Managing security in TrustZone-aware peripherals

This section gives more details on how the security is implemented in the TrustZone-aware peripherals listed in the previous section.

Embedded flash memory

When the TrustZone security is enabled through option bytes (TZEN = 1), the whole flash memory is secure after reset and the following protections, shown in the figure below, are available to the application:

Note: All areas are aligned on the flash memory page granularity.

The flash memory area can be configured as secure while it is tagged as nonsecure in Cortex-M33 IDAU/SAU. In this case, nonsecure accesses by the CPU to the flash memory are denied.

Erase or program operations can be available to secure (resp. nonsecure) code only for secure (resp. nonsecure) pages or memory. A flash memory is considered secure if at least one page is secure.

Figure 11. Flash memory TrustZone protections

Diagram illustrating Flash memory TrustZone protections. It compares 'TrustZone disabled' and 'TrustZone enabled' states for User flash memory and Read-only system Flash memory. In the 'TrustZone disabled' state, User flash memory is divided into alternating Nonsecure and Secure pages, with a Boot area at the bottom. In the 'TrustZone enabled' state, User flash memory is divided into alternating Nonsecure and Secure pages, followed by Flash memory-S(*) and Flash memory-S(*) (HDP) at the bottom, with a Boot area at the bottom. Read-only system Flash memory is divided into Bootloader and Hidden areas in the 'TrustZone disabled' state, and Bootloader-NS and RSS(*) (HDP) in the 'TrustZone enabled' state, with a Boot area at the bottom. A note indicates that (*) represents nonvolatile security configuration. The diagram is labeled MSV64451V1.

(*): nonvolatile security configuration

MSV64451V1

Diagram illustrating Flash memory TrustZone protections. It compares 'TrustZone disabled' and 'TrustZone enabled' states for User flash memory and Read-only system Flash memory. In the 'TrustZone disabled' state, User flash memory is divided into alternating Nonsecure and Secure pages, with a Boot area at the bottom. In the 'TrustZone enabled' state, User flash memory is divided into alternating Nonsecure and Secure pages, followed by Flash memory-S(*) and Flash memory-S(*) (HDP) at the bottom, with a Boot area at the bottom. Read-only system Flash memory is divided into Bootloader and Hidden areas in the 'TrustZone disabled' state, and Bootloader-NS and RSS(*) (HDP) in the 'TrustZone enabled' state, with a Boot area at the bottom. A note indicates that (*) represents nonvolatile security configuration. The diagram is labeled MSV64451V1.

As shown above, when TrustZone is activated (TZEN = 1), the application code can use the HDP area that is part of the flash memory watermark-based secure area. Indeed, when the application sets the HDPx_ACCDIS bit, data read, write, and instruction fetch on this HDP area is denied until the next system reset.

For example, the software code in the secure flash memory HDP area can be executed only once, with any further access to this area denied until the next system reset. Additionally, any flash memory page belonging to an active HDP area cannot be erased anymore.

When the TrustZone is deactivated (TZEN = 0), the volatile/non-volatile secure area features are deactivated and all secure registers are RAZ/WI.

See Section 7: Embedded flash memory (FLASH) for more details.

On-the-fly encryption/decryption (OTFDEC)

When the TrustZone security is activated (TZEN = 1), the OTFDEC can only be initialized by secure applications. Each of the four encrypted regions, once the configuration is confirmed, can be write-locked until the next power-on-reset.

Note: Any application (secure or nonsecure) can verify the initialization context of each OTFDEC region (including the CRC of the keys), by reading the peripheral registers.

Key registers in each OTFDEC are write-only.

See Section 3.9.3 for more details on this cryptographic engine.

Direct memory access controllers (LPDMA and GPDMA)

When a DMA channel x is defined as secure (SECx = 1 in LP/GPDMA_SECCFG), the source and destination transfers can be independently set as secure or nonsecure by a secure application using SSEC and DSEC bits in LP/GPDMA_CxTR1.

The table below summarizes these security options available in each DMA channel.

Table 11. DMA channel use (security) (1)

Destination typeSecure DMA channel x (SECx = 1)Nonsecure DMA channel y (SECy = 0)
Secure sourceNonsecure sourceSecure sourceNonsecure source
Secure destinationOKOK (2)Transfer blocked
Nonsecure destinationOK (3)OK (4)Transfer blockedOK
  1. 1. When a transfer is blocked, the transfer completes but the corresponding writes are ignored, and reads return zeros. Also an illegal access event to TZIC is automatically triggered by the memory/peripheral used as source or destination.
  2. 2. If the source is a memory, the transfer is only possible if SSEC = 0, otherwise the transfer is blocked.
  3. 3. If the destination is a memory, the transfer is only possible if DSEC = 0, otherwise the transfer is blocked.
  4. 4. If the transfer is memory-to-memory, the transfer is only possible if SSEC = 0 and DSEC = 0, otherwise the transfer is blocked.

When a channel is configured as secure:

Note: DMA secure channels are not available when TrustZone is deactivated.

When a channel is configured as nonsecure, in linked-list mode, the loading of the next linked-list data structure from memory is performed with nonsecure transfers.

See Section 18: Low-power direct memory access controller (LPDMA) and Section 17: General purpose direct memory access controller (GPDMA) for more details.

Power control (PWR)

When the TrustZone security is activated (TZEN = 1), the selected PWR registers can be secured through PWR_SECCFGR, protecting the following PWR features:

Other PWR configuration bits become secure:

See Section 10: Power control (PWR) for details.

Secure clock and reset (RCC)

When the TrustZone security is activated (TZEN = 1) and security is enabled in the RCC, the bits controlling the peripheral clocks and resets become TrustZone-aware:

Note: Refer to Section 3.5.4 for the list of securable and TrustZone-aware peripherals.

The SHSI configuration and status bits are secured when the SAES is configured as secure.

Additionally, the following configurations can be made secure-only using RCC_SECCFGR:

See Section 11: Reset and clock control (RCC) for details.

Real time clock (RTC)

Like all TrustZone-aware peripherals, a nonsecure read/write access to a secured RTC register is RAZ/WI. It also generates an illegal access event that triggers a secure illegal access interrupt if the RTC illegal access event is enabled in the TZIC.

After a backup domain power-on reset, all RTC registers can be read or written in both secure and nonsecure modes. The secure boot code can then change this security setup, making registers alarm A, alarm B, wake-up timer, and timestamp secure or not, using RTC_SECCFGR.

When the SEC bit is set in secure-only RTC_SECCFGR:

When the SEC is cleared in secure-only RTC_SECCFGR, it is still possible to restrict access in secure mode to some RTC registers by setting dedicated control bits: INITSEC, CALSEC, TSSEC, WUTSEC, ALRASEC, and ALRBSEC.

Note: The RTC security configuration is not affected by a system reset.

See Section 63: Real-time clock (RTC) for more details.

Tamper and backup registers (TAMP)

Like all TrustZone-aware peripherals, a nonsecure read/write access to a secured TAMP register is RAZ/WI. It also generates an illegal access event that triggers a secure illegal access interrupt if the TAMP illegal access event is enabled in the TZIC.

After a backup domain power-on reset, all TAMP registers can be read or written in both secure and nonsecure modes. The secure boot code can change this security setup, making some registers secure or not as needed, using the TAMP_SECCFGR register.

When TAMPSEC is set in TAMP_SECCFGR:

The application can also:

Note: The TAMP security configuration is not affected by a system reset.

See Section 64: Tamper and backup registers (TAMP) for more details.

General-purpose I/Os (GPIO)

When the TrustZone security is activated (TZEN = 1), each I/O pin of the GPIO port can be individually configured as secure through the GPIOx_SECCFGR registers. Only a secure application can write to GPIOx_SECCFGR registers. After boot, each I/O pin of GPIO is set as secure.

When an I/O pin is configured as secure, its corresponding configuration bits for alternate function (AF), mode selection (MODE), and I/O data are RAZ/WI in case of nonsecure access.

When the digital alternate function is used (input/output mode), in order to protect the data transiting from/to the I/O managed by a secure peripheral, the devices add a secure alternate function gate on the path between the peripheral and its allocated I/Os:

The TrustZone-aware logic around GPIO ports, used as the alternate function, is summarized in the table below.

Table 12. Secure alternate function between peripherals and allocated I/Os

Security configurationAlternate function logicComment
PeripheralAllocated I/O pinInputOutput
SecureSecureI/O dataPeripheral data-
NonsecureOut of reset configuration
SecureNonsecureZeroZero-
NonsecureI/O dataPeripheral data

When an analog function with an analog switch is used, the connection to the peripherals listed in the table below, is blocked by hardware when the peripheral is nonsecure and the I/O is secure.

Table 13. Nonsecure peripheral functions that are not connected to secure I/Os

PeripheralAnalog function (1)InputOutputHow to set a peripheral or function as secure
ADC12ADC12_INy (y = 1 to 17)X-Set ADC12SEC in GTZC1_TZSC_SECCFGR3
ADC4ADC4_INy (y = 1 to 19)Set ADC4SEC in GTZC2_TZSC_SECCFGR1
OPAMPx (x = 1, 2)OPAMPx_VINy (x = 1, 2; y = 1, 2)Set OPAMPSEC in GTZC2_TZSC_SECCFGR1
COMPx (x = 1, 2)COMPx_INy (x = 1; y = 1 to 3)
COMPx_INy (x = 2; y = 1, 2)
Set COMPSEC in GTZC2_TZSC_SECCFGR1

1. Used to find the I/O corresponding to the signal/function on the package (refer to the product datasheet).

Finally, regarding GPIO and security, the table below summarizes the list of peripheral functions that do not have any hardware protection linked to TrustZone. The listed signals (input and/or outputs) are not blocked when the I/O is set as secure, and the associated peripheral function is nonsecure.

For example, when a secure application sets PA4 as secure to be used as LPTIM2_OUT, if the DAC is nonsecure, it can be programmed to output data to PA4, potentially causing malfunction to the secure application.

Similarly, when a secure application sets PA0 as secure to be used as UART4_TX, if TAMP is nonsecure, it can be programmed to capture the USART input traffic through the TAMP_IN function.

It is important that, for each case described in the table below, the secure application decides if a potential effect on data integrity or confidentiality is critical or not. For example, if the USART situation described above is not acceptable (data transiting on secure USART is confidential), then the secure application must configure the TAMP as secure even if it is not used by the secure application.

Note: How to make a peripheral secure is summarized in the right column of the table below.

Table 14. Nonsecure peripheral functions that can be connected to secure I/Os

PeripheralSignal (1)InputOutputHow to set the peripheral or function as secure
DACDAC1_OUTx (x = 1, 2)-XSet DAC1SEC in GTZC2_TZSC_SECCFGR1.
OTG_FS
OTG_HS
OTG_FS_VBUS
OTG_HS_VBUS
XXSet OTGSEC in GTZC1_TZSC_SECCFGR3.
UCPDUCPD1_CCx (x = 1, 2)XXSet UCPD1SEC in GTZC1_TZSC_SECCFGR1.
UCPD1_DBx (x = 1, 2)X-
TAMPTAMP_INx (x = 1 to 8)X-Set TAMPSEC in TAMP_SECCFGR
TAMP_OUTx (x = 1 to 8)-X
RTCRTC_OUTx (x = 1, 2)-XSet SEC in RTC_SECCFGR.
RTC_TSX-Set TSSEC in RTC_SECCFGR.
PWRWKUPx (x = 1 to 8)X-Set WUPxSEC in PWR_SECCFGR.
RCCLSCO-XSet LSESEC in RCC_SECCFGR.
EXTIEXTIx (x= 0 to 22)X-Set SECx bit in EXTI_SECCFGR.

1. To find the I/O corresponding to the signal/function on the package, refer to the product datasheet.

Refer to Section 13: General-purpose I/Os (GPIO) for more details.

Extended interrupts and event controller (EXTI)

When the TrustZone security is activated (TZEN = 1), the EXTI is able to protect event register bits from being modified by nonsecure accesses. The protection can individually be activated per input event via the register bits in EXTI_SECCFGR1. When an input event is configured as secure, only a secure application can change the configuration (including security if applicable), change the masking or clear the status of this input event.

The security configuration in EXTI_SECCFGR1 can be globally locked after reset in EXTI_LOCKR.

See Section 23: Extended interrupts and event controller (EXTI) for more details.

System configuration controller (SYSCFG)

Like all TrustZone-aware peripherals, when the TrustZone security is activated (TZEN = 1), a nonsecure read/write access to a secured SYSCFG register is RAZ/WI. Such access also generates an illegal access event that triggers a secure illegal access interrupt if the SYSCFG illegal access event is not masked in the TZIC.

See Section 15: System configuration controller (SYSCFG) for more details.

Microcontroller debug unit (DBGMCU)

The MCU debug component (DBGMCU) helps the debugger, providing support for:

The DBGCMU is a TrustZone-aware peripheral, managing accesses to its control registers as described in the table below.

Table 15. TrustZone-aware DBGMCU access management

Debug profilePeripheral status (1)DBG_xx_STOP control bits
Write accessRead access
Nonsecure invasive (SPIDEN = 0)NSYes (S (2) or NS)Yes (S or NS)
SNone (S or NS)
Secure invasive (SPIDEN = 1)NSYes (S or NS)
SYes (S only)
  1. 1. As reported by the GTZC, the TrustZone-aware peripheral or the DMA channel.
  2. 2. Secure access from the debugger is converted to nonsecure access in the device.

Refer to Section 75.12: Microcontroller debug unit (DBGMCU) for more details.

3.5.6 Activating TrustZone security

The TrustZone is deactivated by default in all STM32U5 series devices. It can be activated by setting the TZEN user option bit in FLASH_OPTR when in RDP level 0. Once TZEN has changed from 0 to 1, the default security state, after reset, is always the following:

Note: Refer to Section 3.5.4 for the list of securable and TrustZone-aware peripherals.

3.5.7 Deactivating TrustZone security

Once TrustZone is activated, it can only be deactivated during an RDP regression to level 0.

Note: Such RDP regression triggers the erase of embedded memories (SRAM2, flash memory), and the reset of all peripherals, including OTFDEC and all cryptographic engines.

After the TrustZone deactivation, most of the features mentioned in Section 3.5 are no longer available:

Note: When the TrustZone is deactivated, the resource isolation using privilege stays available (see Section 3.6.3 for details).

For more information, refer to the application note Arm TrustZone features for STM32L5 and STM32U5 Series (AN5347) .

3.6 Other resource isolations

These are hardware mechanisms offering an additional level of isolation on top of the TrustZone technology.

3.6.1 Temporal isolation using secure hide protection (HDP)

When the TrustZone security is enabled (TZEN = 1), the embedded flash memory allows an HDP area per watermarked-secure area of each bank (8-Kbyte page granularity) to be defined. The code executed in this HDP area, with its related data and keys, can be hidden after boot until the next system reset.

The hide protection principle is pictured on the figure below.

Figure 12. Flash memory secure HDP area

Diagram illustrating the flash memory secure HDP area. It shows two columns of memory blocks. The left column has 'User applications', 'Secure Flash memory applications', and 'Secure boot code and data (HDP)'. The right column has 'User applications', 'Secure Flash memory applications', and 'Hidden'. A vertical double-headed arrow on the left is labeled 'Secure area'. An arrow labeled '1) Execute after reset' points to the HDP block. An arrow labeled '2) Jump to secure code and hide area' points to the 'Hidden' block, which has a red 'no' symbol over it.

The diagram shows two columns of memory blocks. The left column contains three blocks: 'User applications' at the top, 'Secure Flash memory applications' in the middle, and 'Secure boot code and data (HDP)' at the bottom. A vertical double-headed arrow on the left side of these three blocks is labeled 'Secure area'. The right column contains three blocks: 'User applications' at the top, 'Secure Flash memory applications' in the middle, and 'Hidden' at the bottom. The 'Hidden' block has a red circle with a diagonal line (a 'no' symbol) over it. An arrow labeled '1) Execute after reset' points to the 'Secure boot code and data (HDP)' block. Another arrow labeled '2) Jump to secure code and hide area' points to the 'Hidden' block. The text 'MSV64452V2' is in the bottom right corner.

Diagram illustrating the flash memory secure HDP area. It shows two columns of memory blocks. The left column has 'User applications', 'Secure Flash memory applications', and 'Secure boot code and data (HDP)'. The right column has 'User applications', 'Secure Flash memory applications', and 'Hidden'. A vertical double-headed arrow on the left is labeled 'Secure area'. An arrow labeled '1) Execute after reset' points to the HDP block. An arrow labeled '2) Jump to secure code and hide area' points to the 'Hidden' block, which has a red 'no' symbol over it.

When the HDPxEN and HDPx_ACCDIS bits (x = 1, 2) are set, data read, write, and instruction fetch on the area defined by SECWMx_PSTRT and HDPx_PEND option bytes, are denied until the next device reset.

Note: Bank erase aborts when it contains a write-protected area (WRP or HDP area).
The HDP area can be resized by a secure application if the area is not hidden, and if RDP level \( \neq \) 2.

3.6.2 RSSLIB functions

The RSS provides runtime services thanks to RSS library. As other microcontroller peripherals features and mapping, the RSS library functions are exposed to user within the CMSIS device header file provided by the STM32Cube firmware package. Please refer to UM2656 to get more details regarding STM32Cube firmware package. RSS library functions are named RSSLIB functions hereafter.

The user firmware calls RSSLIB functions using RSSLIB_PFUNC C defined macro, that points to a location within nonsecure system memory. Hence prior calling RSSLIB functions, the secure user firmware must define a nonsecure region above this location within SAU of the Cortex®-M33. This nonsecure region starts from RSSLIB_SYS_FLASH_NS_PFUNC_START up to RSSLIB_SYS_FLASH_NS_PFUNC_END. These last addresses are provided within the CMSIS device header file. The user can set this nonsecure region either by using the CMSIS system partition header file or by implementing its own code for SAU setup. The CMSIS system partition header file is part of the STM32Cube firmware package.

RSSLIB functions are split between nonsecure callable and secure callable function.

The RSS library functions are described within sections hereafter.

CloseExitHDP

Bootloader ID:

CloseExitHDP1 function

Secure attribute:

Secure callable function.

Prototype:

uint32_t CloseExitHDP(uint32_t HdpArea, uint32_t
VectorTableAddr)

Arguments:

Description:

The user calls CloseExitHDP to close flash HDP secure memory area and jump to the reset handler embedded within the vector table which address is passed as input parameter.

CloseExitHDP sets the SP provided by the passed vector table, however it is up to the caller to first set the new vector table. Then it clears all general-purpose Cortex®-M33 registers (r0, r1, ...) before jumping to new vector table reset handler.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), this function returns RSSLIB_ERROR.

Please refer to section Chapter 7.5.3: Secure hide protection (HDP) to get more details on flash memory HDP protection.

3.6.3 Resource isolation using Cortex privileged mode

In parallel to the TrustZone isolation described in Section 3.5 , the hardware and software resources of STM32U5 series devices can be partitioned so that they are restricted to software running in Cortex privileged mode.

Thanks to this hardware isolation technology, available even if TrustZone is deactivated (TZEN = 0), critical code or data can be protected against intentional or unintentional tampering from the more exposed unprivileged code.

Memory and peripheral privileged allocation using MPU

The Cortex-M33 MPU divides the unified memory into eight regions, each aligned to a multiple of 32 bytes. Each memory regions can be programmed to generate faults when accessed inappropriately by unprivileged software.

Memory and peripheral privileged allocation using GTZC

For the Cortex-M33 master, to complement the coarse isolation provided by the MPU, the GTZC reinforces, in a flexible way, the isolation between privileged and unprivileged tasks, for peripherals and selected memories.

For masters other than the Cortex-M33, the GTZC can assign them as unprivileged initiators, automatically protecting resources defined as privileged against this master.

In the devices, a peripheral is either securable privileged-only through GTZC, or is natively privileged-aware:

When such peripheral is made privileged-only with GTZC, if it is master on the interconnect (SDMMC), it automatically issues privileged transactions. Privileged-aware masters like GPDMA or LPDMA, drive privileged signal in the AHB interconnect according to their internal privileged mode, independently to the GTZC.

The list of securable peripherals can be found in Section 5: Global TrustZone controller (GTZC) .

The TZSC logic in GTZC provides the capability to manage the privilege level for all securable external memories, programming the MPCWM resources defined in Section 3.5.4 .

Similarly, the GTZC provides the capability to configure the privilege level of embedded SRAM blocks, programming the MPCBB resources defined in Section 3.5.4 .

Managing security in privileged-aware peripherals

TrustZone-aware peripherals also implement privileged-only access mode. The privileged protection is valid even if TZEN = 0:

By default all embedded flash registers can be read or programmed in both privileged and unprivileged modes.

When secure privileged bit SPRIV is set in FLASH_PRIVCFGGR, reading and writing the flash secure registers are possible only in privileged mode. Write access to this bit is ignored if TrustZone is deactivated (TZEN = 0).

When nonsecure privileged bit NSPRIV is set in FLASH_PRIVCFGGR, reading and writing the flash nonsecure registers are possible only in privileged mode.

Regarding privileged protection of the embedded flash memory, the devices offer the following features:

Note: Switching a page from privileged to unprivileged does not erase the content of the page.

When applicable, an erase or program operation is always available to privileged code, and is available to unprivileged code only for unprivileged pages or unprivileged memory.

When privileged bit PRIV is set in OTFDEC_PRIVCFGGR, the OTFDEC can only be initialized by a privileged application.

Note: OTFDEC_PRIVCFGGR can be read by both privileged and unprivileged code.

When a DMA channel x is defined as privileged (PRIVx = 1 in LP/GPDMA_PRIVCFGGR), special rules apply when accessing privileged/unprivileged source or destination. Those rules are summarized on the table below.

Table 16. DMA channel use (privilege)

DestinationPrivileged DMA channel x (PRIVx = 1)Unprivileged DMA channel y (PRIVy = 0)
Privileged sourceUnprivileged sourcePrivileged sourceUnprivileged source
PrivilegedOKTransfer blocked (1)
UnprivilegedTransfer blockedOK

1. When a transfer is blocked, the transfer completes but the corresponding writes are ignored, and reads return zeros.

See Section 18: Low-power direct memory access controller (LPDMA) and Section 17: General purpose direct memory access controller (GPDMA) for more details.

By default, after a power-on or a system reset, all PWR registers but PWR_PRIVCFGR, can be read or written in both privileged and unprivileged modes.

When secure privileged bit SPRIV is set in PWR_PRIVCFGR, reading and writing the PWR securable registers are possible only in privileged mode. Write access to this bit is ignored if TrustZone is disabled (TZEN = 0).

When nonsecure privileged bit NSPRIV is set in PWR_PRIVCFGR, reading and writing the PWR nonsecure registers are possible only in privileged mode.

See Section 10: Power control (PWR) for details.

By default, after a power-on or a system reset, all RCC registers but RCC_PRIVCFGR can be read or written in both privileged and unprivileged modes.

When the secure privileged bit SPRIV is set in RCC_PRIVCFGR, reading and writing the RCC securable bits are possible only in privileged mode. Write access to this bit is ignored if TrustZone is disabled (TZEN = 0).

When nonsecure privileged bit NSPRIV is set in RCC_PRIVCFGR, reading and writing the RCC nonsecure bits are possible only in privileged mode.

See Section 11: Reset and clock control (RCC) for details.

By default after a backup domain reset, all RTC registers but RTC_PRIVCFGR, can be read or written in both privileged and unprivileged modes.

When PRIV bit is set in privileged-only RTC_PRIVCFGR:

All the other RTC registers can be read only in privileged mode.

When PRIV bit is cleared in privileged-only RTC_PRIVCFGR register, it is still possible to restrict access to privileged mode to some RTC registers by setting dedicated control bits: INITPRIV, CALPRIV, TSPRIV, WUTPRIV, ALRAPRV or ALRBPRIV.

See Section 63: Real-time clock (RTC) chapter for details.

By default after any backup domain reset, all TAMP registers but TAMP_PRIVCFGR can be read or written in both privileged and unprivileged modes.

When PRIV bit is set in privileged-only TAMP_PRIVCFGR:

The application can also:

3.7 Secure execution

Through a mix of special software and hardware features, the devices ensure the correct operation of their functions against abnormal situations caused by programmer errors, software attacks through network access or local attempt for tampering code execution.

This section describes the hardware features specifically designed for secure execution.

3.7.1 Memory protection unit (MPU)

The Cortex-M33 includes a memory protection unit (MPU) that can restrict the read and write accesses to memory regions (including regions mapped to peripherals), based on one or more of the following parameters:

The memory map and the programming of the nonsecure and secure MPUs split memory into regions (up to eight per MPU). Secure MPU is only available when TrustZone is activated.

3.7.2 Embedded flash memory write protection

The embedded flash memory write protection (WRP) prevents illegal or unwanted write/erase to special sections of the embedded flash memory user area (system area is permanently write protected).

Write protected area is defined through the option bytes, writing the start and end addresses: two write-protected areas can be defined in each bank, with the granularity of an 8-Kbyte page.

WRP areas can be modified through option byte changes unless the corresponding FLASH_WRPxA/BR has its UNLOCK option bit cleared (meaning ROM emulation). UNLOCK can be set only when regressing from RDP level 1 to level 0.

Note: Bank erase aborts when it contains a write-protected area (WRP or HDP area).

3.7.3 Tamper detection and response

Principle

The devices include active protection of critical security assets against temperature, voltage and frequency attacks, with the following features:

See Section 64: Tamper and backup registers (TAMP) for more details.

Tamper detection sources

The devices support eight active input/output pins, allowing four independent active-tamper meshes, or up to seven meshes if the same output pin is shared by several input pins (for a total of eight active-tamper I/Os). The active-tamper balls are mapped in the center of packages that can be used in POS market (such as WLCSP90).

The active pins are clocked by the LSE, and are functional in all system operating modes (Run, Sleep, Stop, Standby or Shutdown), and in \( V_{BAT} \) mode.

Detection time is programmable, and a digital filtering is available (tamper triggered after two false comparison in four consecutive comparison samples).

Note: Timestamps are automatically generated when a tamper event occurs.

The internal tamper sources are listed in the table below.

Table 17. Internal tamper sources in TAMP

Tamper inputNOER bit number in TAMP_CR3Tamper source
itamp10Backup domain voltage continuous monitoring, functional in V BAT mode
itamp21Temperature monitoring, functional in V BAT mode
itamp32LSE monitoring, functional in V BAT mode
itamp4, 10-Not used
itamp54RTC calendar overflow (rtc_calovf)
itamp65JTAG/SWD access when RDP > 0
itamp7, 12, 136, 11, 12Voltage monitoring (V CORE , V REF+ ), through ADC analog watchdog, functional down to Stop 2 mode
itamp87Monotonic counter overflow (generated internally)
itamp98Fault generation for cryptographic peripherals (SAES, PKA, AES, RNG)
itamp1110IWDG timeout and potential tamper (IWDG reset when at least one enabled tamper flag is set)

Response to tamper

Each source of tamper in the device can be configured to trigger the following events:

Read/write accesses by software to all these secrets can be blocked, by setting the BKBLOCK bit in TAMP_CR2. The device secrets access is possible only when BKBLOCK is cleared, and no tamper flag is set for any enabled tamper source.

Note: Device secret erase is also triggered by setting BKERASE in TAMP_CR2, or by performing an RDP regression as defined in Section 3.10.1 .

Device secrets are not reset by system reset or when the device wakes up from Standby mode.

Software filtering mechanism

Each tamper source can be configured not to launch an immediate erase, by setting the corresponding TAMPxNOER bit in TAMP_CR2 (for external tamper pin) or TAMP_CR3 (for internal tamper).

In such situation, when the tamper flag is raised, the access to below secrets is blocked until all tamper flags are cleared:

Once the application, notified by the tamper event, analyzes the situation, there are two possible cases:

Note: If the tamper software fails to react to such a tamper flag, an IWDG reset triggers automatically the erase of secrets.

Tamper detection and low-power modes

The effect of low-power modes on a tamper detection are summarized on the table below.

Table 18. Effect of low-power modes on TAMP

ModeDescription
SleepNo effect on tamper detection features
TAMP interrupts cause the device to exit Sleep mode.
StopNo effect on tamper detection features, except for level detection with filtering and active tamper modes that remain active only when the clock source is LSE or LSI
Tamper events cause the device to exit Stop mode.
StandbyNo effect on tamper detection features, except for level detection with filtering and active tamper modes, which remain active only when the clock source is LSE or LSI
Tamper events cause the device to exit Standby mode.
ShutdownNo effect on tamper detection features, except for level detection with filtering and active tamper modes, which remain active only when the clock source is LSE
Tamper events cause the device to exit Shutdown mode.

3.8 Secure storage

A critical feature of any security system is how long-term keys are stored, protected, and provisioned. Such keys are typically used for loading a boot image, or handling of critical user data.

Figure 13 shows how the key management service application can use the AES engine, for example, to compute external image decryption keys. A nonvolatile key can be stored in the embedded secure HDP area (see Section 3.6.1 ), while volatile key storage consists in the battery-powered, tamper-protected SRAM or registers in TrustZone-aware TAMP.

Figure 13 also shows keys that are manipulated by software (like OTFDEC keys), or keys that are managed only by hardware (like DHUK). More information on those hardware keys can be found in Section 3.8.1 .

Figure 13. Key management principle

Figure 13. Key management principle diagram showing the flow of keys between various components.

The diagram illustrates the key management principle. It shows the flow of keys between several components:

Figure 13. Key management principle diagram showing the flow of keys between various components.

Tamper protection is detailed in Section 3.7.3 , while TAMP TrustZone features are briefly described in Section 3.5.5 .

3.8.1 Hardware secret key management

As shown in the previous figure, the devices propose a better protection for application keys, using hardware secret keys. These AES keys can be made usable to the application, without exposing them in clear-text (unencrypted). Such keys also become immediately unusable in case of tamper.

There are three different sources of hardware secret keys:

Note: DHUK is the same for all devices when RDP = 0 (debug/development mode).

These keys can be used:

3.8.2 Unique ID

The devices store a 96-bit ID that is unique to each device (see Section 76.1: Unique device ID register (96 bits) ).

Application services can use this unique identity key to identify the product in the cloud network, or make it difficult for counterfeit devices or clones to inject untrusted data into the network.

Alternatively, the 256-bit device unique key (DHUK) can be used (see Section 3.8.1 ).

3.9 Cryptographic engines

The devices implement state-of-the-art cryptographic algorithms featuring key sizes and computing protection as recommended by national security agencies such as NIST for the U.S.A, BSI for Germany or ANSSI for France. Those algorithms are used to support privacy, authentication, integrity, entropy and identity attestation.

The cryptographic engines embedded in STM32 reduce the weaknesses on the implementation of critical cryptographic functions, preventing, for example, the use of weak cryptographic algorithms and key sizes. They also enable lower processing times and lower power consumption when performing cryptographic operations, offloading those computations from Cortex-M33. This is especially true for asymmetric cryptography.

For product certification purpose, ST can provide certified device information on how these security functions are implemented and validated.

For more information on cryptographic engine processing times, refer to their respective sections in the reference manual.

3.9.1 Cryptographic engines features

Table 19 lists the accelerated cryptographic operations available in the devices. Two AES accelerators are available (both can be reserved to secure application only).

Note: Additional operations can be added using the firmware.

The PKA can accelerate asymmetric cryptographic operations (like key pair generation, ECC scalar multiplication, point on curve check). See Section 53: Public key accelerator (PKA) for more details.

Table 19. Accelerated-cryptographic operations
OperationsAlgorithmSpecificationKey lengths (in bit)Modes
Get entropyRNGNIST SP800-90B (1)N/ASoftware and hardware (2) modes running in parallel
Encryption, decryptionAESFIPS PUB 197
NIST SP800-38A
128, 256ECB, CBC, CTR (3)
Authenticated encryption or decryptionNIST SP800-38C
NIST SP800-38D
128, 256GCM, CCM
Cipher-based message authentication codeNIST SP800-38D128, 256GMAC
ChecksumMD5IETF RFC 1321N/ADigest 128-bit
SHA-1FIPS PUB 180-4Digest 160-bit
Cryptographic hashSHA-2SHA-224, SHA-256
Keyed-hashing for message authenticationHMACFIPS PUB 198-1
IETF RFC 2104
Short, long (> 64 bytes)-
Encryption/decryption
key-pair generation (4)
RSAIETF RFC 8017
NIST SP800-56B
Up to 4160RSAES-OAEP
Signature (4) with hashing
Signature verification
RSAIETF RFC 8017
FIPS PUB 186-4
Up to 4160PKCS1-v1_5, PSS
ECDSAANSI X9.62
IETF RFC 7027
FIPS PUB 186-4
Up to 640Refer to the table 'Family of supported curves for ECC operations' in Section 53: Public key accelerator (PKA) for details.
Key agreementECDHANSI X9.42

1. Certifiable using STMicroelectronics reviewed documents.

2. Random numbers distribution to SAES and PKA using a dedicated hardware bus.

3. ECB and CBC chaining modes protected against side-channel and timing attacks in SAES (see Section 3.9.2 ).

4. Private key cryptography protected against side-channel and timing attacks.

Note: Binary curves, Edwards curves, and Curve25519 are not supported by the PKA.

3.9.2 Secure AES co-processor (SAES)

The devices provide an additional on-chip hardware AES encryption and decryption engine, that implements counter-measures and mitigations against power and electromagnetic side-channel attacks.

With a dedicated 48 MHz SHSI clock, SAES is also slower than the AES, in order to provide best-in-class side-channel protections. The SAES engine supports 128-bit or 256-bit key in electronic code book (ECB) or cipher block chaining (CBC) mode.

As shown in Section 3.8 , the SAES can be used for extra-secure on-chip storage for sensitive information. It can also be made secure-only.

For more information, refer to Section 50: Secure AES coprocessor (SAES) .

3.9.3 On-the-fly decryption engine (OTFDEC)

The OTFDEC TrustZone-aware peripheral proposes on-the-fly decryption of encrypted images stored on external flash memory, connected through the OCTOSPI. This decryption process introduces almost no additional cycle overhead when the standard NOR flash memory is used. The OTFDEC can also be used to encrypt flash memory images on the device (for example to encrypt with a device unique secret key).

When a tamper event is confirmed in TAMP, all OTFDEC keys are erased and encrypted regions are read as zero until the OTFDEC is properly initialized again.

An OTFDEC typical use is detailed in Section 3.12.2 . For more details on the peripheral programming, refer to Section 52: On-the-fly decryption engine (OTFDEC) .

3.10 Product life-cycle

A typical IoT device life-cycle is summarized in the figure below. For each step, the devices propose secure life-cycle management mechanisms embedded in the hardware.

Figure 14. Device life-cycle security

Figure 14. Device life-cycle security diagram showing the flow from Virgin device to Decommissioned product, split into User states and Vendor states.

The diagram illustrates the device life-cycle security flow, divided into two main columns by a vertical dashed line: User states (left) and Vendor states (right).

MSV64454V1

Figure 14. Device life-cycle security diagram showing the flow from Virgin device to Decommissioned product, split into User states and Vendor states.

More details on the various phases and associated transitions, found either at the vendor or end-user premises, are summarized in the table below.

Table 20. Main product life-cycle transitions

TransitionsDescription
Device manufacturingSTMicroelectronics creates new STM32 devices, always checking for manufacturing defects. During this process STM32 is provisioned with ROM firmware, secure firmware install (SFI) unique key pair, and a public ID.
Vendor manufacturingOne (or more) vendor is responsible for the platform assembly, initialization, and provisioning before delivery to the end user. This end user can use the final product (“production” transition) or he/she can use the platform for software development (“user provisioning” transition).
ProductionThe end-user gets a product ready for use. All security functions of the platform are enabled, the debugging/testing features are restricted/disabled, and unique boot entry to immutable code is enforced.
User provisioningPlatform vendor prepares an individual platform for development, not to be connected to a production cloud network.
Field return or decommissioningThese are one-way transitions, with devices kept in user premises or returned to the manufacturer. In both cases, all data including user data is destroyed, therefore the devices lose the ability to operate securely (like connecting to a managed IoT network).

The features described hereafter contribute to secure the device life-cycle.

3.10.1 Life-cycle management with readout protection (RDP)

The readout protection mechanism (full hardware feature) controls the access to the devices debug, test and provisioned secrets, as summarized in the table below.

Table 21. Typical product life-cycle phases

RDP protection levelDebugComments
Level 0Device openSecure (1) and nonsecureBoot address must target a secure area when TrustZone is enabled (secure SRAM, secure flash memory, RSS in system flash memory). Both OEM1 and OEM2 unlocking keys can be provisioned in the flash memory user options. The DHUK in the SAES peripheral is the same for all devices.
Level 0.5 (2)Device partially closed (closed-secure)Nonsecure onlyBoot address must target a secure area when TrustZone is enabled (secure user or system flash memory). Boot on SRAM is not permitted. Access to nonsecure flash memory is allowed when debug is connected. Both OEM1 and OEM2 unlocking keys can be provisioned in the flash memory user options. The DHUK is different for every device.
Level 1Device memories protectedNonsecure only (conditioned)Boot address must target the secure user flash memory. Accesses to nonsecure flash memory, encrypted flash memory (3) , SRAM2, and backup registers are not allowed when debug is connected. Both OEM1 and OEM2 unlocking keys can be provisioned in the flash memory user options. The DHUK is different for every device.
Level 2Device closedNone (JTAG fuse)Boot address must target the user flash memory (secure if TZEN = 1). Option bytes are read-only, hence RDP level 2 cannot be changed, unless the OEM2 unlocking key is activated (see Table 22 ). The DHUK is different for every device.
  1. 1. Debug is not available when executing RSS code.
  2. 2. Only applicable when TrustZone security is activated in the product.
  3. 3. External flash memory area decrypted on-the-fly with the OTFDEC.

Note: OEM1KEY option byte can be modified when OEM1LOCK = 0 (RDP = 0.5 or 1 only).
OEM2KEY option byte can be modified when OEM2LOCK = 0 (RDP = 1 only).

The supported transitions, summarized in the figure below, can be requested (when available) through the debug interface or via the system bootloader.

Figure 15. RDP level transition scheme

Figure 15. RDP level transition scheme. The diagram is split into two columns: 'TrustZone disabled' and 'TrustZone enabled'. In the 'TrustZone disabled' column, there are three nodes: 'RDP Level 0', 'RDP Level 1', and 'RDP Level 2'. Arrows show transitions from Level 0 to Level 1 (conditioned on OEM key1, full flash erase), from Level 1 to Level 2 (conditioned on OEM key2), and from Level 2 back to Level 0. In the 'TrustZone enabled' column, there are four nodes: 'RDP Level 0', 'RDP Level 0.5', 'RDP Level 1', and 'RDP Level 2'. Transitions include Level 0 to Level 0.5 (OEM key1, full flash erase), Level 0.5 to Level 1 (OEM key2, partial flash erase nonsecure only), Level 1 to Level 2 (OEM key2), and Level 2 back to Level 0. Lock icons indicate protected transitions.
Figure 15. RDP level transition scheme. The diagram is split into two columns: 'TrustZone disabled' and 'TrustZone enabled'. In the 'TrustZone disabled' column, there are three nodes: 'RDP Level 0', 'RDP Level 1', and 'RDP Level 2'. Arrows show transitions from Level 0 to Level 1 (conditioned on OEM key1, full flash erase), from Level 1 to Level 2 (conditioned on OEM key2), and from Level 2 back to Level 0. In the 'TrustZone enabled' column, there are four nodes: 'RDP Level 0', 'RDP Level 0.5', 'RDP Level 1', and 'RDP Level 2'. Transitions include Level 0 to Level 0.5 (OEM key1, full flash erase), Level 0.5 to Level 1 (OEM key2, partial flash erase nonsecure only), Level 1 to Level 2 (OEM key2), and Level 2 back to Level 0. Lock icons indicate protected transitions.

As shown in the previous figure, the user flash memory is automatically erased, either partially or in totality, during an RDP regression from RDP1. Those regressions can be conditioned to dedicated 64-bit password keys, if provisioned by the OEM (see next subsection). During the regression from RDP level 1 to RDP level 0.5, only nonsecure embedded flash memory is erased, keeping functional, for example, the secure boot and the secure firmware update. In all regressions from level 1, the OTP area in the flash memory is kept, all SRAMS and targeted device secrets are erased. Hence, no secrets must be stored in the OTP as they are revealed after a regression to RDP level 0. These secrets, also erased as response to tamper, are defined in Section 3.7.3 .

Note: Enabling TrustZone using the option byte TZEN is only possible when RDP level is 0.

For more details on RDP, refer to Section 7: Embedded flash memory (FLASH) .

RDP unlocking sequences

The use of the two OEM password keys described in the last figure is further described hereafter.

Note: The devices support both permanent RDP level 2 (legacy mode) or password-based RDP level 2 regression to level 1. This level 2 regression does not erase the application code, and it does not change the RDP level 1 protections in place.

Details on the password-based regression can be found in the table below.

Table 22. OEM1/2 RDP unlocking methods

OEM1 password optionsOEM2 password options
OEM1 LOCKInitial RDP levelRDP regressionOEM2 LOCKInitial RDP levelRDP regression
11Regression to level 0 possible only through OEM1 unlock sequence (see below)11Regression to level 0.5 possible only through OEM2.1 unlock sequence (see below)
2Automatic regression to level 1 triggered upon successful OEM2.2 unlock sequence (see below)
01Regression to level 0 always granted01Regression to level 0.5 always granted
2Regression to level 1 never granted
RDP remains a permanent state.

Note: Unlocking the device with a password is possible only once per power cycle. Shifting the password key through JTAG/SWD corresponds to writing two 32-bit key words, AUTH_KEY[31:0], then AUTH_KEY[63:32], in the DBGMCU_DBG_AUTH_HOST register.

JTAG 32-bit device specific ID

Unless the JTAG port is deactivated (OEM2LOCK = 0 and RDP level = 2), a 32-bit device specific quantity can always be read through the JTAG port. This information is stored in DBGMCU_DBG_AUTH_DEVICE.

The OEM can use this 32-bit information to derive the expected OEM password keys to unlock this specific device.

Most of the time, the user threat model focuses mainly on software attacks. In this case, it may be sufficient to keep the RDP level 1 as device protection.

For a more aggressive threat model, where the user fears physical attacks on the STM32 device, it is recommended to optimize the level of security by setting the RDP level 2.

The recommended settings are detailed below:

As described in the previous section, the customer can decide to allow any RDP level 2 part to regress to RDP level 1, provided the OEM Key2 has been successfully provisioned, and the OEM2LOCK option bit is set.

3.11 Access controlled debug

The device restricts access to embedded debug features, in order to guarantee the confidentiality of customer assets against unauthorized usage of debug and trace features.

3.11.1 Debug protection with readout protection (RDP)

As described in Section 3.10.1 , the hardware RDP mechanism automatically controls the accesses to the device debug and test. The protection of these debug features is defined in the table below. Possible password-based regressions are described in Section 3.10.1 .

Table 23. Debug protection with RDP

RDP protection levelDebug features protection
Level 0Device openAny debug (1)
Level 0.5 (2)Device partially closedSecure debug is no longer available.
Level 1Device memories protectedNonsecure debug can no longer debug code and data stored in the embedded flash memory, the encrypted external flash memory (3) , SRAM2, and backup registers.
Level 2Device closedJTAG is physically deactivated, unless it is kept operational only for password key injection (OEM2LOCK = 1). See Section 3.10.1 for details.
  1. 1. Including ST engineering test modes, used for field returns.
  2. 2. Only applicable when TrustZone security is activated in the product.
  3. 3. External flash memory area decrypted on-the-fly with the OTFDEC.

3.12 Software intellectual property protection and collaborative development

Thanks to the software intellectual property protection and collaborative model, the devices allow the design of solutions integrating innovative third-party libraries.

Collaborative development is summarized on the figure below. Starting from a personalized device sold by STMicroelectronics, a vendor A can integrate a portion of hardware and software on a platform A, that can then be used by a vendor B, who does the same before deploying a final product to the end users.

Note: Each platform vendor can provision individual platforms for development not to be connected to a production cloud network (“Development Platform X”).

Figure 16. Collaborative development principle

Diagram illustrating the collaborative development principle. The process starts with an STM32 personalized device, which undergoes Vendor A manufacturing to become Platform A. Platform A is then integrated with a Platform part. Platform A is then used by Vendor B manufacturing to become Platform B, which is also integrated with a Platform part. Platform B is then used for User provisioning to become a Deployed product. The Deployed product is then decommissioned to become a Decommissioned product. The diagram is divided into two columns by a dashed line: 'User states' on the left and 'Vendor states' on the right. The flow is: STM32 personalized device -> Vendor A manufacturing -> Platform A -> Vendor B manufacturing -> Platform B -> User provisioning -> Deployed product -> Decommissioning -> Decommissioned product. Platform A and Platform B are also connected to Platform part via 'Integrated' arrows. Development platform B is connected to User provisioning arrows.
graph TD; subgraph Vendor_states; A[STM32 personalized device] -- "Vendor A manufacturing" --> PA[Platform A]; PA -- "Vendor B manufacturing" --> PB[Platform B]; PA -- "Integrated" --> PP1[Platform part]; PB -- "Integrated" --> PP2[Platform part]; end; subgraph User_states; PA -- "User provisioning" --> DPB1[Development platform B]; PB -- "User provisioning" --> DPB2[Development platform B]; PB -- "Productization" --> DP[Deployed product]; DP -- "Decommissioning" --> DPP[Decommissioned product]; end;
Diagram illustrating the collaborative development principle. The process starts with an STM32 personalized device, which undergoes Vendor A manufacturing to become Platform A. Platform A is then integrated with a Platform part. Platform A is then used by Vendor B manufacturing to become Platform B, which is also integrated with a Platform part. Platform B is then used for User provisioning to become a Deployed product. The Deployed product is then decommissioned to become a Decommissioned product. The diagram is divided into two columns by a dashed line: 'User states' on the left and 'Vendor states' on the right. The flow is: STM32 personalized device -> Vendor A manufacturing -> Platform A -> Vendor B manufacturing -> Platform B -> User provisioning -> Deployed product -> Decommissioning -> Decommissioned product. Platform A and Platform B are also connected to Platform part via 'Integrated' arrows. Development platform B is connected to User provisioning arrows.

The features described hereafter contribute to securing the software intellectual property within such a collaborative development.

3.12.1 Software intellectual property protection with RDP

As described in Section 3.10.1 , the hardware RDP mechanism automatically controls the accesses to secrets provisioned in the device.

The protection of these secrets are defined in the table below.

Table 24. Software intellectual property protection with RDP

RDP protection levelSecrets protection
Level 0Device openNo special protections.
Level 0.5 (1)Device partially closedAll peripherals and memories mapped as secure during secure boot cannot be dumped, debugged, or traced
Level 1Device memories protectedData and code stored in embedded flash memory, encrypted external flash memory (2) , SRAM2, and backup registers are no more accessible through the debugger.
Level 2Device closedAll data and code stored in the device or encrypted in external flash memory cannot be dumped clear-text, debugged or traced.

1. Only applicable when TrustZone security is activated in the product.

2. External flash memory area decrypted on-the-fly with OTFDEC peripheral.

3.12.2 Software intellectual property protection with OTFDEC

As described in Section 3.9.3 , the OTFDEC associated with the OCTOSPI is able to decrypt on the fly, the encrypted images stored in external SPI flash memories.

Thanks to this feature, the devices allow the installation of intellectual properties, in one of the following ways:

Figure 17 illustrates this last case, with the provisioning, in a non-trusted environment, of software intellectual properties both in the embedded flash memory and in an external SPI flash memory (encrypted).

Note: Since the OTFDEC uses the AES in counter mode (CTR) to achieve the lowest possible latency, each time the content of one encrypted region is changed, the corresponding cryptographic context (key or initialization vector) must be changed. This constraint makes OTFDEC suitable to decrypt read-only data or code, stored in external NOR flash memory.

Figure 17. External flash memory protection using SFI

Figure 17. External flash memory protection using SFI. The diagram is divided into two sections: Provisioning and Secure boot. The Provisioning section shows a Host (1) connected to an STM32 microcontroller. The STM32 contains a ROM Secure bootloader part I (2), SRAM2 Secure bootloader part II (3), Flash, Option bytes, OTF DEC (4, 5), and SRAM 1. The STM32 is connected to an external Flash memory via an Octo-SPI interface (6). The Secure boot section shows the STM32 containing an Application and a Secure boot section within the Flash. The Secure boot section is connected to an OTF DEC (1) which is connected to an external Flash memory via an Octo-SPI interface (2). A tamper signal is shown entering the STM32.

Provisioning

Host (1) ↔ STM32

STM32 internal components: JTAG, USART, SPI, I 2 C, FDCAN, USB, ROM Secure bootloader part I (2), SRAM2 Secure bootloader part II (3), Flash, Option bytes, OTF DEC (4, 5), SRAM 1.

STM32 ↔ Octo-SPI (6) ↔ Flash memory

① ... ⑥ See details in section “Provisioning” below the figure.

Secure boot

STM32 internal components: Flash (Application, Secure boot), OTF DEC (1), Octo-SPI (2), Flash memory.

-tamper→ STM32

① ... ② See details in section “Secure boot” below the figure.

MSV65211V2

Figure 17. External flash memory protection using SFI. The diagram is divided into two sections: Provisioning and Secure boot. The Provisioning section shows a Host (1) connected to an STM32 microcontroller. The STM32 contains a ROM Secure bootloader part I (2), SRAM2 Secure bootloader part II (3), Flash, Option bytes, OTF DEC (4, 5), and SRAM 1. The STM32 is connected to an external Flash memory via an Octo-SPI interface (6). The Secure boot section shows the STM32 containing an Application and a Secure boot section within the Flash. The Secure boot section is connected to an OTF DEC (1) which is connected to an external Flash memory via an Octo-SPI interface (2). A tamper signal is shown entering the STM32.

Provisioning

Assuming the device is virgin, the first step is to provision both flash memories, as detailed below:

  1. 1. The user creates a SFI image, composed of:
    • – encrypted internal firmware and data (including external flash memory drivers)
    • – encrypted external firmware and data AES key (up to 4)
    • – encrypted external firmware and data image
  2. 2. The secure bootloader stored in the system memory, loads the second part of the secure bootloader in SRAM, through the supported communication ports (USART, SPI, I 2 C, FDCAN, USB, and JTAG). This second part runs in the secure SRAM and is responsible for executing the SFI process, applying the SFI protocol thanks to the commands received through the above mentioned supported communication ports.
  1. 3. The internal flash memory is programmed with decrypted option bytes, internal firmware and data, and external firmware and data AES keys. Alternatively, device unique external firmware AES keys can be used instead of such global keys.
  2. 4. The OTFDEC is properly initialized with encrypted region information, including the corresponding external firmware and data AES key.
  3. 5. Running the SFI process, chunks of encrypted external firmware and data image are decrypted in the device, then re-encrypted in the OTFDEC.
  4. 6. After a chunk OTFDEC re-encryption, the user external flash memory programmer is responsible for programming the last encrypted chunks to the external SPI flash memories through the OCTOSPI.

Alternatively, external firmware and data AES keys for OTFDEC can be generated on the device, if they are not generated by the signing tool.

Secure boot

After provisioning, each time the device initializes on a trusted firmware, the following actions are required:

  1. 1. Secure-boot firmware executes, programming the external firmware and data AES keys to the OTFDEC write-only key registers, along with the other needed information.
  2. 2. The application reads or executes the encrypted external firmware and data through the OCTOSPI in memory mapped mode, unless a tamper event is detected. In this case, all OTFDEC keys are erased and encrypted regions are read as zero until the OTFDEC is properly initialized again.

For more information on SFI solutions for the devices, refer to the application note: “STM32 MCUs secure firmware install (SFI) overview ” (AN4992).

3.12.3 Other software intellectual property protections

The device additional protections to software intellectual property are: