Skip to content

Fix changes to pqc header file rename#501

Open
aidangarske wants to merge 4 commits intowolfSSL:masterfrom
aidangarske:fix-upstream-pqc
Open

Fix changes to pqc header file rename#501
aidangarske wants to merge 4 commits intowolfSSL:masterfrom
aidangarske:fix-upstream-pqc

Conversation

@aidangarske
Copy link
Copy Markdown
Member

@aidangarske aidangarske commented May 8, 2026

@aidangarske aidangarske requested review from Copilot and removed request for Copilot May 8, 2026 17:05
@aidangarske aidangarske marked this pull request as ready for review May 8, 2026 17:34
@aidangarske aidangarske requested review from Copilot and dgarske May 8, 2026 17:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates wolfTPM’s PQC (TPM 2.0 v1.85 / ML-KEM) integration to match an upstream wolfSSL header rename (mlkem.hwc_mlkem.h), preventing --enable-pqc/--enable-v185 configure/build failures with current wolfSSL.

Changes:

  • Switch ML-KEM includes in fwTPM code and tests to wolfssl/wolfcrypt/wc_mlkem.h.
  • Update configure.ac feature probes (AC_CHECK_DECL) and comments to reference wc_mlkem.h.
  • Simplify the ML-KEM include selection logic in src/tpm2_wrap.c.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
configure.ac Updates ML-KEM configure-time probes to include wc_mlkem.h.
src/tpm2_wrap.c Replaces mlkem.h usage with wc_mlkem.h / ext_mlkem.h selection.
src/fwtpm/fwtpm_crypto.c Updates fwTPM PQC include to wc_mlkem.h.
tests/fwtpm_unit_tests.c Updates unit test ML-KEM include to wc_mlkem.h.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread configure.ac
Comment thread configure.ac
Comment thread tests/fwtpm_unit_tests.c
Comment thread src/tpm2_wrap.c
Comment thread src/fwtpm/fwtpm_crypto.c
dgarske
dgarske previously approved these changes May 8, 2026
… upstream-drift CI

configure.ac: add LIBWOLFSSL_VERSION_HEX check so --enable-v185/--enable-pqc
fails fast against unsupported wolfSSL releases (kyber.h era), instead of
relying on transitive header aliasing through wc_mlkem.h.

Add .github/workflows/wolfssl-versions.yml matrix: builds wolfTPM PQC
against wolfSSL v5.8.0-stable, v5.8.4-stable, v5.9.1-stable, and master.
Catches the next upstream rename within the matrix run, not 9 days later.

Add .github/workflows/nightly.yml: cron 02:17 UTC fan-out via
repository_dispatch[nightly-trigger]. 12 workflows opt in (cmake-build,
codespell, fwtpm-test, make-test-swtpm, multi-compiler, pqc-examples,
release-checks, sanitizer, seal-test, win-test, wolfssl-versions, zephyr).
hw-spdm-test deliberately does NOT opt in so the self-hosted Pi runner
cannot be batch-triggered. repository_dispatch is API-only (no UI button)
so only the nightly job can fire these.
…o shim

Three small workarounds let wolfTPM PQC build + run cleanly against every
wolfSSL stable since v5.8.0, instead of requiring v5.9.0+:

* src/fwtpm/fwtpm_crypto.c (FwVerifySignatureCore): cast
  sig->signature.rsapss.sig.buffer to (byte*)(uintptr_t) so the call
  compiles against v5.8.0 (where wc_RsaPSS_VerifyCheck takes byte*) AND
  v5.8.4+ (where it takes const byte*). Cast is a no-op on the const path.

* src/fwtpm/fwtpm_crypto.c (FwMlkemDecapsulate): for
  LIBWOLFSSL_VERSION_HEX < 0x05009000, encode the public key once before
  wc_MlKemKey_Decapsulate. wolfSSL <= v5.8.4 has a Decap-from-seed bug
  (commit 8a75e7d1c "ML-KEM decapsulate: check for H" landed in v5.9.0):
  Decap needs H = hash(pubkey) cached on the key, but MakeKeyWithRandom
  from seed never populated it. EncodePublicKey triggers the cache as a
  side effect.

* wolftpm/tpm2_types.h: when LIBWOLFSSL_VERSION_HEX < 0x05008004, define
  a static-inline wc_ForceZero (volatile byte-wise zero, mirroring
  wolfssl/wolfcrypt/src/misc.c::ForceZero). wc_ForceZero was first
  declared in wolfssl/wolfcrypt/memory.h at v5.8.4. Lives in tpm2_types.h
  so all callers (SPDM, PQ examples, etc.) get it without per-file shims.

Add v5.8.2 and v5.9.0 to wolfssl-versions.yml matrix so the boundaries
of every workaround are covered: 5 stable versions (v5.8.0, v5.8.2,
v5.8.4, v5.9.0, v5.9.1) + master. Locally validated: all 6 pass build +
fwtpm_unit.test (PQC KAT block).
Comment thread .github/workflows/wolfssl-versions-pqc.yml
Make it explicit that this matrix is PQC-only. Other wolfTPM workflows
(fwtpm-test.yml, make-test-swtpm.yml, pqc-examples.yml) already cover
core wolfTPM build/test against wolfSSL master.
@aidangarske aidangarske requested a review from dgarske May 8, 2026 21:51
wolfssl-ref: 'v5.8.0-stable'
cache-key: 'wolfssl-pqc-v5.8.0-v1'
# Latest stable: workarounds gated off via VERSION_HEX.
- wolfssl-version: 'v5.9.1-stable'
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.

We need a dynamic way to get the latest -stable tag...

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