Skip to content

wolfTPM2: harden PCR/hash wrapper validation - #554

Merged
dgarske merged 1 commit into
wolfSSL:masterfrom
tmael:pcr-hash-validation
Aug 5, 2026
Merged

dgarske merged 1 commit into
wolfSSL:masterfrom
tmael:pcr-hash-validation

Conversation

@tmael

@tmael tmael commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Defensive-validation improvements in the PCR/hash wrappers:

  • wolfTPM2_ReadPCR returns TPM_RC_FAILURE on an empty response instead of
    reading digests[0] uninitialized.
  • wolfTPM2_HashStart rejects any non-hash algorithm locally via
    TPM2_GetHashDigestSize(), not only TPM_ALG_NULL.
  • wolfTPM2_ExtendPCR / wolfTPM2_ResetPCR bound pcrIndex, matching ReadPCR.

No API change; builds clean.

- ReadPCR: reject an empty response (count == 0) before dereferencing
  digests[0]
- HashStart: reject any non-hash algorithm (digest size 0), not just
  TPM_ALG_NULL
- ExtendPCR / ResetPCR: bound pcrIndex to [PCR_FIRST, PCR_LAST], matching
  ReadPCR

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Multi-Scan Review

Modes: review + review-security + bugsOverall recommendation: COMMENT
Findings: 1 total — 1 posted, 0 skipped
1 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [Medium] [review+review-security] New wrapper validation paths are not covered by regression tests — src/tpm2_wrap.c:6695-7725

Review generated by Skoll

Comment thread src/tpm2_wrap.c
@tmael
tmael requested a review from dgarske July 28, 2026 17:02
@tmael
tmael removed the request for review from dgarske July 28, 2026 17:03
@dgarske
dgarske removed the request for review from wolfSSL-Bot August 3, 2026 21:47

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests will come later from @tmael. Don't want to hold this PR up.

@dgarske
dgarske merged commit cd6ae53 into wolfSSL:master Aug 5, 2026
202 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants