You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/compile.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,6 +279,10 @@ You can also manually override the fill bytes using `FILL_BYTE=` at build-time.
279
279
280
280
Note: if you are using an external FLASH (e.g. SPI) in combination with a flash with inverted logic, ensure that you store all the flags in one partition, by using the `FLAGS_HOME=1` option described above.
281
281
282
+
### Using One-time programmable (OTP) flash as keystore
283
+
284
+
By default, keys are directly incorporated in the firmware image. To store the keys in a separate, one-time programmable (OTP) flash memory, use the `FLASH_OTP_KEYSTORE=1` option.
285
+
For more information, see [/docs/OTP-keystore.md](/docs/OTP-keystore.md).
## Using One-Time Programmable (OTP) flash area for keystore
2
+
3
+
Some microcontrollers provide a special area in flash memory that can
4
+
only be written once and cannot be erased.
5
+
6
+
This feature comes particularly handy when you want to store the public keys required
7
+
to authenticate the firmware update images, which has exactly the same requirements. A public
8
+
key is a cryptographic key that can be freely distributed and is used to verify the signature
9
+
of the firmware update image. By storing the public keys in the OTP area, you can ensure that
10
+
they are immutable and cannot be tampered with.
11
+
12
+
### Compiling wolfBoot to access OTP as keystore
13
+
14
+
To use the OTP area as a keystore, you need to compile wolfBoot with the `FLASH_OTP_KEYSTORE`
15
+
option enabled. This option is disabled by default, which means that the keystore is incorporated into
16
+
the wolfBoot binary itself.
17
+
18
+
When wolfBoot uses the OTP area as a keystore, it reads the public keys from the OTP area at runtime.
19
+
The public keys are stored in the OTP area, after an initial 16-byte header that contains the number of
20
+
keys stored, the size of each key, and other information.
21
+
22
+
In order for wolfBoot to start authenticating the firmware images at boot and upon update, the public keys
23
+
must be provisioned to the OTP area in a separate step, as described in the next section.
24
+
25
+
### Provisioning the public keys to the OTP area
26
+
27
+
After enabling the `FLASH_OTP_KEYSTORE` option in your `.config` file, when you compile wolfBoot by running "make",
28
+
an additional application called `otp-keystore-primer` is generated under `tools/keytools/otp`. This application is used to
29
+
provision the public keys to the OTP area. By flashing this application to the microcontroller, the public keys contained
30
+
in your keystore (previously generated by `keygen`) are written to the OTP area.
31
+
32
+
The `otp-keystore-primer` application is generated with the public keys embedded in it. The keys are retrieved from the `keystore.c` file,
33
+
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.
34
+
35
+
After generating a new `keystore.c` with the `keygen` application, you can generate the `otp-keystore-primer` application again, by running `make otp`.
36
+
37
+
> [!WARNING]
38
+
> 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,
39
+
> 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,
40
+
> 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.
41
+
42
+
> [!CAUTION]
43
+
> ** Be very careful when using the `otp-keystore-primer` application. Use it at your own risk. **
0 commit comments