Repository navigation
Fix fwTPM session-tagged StartAuthSession, the clock safe flag and more reference response codes - #688
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The response-failure path leaks newly allocated StartAuthSession sessions, allowing repeated failures to exhaust the session table; cleanup and a fault-injection regression test are needed.
1 open issue
What changed in this PR
This PR continues fwTPM’s alignment with the TPM 2.0 reference implementation, correcting response framing, clock safety reporting, validation, and error codes.
Changes:
- Adds session-formatted
StartAuthSessionresponses and reports clock safety as NO without a clock HAL. - Tightens object-attribute, PCR-policy, NV-handle, and journal-key-length validation; adds handle and parameter numbers to affected error codes.
- Adds regression tests and documents clock behavior.
| File | Description |
|---|---|
tests/fwtpm_unit_tests.c |
Adds regression coverage and updates expected response codes. |
src/fwtpm/fwtpm_nv.c |
Rejects integrity-key lengths exceeding the key buffer. |
src/fwtpm/fwtpm_command.c |
Corrects session responses, clock safety, validation, and error codes. |
docs/fwtpm/hal-and-porting.md |
Documents clock safety reporting without a clock HAL. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #688
Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): docs/fwtpm/hal-and-porting.md
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer
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
61c3305 to
b3a13f2
Compare
aidangarske
left a comment
There was a problem hiding this comment.
Skoll Code Review
Scan type: review
Overall recommendation: REQUEST_CHANGES
Findings: 2 total — 2 posted, 0 skipped
2 finding(s) posted as inline comments (see file-level comments below)
Posted findings
- [High] SequenceUpdate reports a handle error as parameter 1 —
src/fwtpm/fwtpm_command.c:12456-12460 - [High] Unknown nameAlg errors lose parameter 2 in three commands —
src/fwtpm/fwtpm_command.c:3170-3172
Review generated by Skoll
50b1ce8 to
383a0e4
Compare

A third and fourth pass over fwTPM behavior that differed from the TPM 2.0 reference implementation, after #686, plus four findings from the Fenrir review. One commit per item or mechanism. Response codes were checked against the reference simulator.
Findings:
TPM2_StartAuthSessionsent withTPM_ST_SESSIONS(an audit or encrypt session present) is answered with a sessions response: parameter size and a response authorization area. It was answered in the no-sessions form.TPMS_CLOCK_INFO.safeis reported NO when no clock HAL is registered, inTPM2_ReadClock, the attestation commands andTPM2_PolicyCounterTimer.TPM2_ClockSetis unchanged.TPM2_LoadExternalandTPM2_Importrefusex509signon an object that is not an asymmetric signing key, in a v1.85 build, as object creation already does.Response codes:
TPM2_HierarchyControlandTPM2_PCR_SetAuthPolicyreport the parameter number, andTPM2_PCR_SetAuthPolicychecks the policy size and hash algorithm.TPM2_PolicyCpHash,TPM2_PolicyNameHashandTPM2_PolicyTemplatereport the parameter number for a digest of the wrong size.TPM2_Signreport the handle number for a key that cannot sign.TPM_RC_VALUEwith the handle number for a handle of the wrong type, and keepTPM_RC_NV_AUTHORIZATIONfor a valid handle the index does not permit.TPM_RC_VALUE, a missing persistent object or NV indexTPM_RC_HANDLE, and an unloaded object or sessionTPM_RC_REFERENCE_H0, each with the handle number.TPM2_Unseal, the HMAC, RSA and ECDH commands,TPM2_MakeCredential,TPM2_Import, the sequence commands andTPM2_VerifySignature.TPM2_PCR_Read,TPM2_SetPrimaryPolicyandTPM2_CreatePrimary, where it succeeded or returnedTPM_RC_FAILURE.Compatibility:
TPM2_StartAuthSessionsees the sessions layout.TPM2_PolicyCounterTimerpolicy on safe YES fails there.TPM2_PCR_SetAuthPolicyrefuses an empty policy with a hash algorithm set and an unsupported hash algorithm; both were accepted.TPM2_Create,TPM2_Load,TPM2_CreateLoadedandTPM2_Importrefuse a parent that is not a restricted decryption key, andTPM2_VerifySignaturerefuses a key withoutsign.TPM2_Signrefuses a ticket that is not a hash check ticket, including a null ticket on an unrestricted key.Resolves F-16133, F-16240, F-16839, F-18946