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/Signing.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ wolfBoot also supports verifying firmware images using certificate chains instea
128
128
129
129
To generate an image for use with this mode, pass the `--cert-chain CERT_CHAIN.der` option to the sign tool, where `CERT_CHAIN.der` is a der encoded certificate chain containing one or more certificates in SSL order (leaf/signer cert last). Note that the sign tool still expects a signing private key to be provided as described above, and assumes that the public key of the signer cert in the chain corresponds to the signing private key.
130
130
131
-
When building wolfBoot and the test app with the Makefile, certificate chain signing can be configured using the following variables:
131
+
When building wolfBoot and the test app with the Makefile, the `USER_*` variables provide a convenience for using your own locally-managed keys and certificate chain, avoiding manual `keygen -i` and file placement steps:
-`USER_PRIVATE_KEY`: Path to your leaf signing key (DER format)
@@ -143,9 +143,12 @@ make CERT_CHAIN_VERIFY=1 \
143
143
USER_PUBLIC_KEY=my-leaf-pubkey.der \
144
144
USER_CERT_CHAIN=my-cert-chain.der
145
145
```
146
-
Note that it is up to the user to guarantee that `USER_PUBLIC_KEY` and `USER_PRIVATE_KEY` both correspond to the leaf certificate identity in the chain.
147
146
148
-
If `USER_CERT_CHAIN` is not provided when `CERT_CHAIN_VERIFY=1`, a dummy certificate hierarchy is auto-generated for testing. See the [Compiling wolfBoot](compile.md#key-generation-and-signing) documentation for full details on these options.
147
+
Note that `USER_PUBLIC_KEY` and `USER_PRIVATE_KEY` must correspond to the leaf certificate identity in the chain.
148
+
149
+
If `USER_CERT_CHAIN` is not provided when `CERT_CHAIN_VERIFY=1`, a dummy certificate hierarchy is auto-generated for testing. See the [Compiling wolfBoot](compile.md#pre-existing-local-keys-for-test-app-builds) documentation for full details on these options.
150
+
151
+
**Note:** If your private key is managed by a third party and you only have access to the public key, use `keygen -i` to import it instead. See the [Keygen tool](#keygen-tool) section above.
149
152
150
153
Certificate chain verification of images is currently limited to use in conjunction with wolfHSM. See [wolfHSM.md](wolfHSM.md) for more details.
Copy file name to clipboardExpand all lines: docs/compile.md
+38-20Lines changed: 38 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,9 +369,13 @@ The key algorithm is determined by the `SIGN` variable (e.g., `SIGN=ECC256`, `SI
369
369
370
370
For most targets, the makefile also builds the wolfBoot test app and signs it with the aforementioned key.
371
371
372
-
### User-Provided Keys
372
+
### Pre-existing Local Keys for Test App Builds
373
373
374
-
Instead of auto-generating keys, you can provide your own pre-existing keys for use with the test app by using the following Makefile variables:
374
+
The `USER_*` Makefile variables provide a convenience for building the test app with your own locally-managed keys, avoiding the need to manually run `keygen -i` and place key files before building.
375
+
376
+
**Note:** If your private key is managed by a third party (e.g., HSM-as-a-service, Azure KeyVault) and you only have access to the public key, use the `keygen -i` option instead. See [Signing.md](Signing.md#keygen-tool) and [Manual Key Management](#manual-key-management) below.
377
+
378
+
The following variables are available:
375
379
376
380
-`USER_PRIVATE_KEY`: Path to your private signing key (DER format)
377
381
-`USER_PUBLIC_KEY`: Path to your public key (DER format)
@@ -385,22 +389,22 @@ make USER_PRIVATE_KEY=/path/to/my-signing-key.der \
385
389
386
390
#### Requirements
387
391
388
-
- Both `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY` must be provided together. You cannot supply one without the other.
392
+
- Both `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY` must be provided together
389
393
- Keys must be in DER format appropriate for the selected `SIGN` algorithm
390
394
391
-
When user-provided keys are specified:
395
+
When these variables are specified, the build:
392
396
393
-
1.The build skips auto-generation of `wolfboot_signing_private_key.der`
394
-
2.The keystore (`src/keystore.c`) is generated from your public key
395
-
3.Your private key is used for all signing operations
397
+
1.Skips auto-generation of `wolfboot_signing_private_key.der`
398
+
2.Generates the keystore (`src/keystore.c`) from your public key via `keygen -i`
399
+
3.Uses your private key to sign the test app
396
400
397
-
The `USER_` variables are meant to simplify the wolfBoot "demo" behavior where wolfBoot boots a simple test app.
401
+
This is primarily useful when you want a single `make` invocation to build wolfBoot and a signed test app using keys you've generated externally. For wolfBoot-only builds (without the test app), the main benefit is automating the `keygen -i` step for simple single-key keystores. If you need multiple keys in the keystore then you must invoke `keygen -i` manually before building wolfBoot.
398
402
399
-
### User-Provided Certificate Chain
403
+
### Pre-existing Certificate Chain for Test App Builds
400
404
401
-
When using certificate chain verification (`CERT_CHAIN_VERIFY=1`), you can also provide your own certificate chain:
405
+
When building the test app using certificate chain verification (`CERT_CHAIN_VERIFY=1`), you can provide your own certificate chain:
402
406
403
-
-`USER_CERT_CHAIN`: Path to your certificate chain (DER format, wolfHSM order with leaf last)
407
+
-`USER_CERT_CHAIN`: Path to your certificate chain (DER format, leaf cert last)
404
408
405
409
**Usage:**
406
410
@@ -413,24 +417,38 @@ make CERT_CHAIN_VERIFY=1 \
413
417
414
418
**Requirements:**
415
419
416
-
-`USER_CERT_CHAIN` requires both `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY` to be set
417
-
- The user-supplied private and public keys must correspond to the identity of the leaf certificate in the chain
420
+
-`USER_CERT_CHAIN` requires both `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY`
421
+
- The private and public keys must correspond to the leaf certificate identity in the chain
422
+
423
+
When `CERT_CHAIN_VERIFY=1` is set without `USER_CERT_CHAIN`, the build auto-generates a dummy 3-tier certificate hierarchy in `test-dummy-ca/` for testing. This also applies to wolfHSM NVM image generation when applicable.
418
424
419
-
When `CERT_CHAIN_VERIFY=1` is set without `USER_CERT_CHAIN`, the build system auto-generates a dummy 3-tier certificate hierarchy (root CA, intermediate, and leaf) in the `test-dummy-ca/` directory for testing purposes. This is then used to sign the test app.
425
+
### Manual Key Management
420
426
421
-
### Manual Key Generation
427
+
For advanced scenarios (multiple keys, mixed algorithms, partition-restricted keys, or third-party managed private keys), use the `keygen` tool directly instead of the `USER_*` variables.
422
428
423
-
As an alternative to the `USER_*` variables, you can manually fulfill the build dependencies:
429
+
**Importing a public key (when private key is externally managed):**
This creates `src/keystore.c` from your public key. Signing must then be performed in two steps following the steps outlined in [Signing.md](./Signing.md#signing-firmware-with-external-private-key-hsm)
436
+
437
+
438
+
**Using locally-managed keys without `USER_XXX` variables:**
439
+
440
+
1. Import your public key to generate the keystore:
The build system will detect these existing files and skip auto-generation when make is subsequently invoked. This approach is required when more advanced options like multiple public keys in the keystore are required. In these cases, the keystore generation using the keygen tool and image signing via the sign tool must be performed manually.
450
+
Now the build system detects existing files and skips auto-generation when building wolfBoot and the test app.
451
+
452
+
**Multiple keys and advanced keystores:**
453
+
454
+
The `keygen` tool supports multiple `-g` (generate) and `-i` (import) arguments, mixed key algorithms, and partition ID restrictions. See [keystore.md](keystore.md) for full details on keystore capabilities. When using these advanced features, image signing via the `sign` tool must also be performed manually.
Copy file name to clipboardExpand all lines: docs/keystore.md
+20-6Lines changed: 20 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,12 +222,26 @@ wolfBoot supports certain platforms that contain connected HSMs (Hardware Securi
222
222
223
223
To support this mode of operation, the `keygen` tool supports the `--nolocalkeys` option, which instructs the tool to generate a keystore entry with a zeroed key material. It still generates the `.der` files for private and public keys, so the wolfBoot key tools can sign images, but the `keystore.c` file that is linked into wolfBoot will contain all zeros in the `pubkey` field. Because the key material isn't present in the keystore, the keypair used to sign the image and stored on the HSM for verification can be updated in the field without needing to rebuild wolfBoot against a new `keystore.c`, as long as the signature algorithm and key size does not change. Most targets that use this option will automatically add it to the key generation options or explicitly mention this step in the build documentation.
224
224
225
-
## Using User-Provided Keys with the Keystore and Build System
225
+
## Build System Integration
226
226
227
-
By default, when running `make` for the first time, wolfBoot automatically generates:
228
-
- A signing keypair at `wolfboot_signing_private_key.der`
229
-
- The keystore module at `src/keystore.c` containing the corresponding public key
227
+
By default, when running `make` to build the default target (`factory.bin`) for the first time, wolfBoot automatically generates a signing keypair and creates a single-key keystore as a "demonstration". This is distinct from using `keygen` directly with `-g` or `-i` options, which provides full control over keystore creation.
230
228
231
-
This default behavior can be overridden using the `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY` Makefile variables, allowing you to use externally-managed keys for building the test application and keystore.
229
+
### Default `make` Behavior
232
230
233
-
See [compile.md](./compile.md#key-generation-and-signing) for more information
231
+
Running `make` without creating the expected pre-existing keys automatically:
232
+
- Generates a signing keypair at `wolfboot_signing_private_key.der`
233
+
- Creates the keystore at `src/keystore.c` with the corresponding public key
234
+
235
+
Note that supplying either of these dependencies manually will cause the build system to skip the generation step
236
+
237
+
### Pre-existing Local Keys for Test App Builds
238
+
239
+
The `USER_PRIVATE_KEY` and `USER_PUBLIC_KEY` Makefile variables provide a convenience for building the test app with your own locally-managed keys, avoiding manual `keygen -i` invocation:
240
+
241
+
```sh
242
+
make USER_PRIVATE_KEY=/path/to/my-key.der USER_PUBLIC_KEY=/path/to/my-pubkey.der
243
+
```
244
+
245
+
This is primarily useful for test app builds where you wish to use your own PKI as a test. For wolfBoot-only builds, the main benefit is automating the `keygen -i` step for simple single-key keystores.
246
+
247
+
**Note:** If your private key is managed by a third party (e.g., HSM-as-a-service) and you only have access to the public key, use `keygen -i` directly instead. See [Signing.md](./Signing.md#signing-firmware-with-external-private-key-hsm) and [compile.md](./compile.md#pre-existing-local-keys-for-test-app-builds) for full details regarding this use case.
0 commit comments