How to perform Secure Boot from Distribution Package
1. Article purpose[edit | edit source]
The purpose of this article is to explain how to perform a secure boot on an STM32 MPU device with the Distribution Package.
To do so, steps, described in chapters below, must be followed:
- Create the signature and encryption keys with the KeyGen tool (if not already done).
- Fuse the signature/encryption keys on the STM32 MPU (if not already done).
- Compile the Distribution Package with a signed binaries.
- Sign the first-stage bootloader binaries with the Signing tool.
- Create a FlashLayout file for signed binaries.
- Flash the STM32 MPU with generated FlashLayout file.
- Check the keys
- Close the device (if not already done).
2. Prerequisites[edit | edit source]
Install the STM32CubeProgrammer with the KeyGen tool and Signing tool.
3. Set up signature and encryption keys[edit | edit source]
3.1. Create signature keys[edit | edit source]
To perform the secure boot, binaries must be signed/verified with a specific signature key.
If this signature key is already present on the STM32 MPU device, go directly to Update Distribution Package with signed binaries chapter.
To create the signature key, use the STM32MP KeyGen CLI Tool.
Refer to the KeyGen tool page for installation and command-line options.
The minimal command to use is:
STM32_KeyGen_CLI -abs <output directory> -pwd <password> -n <number of key>
With:
- <output directory> = Path to the generated files: private and public key files (privateKey*.pem and publicKey*.pem), Hash file (publicKeyHash*.bin), HashHashes file and (publicKeysHashHashes.bin) .
- <password> = Passwords of the private key. The password must contain at least four characters. The number of passwords must match the number of key pairings.
- <number of key> = Number of key pairs, one for STM32MP15 or eight for other platforms.
| With such command, keys pairs, public and private signature keys, are created. With each pair, the hash of the public key ("public hash key" binary) is created. |
To build your signed image correctly, you need to store the private and public keys in the same folder.
Procedure is described below, select the one corresponding to the used STM32MPU.
3.1.1. For STM32MP13x lines
[edit | edit source]
If you want to sign one of the software components listed in the table below, you need to create its signature key.
The Signature keys are used to sign and verify corresponding components. Several components can be signed/verified by the same key, as shown in table below.
| Signature key name | |
|---|---|
| FSBL | |
| TF-A | PKHTH |
| FIP | |
| OP-TEE | PKHTH |
| U-BOOT | PKHTH |
STM32MP13x lines
devices support up to eight signature key pairs (public key/private key).
Example:
STM32_KeyGen_CLI -abs stm32mp13-key/ -pwd password1 password2 password3 password4 password5 password6 password7 password8 -n 8
-------------------------------------------------------------------
STM32MP Key Generator <tool version>
-------------------------------------------------------------------
Prime256v1 curve is selected.
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 0 generated successfully.
+ public key: stm32mp13-key/publicKey00.pem
+ private key: stm32mp13-key/privateKey00.pem
+ public hash key: stm32mp13-key/publicKeyHash00.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 1 generated successfully.
+ public key: stm32mp13-key/publicKey01.pem
+ private key: stm32mp13-key/privateKey01.pem
+ public hash key: stm32mp13-key/publicKeyHash01.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 2 generated successfully.
+ public key: stm32mp13-key/publicKey02.pem
+ private key: stm32mp13-key/privateKey02.pem
+ public hash key: stm32mp13-key/publicKeyHash02.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 3 generated successfully.
+ public key: stm32mp13-key/publicKey03.pem
+ private key: stm32mp13-key/privateKey03.pem
+ public hash key: stm32mp13-key/publicKeyHash03.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 4 generated successfully.
+ public key: stm32mp13-key/publicKey04.pem
+ private key: stm32mp13-key/privateKey04.pem
+ public hash key: stm32mp13-key/publicKeyHash04.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 5 generated successfully.
+ public key: stm32mp13-key/publicKey05.pem
+ private key: stm32mp13-key/privateKey05.pem
+ public hash key: stm32mp13-key/publicKeyHash05.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 6 generated successfully.
+ public key: stm32mp13-key/publicKey06.pem
+ private key: stm32mp13-key/privateKey06.pem
+ public hash key: stm32mp13-key/publicKeyHash06.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 7 generated successfully.
+ public key: stm32mp13-key/publicKey07.pem
+ private key: stm32mp13-key/privateKey07.pem
+ public hash key: stm32mp13-key/publicKeyHash07.bin
------------------------------------------------------------
Hash of table of Hash of {algorithm + public Key} file generated successfully.
+ Hash Hash: stm32mp13-key/publicKeysHashHashes.bin
| It is recommended to rename the generated files to match with key usage: For PKHTH:
where X: 0 to 7 |
3.1.2. For STM32MP15x lines
[edit | edit source]
If you want to sign one of components given in table below, you need to create its signature key.
The Signature keys are used to sign and verify corresponding components. Several components be signed/verified by the same key, as shown in table below.
| Signature key name | |
|---|---|
| FSBL | |
| TF-A | PKH |
| FIP | |
| OP-TEE | PKH |
| U-BOOT | PKH |
STM32MP15 device supports only one signature key pair (public key/private key).
Example:
STM32_KeyGen_CLI -abs stm32mp15-key/ -pwd pass1 -n 1
-------------------------------------------------------------------
STM32MP Key Generator <tool version>
-------------------------------------------------------------------
Prime256v1 curve is selected.
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 0 generated successfully.
+ public key: stm32mp15-key/publicKey00.pem
+ private key: stm32mp15-key/privateKey00.pem
+ public hash key: stm32mp15-key/publicKeyHash00.bin
------------------------------------------------------------
Hash of table of Hash of {algorithm + public Key} file generated successfully.
+ Hash Hash: stm32mp15-key/publicKeysHashHashes.bin
| It is recommended to rename the generated files to match with key usage: For PKH:
|
3.1.3. For STM32MP2 series[edit | edit source]
If you want to sign one of components given in table below, you need to create its signature key.
The Signature keys are used to sign and verify corresponding components. Several components be signed/verified by the same key, as shown in table below.
In chapters below, different way to create keys, defined in the table above, are described depending on the type of key. If you want to sign one of component given in table above, you must create the associated key.
3.1.3.1. Create Signature keys for both TD flavor (A35-TD or M33-TD)
(OEM-KEY1 for Cortex-A35)[edit | edit source]
STM32MP21, STM32MP23 and STM32MP25 devices support up to eight signature key pairs (public key/private key).
Example for STM32MP2X (where stm32mp2X can be stm32mp21, stm32mp23 or stm32mp25):
STM32_KeyGen_CLI -abs stm32mp2X-key/ -pwd password1 password2 password3 password4 password5 password6 password7 password8 -n 8
-------------------------------------------------------------------
STM32MP Key Generator <tool version>
-------------------------------------------------------------------
Prime256v1 curve is selected.
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 0 generated successfully.
+ public key: stm32mp2X-key/publicKey00.pem
+ private key: stm32mp2X-key/privateKey00.pem
+ public hash key: stm32mp2X-key/publicKeyHash00.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 1 generated successfully.
+ public key: stm32mp2X-key/publicKey01.pem
+ private key: stm32mp2X-key/privateKey01.pem
+ public hash key: stm32mp2X-key/publicKeyHash01.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 2 generated successfully.
+ public key: stm32mp2X-key/publicKey02.pem
+ private key: stm32mp2X-key/privateKey02.pem
+ public hash key: stm32mp2X-key/publicKeyHash02.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 3 generated successfully.
+ public key: stm32mp2X-key/publicKey03.pem
+ private key: stm32mp2X-key/privateKey03.pem
+ public hash key: stm32mp2X-key/publicKeyHash03.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 4 generated successfully.
+ public key: stm32mp2X-key/publicKey04.pem
+ private key: stm32mp2X-key/privateKey04.pem
+ public hash key: stm32mp2X-key/publicKeyHash04.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 5 generated successfully.
+ public key: stm32mp2X-key/publicKey05.pem
+ private key: stm32mp2X-key/privateKey05.pem
+ public hash key: stm32mp2X-key/publicKeyHash05.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 6 generated successfully.
+ public key: stm32mp2X-key/publicKey06.pem
+ private key: stm32mp2X-key/privateKey06.pem
+ public hash key: stm32mp2X-key/publicKeyHash06.bin
------------------------------------------------------------
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys packet 7 generated successfully.
+ public key: stm32mp2X-key/publicKey07.pem
+ private key: stm32mp2X-key/privateKey07.pem
+ public hash key: stm32mp2X-key/publicKeyHash07.bin
------------------------------------------------------------
Hash of table of Hash of {algorithm + public Key} file generated successfully.
+ Hash Hash: stm32mp2X-key/publicKeysHashHashes.bin
| It is recommended to rename the generated files to match with key usage: For OEM-KEY1:
where X: 0 to 7 |
3.1.3.2. Create Signature keys for A35-TD flavor
only[edit | edit source]
3.1.3.2.1. Create Signature keys for Cortex-M33 (RPROC-FW-PKH)[edit | edit source]
Since ecosystem release v6.2.0
, signature keys can be created also for the Cortex-M (running as remote processor, in A35-TD flavor
)
See ECC keys chapter from How to protect the Cortex-M coprocessor firmware page for more information.
STM32MP21, STM32MP23 and STM32MP25 device supports one signature key pairs (public key/private key).
Example:
Create private key:
STM32_KeyGen_CLI -abs stm32mp2-rproc-key/ -pwd password1
-------------------------------------------------------------------
STM32MP Key Generator <tool version>
-------------------------------------------------------------------
Prime256v1 curve is selected.
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys generated successfully.
+ public key: stm32mp2-rproc-key/publicKey.pem
+ private key: stm32mp2-rproc-key/privateKey.pem
+ public hash key: stm32mp2-rproc-key/publicKeyhash.bin
| It is recommended to rename the generated files to match with key usage: For RPROC-FW-PKH:
|
Extract public key in DER format and the new hash, based on DER format:
openssl ec -pubin -in stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey.pem -outform DER -pubout -out stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey.der tail -c +28 stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey.der > stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey_der.bin openssl dgst -sha256 -binary stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey_der.bin > stm32mp2-rproc-key/m33_RPROC-FW-PKH_ecc_publicKey_der_hash.bin
3.1.3.3. Signature keys created for M33-TD flavor
only[edit | edit source]
Since ecosystem release v6.2.0
, signature keys can be created also for the Cortex-M in M33-TD flavor
.
3.1.3.3.1. Asymmetric signature keys created for Cortex-M33 (FSBLM-DDR-FW-PKH and FSBLM-M33-FW-PKH)[edit | edit source]
To create an asymmetric key for M33-TD flavor
, you must use ST KeyGen tools.
STM32MP21, STM32MP23 and STM32MP25 device supports one signature key pairs (public key/private key) for those keys..
STM32_KeyGen_CLI -abs stm32mp2-cm33-key/ -pwd password1
-------------------------------------------------------------------
STM32 Key Generator <tool version>
-------------------------------------------------------------------
Prime256v1 curve is selected.
AES_256_cbc algorithm is selected for private key encryption
Generating Prime256v1 keys...
Private key PEM file created
Public key PEM file created
public key hash file created
Keys generated successfully.
+ public key: stm32mp2-cm33-key/publicKey.pem
+ private key: stm32mp2-cm33-key/privateKey.pem
+ public hash key: stm32mp2-cm33-key/publicKeyhash.bin
| The Hash generated by ST KeyGen tools are not usable in case of M33-TD flavor |
Extract Public Key in DER format
openssl ec -pubin -in stm32mp2-cm33-key/publicKey.pem -pubout -outform DER -out stm32mp2-cm33-key/publicKey.der
Hash the key and store the result on hash file
openssl dgst -sha256 -binary stm32mp2-cm33-key/publicKey.der > stm32mp2-cm33-key/hash.bin
| The key can be renamed to match with key usage: For FSBLM-DDR-FW-PKH:
For FSBLM-M33-FW-PKH:
|
3.1.3.3.2. TF-M Initial Attestation Key[edit | edit source]
TF-M requires a key for Initial Attestation[1]. By default it requires asymmetric keys.
However you can choose to use a symmetric key[2]. This is the default implementation made by ST.
To create this symmetric key, you must generate a random key of 32 bytes.
STM32_KeyGen_CLI -rand 32 m33_TFM-IAK_key_256bits.bin
3.2. Fuse signature keys on STM32 MPU[edit | edit source]
| For demonstration and test purposes, the signature materials can be fused manually on the STM32 MPU device using a simple U-Boot command on the development board. For production purposes, it must be set in the production phase, as described in Secure Secret Provisioning (SSP) overview. |
Of course, before fusing the keys, they must have been created. For the creation follow instructions given in #Create signature keys chapter;
Correspondence between signature keys and binary files for STM32MP1 series:
| Signature key name | Binary file | |
|---|---|---|
| STM32MP13 | PKHTH | a7_PKHTH_publicKeysHashHashes.bin |
| STM32MP15 | PKH | a7_PKH_publicKeysHashHashes.bin |
Correspondence between signature keys and binary files forSTM32MP2 series:
To manually fuse thePublic Key Hash file (*publicKeysHash*.bin), generated as described in the #Create signature key chapter, put the file in the bootfs partition (recommended one) and use a U-Boot stm32key command:
- Boot the board
- Stop on the U-Boot console.
- Load public hash key in DDR.
In this example, the hash key file is located in the bootfs partition of the SD card:
stm32key list
- Select the key (keys are given in both table above)
stm32key select <key name> load mmc 0#bootfs ${loadaddr} <binary name>
- Verify the key
stm32key read ${loadaddr}
- Fuse public key hash
stm32key fuse ${loadaddr}
- Verify the key in OTP
stm32key read
For complete information on the fuse procedure, refer to How to use U-Boot stm32key command.
3.3. Create encryption keys[edit | edit source]
Only STM32MP13x lines
and STM32MP2 series support the encryption of binaries.
To perform secure boot with encrypted binaries, you must encrypt binaries with a specific encryption key.
The encryption keys are then also used to decrypt a component/firmware.
If this encryption key is already present on the STM32 MPU device, go directly to Update Distribution Package with signed binaries chapter.
To create an encryption key, you must generate a random key of 16 bytes and another random key of 32 bytes.
STM32_KeyGen_CLI -rand 16 stm32mp_encryption_key_128bits.bin STM32_KeyGen_CLI -rand 32 stm32mp_encryption_key_256bits.bin
3.3.1. For STM32MP13x lines
[edit | edit source]
If you want to encrypt one of the software components listed in the table below, you need to create its encryption key.
The encryption keys are used to encrypt and decrypt corresponding components. Several components can be encrypted/decrypted by the same key, as shown in table below.
| STM32MP13 | Encryption key name |
|---|---|
| FSBL | |
| TF-A | EDMK |
| FIP | |
| OP-TEE | EDMK |
| U-BOOT | |
For STM32MP13x lines , The EDMK key is used for both FSBL encryption (128 bits key) and FIP encryption (256 bits key):
- "a7_EDMK_key_128bits.bin" can be generated with KeyGen tool (128 bits random key)
- "stm32mp13_a7_EDMK_encryption_key_256bits.txt" can be generated with below example:
hexdump -e '/1 "%02x"' a7_EDMK_key_128bits.bin > stm32mp13_a7_EDMK_encryption_key_256bits.txt hexdump -e '/1 "%02x"' a7_EDMK_key_128bits.bin >> stm32mp13_a7_EDMK_encryption_key_256bits.txt printf "\n" >> stm32mp13_a7_EDMK_encryption_key_256bits.txt
In this case, the FIP encryption key is the concatenation of 2 times the EDKM key to constitute a 256 bits encrypt key.
| It is recommended to rename the generated files (stm32mp_encryption_key_128bits.bin and stm32mp13_a7_EDMK_encryption_key_256bits.txt) to match with key usage: For EDMK:
|
3.3.2. For STM32MP2 series[edit | edit source]
If you want to encrypt one of the software components listed in the table below, you need to create its encryption key.
The encryption keys are used to encrypt and decrypt corresponding components. Several components can be encrypted/decrypted by the same key, as shown in table below.
| It is recommended to rename the generated files (stm32mp_encryption_key_128bits.bin and stm32mp_encryption_key_256bits.bin) to match with key usage: For EDMK1-128b:
For EDMK1:
For FIP-EDMK:
For RPROC-FW-ENC-KEY:
|
3.4. Fuse encryption key on STM32 MPU[edit | edit source]
| For demonstration and test purposes, the encryption materials can be fused manually on the STM32 MPU device using a simple U-Boot command on the development board. For production purposes, it must be set in the production phase, as described in Secure Secret Provisioning (SSP) overview. |
Of course, before fusing the keys, they must have been created. For the creation follow instructions given in #Create encryption keys chapter;
Correspondence between platform and key/signature file for
Correspondence between encryption keys and binary files for STM32MP13x lines
:
| Encryption key name | Binary file | |
|---|---|---|
| STM32MP13 | EDMK | a7_EDMK_key_128bits.bin |
Correspondence between encryption keys and binary files for STM32MP2 series:
To manually fuse the key on the STM32 MPU device with a U-Boot stm32key command:
- Fuse the encryption key file (stm32mp_encryption_key.bin), generated as demonstrated in the previous section, on the bootfs partition.
- Boot the board and stop it on the U-Boot console.
- Load the encryption key in DDR.
To manually fuse the encryption key, generated as described in the #Create encryption key chapter, on the bootfs partition (recommended one), use a U-Boot stm32key command:
- Boot the board
- Stop on the U-Boot console.
- Load public hash key in DDR.
In this example, the key file is located in the bootfs partition of the SD card:
stm32key list
- Select the EDMK key to use following the platform (How to use U-Boot stm32key command|)
stm32key select <key name>
load mmc 0#bootfs ${loadaddr} <binary name>
- Verify that the key is registered
stm32key read
- Fuse the encryption key
stm32key fuse ${loadaddr}
- Verify the key in OTP
stm32key read
For complete information on the fuse procedure, refer to How to use U-Boot stm32key command.
4. Update the Distribution Package with signed binaries[edit | edit source]
4.1. Prerequisites[edit | edit source]
Signature and encryption keys must have been created and associated materials fused in the board. If not done come back to #Set up signature and encryption keys chapter.
List of signature/encryption keys, mandatory or optional, for STM32MP1 series:
| Signature keys list | Encryption keys list | ||
|---|---|---|---|
| STM32MP13 | Mandatory | PKHTH | EDMK |
| Optional | |||
| STM32MP15 | Mandatory | PKH | |
| Optional |
List of signature/encryption keys, mandatory or optional, for STM32MP2 series:
- Install the STM32MPU Distribution Package .
- Source the environment of the Distribution Package:
source layers/meta-st/scripts/envsetup.sh
- select your DISTRO and your machine.
| Only two modes are supported: signed binaries or signed and encrypted binaries . |
4.2. Configure a Distribution Package with signed or signed / encrypted partition binaries[edit | edit source]
| Only two modes are supported: signed binaries or signed and encrypted binaries . |
The configuration of the Distribution Package with signed or signed/encrypted binaries is done by adding lines, given in chapters below, to local.conf file, available in the build directory, and generate your image. In chapters below, select the part corresponding to your case.
4.2.1. For STM32MP1 series[edit | edit source]
Generate a Distribution Package with signed or signed / encrypted configurations for STM32MP13x lines
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp13/a7_PKHTH_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a7_PKHTH_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_FSBL_KEY = "key/stm32mp13/a7_EDMK_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp13/stm32mp13_a7_EDMK_encryption_key_256bits.txt" ' >> conf/local.conf
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf
Generate Distribution Package with signed configuration for STM32MP15x lines
.
You can enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "1" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp15/a7_PKH_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "key/stm32mp15/a7_PKH_publicKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
4.2.2. ForSTM32MP2 series with A35-TD flavor
[edit | edit source]
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP21x lines
with A35-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.3" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp21/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
If you would like to activate the signature of binaries used on Cortex-M33 coprocessor:
echo 'SIGN_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_INFOKEY = "key/stm32mp21/m33_RPROC-FW-PKH_ecc_publicKey.der" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PRIVKEY = "key/stm32mp21/m33_RPROC-FW-PKH_ecc_privateKey.pem" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PASS = "password of remote processor signature key " ' >> conf/local.conf
To desactivate it, just not provide the SIGN_COPRO_ECC information and set SIGN_COPRO_DEFAULT (software signature key provided by OP-TEE)
echo 'SIGN_COPRO_DEFAULT = "1" ' >> conf/local.conf
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp21/a35_EDMK1-128b_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp21/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you want to activate the encryption of binaries use on Cortex-M33 coprocessor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp21/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP23x lines
with A35-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.2" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp23/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
If you would like to activate the signature of binaries used on Cortex-M33 coprocessor:
echo 'SIGN_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_INFOKEY = "key/stm32mp23/m33_RPROC-FW-PKH_ecc_publicKey.der" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PRIVKEY = "key/stm32mp23/m33_RPROC-FW-PKH_ecc_privateKey.pem" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PASS = "password of remote processor signature key " ' >> conf/local.conf
To desactivate it, just not provide the SIGN_COPRO_ECC information and set SIGN_COPRO_DEFAULT (software signature key provided by OP-TEE)
echo 'SIGN_COPRO_DEFAULT = "1" ' >> conf/local.conf
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp23/a35_EDMK1_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp23/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you want to activate the encryption of binaries use on Cortex-M33 coprocessor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp23/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP25x lines
with A35-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.2" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp25/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
If you would like to activate the signature of binaries used on Cortex-M33 coprocessor:
echo 'SIGN_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_INFOKEY = "key/stm32mp25/m33_RPROC-FW-PKH_ecc_publicKey.der" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PRIVKEY = "key/stm32mp25/m33_RPROC-FW-PKH_ecc_privateKey.pem" ' >> conf/local.conf echo 'SIGN_COPRO_ECC_PASS = "password of remote processor signature key " ' >> conf/local.conf
To desactivate it, just not provide the SIGN_COPRO_ECC information and set SIGN_COPRO_DEFAULT (software signature key provided by OP-TEE)
echo 'SIGN_COPRO_DEFAULT = "1" ' >> conf/local.conf
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp25/a35_EDMK1_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp25/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you want to activate the encryption of binaries use on Cortex-M33 coprocessor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp25/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
4.2.3. ForSTM32MP2 series with M33-TD flavor
[edit | edit source]
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP21x lines
with M33-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.3" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp21/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
echo 'SIGN_M33DDR_KEY = "key/stm32mp21/m33_FSBLM-DDR-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33DDR_KEY_PASS = "root" ' >> conf/local.conf echo 'SIGN_M33FW_KEY = "key/stm32mp21/m33_FSBLM-M33-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33FW_KEY_PASS = "root" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with OEM-KEY1 and EDMK1 are supported for the two cores. |
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp21/a35_EDMK1-128b_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp21/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you would like to activate the encryption of binaries use on co-processor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp21/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with EDMK1-128b is supported for the two cores. |
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP23x lines
with M33-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.2" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp23/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
echo 'SIGN_M33DDR_KEY = "key/stm32mp23/m33_FSBLM-DDR-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33DDR_KEY_PASS = "root" ' >> conf/local.conf echo 'SIGN_M33FW_KEY = "key/stm32mp23/m33_FSBLM-M33-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33FW_KEY_PASS = "root" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with OEM-KEY1 and EDMK1 are supported for the two cores. |
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp23/a35_EDMK1_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp23/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you would like to activate the encryption of binaries use on co-processor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp23/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with EDMK1 is supported for the two cores. |
Generate Distribution Package with signed or signed / encrypted configuration for STM32MP25x lines
with M33-TD flavor
.
First, you must enable the secure boot with signature support:
echo 'SIGN_HEADER_VERSION = "2.2" ' >> conf/local.conf echo 'EXTERNAL_KEY_CONF = "1" ' >> conf/local.conf
echo 'SIGN_KEY = "key/stm32mp25/a35_OEM-KEY1_privateKey00.pem" ' >> conf/local.conf echo 'SIGN_KEY_PUB = "<list of public key (a35_OEM-KEY1_publicKey*.pem)" ' >> conf/local.conf echo 'SIGN_KEY_PASS = "<passwords of signature key>" ' >> conf/local.conf
echo 'SIGN_ENABLE = "1" ' >> conf/local.conf echo 'SIGN_TOOL = "<path to STM32_SigningTool tools>" ' >> conf/local.conf
If there are eight key pairs, you need to declare eight passwords:
SIGN_KEY_PASS = "password0 password1 password2 password3 password4 password5 password6 password7" |
echo 'SIGN_M33DDR_KEY = "key/stm32mp25/m33_FSBLM-DDR-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33DDR_KEY_PASS = "root" ' >> conf/local.conf echo 'SIGN_M33FW_KEY = "key/stm32mp25/m33_FSBLM-M33-FW-PKH_privateKey.pem" ' >> conf/local.conf echo 'SIGN_M33FW_KEY_PASS = "root" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with OEM-KEY1 and EDMK1 are supported for the two cores. |
Then, if wished, you can enable secure boot with encryption support:
echo 'ENCRYPT_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_FSBL_KEY = "key/stm32mp25/a35_EDMK1_key_128bits.bin" ' >> conf/local.conf echo 'ENCRYPT_FIP_KEY = "key/stm32mp25/a35_FIP-EDMK_key_256bits.bin" ' >> conf/local.conf
If you would like to activate the encryption of binaries use on co-processor:
echo 'ENCRYPT_COPRO_ENABLE = "1" ' >> conf/local.conf echo 'ENCRYPT_COPRO_KEY = "key/stm32mp25/m33_RPROC-FW-ENC-KEY_key_256bits.bin" ' >> conf/local.conf
| For the moment, only the usage of same FSBL key with EDMK1 is supported for the two cores. |
4.3. Generate the Distribution Package[edit | edit source]
Compile the binaries for signed binaries or signed and encrypted partition binaries:
bitbake st-image-weston
The binaries file, signed or signed encrypted ready to be programmed on the board, can be found in:
- tmp-glibc/deploy/images/<machine name>/arm-trusted-firmware
- tmp-glibc/deploy/images/<machine name>/fip
- tmp-glibc/deploy/images/<machine name>/arm-trusted-firmware-m (specific for STM32MP2 series M33-TD flavor
) - tmp-glibc/deploy/images/<machine name>/arm-trusted-firmware-m/bl2 (specific for STM32MP2 series M33-TD flavor
) - tmp-glibc/deploy/images/<machine name>/m33-firmware (specific for STM32MP2 series M33-TD flavor
)
5. FlashLayout file content[edit | edit source]
Example for FlashLayout_sdcard_stm32mp157f-dk2-optee_Signed.tsv with signature enabled:
#Opt Id Name Type IP Offset Binary - 0x01 fsbl-boot Binary none 0x0 arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb_Signed.stm32 - 0x03 fip-boot FIP none 0x0 fip/fip-stm32mp157f-dk2-optee_Signed.bin P 0x04 fsbl1 Binary mmc0 0x00004400 arm-trusted-firmware/tf-a-stm32mp157f-dk2-sdcard_Signed.stm32 P 0x05 fsbl2 Binary mmc0 0x00044400 arm-trusted-firmware/tf-a-stm32mp157f-dk2-sdcard_Signed.stm32 P 0x06 metadata1 Binary mmc0 0x00084400 arm-trusted-firmware/metadata.bin P 0x07 metadata2 Binary mmc0 0x000C4400 arm-trusted-firmware/metadata.bin P 0x08 fip-a FIP mmc0 0x00104400 fip/fip-stm32mp157f-dk2-optee_Signed.bin PED 0x09 fip-b FIP mmc0 0x00504400 none PED 0x0A u-boot-env Binary mmc0 0x00904400 none P 0x10 bootfs System mmc0 0x00984400 st-image-bootfs-openstlinux-weston-stm32mp1.ext4 P 0x11 vendorfs FileSystem mmc0 0x04984400 st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 P 0x12 rootfs FileSystem mmc0 0x05984400 st-image-weston-openstlinux-weston-stm32mp1.ext4 P 0x13 userfs FileSystem mmc0 0x33984400 st-image-userfs-openstlinux-weston-stm32mp1.ext4
Example for FlashLayout_sdcard_stm32mp157f-dk2-optee_Encrypted_Signed.tsv with signature and encryption enabled:
#Opt Id Name Type IP Offset Binary - 0x01 fsbl-boot Binary none 0x0 arm-trusted-firmware/tf-a-stm32mp157f-dk2-usb_Encrypted_Signed.stm32 - 0x03 fip-boot FIP none 0x0 fip/fip-stm32mp157f-dk2-optee_Encrypted_Signed.bin P 0x04 fsbl1 Binary mmc0 0x00004400 arm-trusted-firmware/tf-a-stm32mp157f-dk2-sdcard_Encrypted_Signed.stm32 P 0x05 fsbl2 Binary mmc0 0x00044400 arm-trusted-firmware/tf-a-stm32mp157f-dk2-sdcard_Encrypted_Signed.stm32 P 0x06 metadata1 Binary mmc0 0x00084400 arm-trusted-firmware/metadata.bin P 0x07 metadata2 Binary mmc0 0x000C4400 arm-trusted-firmware/metadata.bin P 0x08 fip-a FIP mmc0 0x00104400 fip/fip-stm32mp157f-dk2-optee_Encrypted_Signed.bin PED 0x09 fip-b FIP mmc0 0x00504400 none PED 0x0A u-boot-env Binary mmc0 0x00904400 none P 0x10 bootfs System mmc0 0x00984400 st-image-bootfs-openstlinux-weston-stm32mp1.ext4 P 0x11 vendorfs FileSystem mmc0 0x04984400 st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 P 0x12 rootfs FileSystem mmc0 0x05984400 st-image-weston-openstlinux-weston-stm32mp1.ext4 P 0x13 userfs FileSystem mmc0 0x33984400 st-image-userfs-openstlinux-weston-stm32mp1.ext4
If you manage to create a flashlayout with Signature and Encryption, the name of file is extended with the pattern _Encrypted_Signed
|
6. Load the generated FlashLayout file in board[edit | edit source]
Use the previously created FlashLayout file with the signed binaries to populate the correct binaries on the board.
You can refer to STM32CubeProgrammer#How_to_flash_with_STM32CubeProgrammer article and follow instructions related to your ST boards.
7. Check the set up[edit | edit source]
At board boot time, check the two levels of the secure boot: the ROM code secure boot validation and the TF-A BL2 trusted board boot validation.
8. Close the device[edit | edit source]
| For demonstration and test purposes, the STM32MP device can be closed with a simple U-Boot command on the development board. For production purposes, it must be set in production step as described in AN5510: Overview of the secure secret provisioning (SSP) on STM32MP1 series. |
For more information, refer to How to secure STM32 MPU.
In U-Boot console:
stm32key close
For more information, see the How to use U-Boot stm32key command.
As soon as the device is closed, the operation is irreversible; the user is forced to only use signed images.
9. Summary[edit | edit source]
9.1. For STM32MP1 series[edit | edit source]
Generate a Distribution Package with signed and "signed/encrypted" configurations for STM32MP13x lines
.
Generate a Distribution Package with signed and signed/encrypted configurations for STM32MP15x lines
.
9.2. For STM32MP2 series with A35-TD flavor
[edit | edit source]
Generate a Distribution Package with signed and signed/encrypted configuration for STM32MP21x lines
with A35-TD flavor
.
Generate a Distribution Package with signed and signed/encrypted configurations for STM32MP23x lines
with A35-TD flavor
.
Generate a Distribution Package with signed and signed/encrypted configurations for STM32MP25x lines
with A35-TD flavor
.
9.3. ForSTM32MP2 series with M33-TD flavor
[edit | edit source]
Generate a Distribution Package with signed or signed/encrypted configurations for STM32MP21x lines
with M33-TD flavor
.
Generate a Distribution Package with signed or signed/encrypted configurations for STM32MP23x lines
with M33-TD flavor
.
Generate a Distribution Package with signed or signed/encrypted configurations for STM32MP25x lines
with M33-TD flavor
.
10. References[edit | edit source]