Skip to content

Add client commands for ReadOnlyControl, ECC encrypt, two policies and NV public 2 - #690

Merged
aidangarske merged 6 commits into
wolfSSL:masterfrom
dgarske:client_v185_cmds
Dec 1, 2026
Merged

aidangarske merged 6 commits into
wolfSSL:masterfrom
dgarske:client_v185_cmds

Conversation

@dgarske

@dgarske dgarske commented Dec 1, 2026

Copy link
Copy Markdown
Member

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_ReadOnlyControl
  • TPM2_ECC_Encrypt and TPM2_ECC_Decrypt
  • TPM2_PolicyCapability and TPM2_PolicyParameters
  • TPM2_NV_DefineSpace2 and TPM2_NV_ReadPublic2, with the TPM2B_NV_PUBLIC_2 family of types and the TPM_HT_EXTERNAL_NV and TPM_HT_PERMANENT_NV handle types
  • Unit tests for each command, and a marshalling test for the NV public 2 forms
  • Release note entries

Parameter encryption is offered where Part 3 allows it for each command.

Each group has its own macro, on with WOLFTPM_V185 unless the matching WOLFTPM_NO_* is defined, and usable alone without v1.85: WOLFTPM_READONLY, WOLFTPM_ECC_ENCRYPT, WOLFTPM_POLICY_CAP_PARAMS and WOLFTPM_NV_PUBLIC_2. They are listed in docs/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

  • The ECC encrypt test against the fwTPM needs a wolfSSL built with WOLFSSL_PUBLIC_ECC_ADD_DBL and HAVE_X963_KDF; it skips otherwise.
  • The fwTPM refuses the external NV form of TPM2_NV_DefineSpace2, so that form is covered by the marshalling test only.
  • No wolfTPM2_* wrappers are added; those are follow-on work.

Resolves F-18966

Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:22
@dgarske dgarske self-assigned this Dec 1, 2026

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

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
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_V185 or 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

Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2.c Resolved
Comment thread src/tpm2_packet.c Resolved

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

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

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review December 1, 2026 21:11

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

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

@dgarske dgarske assigned wolfSSL-Bot and aidangarske and unassigned dgarske Dec 1, 2026
@aidangarske
aidangarske merged commit 02c3979 into wolfSSL:master Dec 1, 2026
264 checks passed
@aidangarske
aidangarske deleted the client_v185_cmds branch December 1, 2026 23:48
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.

5 participants