Repository navigation
Add client commands for ReadOnlyControl, ECC encrypt, two policies and NV public 2 - #690
Conversation
d726fad to
8249fc6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unchecked input lengths can cause out-of-bounds reads and disclose adjacent memory to the TPM, while response-validation and Name-handling flaws can falsely report success or break authenticated reads.
11 open issues
Validate plaintext length against its source buffer · New Validate ciphertext and integrity lengths before copying · New Bound operandB length to its digest buffer · New Bound pHash length to its digest buffer · New Validate NV authorization length before copying · New Bound authPolicy length to the selected policy buffer · New Reject encryption responses with parsing errors or truncation · New Reject decrypted plaintext that exceeds the output buffer · New Include external and permanent NV handles in Name lookup · New Propagate public-area and Name parsing failures · New Parse NV public data within its declared size · New
What changed in this PR
Adds seven native client commands for TPM 2.0 v1.83/v1.84, exposing functionality already implemented by fwTPM without adding wrapper APIs.
Changes:
- Adds ReadOnlyControl, ECC encryption/decryption, two policy commands, and NV public 2 APIs and marshalling.
- Enables command groups through
WOLFTPM_V185or individual feature macros, with opt-outs. - Adds command and marshalling tests, build-option documentation, and release notes.
| File | Description |
|---|---|
wolftpm/tpm2.h |
Declares new commands, NV structures, and handle types. |
wolftpm/tpm2_types.h |
Adds feature macros and opt-out controls. |
wolftpm/tpm2_packet.h |
Declares NV public 2 packet helpers. |
tests/unit_tests.c |
Adds command, parameter-encryption, and marshalling tests. |
src/tpm2.c |
Implements the seven native client commands. |
src/tpm2_packet.c |
Adds NV public 2 serialization and parsing. |
docs/release-notes.md |
Documents the new native APIs. |
docs/build-options.md |
Explains command-group feature controls. |
ChangeLog.md |
Records the additions in the changelog. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #690
Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): ChangeLog.md, docs/build-options.md, docs/release-notes.md
Coverage: 5 of 6 in-scope changed file(s) opened by the reviewer; not opened: wolftpm/tpm2_packet.h
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
8249fc6 to
ccc9e67
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #690
Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): ChangeLog.md, docs/build-options.md, docs/release-notes.md
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/unit_tests.c
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: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
ccc9e67 to
17ee368
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #690
Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): ChangeLog.md, docs/build-options.md, docs/release-notes.md
Coverage: 2 of 4 in-scope changed file(s) opened by the reviewer; not opened: tests/unit_tests.c, wolftpm/tpm2_packet.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: Lite


Adds the native client API for seven commands from TPM 2.0 v1.83 and v1.84 that the Firmware TPM (fwTPM) already implements. They are built with
--enable-v185, so a default build does not grow, and no existing function or structure changes.What it adds
TPM2_ReadOnlyControlTPM2_ECC_EncryptandTPM2_ECC_DecryptTPM2_PolicyCapabilityandTPM2_PolicyParametersTPM2_NV_DefineSpace2andTPM2_NV_ReadPublic2, with theTPM2B_NV_PUBLIC_2family of types and theTPM_HT_EXTERNAL_NVandTPM_HT_PERMANENT_NVhandle typesParameter encryption is offered where Part 3 allows it for each command.
Each group has its own macro, on with
WOLFTPM_V185unless the matchingWOLFTPM_NO_*is defined, and usable alone without v1.85:WOLFTPM_READONLY,WOLFTPM_ECC_ENCRYPT,WOLFTPM_POLICY_CAP_PARAMSandWOLFTPM_NV_PUBLIC_2. They are listed indocs/build-options.md.Test status
Run against the fwTPM and against the ibmswtpm2 reference simulator, which implements all but ReadOnlyControl. Each test skips when the TPM answers
TPM_RC_COMMAND_CODE. No hardware TPM was used.Scope
WOLFSSL_PUBLIC_ECC_ADD_DBLandHAVE_X963_KDF; it skips otherwise.TPM2_NV_DefineSpace2, so that form is covered by the marshalling test only.wolfTPM2_*wrappers are added; those are follow-on work.Resolves F-18966