Skip to content

fwtpm: reject ML-DSA signing with no private seed - #643

Merged
dgarske merged 1 commit into
wolfSSL:masterfrom
deadcaf3:worktree-check-seed-exists
Oct 22, 2026
Merged

dgarske merged 1 commit into
wolfSSL:masterfrom
deadcaf3:worktree-check-seed-exists

Conversation

@deadcaf3

Copy link
Copy Markdown
Contributor

SignSequenceComplete and SignDigest never checked that an ML-DSA key has a private seed. For a public-only key from TPM2_LoadExternal they returned success with a signature from the all-zero seed.

Both now return TPM_RC_KEY when no seed is loaded, matching FwSignAttestMldsa. The sequence check is in Complete, where the key is actually used.

Test: test_fwtpm_mldsa_sign_public_only_returns_key fails before the fix and passes after.

SignSequenceComplete and SignDigest signed with obj->privKey without
checking that a private seed was loaded. For a public-only ML-DSA or
Hash-ML-DSA key from TPM2_LoadExternal they returned success with a
signature from the all-zero seed, which does not verify against the
key's public area.

Return TPM_RC_KEY when privKeySize is not MAX_MLDSA_PRIV_SEED_SIZE,
matching FwSignAttestMldsa. For sequences the check is in Complete,
where the key is used: the object at keyHandle can differ from the one
given to Start while keeping the same Name.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 18:10

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

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.

🟢 Approval recommended

The targeted guards preserve valid-key behavior and cleanup, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Prevents firmware TPM signing with public-only ML-DSA keys, matching existing attestation validation.

Changes:

  • Rejects missing private seeds with TPM_RC_KEY in both signing paths.
  • Adds regression coverage using public-only keys loaded through TPM2_LoadExternal.
File Description
tests/​fwtpm_unit_tests.c Tests public-only key rejection for sequence and digest signing.
src/​fwtpm/​fwtpm_command.c Validates private seed size before signing.

Review effort: Balanced

@dgarske

dgarske commented Oct 21, 2026

Copy link
Copy Markdown
Member

Okay to test. Contributor agreement on file

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

Thanks @deadcaf3! This looks good. Seed check is the right call and matches FwSignAttestMldsa and it covers the entry points that actually reach the ML-DSA signer. It needs ML-DSA build guards though. Specifics inline.

Comment thread src/fwtpm/fwtpm_command.c
Comment thread tests/fwtpm_unit_tests.c
@dgarske
dgarske merged commit 195dd15 into wolfSSL:master Oct 22, 2026
243 checks passed
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