Skip to content

Commit e14165a

Browse files
committed
Add support for PCR predictions and measured boot
Add PCR-prediction nodes to allow storing expected TPM PCR values in configurations, enabling TPM policy binding where secrets sealed to expected PCR values can only be unsealed when the correct images are loaded. Use the existing signature-node structure to sign the PCR predictions for remote attestation, and document the measured boot algorithm specifying the order in which images are measured: kernel, ramdisk, loadables, fdt (with overlays), and cmdline. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
1 parent 1be2a60 commit e14165a

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed

source/chapter2-source-file-format.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ signature-1
551551
Each signature sub-node represents a separate signature
552552
calculated for the configuration according to specified algorithm.
553553

554+
pcr-1
555+
Each PCR-prediction sub-node represents an expected PCR value
556+
for a particular TPM bank. See :ref:`pcr_prediction_nodes`.
557+
554558

555559
Configuration nodes
556560
-------------------
@@ -567,6 +571,7 @@ Each configuration has the following structure::
567571
|- script = "script sub-node unit-name";
568572
|- compatible = "vendor,board-style device tree compatible string";
569573
o signature-1 {...}
574+
o pcr-1 {...}
570575

571576
Mandatory properties
572577
~~~~~~~~~~~~~~~~~~~~
@@ -691,5 +696,97 @@ padding
691696
if no value is provided we assume pkcs-1.5
692697

693698

699+
.. index:: PCR-prediction nodes
700+
701+
.. _pcr_prediction_nodes:
702+
703+
PCR-prediction nodes
704+
--------------------
705+
706+
PCR-prediction nodes allow a FIT to include expected Platform Configuration
707+
Register (PCR) values.
708+
These values represent what the PCR should contain after the bootloader has
709+
measured the configuration's images into the TPM.
710+
This enables TPM policy binding,
711+
where secrets sealed to expected PCR values can only be unsealed when the
712+
correct images are loaded.
713+
714+
::
715+
716+
o pcr-1
717+
|- description = "PCR11 sha256 bank"
718+
|- pcr = <11>;
719+
|- algo = "sha256";
720+
|- value = [expected PCR value]
721+
722+
Mandatory properties
723+
~~~~~~~~~~~~~~~~~~~~
724+
725+
pcr
726+
The PCR index.
727+
PCR 11 is conventionally used for kernel and related components.
728+
729+
algo
730+
Hash algorithm for this PCR bank.
731+
Supported algorithms are:
732+
733+
=========== ============ ==========================================
734+
Algorithm Size (bytes) Meaning
735+
=========== ============ ==========================================
736+
sha256 32 Secure Hash Algorithm 2 (SHA256)
737+
sha384 48 Secure Hash Algorithm 2 (SHA384)
738+
sha512 64 Secure Hash Algorithm 2 (SHA512)
739+
=========== ============ ==========================================
740+
741+
value
742+
Expected PCR value after all images have been measured.
743+
This is computed by the signing tool based on the measurement algorithm
744+
described in :ref:`measured_boot`.
745+
746+
Optional properties
747+
~~~~~~~~~~~~~~~~~~~
748+
749+
description
750+
Textual description of this PCR prediction.
751+
752+
Multiple PCR-prediction nodes may be present to support different TPM banks
753+
(e.g., both sha256 and sha384).
754+
755+
Signing PCR predictions
756+
~~~~~~~~~~~~~~~~~~~~~~~
757+
758+
PCR-prediction nodes can be signed using a standard configuration signature
759+
node to enable remote attestation and TPM policy binding.
760+
The signature covers the PCR-prediction node values,
761+
allowing a remote party to verify the expected measurements were produced by
762+
a trusted authority.
763+
764+
To sign PCR predictions, include the PCR-prediction nodes in the signature's
765+
``hashed-nodes`` property::
766+
767+
o config-1
768+
|- description = "Boot configuration with PCR predictions";
769+
|- kernel = "kernel";
770+
|- fdt = "fdt-1";
771+
o pcr-1
772+
|- pcr = <11>;
773+
|- algo = "sha256";
774+
|- value = [expected PCR value for sha256 bank]
775+
o pcr-2
776+
|- pcr = <11>;
777+
|- algo = "sha384";
778+
|- value = [expected PCR value for sha384 bank]
779+
o signature-1
780+
|- algo = "sha256,rsa2048";
781+
|- key-name-hint = "pcr-policy-key";
782+
|- hashed-nodes = "/configurations/config-1/pcr-1",
783+
"/configurations/config-1/pcr-2";
784+
|- value = [signature value]
785+
786+
In this example, the signature covers two PCR-prediction nodes for different
787+
TPM banks (sha256 and sha384),
788+
allowing a single signature to attest to all bank predictions.
789+
790+
694791
.. sectionauthor:: Marian Balakowicz <m8@semihalf.com>
695792
.. sectionauthor:: External data additions, 25/1/16 Simon Glass <sjg@chromium.org>

source/chapter3-usage.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,61 @@ For more information on FIT security, see
252252
The mechanism is also widely covered in conference talks, some of which are
253253
listed at `elinux.org <https://elinux.org/Boot_Loaders#U-Boot>`_.
254254

255+
.. _measured_boot:
256+
257+
Measured boot
258+
-------------
259+
260+
FIT supports measured boot through integration with a Trusted Platform Module
261+
(TPM).
262+
When enabled, the bootloader extends a PCR with measurements of each image
263+
before loading it.
264+
This creates a cryptographic record of what was booted,
265+
enabling attestation and TPM-sealed secrets.
266+
267+
Measurement algorithm
268+
~~~~~~~~~~~~~~~~~~~~~
269+
270+
Images are measured in the following order:
271+
272+
#. kernel or firmware
273+
#. ramdisk (if present)
274+
#. loadables (each image, in the order specified)
275+
#. fdt (each blob and overlay, in the order specified)
276+
#. cmdline (if present in the configuration)
277+
278+
For each item, the measurement is performed as::
279+
280+
PCR = hash(PCR || hash(data))
281+
282+
Where:
283+
284+
- ``PCR`` is the current PCR value (initially all zeros if the PCR was reset)
285+
- ``hash`` is the TPM bank's hash algorithm (e.g., SHA-256)
286+
- ``data`` is the raw image data, after any decompression
287+
288+
Only the image data is measured, not metadata such as load addresses,
289+
compression type, or image descriptions.
290+
For cmdline, the UTF-8 encoded string value is measured directly.
291+
292+
The signing tool can pre-calculate expected PCR values using this algorithm.
293+
These values may be stored in PCR-prediction nodes within the configuration.
294+
295+
TPM policy binding
296+
~~~~~~~~~~~~~~~~~~
297+
298+
Expected PCR values enable TPM policy binding.
299+
Secrets can be sealed to a TPM policy that requires specific PCR values.
300+
The secrets can only be unsealed when the measured boot produces the expected
301+
PCR state.
302+
303+
This is useful for:
304+
305+
- Encrypting disk encryption keys that are only released to authorised images
306+
- Protecting credentials that should only be available to verified boot chains
307+
- Remote attestation, where a third party verifies the boot state
308+
309+
For interoperability, PCR 11 is recommended for FIT image measurements,
310+
following the convention established by Unified Kernel Images (UKI).
311+
255312
.. sectionauthor:: Simon Glass <sjg@chromium.org>

0 commit comments

Comments
 (0)