@@ -117,24 +117,48 @@ By default, when a new keystore is created, the permissions mask is set
117117to ` KEY_VERIFY_ALL ` , which means that the key can be used to verify a firmware
118118targeting any partition id.
119119
120- To restrict the permissions for single keys, it would be sufficient to change the value
121- of their ` part_id_mask ` attributes.
122-
123120The ` part_id_mask ` value is a bitmask, where each bit represent a different partition.
124121The bit '0' is reserved for wolfBoot self-update, while typically the main firmware partition
125122is associated to id 1, so it requires a key with the bit '1' set. In other words, signing a
126123partition with ` --id 3 ` would require turning on bit '3' in the mask, i.e. adding (1U << 3) to it.
127124
128- Beside ` KEY_VERIFY_ALL ` , pre-defined mask values can also be used here:
125+ To restrict the permissions for single keys, it would be sufficient to change the value
126+ of each key ` part_id_mask ` . This is done via the ` --id ` command line option for keygen.
127+ Each generated or imported key can be associated with a number of partition by passing the
128+ partition IDs in a comma-separated list, e.g.:
129+
130+ ```
131+ keygen --ecc256 -g generic.key --id 1,2,3 -g restricted.key
132+ ```
129133
130- - ` KEY_VERIFY_APP_ONLY ` only verifies the main application, with partition id 1
131- - ` KEY_VERIFY_SELF_ONLY ` this key can only be used to authenticate wolfBoot self-updates (id = 0)
132- - ` KEY_VERIFY_ONLY_ID(N) ` macro that can be used to restrict the usage of the key to a specific partition id ` N `
134+ Generates two keypairs, ` generic.key ` and ` restricted.key ` . The former assumes the
135+ default mask ` KEY_VERIFY_ALL ` , which makes it possible to use it to authenticate any
136+ of the system components. The latter instead, will carry a mask with only the bits
137+ '1', '2', and '3' set (mask = b00001110 =0x000e), allowing the usage only with the assigned
138+ partition IDs.
133139
134140
135141### Importing public keys
136142
137- Work in progress.
143+ The "-i" option is used to import existing public keys into the keyvault. The usage is identical to the '-g' option, except that
144+ the file provided must exist and contain a valid public key of the given algorithm and key size.
145+
146+ ### Generating and importing keys of different types
147+
148+ By default, wolfBoot hardcodes the type of key used for all the signature verification operations into the keystore format.
149+
150+ Alternatively, wolfBoot can be compiled with the option ` WOLFBOOT_UNIVERSAL_KEYSTORE=1 ` , which disables the check at compile
151+ time and allows adding keys of different types to the keystore. For example, if we want to create two keypairs with different ECC curves,
152+ and additionally store a pre-existing RSA2048 public key file ` rsa-pub.der ` , we could run the following:
153+
154+ ` keygen --ecc256 -g a.key --ecc384 -g b.key --rsa2048 -i rsa-pub.der `
155+
156+ The command above generates a keystore with three public keys that are accessible by the bootloader at runtime.
157+
158+ Please note that by default wolfBoot does not include any public key algorithm implementations besides the one
159+ selected via the option ` SIGN= ` , so usually this feature is reserved to specific use cases where other policies or components
160+ in the chain-of-trust require to store different key types for different purposes.
161+
138162
139163## Using KeyStore with external Key Vaults
140164
@@ -152,7 +176,7 @@ The API consists of a few functions described below.
152176
153177Returns the number of slots in the keystore. At least one slot
154178should be populated if you want to authenticate your firmware today.
155- The interface assumes that the slots are numbered sequentially, from zero to
179+ The interface assumes that the slots are numbered sequentially, from zero to
156180` keystore_num_pubkeys() - 1 ` . Accessing those slots through this API should always
157181 return a valid public key.
158182
@@ -174,5 +198,3 @@ public key associated to the slot `id`.
174198` uint32_t keystore_get_mask(int id) `
175199
176200Returns the permissions mask, as a 32-bit word, for the public key stored in the slot ` id ` .
177-
178-
0 commit comments