Commit Graph

5 Commits (fc511714d37e8052a089e602ddaaf6b8c4af5ce7)

Author SHA1 Message Date
Tobias Frauenschläger 77e31c0ebb ML-DSA renaming 2026-05-20 13:09:26 -07:00
Aidan Garske 9ce41885e0 fwTPM v185: PR review fixes + TCG/security hardening
Build / portability:
  - Drop #pragma message in fwtpm_crypto.c (MSVC-incompatible)
  - Replace non-ASCII section sign with Sec. across all sources/docs

  Configure:
  - Add --enable-pqc alias for --enable-v185 (same WOLFTPM_V185 macro)
  - Auto-detect: when --enable-fwtpm + wolfCrypt has dilithium.h+mlkem.h
    and neither flag is set, configure auto-enables PQC; --disable-pqc
    opts out
  - Both flags probe the wolfSSL PQC headers and fail at configure time
    with a clear hint when missing

  Spec / security hardening:
  - VerifySequenceComplete now emits TPM_ST_DIGEST_VERIFIED (with hashAlg
    metadata) for Hash-ML-DSA tickets, MESSAGE_VERIFIED for Pure ML-DSA
    (was mis-tagging digests as messages, breaking PolicyTicket consumers)
  - Sign/VerifySequenceComplete: free the slot on TPM_RC_SIGN_CONTEXT_KEY
    too, so wrong-key Complete cannot exhaust FWTPM_MAX_SIGN_SEQ slots
    (CWE-772 DoS)
  - TestParms PQC arms return TPM_RC_PARMS (spec-correct) instead of
    TPM_RC_VALUE; reject MLDSA/MLKEM parameter sets not actually compiled
    in; parse TPMS_MLKEM_PARMS.symmetric via TPM2_Packet_ParseSymmetric
  - GetCapability TPMA_ML_PARAMETER_SETS gates each MLDSA/MLKEM bit on the
    per-set wolfCrypt availability macro (subset builds advertise truth)
  - TPM2_VerifySignature client parser now defensive: only consume the
    v1.85 metaAlg when tag==DIGEST_VERIFIED && hierarchy!=RH_NULL
  - VerifyDigestSignature: hard-fail on keyName overflow instead of
    silently emitting a ticket missing the name binding
  - TPM_GENERATED_VALUE prefix check guarded with rc==0
  - Drop dead (void)cmdSize casts in Sign/VerifySequenceStart
  - wolfTPM2_EncryptSecret_MLKEM: track wc_InitRng_ex/wc_MlKemKey_Init
    success flags so Free is only called on initialized state
  - UBSan-v185 sanitizer cflags: explicitly disable signed-integer-overflow
    and shift checks (matches the comment about wolfSSL Hash_df 440<<24)

  Embedded RAM:
  - FWTPM_NV_PUBAREA_EST derives from FWTPM_MAX_MLDSA_PUB_SIZE /
    FWTPM_MAX_MLKEM_PUB_SIZE auto-shrink macros (subset builds save NV)
  - tpm2_types.h MAX_MLDSA_*/MAX_MLKEM_* stay at worst-case (ABI floor
    for TPM2B wire buffers) with comment

  Tests:
  - Negative test for Hash-MLDSA VerifySeqComplete ticket tag
  - Negative test exposing sign-seq slot leak on TPM_RC_SIGN_CONTEXT_KEY
  - Roundtrip test for wolfTPM2_SignDigest + VerifyDigestSignature

  Documentation:
  - README, FWTPM.md, fwtpm/README.md, examples/pqc/README.md mention
    both --enable-pqc and --enable-v185 + auto-detect
  - README wolfSSL line: --enable-pkcallbacks + WC_RSA_NO_PADDING
  - fwtpm/README.md: drop FWTPM_SPEC_* labels (macros never existed),
    remove v1.85 Additions table (all 8 commands implemented), update
    coverage table to 137/113/24 (82%); note remaining gaps are
    inherited v1.59/v1.84 commands, not PQC
  - fwtpm_nv.h:52: clarify 2592 vs 2720 math (PQC pub key + header slack)
2026-04-29 10:29:51 -07:00
Aidan Garske 1b909655bf Add Sign + verify examples 2026-04-29 10:28:44 -07:00
Aidan Garske 8311223bee docs: add v1.85 PQC build + usage section to main README and examples
Main README:
   - New ## Post-Quantum Cryptography (v1.85) section between fwTPM and
     TPM 2.0 Overview. Covers supported algorithms (ML-DSA-44/65/87,
     Hash-ML-DSA, ML-KEM-512/768/1024), exact wolfSSL + wolfTPM build
     config (--enable-dilithium --enable-mlkem --enable-experimental ...
     for wolfSSL; --enable-fwtpm --enable-v185 for wolfTPM), and a
     make check pointer.
   - Existing feature-list bullet at line 41 now points to the new
     section instead of directly to docs/FWTPM.md.

   examples/pqc/README.md:
   - Rewrite around three audience splits: (1) build steps, (2) run
     everything with make check, (3) per-example details.
   - New sections for mlkem_encap and the -mldsa/-hash_mldsa/-mlkem
     options on examples/keygen/keygen.
   - Drop stale --enable-swtpm reference (wrong flag; caused reviewer
     confusion).
   - Point users at the existing tests/fwtpm_check.sh and
     tests/pqc_mssim_e2e.sh for targeted reruns without the full classical
     suite.

   Documentation split (no duplication):
   - Top-level README - build + I just want to run it
   - examples/pqc/README.md per-example usage
   - docs/FWTPM.md#tpm-20-v185-post-quantum-support -> server internals
     (commands, primary-key derivation, buffer constants, spec
     interpretation decisions)
2026-04-29 10:28:44 -07:00
Aidan Garske 552032d357 fwTPM PQC: mssim E2E test + output formatting
Cross-process PQC validation: new examples/pqc/pqc_mssim_e2e exercises
  wolfTPM2_* client wrappers against a running fwtpm_server over the
  mssim (SWTPM) socket transport. Two round-trips in one binary:

  - MLKEM-768 Encap/Decap: asserts ciphertext = 1088 bytes and the two
    derived shared secrets are byte-identical.
  - HashMLDSA-65 SignDigest/Verify: asserts signature = 3309 bytes and
    the validation ticket carries TPM_ST_DIGEST_VERIFIED.

  tests/pqc_mssim_e2e.sh spawns fwtpm_server, waits for TCP readiness,
  runs the client, and cleans up. Proves client marshaling + mssim
  framing + fwtpm_server unmarshaling + PQC handler dispatch agree over
  a real socket between two separately-compiled processes — orthogonal
  to the in-process fwtpm_unit.test suite.

  Infrastructure:
  - configure.ac: new AM_CONDITIONAL BUILD_V185 so the example only
    builds when --enable-v185 is passed (matches the pattern of
    BUILD_SWTPM, BUILD_DEVTPM, etc.).
  - examples/include.am, examples/pqc/include.am: register the example.

  Output polish: replaced 85 inconsistent calls with a
  fwtpm_pass(name, is_pqc) helper that produces aligned
  columns. PQC tests are tagged [PQC] so they're visually distinct
  from the classical suite at a glance. All 86 existing tests still pass.
2026-04-29 10:27:50 -07:00