Skip to content

Make fwTPM state changes transactional and harden PolicyPCR and private-blob wrapping - #593

Merged
dgarske merged 5 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-12712-13524-13525-13526-13527
Sep 8, 2026
Merged

Make fwTPM state changes transactional and harden PolicyPCR and private-blob wrapping#593
dgarske merged 5 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-12712-13524-13525-13526-13527

Conversation

@aidangarske

Copy link
Copy Markdown
Member
F-12712, F-13524, F-13525, F-13526, F-13527

@aidangarske aidangarske self-assigned this Sep 8, 2026
Copilot AI lite review requested due to automatic review settings September 8, 2026 01:24
@aidangarske
aidangarske requested a review from dgarske September 8, 2026 01:26
@aidangarske
aidangarske marked this pull request as ready for review September 8, 2026 01:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Two correctness/security issues remain: bounds validation for TPM2B_NAME length in wrap-key derivation and missing error handling for PolicyPCR hash finalization.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR strengthens fwTPM’s security and crash-consistency by making NV-backed state mutations transactional (rollback on persistence failure), hardening PolicyPCR correctness (digest verification + PCR-change invalidation), and improving private-blob wrapping so wrapped objects are bound to their public area and use per-blob IVs.

Changes:

  • Make NV journal appends/compactions act as a commit boundary, with rollback/“NV unavailable” behavior on failed commits/checkpoints.
  • Harden policy/session behavior: PolicyPCR verifies caller-provided digests for real policy sessions and invalidates authorization if PCRs change.
  • Rework private blob wrapping: per-blob random IV + HMAC over (IV || ciphertext), and keys derived from (parent private || child Name) to bind private blobs to the public area.
File summaries
File Description
wolftpm/fwtpm/fwtpm.h Adds session/ctx fields to track PCR update counters and NV transactional state.
wolftpm/fwtpm/fwtpm_crypto.h Updates crypto API signatures for public-name binding and RNG-provided IVs.
src/fwtpm/fwtpm_crypto.c Implements Name-bound wrap-key derivation, per-blob IV, and updated wrap/unwrap formats.
src/fwtpm/fwtpm_nv.c Implements transactional append semantics, compaction-as-commit logic, and deletion-aware compaction.
src/fwtpm/fwtpm_command.c Rolls back volatile state on NV persist failures and hardens PolicyPCR behavior.
tests/fwtpm_unit_tests.c Adds regression tests for NV transactional behavior, PolicyPCR verification/invalidation, and private-blob wrapping properties.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/fwtpm/fwtpm_crypto.c Outdated
Comment thread src/fwtpm/fwtpm_command.c
@aidangarske
aidangarske force-pushed the fenrir-fixes-12712-13524-13525-13526-13527 branch from 12c83df to c9e6529 Compare September 8, 2026 01:46
@dgarske
dgarske merged commit 17f1230 into wolfSSL:master Sep 8, 2026
218 checks passed
@aidangarske
aidangarske deleted the fenrir-fixes-12712-13524-13525-13526-13527 branch September 8, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants