wolfTPM is a highly portable TPM 2.0 library, designed for embedded use.
wolfTPM is a highly portable TPM 2.0 library, designed for embedded use.
Portable TPM 2.0 project designed for embedded use.
/dev/tpmX) and direct SPI access at runtime - a simple ./configure && make works with either interface./dev/tpmX) to talk with any physical TPM on SPI, I2C and even LPC bus.--enable-v185 (full v1.85) or the leaner --enable-pqc (ML-DSA / ML-KEM only), with per-operation trimming via --enable-mldsa/--enable-mlkem. Auto-detected when --enable-fwtpm is built against a wolfCrypt that has ML-DSA + ML-KEM. Both the client library and the fwTPM server implement the eight new v1.85 PQC commands. See Post-Quantum Cryptography (v1.85) below.--enable-spdm. The fwTPM server includes an SPDM 1.3 responder so the stack can be exercised end-to-end in CI without discrete silicon. See SPDM Attestation below.Note: See examples/README.md for details on using the examples.
wolfTPM includes a portable firmware TPM 2.0 implementation (fwtpm_server)
built entirely on wolfCrypt. It provides a standards-compliant TPM 2.0 command
processor that can replace a hardware TPM on embedded platforms without a
discrete TPM chip, or serve as a drop-in development and CI/CD replacement for
external simulators like swtpm or the Microsoft TPM simulator.
Features:
tpm2-tools and wolfTPM examplesNO_RSA, FWTPM_NO_NV, and independent per-command-group gates you pick and choose to shrink the fTPM footprint)WOLFTPM_SMALL_STACK support for constrained environmentsSee docs/FWTPM.md for build instructions, configuration, and API reference.
wolfTPM implements the post-quantum algorithms added in TCG TPM 2.0 Library Specification v1.85, built on wolfCrypt's FIPS 203 (ML-KEM) and FIPS 204 (ML-DSA) modules.
Supported algorithms:
| Algorithm | Standard | Parameter sets |
|---|---|---|
| ML-DSA (signing) | FIPS 204 | ML-DSA-44 / 65 / 87 |
| Hash-ML-DSA (pre-hash signing) | FIPS 204 | ML-DSA-44 / 65 / 87 with caller hash |
| ML-KEM (key encapsulation) | FIPS 203 | ML-KEM-512 / 768 / 1024 |
wolfTPM officially supports the SealSQ QVault TPM, the first shipping TPM 2.0
with these v1.85 PQC algorithms in silicon. Build for it with --enable-sealsq --enable-pqc. The same examples and wrapper API also run against the in-tree
fwTPM server for CI or when no hardware is present. See the
TPM2 Benchmarks section for measured ML-DSA / ML-KEM
performance on the QVault TPM.
wolfSSL (ML-DSA and ML-KEM in wolfCrypt):
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
--enable-mldsa --enable-mlkem \
--enable-harden CFLAGS="-DWC_RSA_NO_PADDING"
make
sudo make installwolfTPM:
./configure --enable-fwtpm --enable-pqc
make--enable-v185 turns on the full v1.85 build (WOLFTPM_V185): the PQC
algorithms plus the non-PQC v1.85 spec additions. --enable-pqc turns on
just the lean PQC subset (WOLFTPM_PQC) — ML-DSA / ML-KEM only — which is
smaller for deployments that do not need the rest of v1.85. If you omit both
but --enable-fwtpm is set and wolfCrypt has ML-DSA + ML-KEM available,
configure auto-detects and enables full v1.85. Pass --disable-pqc to opt
out explicitly.
To compile only the operations you call (smaller binary, no malloc needed), mirror the wolfSSL flags:
# ML-DSA verify-only + ML-KEM encapsulate-only (no sign, no decapsulate)
./configure --enable-pqc --enable-mldsa=verify-only --enable-mlkem=enc| Flag | Values | Drops |
|---|---|---|
--enable-mldsa |
all (default) / sign-only / verify-only / no |
the unselected ML-DSA operation |
--enable-mlkem |
all (default) / enc / dec / no |
the unselected ML-KEM operation |
--disable-hash-mldsa |
— | pre-hash ML-DSA key support |
These map to WOLFTPM_NO_MLDSA_SIGN, WOLFTPM_NO_MLKEM_DECAP, etc., which
embedded integrators can also pass directly via CFLAGS without autotools.
Existing --enable-v185 builds are unaffected (every operation defaults on).
Disabling both algorithms (--enable-mldsa=no --enable-mlkem=no) is a configure
error — use --disable-pqc to build without any post-quantum support.
The same flags also trim the fwTPM server: --enable-fwtpm --enable-mldsa=verify-only builds a server that implements only ML-DSA verify
(the sign command handlers, dispatch entries, and crypto are compiled out).
fwTPM always builds the full v1.85 spec surface, so the trims apply on top of
WOLFTPM_V185.
make checkSee examples/pqc/README.md for per-example
details — the pqc_ctrl control center (every PQC operation plus board
control in one CLI, with pqc_ctrl.sh running the full command set),
pqc_mssim_e2e, mlkem_encap, and PQC options on the general-purpose
keygen/keyload tools (-mldsa, -hash_mldsa, -mlkem).
For the fwTPM server's PQC internals — the eight v1.85 commands, primary-key derivation, buffer constants, and spec-interpretation decisions — see docs/FWTPM.md.
wolfTPM implements SPDM (Security Protocol and Data Model, DMTF DSP0274) for TPM 2.0 attestation over the TCG SPDM-over-TPM binding. Both the TCG certificate handshake and the DSP0274 pre-shared-key (PSK) handshake are supported, negotiating SPDM protocol version 1.3.
For testing without discrete silicon, the fwtpm_server ships an SPDM 1.3
responder that drives the same handshake the real Nuvoton and Nations
parts use, so the SPDM stack can be exercised end-to-end in CI.
Build with --enable-spdm plus at least one handshake mode
(--enable-tcg for the certificate handshake, --enable-psk for the PSK
handshake). Vendor wire-format adapters are optional (--enable-nuvoton,
--enable-nations).
See src/spdm/README.md and src/fwtpm/README.md for build instructions, responder modes, and the end-to-end test scripts.
Platform TPM_RH_PLATFORM
Owner TPM_RH_OWNER
Endorsement TPM_RH_ENDORSEMENTEach hierarchy has their own manufacture generated seed.
The arguments used on TPM2_Create or TPM2_CreatePrimary create a template, which is fed into a KDF to produce the same key based hierarchy used. The key generated is the same each time; even after reboot. The generation of a new RSA 2048 bit key takes about 15 seconds. Typically these are created and then stored in NV using TPM2_EvictControl. Each TPM generates their own keys uniquely based on the seed.
There is also an Ephemeral hierarchy (TPM_RH_NULL), which can be used to create ephemeral keys.
Contains hash digests for SHA-1 and SHA-256 with an index 0-23. These hash digests can be extended to prove the integrity of a boot sequence (secure boot).
This project uses the terms append vs. marshall and parse vs. unmarshall.
Acronyms:
The examples in this library are written for use on a Raspberry Pi and use the spi_dev interface.
See the HAL manual in hal/README.md.
For interfacing to your hardware interface (SPI/I2C) a single HAL callback is used and configuration on initialization when calling TPM2_Init or wolfTPM2_Init.
There are HAL examples in hal directory for:
We also support an advanced IO option (--enable-advio/WOLFTPM_ADV_IO), which adds the register and read/write flag as parameter to the IO callback. This is required for I2C support.
Tested with:
Infineon SLB9670: TPM2: Caps 0x30000697, Did 0x001b, Vid 0x15d1, Rid 0x10 Mfg IFX (1), Vendor SLB9670, Fw 7.85 (4555), FIPS 140-2 1, CC-EAL4 1
Infineon SLB9672: TPM2: Caps 0x30000697, Di
No open issues yet, or sync has not completed.