3. System security

The STM32C5 is designed with a comprehensive set of security features.

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 the STM32C5 devices.

3.1 Key security features

3.2 Resource isolation

3.2.1 Temporal isolation using secure hide protection (HDP)

The embedded flash memory allows an HDP (high-density protection) area to be defined for each watermarked-secure area of each bank, with a granularity of 8-Kbyte sectors.

The code executed in this HDP area, with its related data and keys, can be hidden after boot until the next system reset.

The following figure shows the hidden protection principle.

Figure 5. Flash memory HDP area

Diagram showing three stages of flash memory protection levels. Stage 1: 'Execute after reset' shows 'User applications', 'User application or updatable RoT', and 'OEM immutable Root of Trust (RoT) code and data (HDP)'. Stage 2: 'Jump to 2nd HDP Level (uRoT) or to 3rd HDP Level (user application, no uRoT) and hide area' shows 'User applications', 'User application or updatable RoT', and a 'Hidden' area with a red 'no entry' symbol. Stage 3: 'Jump to 3rd HDP Level and uRoT hide area' shows 'User applications' and a 'Hidden' area with a red 'no entry' symbol. Arrows indicate the progression between stages. A reference 'MSv76146V1' is at the bottom right.
Diagram showing three stages of flash memory protection levels. Stage 1: 'Execute after reset' shows 'User applications', 'User application or updatable RoT', and 'OEM immutable Root of Trust (RoT) code and data (HDP)'. Stage 2: 'Jump to 2nd HDP Level (uRoT) or to 3rd HDP Level (user application, no uRoT) and hide area' shows 'User applications', 'User application or updatable RoT', and a 'Hidden' area with a red 'no entry' symbol. Stage 3: 'Jump to 3rd HDP Level and uRoT hide area' shows 'User applications' and a 'Hidden' area with a red 'no entry' symbol. Arrows indicate the progression between stages. A reference 'MSv76146V1' is at the bottom right.

The activation of the HDP area in the user flash memory is related to HDPL1. It means that as soon as HDPL becomes equal or greater than 2, data read, write, and instruction fetch on the area defined by HDPx_PSTRT and HDPx_PEND in FLASH_HDPxR_PRG option bytes are denied until the next device reset.

The END of the HDPx areas can be extended dynamically by the application using the FLASH_HDPEXTR register. This extension prevents access to protected sectors under HDPL3.

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

3.2.2 Resource isolation using Cortex privileged mode

The hardware and software resources of STM32C5 devices can be partitioned to restrict access to software running in Cortex privileged mode.

Thanks to this hardware isolation technology, a 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 region can be programmed to generate faults when accessed inappropriately by unprivileged software.

3.3 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.3.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 MPU split memory into up to eight regions.

3.3.2 Embedded flash memory write protection

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

Write-protected sectors can be modified through option byte changes only when RDP_LEVEL = L0.

Note: Bank erase aborts when it contains a write-protected area (WRP or HDP area). For more information, see Section 6.5.5: Write protection.

3.3.3 Tamper detection and response

Principle

The devices include protection of critical security assets against attacks, with the following features:

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

Tamper detection sources

The devices support three input tampers that can be mapped on five different pins.

Detection time is programmable, and a digital filtering is available (tamper triggered after two false comparisons 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 5. Internal tampers in TAMP

Tamper inputTamper source
itamp3LSE monitoring(1)
itamp4HSE monitoring
itamp5RTC calendar overflow (rtc_calovf)
itamp6JTAG/SWD access
itamp9Fault generation for cryptographic peripherals (SAES, PKA, AES, RNG)(2)
itamp11IWDG timeout and potential tamper (IWDG reset when at least one enabled tamper flag is set)
  1. 1. LSE missing or over frequency detection (> 2 MHz), glitch filter (> 2 MHz).
  2. 2. Only RNG fault on STM32C53x/C54x/C55x/C56x.

Response to tampers

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 the BKERASE bit in TAMP_CR2, or by performing a RDP_LEVEL regression as defined in Section 3.7.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 TAMPxPOM bit in TAMP_CR2 (for external tamper pin) or TAMP_CR3 (for internal tamper).

In such a situation, when the tamper flag is raised, 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, the tamper input associated to IWDG reset must trigger automatically the erase of secrets.

Tamper detection and low-power modes

The effect of low-power modes on a tamper detection is summarized in the following table.

Table 6. Effect of low-power modes on TAMP

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

3.4 Secure storage

This section applies only to STM32C59xx and STM32C5Axx devices.

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

Figure 6 shows how the key management service application can use the AES engine, for example, to compute external image decryption keys. Nonvolatile keys are stored in the flash memory in a dedicated area with access control (Section 3.2.1: Temporal isolation using secure hide protection (HDP)), while volatile key storage consists of tamper-protected SRAM.

Figure 6 also shows keys that are manipulated by software, or keys that are managed only by hardware (such as DHUK). More information about those hardware keys can be found in Section 3.4.1: Hardware secret key management.

Figure 6. Key management principle

Figure 6. Key management principle diagram showing the flow of keys between secure and non-secure components.

The diagram illustrates the key management principle within a system. It features a large box labeled 'Secure AES' which contains 'Hardware key derivation' and 'Derived hardware unique key'. 'Peripheral usage' is shown as an input to the 'Hardware key derivation' block. Outside the 'Secure AES' box, there is 'Embedded non-volatile storage (software secret)' which provides input to 'Hardware key derivation'. The 'Derived hardware unique key' is transferred via a solid arrow labeled 'Hardware key' to 'AES with DPA' inside the 'Secure AES' box. 'Embedded volatile storage (tamper resistant)' provides a 'Hardware key' (solid arrow) to 'AES with DPA' and a 'key' (dashed arrow) to 'AES without DPA'. 'Embedded non-volatile storage' provides a 'key' (dashed arrow) to 'AES without DPA'. 'AES with DPA' outputs an 'Hw Key' (solid arrow) to 'AES without DPA'. A legend indicates that solid arrows represent 'Hardware transfer of key' and dashed arrows represent 'Software transfer of key'. The reference code 'MSv76145V1' is located in the bottom right corner of the diagram area.

Figure 6. Key management principle diagram showing the flow of keys between secure and non-secure components.

3.4.1 Hardware secret key management

As shown in the previous figure, the devices provide better protection for application keys by using hardware secret keys. This AES key can be made usable by the application, without exposing it in clear text (unencrypted). Such keys also become immediately unusable in case of tampering.

STM32C59xx/C5Axx devices embed a unique source of hardware secret key:

These keys can be used in the following modes:

3.5 Unique ID

The devices store a 96-bit ID that is unique to each device (see Section 50.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 (Section 3.4.1: Hardware secret key management).

3.6 Crypto engines

Refer to the product datasheet to identify the cryptographic engines embedded in the selected devices.

The devices implement advanced cryptographic algorithms featuring key sizes and computing protection as recommended by national security agencies such as NIST for the United States, BSI for Germany, and ANSSI for France. These algorithms support privacy, authentication, integrity, entropy, and identity attestation.

The cryptographic engines embedded in STM32 reduce the weaknesses in the implementation of critical cryptographic functions. They prevent the use of weak cryptographic algorithms and key sizes. They enable lower processing times, and lower power consumption during cryptographic operations. These engines offload computations from Cortex-M33, particularly true for asymmetric cryptography.

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

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

3.6.1 Cryptographic engines features

Figure 7 lists the accelerated cryptographic operations available in the devices. Two AES accelerators are supported.

Note: Additional operations can be added by using the firmware.

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

Table 7. Accelerated cryptographic operations

OperationsAlgorithmSpecificationKey lengths (in bit)Modes
Get entropyRNGNIST SP800-90B(1)N/ASoftware and hardware(2) modes running in parallel

Table 7. Accelerated cryptographic operations (continued)

OperationsAlgorithmSpecificationKey lengths (in bit)Modes
Encryption, decryptionAES(3)FIPS PUB 197 NIST SP800-38A128, 256ECB, CBC, CTR
Authenticated encryption or decryptionNIST SP800-38C
NIST SP800-38D
128, 256GCM, CCM
Cipher-based message authentication codeNIST SP800-38D128, 256GMAC
ChecksumSHA-1FIPS PUB 180-4N/ADigest 160-bit
Cryptographic hashSHA-2SHA-224, SHA-256, SHA-384, SHA-51
Keyed-hashing for message authenticationHMACFIPS PUB 198-1 IETF RFC 2104Short, long (> 64 bytes)-
Encryption/decryption on key-pair generationRSA(4)IETF RFC 8017Up to 4160RSAES-OAEP
NIST SP800-56B
Signature with hashingRSA(4)IETF RFC 8017 FIPS PUB 186-4Up to 4160PKCS1-v1_5, PSS
Signature verificationECDSAANSI X9.62 IETF RFC 7027 FIPS PUB 186-4Up to 640Refer to Table 269: Family of supported curves for ECC operations for details.
Key agreementECDHANSI X9.42
  1. 1. Certifiable by using STMicroelectronics-reviewed documents.
  2. 2. Random number distribution to SAES and PKA through a dedicated hardware bus.
  3. 3. ECB and CBC chaining modes are protected against side-channel and timing attacks in SAES (see Section 3.6.2: Secure AES co-processor (SAES)).
  4. 4. Private key cryptography is protected against side-channel and timing attacks.

3.6.2 Secure AES co-processor (SAES)

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

Clocked by the system clock, the SAES delivers excellent performance for a DPA-resistant hardware accelerator. The SAES engine supports 128-bit or 256-bit keys in electronic code book (ECB), cipher block chaining (CBC), (CTR), (GCM), (CCM), (GMAC) modes.

As shown in Section 3.4: Secure storage, the SAES can be used for highly secure on-chip storage for sensitive information. It can also be made secure-only.

For more information, refer to Section 27: AES hardware accelerator (AES).

3.7 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 7. Device life cycle security

A flowchart titled 'Figure 7. Device life cycle security' showing the lifecycle of an IoT device. A vertical dashed line separates 'User states' (left) and 'Vendor states' (right). Vendor states include: 'Virgin device' -> 'Device manufacturing' -> 'STM32 personalized device' -> 'Vendor manufacturing' -> 'Platform'. User states include: 'Development platform' -> 'Deployed product' -> 'Decommissioning' -> 'Decommissioned product'. Transitions between states are: 'User provisioning' (Platform to Development platform), 'Productization' (Platform to Deployed product), and 'Field return' (Deployed product to Return material for analysis).
graph TD; subgraph Vendor_states [Vendor states]; VD([Virgin device]) -- "Device manufacturing" --> SPD([STM32 personalized device]); SPD -- "Vendor manufacturing" --> P([Platform]); end; subgraph User_states [User states]; DP([Development platform]); DP -- "Productization" --> DProd([Deployed product]); DProd -- "Decommissioning" --> DProdDec([Decommissioned product]); end; P -- "User provisioning" --> DP; DProd -- "Field return" --> RMA([Return material for analysis]);

MSv64454V1

A flowchart titled 'Figure 7. Device life cycle security' showing the lifecycle of an IoT device. A vertical dashed line separates 'User states' (left) and 'Vendor states' (right). Vendor states include: 'Virgin device' -> 'Device manufacturing' -> 'STM32 personalized device' -> 'Vendor manufacturing' -> 'Platform'. User states include: 'Development platform' -> 'Deployed product' -> 'Decommissioning' -> 'Decommissioned product'. Transitions between states are: 'User provisioning' (Platform to Development platform), 'Productization' (Platform to Deployed product), and 'Field return' (Deployed product to Return material for analysis).

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 8. 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.
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.7.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 9. Typical product life cycle phases

RDP protection levelDebugComments
Level 0Device openAvailableOEM and BS unlocking/locking keys can be provisioned in the flash memory user options. The keys programming, while not readable, can be verified under reset through debugger.
Level 2 with boundary scanDevice closedNone (boundary scan available under reset)Boot address must target the user flash memory. Option-byte modification limited, RDP_LEVEL not modifiable hence RDP level 2 with boundary scan cannot be changed, unless the OEM unlocking key is activated or the BS locking key to progress to level 2 (see Table 10).
Level 2Device closedNone (JTAG fuse)Boot address must target the user flash memory. Option-byte modification limited, RDP_LEVEL not modifiable hence RDP level 2 cannot be changed, unless the OEM unlocking key is activated (see Table 10).

Note: OEMKEY option byte can be modified when RDP = 0 only.

The supported transitions, summarized in the following figure can be requested (when available) through the debug interface, or via the system bootloader to go to RDP L2_wBS or L2. Additionally, through JTAG/SWD under reset, once in L2_wBS or L2, it is possible to either progress to L2 or regress to L0.

Figure 8. RDP level transition scheme

Diagram showing RDP level transitions between RDP level 2 with BS, RDP level 2, and RDP level 0. Transitions are labeled with conditions like 'Conditioned by BSKEY' and 'Regression to level 0 conditioned by OEMKEY, full FLASH erase'.
graph TD
    L2BS([RDP level 2 with BS])
    L2([RDP level 2])
    L0([RDP level 0])

    L2BS -.->|Conditioned by BSKEY 🔒| L2
    L2BS -.->|Regression to level 0 conditioned by OEMKEY, full FLASH erase 🔒| L0
    L2BS --> L0
    L2 --> L0
    L0 --> L2BS
    L0 --> L2
  

The diagram illustrates the RDP level transition scheme. It shows three states: RDP level 2 with BS, RDP level 2, and RDP level 0. Transitions are as follows:

MSv76018V2

Diagram showing RDP level transitions between RDP level 2 with BS, RDP level 2, and RDP level 0. Transitions are labeled with conditions like 'Conditioned by BSKEY' and 'Regression to level 0 conditioned by OEMKEY, full FLASH erase'.

As shown in the previous figure, the user flash memory is automatically erased, during an RDP regression. These regressions can be conditioned on dedicated 128-bit password keys, if provisioned by the OEM (see the next subsection). During the regression from RDP L2 or L2_wBS to RDP L0, the FLASH is erased. 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 L0. These secrets, also erased as response to tamper, are defined in Section 3.3.3: Tamper detection and response.

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

RDP unlocking sequences

The use of the OEM and BS password keys described in Figure 8 is described hereafter.

Note: The devices support password-based RDP L2 (or L2_wBS) regression to L0. This L2 regression erases the application code.

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

Table 10. OEM RDP unlocking methods

OEM password options
OEM LOCKRDP levelRDP regression
1L2_wBSAutomatic regression to L0 triggered upon successful OEM unlock sequence
L2
0L2_wBSRegression to L0 impossible. Possibility to transition to RDP L2.
L2Regression to L0 impossible. RDP L2 remains a permanent state.

Table 11. BS RDP locking methods

BS password options
Initial RDP levelRDP regression
L2_wBS, with BSKEY not provisionedAutomatic progression to L2 triggered upon successful BS lock sequence using default key
L2_wBS, with BSKEY provisionedAutomatic progression to L2 triggered upon successful BS lock sequence using custom key provisioned under RDP L0

Note: Unlocking the device with a password is possible only once per power cycle.

Shifting the OEM password key through JTAG/SWD corresponds to writing four 32-bit key words: AUTH_KEY[31:0], then AUTH_KEY[63:32], AUTH_KEY[95:64], then AUTH_KEY[127:96] in the DBGMCU_DBG_AUTH_HOST register.

Shifting the BS password key through JTAG/SWD corresponds to writing a 32-bit key word: BS_KEY[31:0] in the DBG_BSKEY_PWD register.

JTAG 32-bit device specific ID

Unless the JTAG port is deactivated (OEMLOCK = 0 and RDP L2), 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.

3.8 Summary of protection mechanism

The different security mechanism may reset, block or erase device secrets or sensitive peripherals. To be more explicit on those effects, please refer to the below table:

Table 12. Summary of protected assets and protection mechanism(1)

AssetsRegression to RDP L0Potential tamperConfirmed tamperPORSystem resetRTC domain reset
SRAM1E---Erase if SRAM1_RST bit is '0' (erase done at OPT activation)-
SRAM2EBEEErase if SRAM2_RST bit is '0' (erase done at OPT activation)-
FLASHE-----
FLASH EDATA pageE-----
Flash OTP------
BKUP registersRB(2)R/B(2)R(3)-R
ICACHEEEEEE-
PKA RAMEE/B(4)E/B(4)EE-
FDCAN RAM------
USB RAM------
ETH RAM------
AES/HASH/SAES/CCB registersRRRRR-
Table 12. Summary of protected assets and protection mechanism(1)
AssetsRegression to RDP L0Potential tamperConfirmed tamperPORSystem resetRTC domain reset
PKA registersRRRRR-
RNG registersR--RR-
  1. 1. E = Erase, B = Access blocked, R = Reset, N.A. = Not applicable, "-" = No effect
  2. 2. Blocked up to clearing of TAMP status register flag.
  3. 3. Erase after POR
  4. 4. Blocked during erasing.