Skip to content

fwtpm: size RSASSA DigestInfo buffers for SHA-512, check Sign digest … - #655

Open
embhorn wants to merge 2 commits into
wolfSSL:masterfrom
embhorn:zd22700
Open

embhorn wants to merge 2 commits into
wolfSSL:masterfrom
embhorn:zd22700

Conversation

@embhorn

@embhorn embhorn commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Size checking in FwSignDigestAndAppend, FwVerifySignatureCore, and TPM2_Sign

  • Size both buffers with MAX_DER_DIGEST_SZ, the constant wolfCrypt uses for this encoding.
  • Reject TPM2_Sign with TPM_RC_SIZE when the digest size does not match the resolved scheme hashAlg, matching FwCmd_SignDigest.
  • examples/pcr/policy_sign: the local buffer was 73 bytes; size it with WOLFTPM_MAX_DER_DIGEST_SZ (100)
  • tests: add RSASSA-SHA512 Sign/VerifySignature and Sign digest-size mismatch tests, run the SignDigest RSA roundtrip with SHA-512 too, and move BuildRsa2048SignPrimary out of the WOLFTPM_V185 block so builds without v1.85 can use it.

Fixes ZD22700

Thanks to Alexandre Laroche for submitting this issue and confirming the fix.

…size

FwSignDigestAndAppend and FwVerifySignatureCore sized their PKCS#1
v1.5 DigestInfo buffers as WC_MAX_DIGEST_SIZE + MAX_ENCODED_DIG_ASN_SZ,
which leaves out the outer SEQUENCE and the AlgorithmIdentifier. A
SHA-512 DigestInfo is 83 bytes. Size both buffers with
MAX_DER_DIGEST_SZ, the constant wolfCrypt uses for this encoding.

- Reject TPM2_Sign with TPM_RC_SIZE when the digest size does not
  match the resolved scheme hashAlg (Part 3 Sec.20.2.1), matching
  FwCmd_SignDigest.
- examples/pcr/policy_sign: size the DigestInfo buffer with
  WOLFTPM_MAX_DER_DIGEST_SZ, since older wolfSSL does not export
  MAX_DER_DIGEST_SZ.
- tests: add RSASSA-SHA512 Sign/VerifySignature and Sign digest-size
  mismatch tests, run the SignDigest RSA roundtrip with SHA-512 too,
  and move BuildRsa2048SignPrimary out of the WOLFTPM_V185 block so
  builds without v1.85 can use it.
@embhorn embhorn self-assigned this Oct 27, 2026
Copilot AI balanced review requested due to automatic review settings October 27, 2026 16:06

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@embhorn
embhorn requested a review from dgarske October 27, 2026 16:18
Comment thread examples/pcr/policy_sign.c Outdated
Comment thread src/fwtpm/fwtpm_crypto.c Outdated
@embhorn
embhorn requested a review from dgarske October 27, 2026 18:30
@dgarske dgarske self-assigned this Oct 27, 2026
@embhorn

embhorn commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Customer has confirmed this fix

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