Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
SHA-384 PCR selection can cause existing 32-byte measurement buffers to be read as 48-byte inputs.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
This PR makes TPM PCR algorithm and digest-size configuration explicit and adds SHA-384 PCR-bank selection.
Changes:
- Detects half-specified PCR overrides at compile time.
- Adds
WOLFBOOT_TPM_PCR_SHA384for SHA-384/48-byte PCRs. - Retains SHA-256/32-byte defaults.
| File | Description |
|---|---|
include/tpm.h |
Defines PCR algorithm and digest-size selection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+57
to
+61
| #ifdef WOLFBOOT_TPM_PCR_SHA384 | ||
| /* SHA2-384 bank. Present on parts like the Infineon SLB9672, absent on | ||
| * the SLB9670 - selecting it on a part with no such bank makes every | ||
| * extend fail, which measured boot treats as fatal. */ | ||
| #define WOLFBOOT_TPM_PCR_ALG TPM_ALG_SHA384 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Found while adding SHA2-384 measured boot for a Tiger Lake TPM target.
WOLFBOOT_TPM_PCR_ALGandWOLFBOOT_TPM_PCR_DIG_SZwere defined together under a single#ifndefon the algorithm. Overriding only the algorithm therefore left the digest size undefined, and an undefined macro is0to the preprocessor, so the downstream digest-size checks silently changed meaning rather than failing to build.This selects the pair with one switch -
WOLFBOOT_TPM_PCR_SHA384chooses SHA2-384 (digest size 48), otherwise SHA2-256 (digest size 32) - and adds an#errorwhen exactly one of the two macros is defined, so a half-specified override is caught at compile time. The algorithm itself cannot be validated with#if:TPM_ALG_SHA256and friends are enum constants, not macros, so any#ifcomparison against them evaluates0 == 0and is always true.Note: a SHA2-384 PCR bank exists on parts like the Infineon SLB9672 but not the SLB9670; selecting it on a part without that bank makes every extend fail, which measured boot treats as fatal.