Skip to content

wolfSPDM migration to wolfTPM/spdm with Nuvoton and spdm-emu support#458

Open
aidangarske wants to merge 1 commit intowolfSSL:masterfrom
aidangarske:add-full-spdm-support
Open

wolfSPDM migration to wolfTPM/spdm with Nuvoton and spdm-emu support#458
aidangarske wants to merge 1 commit intowolfSSL:masterfrom
aidangarske:add-full-spdm-support

Conversation

@aidangarske
Copy link
Member

@aidangarske aidangarske commented Feb 20, 2026

Description

Migrates the standalone wolfSPDM library into wolfTPM as an in-tree spdm/ subdirectory (~7.9K lines). This eliminates the external dependency and simplifies the build to a single --enable-spdm configure flag.

wolfSPDM Library (spdm/)

  • Full SPDM 1.2/1.3 protocol implementation (DSP0274) with Algorithm Set B (P-384, SHA-384, AES-256-GCM, HKDF)
  • Standard mode: works with libspdm spdm_responder_emu for testing
  • Nuvoton mode: TCG SPDM Binding framing, vendor-defined commands (GET_PUBK, GIVE_PUB, SPDMONLY, GET_STS_, TPM2_CMD)
  • Session establishment: GET_VERSION, GET_CAPABILITIES, NEGOTIATE_ALGORITHMS, GET_DIGESTS, GET_CERTIFICATE, KEY_EXCHANGE, FINISH
  • Secured messaging: AES-256-GCM encryption/decryption with AEAD, sequence number tracking, key update
  • Sessionless attestation: CHALLENGE authentication with signature verification
  • HEARTBEAT keep-alive support
  • Static memory mode (zero-malloc) and dynamic memory mode (--enable-spdm-dynamic-mem)
  • Unit test suite (spdm/test/unit_test.c)

wolfTPM Integration (src/tpm2_spdm.c, src/tpm2_wrap.c)

  • 13 new wolfTPM2_Spdm*() wrapper API functions in tpm2_wrap.h
  • Transparent SPDM transport in TPM2_SendCommand() — when an SPDM session is active, all TPM commands are automatically encrypted
  • TPM commands wrapped in SPDM VENDOR_DEFINED_REQUEST("TPM2_CMD") for Nuvoton SPDM-only mode
  • TIS I/O callback for routing SPDM through SPI/I2C TPM FIFO
  • NTC2_PreConfig vendor commands for SPDM enable/disable on Nuvoton TPMs
  • Auto-generated ephemeral P-384 key pair for mutual authentication

SPDM Demo (examples/spdm/)

  • spdm_demo.c: Full-featured example supporting emulator and Nuvoton hardware modes
  • spdm_test.sh: Automated test script with --emu (6 tests) and --nuvoton (6 tests) modes
  • Emulator tests: session, signed/unsigned measurements, challenge auth, heartbeat, key update
  • Nuvoton tests: status query, connect, lock SPDM-only, unit test over SPDM, unlock, cleartext verify

Build & CI

  • --enable-spdm configure flag builds wolfSPDM in-tree (no external --with-wolfspdm needed)
  • --enable-spdm-dynamic-mem for heap allocation instead of static buffers
  • wolfSSL requires: --enable-wolftpm --enable-ecc --enable-sha384 --enable-aesgcm --enable-hkdf --enable-sp
  • New CI workflow: spdm-emu-test.yml — builds and runs emulator tests against libspdm spdm_responder_emu
  • SPDM entries added to existing make-test-swtpm.yml matrix
  • Zephyr CMakeLists.txt updated for SPDM source files

Test plan

  • Build with --enable-spdm --enable-nuvoton (static mem)
  • Build with --enable-spdm --enable-spdm-dynamic-mem --enable-nuvoton (dynamic mem)
  • Build without --enable-spdm (no breakage)
  • spdm_test.sh --emu — 6/6 pass (static + dynamic mem)
  • spdm_test.sh --nuvoton — 6/6 pass on hardware (static + dynamic mem)
  • 24/24 total tests pass across all configurations
  • spdm-emu-test.yml passing and tested
  • copilot review

Copy link

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 pull request migrates the standalone wolfSPDM library (~7.9K lines) into wolfTPM as an in-tree spdm/ subdirectory, eliminating the external dependency and simplifying the build to a single --enable-spdm configure flag. The PR adds full SPDM 1.2/1.3 protocol support for encrypted TPM communication with both standard SPDM responders (libspdm emulator) and Nuvoton NPCT75x hardware TPMs.

Changes:

  • Adds wolfSPDM library in spdm/ with Algorithm Set B (P-384, SHA-384, AES-256-GCM)
  • Integrates SPDM transport into wolfTPM with 13 new wrapper APIs and transparent command encryption
  • Provides demo application with automated test suite for emulator and Nuvoton hardware
  • Updates build system with --enable-spdm flag and CI workflows

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
configure.ac Adds --enable-spdm configuration with Nuvoton and dynamic memory options
Makefile.am / include files Integrates SPDM build into automake system
wolftpm/tpm2_spdm.h New header defining SPDM integration API and constants
wolftpm/tpm2_wrap.h Adds 13 SPDM wrapper functions to public API
wolftpm/tpm2.h Adds SPDM protocol constants and NTC2 vendor command support
src/tpm2_spdm.c Implements SPDM context management and secured exchange
src/tpm2_wrap.c Implements SPDM wrapper APIs and auto-SPDM detection
src/tpm2.c Adds transparent SPDM routing in TPM2_SendCommand paths
spdm/wolfspdm/*.h Public wolfSPDM headers (types, errors, Nuvoton support)
spdm/src/*.c Core wolfSPDM implementation (context, crypto, sessions, secured messaging)
examples/spdm/* Demo application and test scripts for emulator and hardware
tests/unit_tests.c Adds SPDM API unit tests
.github/workflows/* New CI workflow for emulator testing and SPDM build matrix
zephyr/CMakeLists.txt Excludes tpm2_spdm.c from Zephyr builds

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

Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

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

Copilot reviewed 38 out of 39 changed files in this pull request and generated no new comments.


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

@aidangarske aidangarske requested a review from dgarske February 20, 2026 21:58
@dgarske dgarske assigned dgarske and wolfSSL-Bot and unassigned aidangarske Feb 21, 2026
Copilot AI review requested due to automatic review settings February 24, 2026 16:26
Copy link

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

Copilot reviewed 39 out of 40 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

zephyr/CMakeLists.txt:1

  • The filter patterns use double backslash escaping which is unnecessary in CMake regex strings. Single backslash is sufficient for escaping the dot character.
    wolftpm/tpm2_wrap.h:1
  • The acHandleCount and acHandles fields are added to WOLFTPM2_CAPS but are never populated or used in the provided code. If these are reserved for future use, add a comment explaining this. Otherwise, consider removing them until they're actually needed.
    src/tpm2_swtpm.c:1
  • The conditional includes replace the original #ifdef HAVE_NETDB_H guard with #ifndef WOLFTPM_ZEPHYR. This changes the portability logic - the original guard checked for actual header availability, while the new guard only excludes Zephyr. Consider using #if !defined(WOLFTPM_ZEPHYR) && defined(HAVE_NETDB_H) to preserve both checks.

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

Copy link

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

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


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

@dgarske dgarske removed their assignment Feb 24, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 18:20
Copy link

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

Copilot reviewed 39 out of 40 changed files in this pull request and generated no new comments.


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

@aidangarske aidangarske force-pushed the add-full-spdm-support branch from b684e06 to e56719c Compare February 26, 2026 18:25
@aidangarske aidangarske requested a review from dgarske February 26, 2026 18:30
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