forked from wolfSSL/wolfBoot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wolfSSL#449 from danielinux/stm32h7_otp
Support for OTP Flash as trust anchor for keystore
- Loading branch information
Showing
26 changed files
with
1,497 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
ARCH?=ARM | ||
TZEN?=1 | ||
TARGET?=stm32h5 | ||
SIGN?=ECC256 | ||
HASH?=SHA256 | ||
DEBUG?=0 | ||
VTOR?=1 | ||
CORTEX_M0?=0 | ||
CORTEX_M33?=1 | ||
NO_ASM?=0 | ||
NO_MPU=1 | ||
EXT_FLASH?=0 | ||
SPI_FLASH?=0 | ||
ALLOW_DOWNGRADE?=0 | ||
NVM_FLASH_WRITEONCE?=1 | ||
WOLFBOOT_VERSION?=1 | ||
V?=0 | ||
SPMATH?=1 | ||
RAM_CODE?=0 | ||
DUALBANK_SWAP?=1 | ||
WOLFBOOT_PARTITION_SIZE?=0xC0000 | ||
WOLFBOOT_SECTOR_SIZE?=0x2000 | ||
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08040000 | ||
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x8140000 | ||
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xFFFFFFFF | ||
FLAGS_HOME=0 | ||
DISABLE_BACKUP=0 | ||
FLASH_OTP_KEYSTORE=1 | ||
WOLFCRYPT_TZ=1 | ||
WOLFCRYPT_TZ_PKCS11=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## Using One-Time Programmable (OTP) flash area for keystore | ||
|
||
Some microcontrollers provide a special area in flash memory that can | ||
only be written once and cannot be erased. | ||
|
||
This feature comes particularly handy when you want to store the public keys required | ||
to authenticate the firmware update images, which has exactly the same requirements. A public | ||
key is a cryptographic key that can be freely distributed and is used to verify the signature | ||
of the firmware update image. By storing the public keys in the OTP area, you can ensure that | ||
they are immutable and cannot be tampered with. | ||
|
||
### Compiling wolfBoot to access OTP as keystore | ||
|
||
To use the OTP area as a keystore, you need to compile wolfBoot with the `FLASH_OTP_KEYSTORE` | ||
option enabled. This option is disabled by default, which means that the keystore is incorporated into | ||
the wolfBoot binary itself. | ||
|
||
When wolfBoot uses the OTP area as a keystore, it reads the public keys from the OTP area at runtime. | ||
The public keys are stored in the OTP area, after an initial 16-byte header that contains the number of | ||
keys stored, the size of each key, and other information. | ||
|
||
In order for wolfBoot to start authenticating the firmware images at boot and upon update, the public keys | ||
must be provisioned to the OTP area in a separate step, as described in the next section. | ||
|
||
### Provisioning the public keys to the OTP area | ||
|
||
After enabling the `FLASH_OTP_KEYSTORE` option in your `.config` file, when you compile wolfBoot by running "make", | ||
an additional application called `otp-keystore-primer` is generated under `tools/keytools/otp`. This application is used to | ||
provision the public keys to the OTP area. By flashing this application to the microcontroller, the public keys contained | ||
in your keystore (previously generated by `keygen`) are written to the OTP area. | ||
|
||
The `otp-keystore-primer` application is generated with the public keys embedded in it. The keys are retrieved from the `keystore.c` file, | ||
generated by the `keygen` command. The `otp-keystore-primer` application reads the public keys from the `keystore.c` file and writes them to the OTP area. | ||
|
||
After generating a new `keystore.c` with the `keygen` application, you can generate the `otp-keystore-primer` application again, by running `make otp`. | ||
|
||
> [!WARNING] | ||
> The `otp-keystore-primer` application is a one-time use application. Once the application runs on your target, the public keys are written to the OTP area, | ||
> and it will be impossible to erase them. Therefore, it is important to ensure that the public keys are correct before provisioning them to the OTP area, | ||
> and that the associated private keys are stored securely. Accidentally losing the private keys will render the public keys stored in the OTP area useless. | ||
> [!CAUTION] | ||
> ** Be very careful when using the `otp-keystore-primer` application. Use it at your own risk. ** | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.