AN5156 · Application noteIntroduction to security for STM32 MCUs
Download .pdfOpen in the full document

Arm TF-M solution

Arm TF-M solution

Arm trusted firmware existed for chips based on Cortex-A when the secure Cortex-M33 core was introduced with Armv8-M architecture. A more compact TF-M open-source implementation of PSA standard was provided as a reference secure firmware framework.

For STMicroelectronics MCUs that take advantage of the Armv8 architecture (such as STM32H5, STM32L5, STM32U3, and STM32U5 devices), the SBSFU is enhanced with the TF-M based solution.

For a documentation on TF-M itself, refer to the UM2851, and use Arm resources as well as the code comments.

For guidance on TF-M integration on the STM32L5 and STM32U5 devices, refer to the user manuals Getting started with STM32CubeL5 TF-M application (UM2671) or Getting started with STM32CubeU5 TF-M application (UM2851).

Refer to document AN5156_General-Info.html#concept_vts_yqx_fcb__entry_h2q_brz_qvb for a detailed comparison when migrating from X-CUBE-SBSFU package SBSFU to TF-M.

Table 8. Basic feature differences of TrustZone®-based secure software
FeatureSBSFU for TrustZone®TF-M
RoT servicesImmutable RoTImmutable RoT + updatable RoT
Cryptographic key managementStatic keys onlyKey storage hierarchy with HUK root key
Secure storageAbsentInternal and external
NV counterNo Yes

Both alternatives are based on TF-M and MCU boot, but while SBSFU intends to replicate familiar features of X-CUBE-SBSFU while retaining most flash memory space for user code, TF-M offers more functionality. Some of that can be dropped to gain memory space. For the STM32H57x line, the Secure Manager, a closed-source implementation of TF-M, offers a convenient and express way to adopt certified secure solutions.

Secure manager

The goal of the Secure manager is to guide customers to a certified secure software solution. Secure manager implements the PSA secure APIs (similar to the TF-M) and by using them, the user nonsecure application can form a secure system with certified attack resistance.

The Secure manger application kit is distributed in the form of encrypted binary and is free to use on compatible STM32H5 MCUs.

Secure manager can expand its secure functionality by using modules.

Product certifications

Different secure applications often require certain certifications to prove their capability to perform in a secure manner. Independent or government agencies grant certification status to either an MCU application or a combination of MCUs with secure firmware after testing them against evaluation goals.

The certifications and evaluations related to STM32 microcontrollers include, but are not limited to:

  • PSA Certified (platform security architecture), governed by Arm, focused on IoT security, MCU certification, three levels of assessment
    • STM32L4, STM32G0, and STM32G4 devices are certified up to level 1.
    • STM32L5 devices with TF-M are certified PSA level 2, SESIP level 3.
    • STM32C0, STM32C5, STM32U0, and STM32H7RS are PSA level 3 and SESIP level 3 certified or certifiable and under evaluation in their scope of secure boot features despite not having TrustZone® isolation
    • STM32U5, STM32H7S, STM32U0, STM32U3, and STM32H5 devices with TF-M are certifiable up to level 3.
    • To achieve Arm PSA certifiable security level, refer to the user manual STM32U585 security guidance for PSA Certified level 3 with SESIP profile (UM2852). Details of the particular PSA certificates are available online at https://products.psacertified.org/
  • SESIP (security evaluation standard for IoT platforms), international methodology adopted by several major security evaluation labs, five levels
    • Systems using SBSFU or TF-M are compliant to level 3 with STM32L4, STM32L4+, STM32L5, STM32H5, STM32N6, and STM32U5 devices.
  • PCI (payment card information), an important security standard focusing on point of sale (POS) applications
    • Good record of successful evaluation of systems, using, for example, STM32L4 devices
Note:

FIPS (Federal Information Processing Standards) is a set of standards published by NIST, some of which (FIPS 140, SP800) are related to security or cryptography.

Table 9. Certifications coverage
MCU seriesCrypto conformance certificationSecurity system certificationSecurity system certification with physical resistance (invasive)

STM32G0/

STM32G4
FIPS CAVP, SP800-90APSA L1-
STM32L4
STM32L4+FIPS CAVP, SP800-90B
STM32H7
STM32L5PSA L1, SESIP L3
STM32WBAYesPSA L3, SESIP L3 (with TF-M)
STM32U5
STM32H5PSA L3, SESIP L3 (with Secure Manager)
STM32H7Sx, STM32C0, STM32C5, STM32U0PSA L3, SESIP L3 (using iRoT)
For detailed and most recent evaluation status, refer to the official certificate listings:

STM32 security features

This section presents all the STM32 features that can be used to meet the different security concepts presented in previous sections, and to achieve a high level of security.

Static and dynamic protections

A distinction can be made depending on whether protection features are static or dynamic:
  • Static protections refer to features that are set with option bytes. Their configuration is retained at power off.

    Static protections are RDP (or product state), PCROP, WRP, BOR, OTP, and secure hide protection (when available).

  • Dynamic (or run time) protections do not retain their status at reset. They have to be configured at each boot (for example during Secure boot (SB) ).

    Dynamic protections provided by STM32 include MPU, tamper detection, and firewall.

    Other dynamic protections are related to both security and safety. An abnormal environment behavior may be accidental (safety) or intentional, in order to carry out an attack. These protections include clock and power monitoring systems, memory integrity bits, and independent watchdog (IWDG).

Security features by STM32 devices

The following tables are intended for reference and the prospects of secure code porting between STM32 products. The presence or absence of a particular feature may not be indicative of achievable security. For that reason, refer to the available security certifications for the particular product.

Table 10. Security features for STM32C0/5, STM32F0/1/2/3/4, STM32G0/4 devices
FeatureSTM32C0STM32C5STM32F0STM32F1STM32F2STM32F3STM32F4STM32G0STM32G4
Cortex coreCortex‑M0+Cortex‑M33Cortex‑M0Cortex‑M3Cortex‑M3Cortex‑M4Cortex‑M4Cortex‑M0+Cortex‑M4
RDP additional protectionBad OBL recoveryBackup registers, SRAM2, 2-level RDP onlyBackup registers2-level RDP onlyBackup SRAMBackup registersBackup SRAMBackup registers

Backup registers, CCMSRAM

Flash WRPBy area with 2‑Kbyte granularity, two areas availableBy pages (8 Kbytes)By sectors (4 Kbytes)By pages (4 K or 8 Kbytes)By sectors (16 K, 64 K, or 128 Kbytes)By sectors (4 Kbytes)By sectors (16 K, 64 K, or 128 Kbytes)By area with 2‑Kbyte granularity, two areas availableBy page (2 K or 4 Kbytes)
SRAM WRPNoSRAM2, 1‑Kbyte granularityNoNoNoNoNoNoCCM SRAM, with 1‑Kbyte granularity
PCROPBy area with 256‑byte granularity, one area per bankNoNoNoNoNoBy sectorsBy area with 512‑byte granularity, two areas availableBy area with 64‑ or 128‑bit granularity, up to two areas
HDPYes (securable memory area)Yes, 3 levelsNoNoNoNoNoYes (securable memory area)
FirewallNoNoNoNoNoNoNoNoNo
MPUYesYesNoYes1YesYes2YesYesYes
OTP1 Kbyte4.5 KbyteNoNoYesYes512 bytes1 Kbyte1 Kbyte
UBE3Yes (boot lock feature)Yes (boot lock feature)NoNoNoNoNoYes (boot lock feature)Yes
Internal tamper detectionNoYesNoNoNoNoNoYesYes
Hardware crypto4NoAES, HASH, SAES, PKA, CCBNoNoAES, HASHNoAES, HASHAES
RNGNoSP800‑90‑BNoNoSP800‑90‑ANoSP800‑90‑A
Secure softwareSBSFUNoYesNoNoNoNoYesYesYes
TF-MNoNoNoNoNoNoNoNoNo
KMSNoNoNoNoNoNoNoNoNo
Table 11. Security features for STM32L0/1/4/4+ and STM32U0 devices
FeatureSTM32L0 STM32L1STM32L4STM32L4+STM32U0
Cortex coreCortex‑M0Cortex‑M3Cortex‑M4Cortex‑M0+
RDP additional protectionEEPROM

Backup registers, SRAM2

Backup registers, SRAM2
Flash WRPBy sectors (4 Kbytes)By area with 2‑Kbyte granularity, one area per bankTwo areas per bank defined by page range
SRAM WRPNoNoSRAM2, with 1‑Kbyte granularityNo
PCROPBy sectorsBy area with 8‑byte granularity, one area per bankNo
HDPNoNoNoNoYes, with second stage extension
FirewallYesNoYesYesNo
MPUYesYesYesYesYes
OTPNoNo1 Kbyte1 Kbyte
UBE5NoNoNoNoYes (boot lock feature)
Internal tamper detectionNoNoNoNoYes
Hardware crypto6AESAES, HASH

AES, HASH,
(some PKA)

AES
RNGNoNoSP800‑90‑ASP800‑90‑BSP800‑90‑B
Secure softwareSBSFUYesYesYesYesMCUboot
TF-MNoNoNoNoNo
KMSNoNoYesYesNo
Table 12. Security features for STM32WB, STM32WBA, STM32WB0x, STM32WL, and STM32WL3 devices
FeatureSTM32WBSTM32WBASTM32WB0xSTM32WLSTM32WL3
Cortex coreCortex‑M4/Cortex‑M0+Cortex‑M33Cortex‑M0+Cortex‑M4/Cortex‑M0+Cortex‑M0+
RDP additional protectionBackup registers, SRAM2RDP four levels,backup registers, SRAMNo

Backup registers, SRAM2

No
Flash WRPBy area with 4‑Kbyte granularity, two areas availableTwo areas, defined by page rangeBy area with 2‑Kbyte granularity, two areas availableFour areas
SRAM WRPSRAM2, with 1‑Kbyte granularityNoSRAM2, with 1‑Kbyte granularityNo
PCROPBy area with 2‑Kbyte granularity, up to two areasNoBy area with 1‑Kbyte granularity, two areas availableNo
HDPYes (dedicated to Cortex‑M0+ firmware only)YesNoYesNo
FirewallNoNoYesNo
MPUYes (Cortex‑M4)YesYesYesYes
OTP1 Kbyte
UBE7NoYes (lockable secure and NS address)NoYes (boot lock feature)No
Internal tamper detectionNoYesNoYesNo
Hardware crypto8AES, PKAAES, HASH, PKAAES9, PKAAES
RNGSP800‑90‑ASP800‑90‑B
Secure softwareSBSFUYesYesYes10YesYes10
TF-MNoYesNoNoNo
KMSNoNoNoNoNo
Table 13. Security features for STM32L5, STM32U3, STM32U5, STM32H503/5, STM32H7R/S, STM32H72x/73/74x/75, STM32H7Ax/7Bx, STM32F7 devices
FeatureSTM32L5

STM32U3

STM32U5
STM32H503STM32H5

STM32

H7R/S

STM32

H72x/73x

STM32

H74x/75x

STM32

H7Ax/7Bx
STM32F7
Cortex coreCortex‑M33Cortex‑M33Cortex‑M7
RDP additional protectionRDP four levels, backup registers, SRAM2RDP four levels, backup registers, SRAM3Product state instead of RDPProduct state instead of RDP, backup SRAMBackup SRAM, backup registers, OTFDECBackup SRAM, backup registersBackup SRAM, backup registers, OTFDECBackup SRAM
Flash WRPUp to four protected areas with 2‑K or 4‑Kbyte granularityTwo areas per bank defined by page rangeBy group of 4 pages of 8‑Kbyte By sectors (8 Kbytes)By sectors (128 Kbytes)By group of 4 8‑Kbyte sectorsBy sectors (16 K, 64 K, 128 K, or 256 Kbytes)
SRAM WRPSRAM2, with 1‑Kbyte granularitySRAM2, with 1‑Kbyte granularityNoNoNoNoNo
PCROPNo (replaced by TrustZone)No (replaced by TrustZone)NoNo (replaced by TrustZone)NoBy area with 256‑byte granularityBy area with 256‑byte granularity, one area per bankBy sectors
HDPUp to two secure hide areas (HDP) inside the TrustZone secure domainUp to two secure hide areas (HDP) inside the TrustZone secure domain3‑stage temporal isolation, one per bankYes (secure user memory, with 256‑byte granularity)No
FirewallNo (replaced by TrustZone)No (replaced by TrustZone)NoNo (replaced by TrustZone)NoNoNoNoNo
MPUYesYesYesYesYesYesYesYesYes
OTP512 bytes512 bytes2 Kbytes1 KbyteNoNoNoNo
UBE11Yes (boot lock feature)YesYesYes (boot lock feature)Yes (unique entry point in secure access)No
Internal tamper detectionYesYesYesYesYesYesYesYesYes
Hardware crypto12AES, HASH, PKAAES, HASH, PKA, SAES, CCB13HASHAES,SAES, HASH, OTFDEC, PKA AES, SAES, HASH, PKA, MCEAES, DES, HASH, OTFDECAES, HASH
RNGSP800‑90‑BSP800‑90‑A14SP800‑90‑BSP800‑90‑A14
Secure softwareSBSFUNoNoNoNoMCUbootLegacyLegacyLegacyLegacy
TF-MYesYesNoYes-NoNoNoNo
KMSNoNoNoYes-NoNoNoNo
1 Only XL density devices feature the MPU.
2 MPU is not universally supported in STM32F3 series. Refer to the product datasheet to confirm availability.
3 Unique boot entry.
4 For most devices with hardware crypto capability, there is a direct equivalent without it.
5 Unique boot entry.
6 For most devices with hardware crypto capability, there is a direct equivalent without it.
7 Unique boot entry.
8 For most devices with hardware crypto capability, there is a direct equivalent without it.
9 For STM32WB0, the AES is only available on the radio peripheral.
10 Secure boot solution separated from the usual X-CUBE-SBSFU package.
11 Unique boot entry.
12 For most devices with hardware crypto capability, there is a direct equivalent without it.
13 Only the selected STM32U3 series feature the CCB. It is not available on STM32U5 series.
14 RNG v2.0 can be used as a seed source for DRBG.