Skip to content

Fix RSA 4096 public area buffer sizing and packet overflow checks - #640

Merged
aidangarske merged 1 commit into
wolfSSL:masterfrom
dgarske:fwtpm_rsa4096
Oct 21, 2026
Merged

aidangarske merged 1 commit into
wolfSSL:masterfrom
dgarske:fwtpm_rsa4096

Conversation

@dgarske

@dgarske dgarske commented Oct 19, 2026

Copy link
Copy Markdown
Member

Three RSA 4096 issues in fwTPM were fixed (all undetected at RSA 2048):

  • Buffer Under-allocation & Name Collisions: TPM2_Packet_AppendBytes() skips oversized fields instead of truncating. At RSA 4096, an RSA public area requires 604 bytes, but FWTPM_MAX_PUB_BUF was capped at 512. The omitted field was the modulus, causing every object to hash to the same Name. Similarly, FWTPM_NV_PUBAREA_EST was capped at 600. Both buffers now dynamically size their RSA arms using MAX_RSA_KEY_BITS, leaving RSA 2048 output byte-identical.
  • Unchecked Overflow & Uninitialized Memory: FwComputePublicName(), FwSpdmTpmKeyName(), and Name calculations in FwCmd_Create() / FwCmd_Import() used packet.pos without checking packet.overflow (matching wolfTPM2_ComputeName()). Two of those packets were also left uninitialized.
  • Benchmark Mislabeling: examples/bench/bench.c sent a fixed 256-byte unpadded RSA message and labeled all results as 2048-bit, even though unpadded RSA requires a payload width matching the modulus.

Verification: Built and tested at RSA 2048, RSA 4096 (--enable-infineon=slb9672), and --disable-rsa (--enable-pqc was skipped; requires ML-DSA wolfSSL). An additional RSA 4096 failure in tests/unit_tests.c (FWTPM_MAX_PRIVKEY_DER) is resolved by #628.

@dgarske dgarske self-assigned this Oct 19, 2026
@dgarske
dgarske requested a review from aidangarske October 20, 2026 17:48
@dgarske dgarske assigned wolfSSL-Bot and aidangarske and unassigned dgarske Oct 20, 2026

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

Skoll Code Review

Scan type: review

Overall recommendation: COMMENT
Findings: 2 total — 2 posted, 0 skipped
2 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [Medium] RSA-disabled builds still pay the RSA-4096 buffer cost — wolftpm/fwtpm/fwtpm.h:302-303; wolftpm/fwtpm/fwtpm_nv.h:60-66
  • [Medium] Regression test does not exercise the changed failure paths — tests/fwtpm_unit_tests.c:18176-18219

Review generated by Skoll

Comment thread wolftpm/fwtpm/fwtpm.h Outdated
Comment thread tests/fwtpm_unit_tests.c
@aidangarske
aidangarske merged commit e4e3bfe into wolfSSL:master Oct 21, 2026
243 checks passed
@aidangarske
aidangarske deleted the fwtpm_rsa4096 branch October 21, 2026 19:23
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.

3 participants