Skip to content

Gate fwTPM ML-KEM parameter sets on wolfCrypt's ML-KEM names - #676

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:fwtpm_mlkem_names
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:fwtpm_mlkem_names

Conversation

@dgarske

@dgarske dgarske commented Nov 17, 2026

Copy link
Copy Markdown
Member

The fwTPM decided which ML-KEM parameter sets it supports from WOLFSSL_NO_KYBER512/768/1024. In wolfCrypt those switches only apply to the pre-standard Kyber variant (WOLFSSL_MLKEM_KYBER); FIPS 203 ML-KEM, which TPM 2.0 v1.85 uses, is controlled by WOLFSSL_NO_ML_KEM_512/768/1024, and that is what ./configure --enable-mlkem=768 sets. A wolfCrypt build with a subset of ML-KEM sets therefore produced a fwTPM that advertised all three in TPM_PT_ML_PARAMETER_SETS, accepted all three in the TPMI_MLKEM_PARMS check, and sized its buffers for ML-KEM-1024, while key operations for the missing sets failed inside wolfCrypt. With every set enabled, as in the default build, the two name families agree, which is why it went unnoticed.

Changes

  • wolftpm/fwtpm/fwtpm.h, src/fwtpm/fwtpm_command.c - the buffer sizing, the TPM_PT_ML_PARAMETER_SETS bits and the parameter-set check use FWTPM_NO_MLKEM_512/768/1024, which resolve a set's availability the way wc_mlkem.h does: present from FIPS 203 ML-KEM (WOLFSSL_NO_ML_KEM, WOLFSSL_NO_ML_KEM_*) or from original Kyber with WOLFSSL_MLKEM_KYBER (WOLFSSL_NO_KYBER*). Advertising, TestParms, buffer sizing and key creation now agree in every wolfCrypt ML-KEM mode.
  • tests/fwtpm_unit_tests.c - the expected TPM_PT_ML_PARAMETER_SETS value follows the enabled sets; generic ML-KEM tests use an enabled parameter set and set-specific ones (the ML-KEM-512 KATs, the ML-KEM-768 EK credential profile, the ML-KEM-1024 max buffer) are gated like the ML-DSA ones, so the suite runs on subset builds. A new TestParms test checks that enabled ML-KEM sets are accepted and missing ones rejected with TPM_RC_PARMS.
  • docs/fwtpm/building.md, docs/ja/fwtpm/building.md - name the switches the buffer sizing follows.

Testing

  • fwtpm_server built against wolfSSL --enable-mlkem=768: TPM_PT_ML_PARAMETER_SETS was 0x3f (ML-KEM-512/768/1024 plus ML-DSA) before and is 0x3a (ML-KEM-768 plus ML-DSA) after.
  • fwTPM unit tests pass against wolfSSL with all ML-KEM sets and with 512-only, 768-only and 1024-only builds (previously they aborted on any subset build); make check passes on the default build.

Scope

With original Kyber (--enable-mlkem=original), the fwTPM now advertises the sets wolfCrypt provides, but ML-KEM key creation in that mode already fails with TPM_RC_FAILURE on master; that is unchanged here.

Found while building a TPM 2.0 v1.85 fwTPM limited to ML-KEM-768 for the PolarFire SoC example in wolftpm-examples.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:38

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

No active review issues were identified for the ML-KEM feature-switch alignment.

No open issues 🎉

What changed in this PR

Aligns fwTPM’s ML-KEM parameter-set handling with wolfCrypt’s feature switches so subset builds report and validate the available sets and size buffers accordingly.

Changes:

  • Adds shared availability macros used by buffer sizing, capability reporting, and TestParms.
  • Adapts ML-KEM tests to enabled parameter sets and adds checks for accepting supported sets and rejecting unsupported ones.
  • Updates English and Japanese build documentation to name the ML-KEM switches.
File Description
wolftpm/​fwtpm/​fwtpm.h Defines parameter-set availability macros and applies them to buffer sizing.
tests/​fwtpm_unit_tests.c Adapts tests for subset builds and adds TestParms coverage.
src/​fwtpm/​fwtpm_command.c Uses shared availability gates for capabilities and parameter validation.
docs/​ja/​fwtpm/​building.md Corrects ML-KEM switch names in Japanese documentation.
docs/​fwtpm/​building.md Corrects ML-KEM switch names in English documentation.

Review effort: Balanced

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.

4 participants