Skip to content

Commit a6a9f58

Browse files
authored
Merge pull request #1238 from Dasharo/sealed-capsules
Updates for sealed capsules
2 parents 9f5391c + ce83a18 commit a6a9f58

4 files changed

Lines changed: 89 additions & 16 deletions

File tree

docs/guides/capsule-update.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ mentioned, it means that it doesn't support this update method.
2929
| NovaCustom | NUC BOX | v0.9.0 ||
3030
| Protectli | Vault VP66xx | v0.9.3 ||
3131

32+
!!! note
33+
34+
Enforcing capsule authentication in V2 made newer capsules incompatible
35+
with the older ones. The first release with V2 publishes capsules of the
36+
older kind which can be used to upgrade from prior releases, but starting
37+
with this release **older capsules are no longer accepted** to not
38+
compromise capsule authentication enhancements.
39+
3240
## Prerequisites
3341

3442
* _UEFI Shell_<br>

docs/kb/capsule-updates-configs.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
# Capsule Update releases
22

33
Dasharo releases that support Capsule Updates need to include a number of
4-
additional options in their coreboot configuration file. The options correspond
5-
to the required payload data described in
6-
[Capsule Updates Details - Required Payload Data](./edk2-capsule-updates.md#capsule-information)
4+
additional options in their coreboot configuration file. The most important
5+
options directly correspond to the required payload data described in
6+
[Capsule Updates Details - Required Payload Data](./edk2-capsule-updates.md#capsule-information).
77

88
## Configuration
99

1010
The coreboot configuration file can be found in the coreboot repository
1111
in the `configs/` directory under the name of
1212
`config.<coreboot_mainboard_vendor>_<coreboot_mainboard_model>`.
1313

14-
The options that need to be set are:
14+
The options that must be set are:
1515

16-
- `CONFIG_DRIVERS_EFI_MAIN_FW_GUID`
17-
- `CONFIG_DRIVERS_EFI_MAIN_FW_VERSION`
18-
- `CONFIG_DRIVERS_EFI_MAIN_FW_LSV`
16+
- [`CONFIG_DRIVERS_EFI_MAIN_FW_GUID`](#config_drivers_efi_main_fw_guid)
17+
- [`CONFIG_DRIVERS_EFI_MAIN_FW_VERSION`](#config_drivers_efi_main_fw_version)
18+
- [`CONFIG_DRIVERS_EFI_MAIN_FW_LSV`](#config_drivers_efi_main_fw_lsv)
19+
20+
The following settings may not be set (read their description to know under
21+
which conditions):
22+
23+
- [`CONFIG_EDK2_CAPSULES_V2`](#config_edk2_capsules_v2)
24+
- [`CONFIG_EDK2_CAPSULES_V2_TRANSITION`](#config_edk2_capsules_v2_transition)
1925

2026
### CONFIG_DRIVERS_EFI_MAIN_FW_GUID
2127

@@ -40,8 +46,8 @@ Capsule Update.
4046
The `CONFIG_LOCALVERSION` option is a string representation of the version
4147
which does not allow reliable comparisons.
4248
The value consists of 8 hexadecimal digits which are grouped
43-
into four groups of two numbers. Each group represents a single component of
44-
a Dasharo version according to the [Versioning](https://docs.dasharo.com/dev-proc/versioning/)
49+
into four groups of two digits. Each group represents a single component of
50+
a Dasharo version according to the [Versioning](../dev-proc/versioning.md).
4551
`CONFIG_DRIVERS_EFI_MAIN_FW_VERSION` has to be updated on new releases to always
4652
match the `CONFIG_LOCALVERSION`.
4753

@@ -67,8 +73,38 @@ The value represents the lowest firmware version, that will be accepted as
6773
a valid one. A Capsule Update to a version lower than
6874
`CONFIG_DRIVERS_EFI_MAIN_FW_LSV` will not be allowed. May be used to forbid
6975
downgrading to versions with severe security vulnerabilities. The value
70-
takes the same format as `CONFIG_DRIVERS_EFI_MAIN_FW_VERSION`
76+
takes the same format as `CONFIG_DRIVERS_EFI_MAIN_FW_VERSION`.
7177

7278
Examples:
7379

7480
- Forbid changing the version to anything below release v0.1.0 - `CONFIG_DRIVERS_EFI_MAIN_FW_LSV="0x00010080"`
81+
82+
### CONFIG_EDK2_CAPSULES_V2
83+
84+
This boolean option enables more advanced features:
85+
86+
- Enforcing authentication of capsule images before processing them.
87+
- Vendor's logo shown on the screen during an update, scaled proportionally.
88+
- Smoother progress bar increments that better reflect amount of work done/left.
89+
- Pop-up reporting success/failure of the firmware update with some diagnostic
90+
information.
91+
- Best-effort recovery if the update has failed halfway.
92+
93+
Some devices don't have this option set, but newer releases may transition to
94+
this version of capsules (see
95+
[`CONFIG_EDK2_CAPSULES_V2_TRANSITION`](#config_edk2_capsules_v2_transition)).
96+
Devices that have capsules enabled for the first time should preferably use
97+
this option from the start to avoid transitioning later.
98+
99+
### CONFIG_EDK2_CAPSULES_V2_TRANSITION
100+
101+
This boolean option marks a release as transitional from initial capsule
102+
implementation (v1) to a more advanced version (v2). Due to authentication
103+
changes capsules can only be processed by an appropriate firmware (i.e.,
104+
v1-firmware and v1-capsule, v2-firmware and v2-capsule), which on its own makes
105+
upgrading to a v2-firmware via capsules impossible. Enabling this option
106+
requests [`capsule.sh` script](./edk2-capsule-updates.md#capsulesh-script) to
107+
build v1-capsule for a v2-firmware thus permitting updates from v1-firmware.
108+
109+
This option needs to be set only for a single public release, the first one that
110+
gets `CONFIG_EDK2_CAPSULES_V2` set after using v1-capsules in previous releases.

docs/kb/capsule-updates-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ on the user, resulting in higher probability of making a mistake.
3333
### Embedded Flashing Code
3434

3535
Firmware reads and writes system flash chip as part of its normal operation.
36-
Capsule update mechanism reuses very same code to switch to a different firmware
37-
image.
36+
Capsule update mechanism reuses the very same code to switch to a different
37+
firmware image.
3838

3939
This way the means for firmware update are always there and require only minimal
4040
extra input to submit the capsule for an update.
@@ -53,7 +53,7 @@ require use of several firmware update tools in the right order.
5353
The metadata can even take into account compatibility requirements between
5454
firmware of different components. For example, if you're trying to update a
5555
system firmware which requires EC version 1.2 but currently running EC firmware
56-
is of version 1.1, the update will no happen, likely avoiding bricking the
56+
is of version 1.1, the update will not happen, likely avoiding bricking the
5757
device.
5858

5959
### Convenience

docs/kb/edk2-capsule-updates.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,31 @@ of the output JSON file.
294294

295295
The verification of capsules is performed via
296296
[public-key cryptography][wiki-pkc] (the concepts most relevant here: key pairs
297-
and subkeys). This security mechanism uses a root key pair like this:
297+
and subkeys). This security mechanism is meant to use a root key pair like
298+
this:
298299

299300
1. Public key is embedded into the firmware at build time (one key is enough,
300301
but using multiple keys is also supported).
301302
2. Private key is used to (indirectly, via a subkey) sign capsules.
302303
3. Signature embedded in the capsule is validated against the public key when
303304
an update is attempted to decide whether to perform the update.
304305

305-
Things to note:
306+
The above describes a situation when `FmpDxe` is part of the firmware rather
307+
than a capsule. The latter is more desirable in practice because it distributes
308+
update code in the capsule, thus permitting changes to the update process which
309+
were not anticipated at the time of the previous release. Because `FmpDxe` is
310+
the entity responsible for capsule verification, moving it into the capsule
311+
removes the security guarantee unless it's enforced by other means.
312+
`SignedCapsulePkg` is one way of addressing this situation which it does by
313+
having a two-part driver: a smaller part lives in the firmware and another one
314+
goes into capsules. However, `SignedCapsulePkg` comes with a lot of baggage
315+
and is hard to use when EDK is a payload for a multitude of different devices,
316+
which is why [sealed capsules] were implemented as a much simpler alternative.
317+
In short: an update capsule with `FmpDxe` is embedded as a payload of a capsule
318+
with no drivers, firmware checks signature on the outer capsule's payload and
319+
then processes the inner capsule in its place.
320+
321+
More things to note:
306322

307323
- public root key is well-known
308324
- private root key is stored in a safe place and nobody but the owner should
@@ -328,6 +344,7 @@ versions will be compatible with one another (unless `LowestSupportedVersion`
328344
interferes).
329345

330346
[wiki-pkc]: https://en.wikipedia.org/wiki/Public-key_cryptography
347+
[sealed capsules]: https://github.com/tianocore/edk2/pull/12254
331348

332349
## Generating signing keys with OpenSSL
333350

@@ -440,7 +457,7 @@ for these types of files in general, so don't read too much meaning into them.
440457

441458
#### Prepare _root_ for EDK build system
442459

443-
EDK gets _root_ certificate(s) in a PCD. The PCD name differ and support one
460+
EDK gets _root_ certificate(s) in a PCD. The PCD names differ and support one
444461
or many certificates, in this case it's
445462
`gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr` which expects one
446463
or more certificates in DER (binary) form combined via XDR (simple format where
@@ -687,6 +704,18 @@ Output file name is generated based on coreboot options like
687704
- `emulation-qemu-q35-v0.2.0.cap`
688705
- `msi-ms7d25-ddr4-v1.1.9.cap`
689706

707+
### Sealed capsules
708+
709+
When `CONFIG_EDK2_CAPSULES_V2` is set but `CONFIG_EDK2_CAPSULES_V2_TRANSITION`
710+
isn't, `capsule.sh` produces a two-level capsule where the outer one is signed
711+
by the keys specified by the parameters and the inner one is signed with EDK's
712+
test keys.
713+
714+
The inner capsule is signed because `FmpDxe` fails if there is no signature.
715+
The test keys are used because it doesn't matter what the keys are as long as
716+
the signature is valid and matches root key embedded into `FmpDxe` (not to be
717+
confused with the key embedded into the firmware itself).
718+
690719
### Generating test signing keys
691720

692721
In order to test capsules signed with unsupported keys, one needs to generate a

0 commit comments

Comments
 (0)