fwTPM command-code masking + vendor-bit return-code fix#556
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens fwTPM command-code handling and improves compatibility with TPMs that return vendor-decorated error codes, aligning capability reporting and dispatch behavior more closely with the TPM 2.0 expectations.
Changes:
- Enforce fwTPM command-code validity by rejecting any wire command code with reserved bits set (allowing only the 16-bit index plus
CC_VEND). - Make
TPM2_GetCapability(TPM_CAP_COMMANDS)emitTPMA_CCentries (including handle attributes and vendor V bit) and update fwTPM tests accordingly. - Update
WOLFTPM_IS_COMMAND_UNAVAILABLEto recognize vendor-decoratedTPM_RC_COMMAND_CODEand add unit test coverage; gate the optional vendor echo command behindWOLFTPM_FWTPM_TCG_TEST.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
wolftpm/tpm2.h |
Mask base return-code bits in WOLFTPM_IS_COMMAND_UNAVAILABLE to recognize vendor-decorated TPM_RC_COMMAND_CODE. |
src/fwtpm/fwtpm_command.c |
Reject reserved-bit command codes, emit TPMA_CC for TPM_CAP_COMMANDS, and gate vendor test command behind WOLFTPM_FWTPM_TCG_TEST. |
tests/unit_tests.c |
Add unit test ensuring vendor-decorated TPM_RC_COMMAND_CODE is treated as “command unavailable”. |
tests/fwtpm_unit_tests.c |
Add fwTPM tests for reserved-bit rejection and TPM_CAP_COMMANDS TPMA_CC reporting/paging behavior. |
src/fwtpm/README.md |
Document reserved-bit enforcement, TPMA_CC reporting, and the optional vendor test command flag. |
docs/FWTPM.md |
Document WOLFTPM_FWTPM_TCG_TEST and the command-code enforcement / capability behavior. |
ChangeLog.md |
Add release-note entry describing the fwTPM hardening and vendor-decorated RC handling. |
aidangarske
reviewed
Jul 21, 2026
aidangarske
left a comment
Member
There was a problem hiding this comment.
Skoll Multi-Scan Review
Modes: review + review-security + bugsOverall 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] [review+review-security+bugs] Unavailable-command macro aliases negative wolfCrypt errors —
wolftpm/tpm2.h:2157-2159 - [High] [review] TPMA_CC rHandle bit is missing for response-handle commands —
src/fwtpm/fwtpm_command.c:16057
Review generated by Skoll
dgarske
force-pushed
the
fwtpm_cc_enforcement
branch
from
July 22, 2026 16:29
b6e88c1 to
1245e28
Compare
…TPMA_CC reporting; mask vendor bits in WOLFTPM_IS_COMMAND_UNAVAILABLE
dgarske
force-pushed
the
fwtpm_cc_enforcement
branch
from
July 22, 2026 17:41
1245e28 to
c5e0636
Compare
aidangarske
self-requested a review
July 22, 2026 17:45
aidangarske
approved these changes
Jul 22, 2026
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.
Fixes
CC_VENDvendor bit are valid) so none can alias a command.TPM2_GetCapability(TPM_CAP_COMMANDS)now returns well-formedTPMA_CCvalues (index + handle attributes + vendor V bit) instead of a bare index.WOLFTPM_IS_COMMAND_UNAVAILABLEmasks vendor bits from the return code, so a vendor-decoratedTPM_RC_COMMAND_CODE(e.g. Nations NS3500x000b0143) is recognized; fixes bench/wrap/native aborting instead of skipping unsupported commands.Features
WOLFTPM_FWTPM_TCG_TESTbuild flag gates the optionalVendor_TCG_Testecho command (off by default).Tests
TPMA_CCreporting; a hardware-free unit test for the vendor-decorated return code.Fixes #553