Programming tool manufacturers who want to support SFI/SMI/SFIx solutions from STMicroelectronics and integrate them into their production line equipment should contact ST sales office for additional information under NDA.
Note:
Arm and Cortex are registered trademarks of Arm Limited (or its subsidiaries or affiliates) in the US and/or
elsewhere.
Arm and TrustZone are registered trademarks of Arm Limited (or its subsidiaries or affiliates) in the US and/or
elsewhere.
The Arm word and logo are trademarks of Arm Limited (or its subsidiaries) in the US and/or elsewhere. All rights
reserved.
Glossary
Table 2. Glossary terms
Term
Definition
AES
Advanced encryption standard
AES GCM
AES Galois counter mode
CM
Contract manufacturer
FT
Flash memory programming tool
HDP
Hide data protection
HDPL
HDP level
MAC
Message authentication code
MCU
Microcontroller unit
OB
Option bytes
OBK
Option bytes key
OCTOSPI
Octo-SPI interface
OEM
Original equipment manufacturer
OTFDEC
On-the-fly decryption engine
RDP
Readout protection
Secure boot
Root of trust, check STM32 security protection
Secure bootloader
Standard ST bootloader with additional security features
Flash memory embedded within STM32 microcontrollers (internal flash memory)
WRP
Write protection
STM32 secure firmware install (SFI)
SFI principles overview
SFI is a secure mechanism implemented in STM32 microcontrollers that allows secure and counted installation of OEM firmware and STM32TRUSTEE-SM in untrusted production environment (such as OEM contract manufacturer). SFI is implemented in a secure bootloader.
The SFI process prevents the OEM firmware and STM32TRUSTEE-SM code from:
Being accessed by the contract manufacturer.
Being extracted or disclosed.
This mechanism consists in having the following content encrypted with an AES secret key, thanks to the STM32 Trusted Package Creator tool(1) , during OEM firmware development in the OEM trusted office:
The whole OEM firmware
OTP data
Note:
On STM32H5, each programmed OTP block, even if only partially programmed, is write-protected to guarantee the authenticity and integrity of OTP data. Because an OTP block can be written only once through the SFI, the manufacturer must anticipate the content of the OTP block before programming.
STM32TRUSTEE-SM (in case of STM32H562/H563/H573, STM32H5E5/H5F5)
OBK (in case of STM32H5 and STM32H7RS)
The option bytes.
OEM must use STM32 Trusted Package Creator tool to program ST HSM with its own AES secret key(2) , its own nonce, and a maximum installation counter.
In order to properly protect the firmware confidentiality, the AES secret key must be different every time the OEM encrypts a new firmware or a new release of the same firmware. As a consequence, ST HSM must be changed.
Then, the OEM contract manufacturer have to use STM32CubeProgrammer to initiate SFI process and send encrypted SFI image(3) to STM32 device.
A hardware security module (ST HSM) is in charge of:
Securely storing OEM AES secret key
Checking STM32 device certificate(4) that is used to authenticate STM32 device(5)
Generating and providing the license(6) to the secure bootloader to securely install the encrypted firmware on STM32 device.
Counting number of produced STM32 devices.
The applicable STM32 microcontrollers are provisioned by STMicroelectronics with device dedicated public/private keys (unique key pair per device). The device keys can be accessed only through the embedded secure bootloader that retrieve AES secret key(7) by decrypting license using device private key.
Thanks to STM32 security features and cryptographic algorithm, the STM32 supports the programming in internal flash memory of:
Secure OEM firmware
STM32TRUSTEE-SM (in case of STM32H562/H563/H573, STM32H5E5/H5F5)
OBK (in case of STM32H5 and STM32H7RS)
and ensures OEM firmware protection (confidentiality, authenticity and integrity) during OEM CM manufacturing stage. The secure firmware install solution securely receives and decrypts the firmware, OBK (in case of STM32H5 and STM32H7RS), and option bytes inside STM32 internal flash memory(8) and optionally external flash memory. SFI and internal flash memory focuses on the way SFI process securely installs firmware and data within the internal flash memory, whereas SFI and external flash memory focuses on the way SFI process securely installs firmware and data within the external flash memory.
SFI image (encrypted) available from STM32 Trusted Package Creator.
Program ST HSM with AES secret key.
SFI process launch.
Device certificate.
STM32 device authentication.
Provide license.
Retrieve AES secret key.
OEM firmware, STM32TRUSTEE-SM (in case of STM32H562/H563/H573, STM32H5E5/H5F5), OBK (in case of STM32H5 and STM32H7RS), and option bytes programming.
The secure bootloader is a standard ST bootloader with additional security features.
If the STM32 microcontroller is reset during retrieving AES secret key
(7)
, all sensitive data are erased before restarting initial SFI procedure.
During SFI process, the secure bootloader never allows any other code to access user flash memory or SRAM.
SFI and external flash memory
This section applies to STM32 products with OTFDEC:
STM32L562xx
STM32U585xx/STM32U5Axxx/STM32U5Gxxx
STM32H5Fx/573/533
When speaking of external flash memory, it matters to clearly identify the firmware and data that reside in external flash memory from the firmware and data that reside in user flash memory. Firmware and data in user flash memory are named hereafter internal firmware and data.
The firmware and data that reside in external flash memory are referenced as external firmware and external data throughout the next sections.
The internal firmware must enable the read/fetch of data/code within external flash memory, using OTFDEC and OCTOSPI peripherals.
Note:
SFI cannot handle internal flash memory in a first sequence and external in a separate independent one: when SFI handles external firmware and data, it must first handle internal firmware and data that in turn enable decryption at runtime of external firmware and data.
External firmware and data on-the-fly decryption is handled by the OTFDEC peripheral. This peripheral can encrypt and decrypt on-the-fly external firmware and data stored in external flash memory connected to STM32 microcontrollers through the OCTOSPI interface. The OTFDEC can handle up to 4 regions of external flash memory, each one with its own dedicated Key. The OTFDEC uses standard AES CTR 128-bit algorithm for encryption and decryption operations. Refer to the OTFDEC section of the STM32 microcontroller reference manual to get more insight.
OEM can ensure the confidentiality of external firmware and data within external flash memory through 3 different use cases that are depicted within next sections.
External flash memory encryption without secure bootloader
The cryptographic engine responsible for the on-the-fly external flash memory decryption (OTFDEC) supports AES standard cryptographic algorithm. Thanks to this standard algorithm, OEM can encrypt external firmware and data on host before programming external flash memory, without using secure bootloader.
If external flash memory programming is done within a non-trusted facility, OEM must encrypt the external firmware and data before sending them to the non-trusted facility.
OEM internal firmware must handle the configuration of the OTFDEC peripheral with the AES key for external flash memory decryption. OEM must implement this part within the secure internal firmware in order to guaranty the confidentiality of the external flash memory AES encryption keys.
OEM internal firmware must also handle external flash memory drivers (through OCTOSPI) in order to get access to the external firmware and data.
Since OEM programs external flash memory on host, OEM must not encrypt external firmware and data thanks to STM32 Trusted Package Creator. However, OEM must send the external firmware and data AES encryption keys within the SFI image. Then, when building the SFI image thanks to STM32 Trusted Package Creator, OEM must create the SFI image with at least:
Internal firmware and data (include external flash memory drivers).
Figure 2 SFI and external flash memory encryption without secure bootloader shows that the secure programming of internal flash memory(1) and the encryption plus programming of external firmware and data(2) are done in two separated flows within SFI. The first flow uses secure bootloader, the second one uses host for programming respectively internal flash memory and external flash memory.
Figure 2. SFI and external flash memory encryption without secure bootloader
Secure programming of internal flash memory.
Encryption plus programming of external firmware and data.
Figure 3. Internal firmware and external flash memory handling
AES external firmware and data key programming in OTFDEC peripheral.
On-the-fly external flash memory decryption.
At runtime, during secure boot, the secure internal firmware first copies the AES firmware and data key within the OTFDEC peripheral and activates the OTFDEC region tied to this key(1). Then the CPU can seamlessly read/fetch data/code from external flash memory once the OCTOSPI driver has been initialized(2).
External flash memory encryption with secure bootloader and global key
In the next two sections, this document focuses on SFI use cases with encryption of the external firmware and data by the secure bootloader. The STM32 receives encrypted external firmware and data, decrypts them with the SFI OEM key, and re-encrypts them with an external flash memory AES key common to all devices to be programmed or with a unique external flash memory AES key per device. This section focuses on the first scenario: a key common to all devices.
The STM32 secure bootloader uses the OTFDEC peripheral to encrypt external firmware and data, the STM32 secure bootloader stores the encryption result within SRAM. Then an external flash memory loader takes the previous result and program it within the external flash memory.
The external flash memory programming is under the responsibility of OEM, meaning that OEM must use an external flash memory loader that fits its external flash memory specificities. ST does not provide such external flash memory loader, except for demonstration purpose on ST boards supporting external flash memory.
Consequently, OEM must implement in internal flash memory the firmware parts dedicated to external flash memory handling (external flash memory keys and drivers).
OEM must create SFI image with:
Internal firmware and data (include external flash memory drivers).
External firmware and data AES key.
External firmware and data.
OEM must take care to specify, in STM32 TPC, the same address in internal flash memory for external firmware and data AES key than the one its internal firmware uses for external flash memory on-the-fly decryption with OTFDEC peripheral.
The picture below shortly depicts an SFI sequence where STM32 secure bootloader handles both internal firmware installation and external firmware installation with the help of external flash memory loader.
Figure 4. External flash memory encryption with secure bootloader and global AES Key
Internal flash memory programming.
AES external firmware and data key programming in OTFDEC peripheral.
External flash memory chunk encryption.
External flash memory programming.
Figure 4 External flash memory encryption with secure bootloader and global AES Key above shows that internal firmware and external firmware and data AES key must be installed first(1), then the previously mentioned key is copied within the OTFDEC peripheral(2) that is used to encrypt the external firmware and data for external flash memory(3). At last, OEM external flash memory loader programs the encrypted external firmware and data into the external flash memory(4) .
Figure 5. Internal firmware and external flash memory handling (using global key)
AES external firmware and data key programming in OTFDEC peripheral.
On-the-fly external flash memory decryption.
At runtime, during secure boot, the secure internal firmware first copies the AES firmware and data key within the OTFDEC peripheral and activates the OTFDEC region tied to this key(1). Then the CPU can seamlessly read/fetch data/code from external flash memory once the OCTOSPI driver has been initialized(2).
External flash memory encryption with secure bootloader and unique key
This section focuses on the scenario where the secure bootloader encrypts the external firmware and data with a unique key per device. During SFI, the STM32CubeProgrammer first performs secure programming of the internal flash memory(1) then it requests the STM32 to randomly generate a key dedicated to the external flash memory encryption(2). The STM32 uses the TRNG peripheral to generate this key. After key generation the secure bootloader programs this last key(3) in the internal flash memory.
The STM32 uses the OTFDEC peripheral to encrypt the external firmware and data(4)(5). The STM32 stores the encryption result within SRAM. Then an external flash memory loader takes the previous result to program it within the external flash memory(6).
The external flash memory programming is under the responsibility of OEM, meaning that OEM must use an external flash memory loader that fits its external flash memory specificities. ST does not provide such external flash memory loader, except for demonstration purpose on ST boards supporting external flash memory.
Consequently, OEM must implement in internal flash memory the firmware parts dedicated to external flash memory handling (external flash memory keys and drivers).
OEM must create the SFI image with:
Internal firmware and data (include external flash memory drivers).
External firmware and data AES key.
External firmware and data.
The STM32CubeProgrammer requests the STM32 secure bootloader to randomly generate a unique set of keys during the SFI sequence. Then OEM must take care to specify, within STM32 TPC, the same address in internal flash memory for key generation than the one its internal firmware uses for external flash memory on-the-fly decryption with OTFDEC peripheral.
The picture below shortly depicts an SFI sequence where the STM32 secure bootloader handles both internal firmware installation and external firmware installation with a unique external flash memory AES key and the help of an external flash memory loader.
Figure 6. External flash memory encryption with secure bootloader and unique AES Key
Internal flash memory programming.
AES external firmware and data key generation.
AES external firmware and data key programming in internal flash memory.
AES external firmware and data key programming in OTFDEC peripheral.
AES external firmware and data key programming in OTFDEC peripheral.
On-the-fly external flash memory decryption.
At runtime, during secure boot, the secure internal firmware first copies the AES firmware and data key within the OTFDEC peripheral and activates the OTFDEC region tied to this key(1). Then the CPU can seamlessly read/fetch data/code from external flash memory once the OCTOSPI driver has been initialized(2).