Commit Graph

4 Commits (master)

Author SHA1 Message Date
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 71e28c12a8 Extend fuzz CI matrix to cover v1.85 PQC paths
tests/fuzz/tpm2.dict gains:
  - 8 new command codes (Encapsulate 0x1A7, Decapsulate 0x1A8,
    SignSequenceStart 0x1AA, SignSequenceComplete 0x1A4,
    VerifySequenceStart 0x1A9, VerifySequenceComplete 0x1A3,
    SignDigest 0x1A6, VerifyDigestSignature 0x1A5)
  - 3 PQC algorithm IDs (MLKEM 0x00A0, MLDSA 0x00A1, HASH_MLDSA 0x00A2)
  - 6 parameter-set values (MLKEM 512/768/1024, MLDSA 44/65/87)
  - 3 new response codes (RC_EXT_MU, RC_ONE_SHOT_SIGNATURE,
    RC_SIGN_CONTEXT_KEY)

  tests/fuzz/gen_corpus.py gains 10 PQC seed files:
  - pqc_encapsulate_mlkem, pqc_decapsulate_mlkem
  - pqc_signseqstart_mldsa, pqc_signseqcomplete_mldsa
  - pqc_verifyseqstart_mldsa, pqc_verifyseqcomplete_mldsa
  - pqc_signdigest_mldsa, pqc_verifydigestsig_mldsa
  - pqc_createprimary_mlkem, pqc_createprimary_mldsa

  These give libFuzzer starting shapes for the 8 new command paths rather
  than relying on coverage-guided discovery from scratch.

  .github/workflows/fuzz.yml matrix expanded:
  - Existing 2 entries (fuzz-full, fuzz-smoke) classical-only, unchanged
    flags, zero regression risk
  - New fuzz-full-pqc (10-min weekly) and fuzz-smoke-pqc (60s every PR)
    build wolfSSL with --enable-dilithium --enable-mlkem --enable-
    experimental --enable-harden and wolfTPM with --enable-v185, use
    -max_len=8192 to accommodate MLDSA-87 sigs (4627 bytes).
2026-04-29 10:28:44 -07:00
David Garske 579ec8cc7f Bump copyright year to 2026 and version to 4.0.0
Release prep for v4.0.0:
- Copyright headers updated 2025 -> 2026 across sources, headers, and examples
- Library version 3.10.0 -> 4.0.0 (libtool 16:8:0 -> 17:0:0)
- configure.ac WOLFSSL_URL http -> https
2026-04-22 09:24:55 -07:00
David Garske 0c52f3be4d Add firmware TPM 2.0 (fwTPM) implementation
Add portable firmware TPM 2.0 implementation (fwTPM) built on wolfCrypt.
Implements 105/113 TPM 2.0 v1.38 commands (93%) as a standalone server
with socket and TIS transports, NV storage, and full CI/fuzz coverage.
2026-04-16 16:57:57 -07:00