Skip to content

Fix fwTPM NV journal integrity and align more fwTPM commands with the reference - #685

Merged
aidangarske merged 25 commits into
wolfSSL:masterfrom
dgarske:fwtpm_nv_refmatch
Nov 30, 2026
Merged

aidangarske merged 25 commits into
wolfSSL:masterfrom
dgarske:fwtpm_nv_refmatch

Conversation

@dgarske

@dgarske dgarske commented Nov 30, 2026

Copy link
Copy Markdown
Member

More fixes from the Fenrir review of the fwTPM, after #682 and #683. One commit per finding. Response codes were checked against the TPM 2.0 reference implementation.

NV journal:

  • A full save writes the journal header and MAC only after the last entry, so an interrupted save is never loaded as a complete journal.
  • The default file backend fails closed when its integrity key file exists but cannot be used. It previously ran without a MAC.
  • A failed append restores the MAC of the last commit.
  • docs/fwtpm/hal-and-porting.md documents what a power loss does in each journal mode.

Commands:

  • TPM2_EvictControl: platform authorization can evict an owner-range object, an object with an stClear ancestor is refused, the hierarchy is checked before the handle range, and errors carry the handle or parameter number.
  • TPM2_DictionaryAttackParameters accepts a newMaxTries of zero, which puts the TPM in lockout.
  • TPM2_PolicySigned, TPM2_PolicySecret, TPM2_PolicyTicket and TPM2_PolicyParameters: parameter numbers on errors, no nonceTPM or cpHashA checks in a trial session, a repeated pHash and an authHandle that is not an entity are refused, and a PolicyTicket timeout of zero does not expire.
  • TPM2_ClockRateAdjust validates rateAdjust, and TPM2_NV_DefineSpace returns TPM_RC_SIZE for an oversized dataSize.
  • RSA primary key derivation skips a prime that is unfit for the public exponent. A failure to compute an NV index Name fails the command.

Compatibility:

  • No change to the NV journal format, except one marker byte in the flags record when maxTries is zero. An installation whose key file was already unusable now fails to start until it is repaired.
  • No existing primary key changes.
  • The response codes above change for callers that depended on the previous values.

A power loss during a journal write can still lose the TPM state; that needs a journal format change and is follow-on work.

Resolves F-17151, F-18887, F-18888, F-18898, F-18943, F-18945, F-18956, F-18957, F-18958, F-18963, F-18964

Comment thread tests/fwtpm_unit_tests.c Fixed
Comment thread tests/fwtpm_unit_tests.c Fixed
Comment thread tests/fwtpm_unit_tests.c Fixed
Comment thread tests/fwtpm_unit_tests.c Fixed
Comment thread tests/fwtpm_unit_tests.c Fixed
Comment thread tests/fwtpm_unit_tests.c Fixed

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #685

Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): docs/fwtpm/hal-and-porting.md, docs/fwtpm/overview.md
Coverage: 6 of 7 in-scope changed file(s) opened by the reviewer; not opened: wolftpm/tpm2_wrap.h

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@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.

Looks good

@aidangarske
aidangarske merged commit edf1a1c into wolfSSL:master Nov 30, 2026
262 checks passed
@aidangarske
aidangarske deleted the fwtpm_nv_refmatch branch November 30, 2026 21:17
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