百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

wolfTPM

> 数据库
开源

wolfTPM 是一款高度可移植的 TPM 2.0 库,专为嵌入式使用而设计。

336 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

wolfTPM 是一款高度可移植的 TPM 2.0 库,专为嵌入式使用而设计。

wolfTPM (TPM 2.0)

Portable TPM 2.0 project designed for embedded use.

Project Features

  • This implementation provides all TPM 2.0 API's in compliance with the specification.
  • Wrappers provided to simplify Key Generation/Loading, RSA encrypt/decrypt, ECC sign/verify, ECDH, NV, Hashing/HACM, AES, Sealing/Unsealing, Attestation, PCR Extend/Quote and Secure Root of Trust.
  • Any TPM 2.0 compliant module is supported. Tested modules include Infineon SLB9670, SLB9672, SLB9673, STMicroelectronics ST33KTPM2XSPI, ST33KTPM2I, ST33TPHF2XSPI, ST33TPHF2XI2C, Microchip ATTPM20, Nations Technologies/NSING Z32H330, NS350, Nuvoton NPCT650, NPCT750, and SealSQ QVault TPM (first TPM with post-quantum ML-DSA/ML-KEM in silicon).
  • wolfTPM uses the TPM Interface Specification (TIS) to communicate either over SPI, or using a memory mapped I/O range.
  • On Linux, wolfTPM auto-detects between the kernel TPM driver (/dev/tpmX) and direct SPI access at runtime - a simple ./configure && make works with either interface.
  • wolfTPM can also use the Linux TPM kernel interface (/dev/tpmX) to talk with any physical TPM on SPI, I2C and even LPC bus.
  • Platform support for Raspberry Pi (Linux), MMIO, STM32 with CubeMX, Atmel ASF, Xilinx, QNX, Infineon TriCore, wolfHAL and Barebox.
  • The design allows for easy portability to different platforms:
    • Native C code designed for embedded use.
    • Single IO callback for hardware SPI interface.
    • No external dependencies.
    • Compact code size and minimal memory use.
  • Includes example code for:
    • Most TPM2 native API's
    • All TPM2 wrapper API's
    • PKCS 7
    • Certificate Signing Request (CSR)
    • TLS Client
    • TLS Server
    • Use of the TPM's Non-volatile memory
    • Attestation (activate and make credential)
    • Benchmarking TPM algorithms and TLS
    • Key Generation (primary, RSA/ECC and symmetric), loading and storing to flash (NV memory)
    • Sealing and Unsealing data with an RSA key or externally signed policy.
    • Time signed or set
    • PCR read/reset
    • GPIO configure, read and write.
    • Endorsement Key/Cert retrieval and validation.
  • Parameter encryption support using AES-CFB or XOR.
  • Support for salted unbound authenticated sessions.
  • Support for HMAC Sessions.
  • Support for reading Endorsement certificates (EK Credential Profile).
  • Includes a portable firmware TPM 2.0 implementation (fwTPM, also known as fTPM / swtpm) for embedded platforms without a discrete TPM chip. See Firmware TPM (fwTPM / fTPM / swtpm) below.
  • Post-quantum cryptography support via TPM 2.0 Library Specification v1.85: ML-DSA (FIPS 204) signing and ML-KEM (FIPS 203) key encapsulation, enabled with --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.
  • SPDM attestation support (DMTF DSP0274) over the TCG SPDM-over-TPM binding, with a TCG certificate handshake and a DSP0274 pre-shared-key (PSK) handshake, enabled with --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.

Firmware TPM (fwTPM / fTPM / swtpm)

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:

  • 105 TPM 2.0 commands implemented (93% of v1.38 spec) with wolfCrypt cryptography (RSA, ECC, SHA, AES, HMAC)
  • Socket transport (Microsoft TPM simulator protocol) compatible with tpm2-tools and wolfTPM examples
  • TIS register-level transport over shared memory or SPI/I2C for bare-metal integration
  • HAL abstractions for IO transport and NV storage portability
  • File-based or custom NV storage via HAL callbacks
  • Compile-time algorithm and per-command-group feature selection (e.g., NO_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 environments

See docs/FWTPM.md for build instructions, configuration, and API reference.

Post-Quantum Cryptography (v1.85)

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.

Building

wolfSSL (ML-DSA and ML-KEM in wolfCrypt):

bash
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
            --enable-mldsa --enable-mlkem \
            --enable-harden CFLAGS="-DWC_RSA_NO_PADDING"
make
sudo make install

wolfTPM:

./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.

Trimming the PQC footprint

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.

Running the examples

make check

See 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.

SPDM Attestation

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.

TPM 2.0 Overview

Hierarchies

Platform    TPM_RH_PLATFORM
Owner       TPM_RH_OWNER
Endorsement TPM_RH_ENDORSEMENT

Each 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.

Platform Configuration Registers (PCRs)

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).

Terminology

This project uses the terms append vs. marshall and parse vs. unmarshall.

Acronyms:

  • HAL: Hardware Abstraction Layer.
  • NV: Non-Volatile memory.
  • TPM: Trusted Platform Module.

Platform

The examples in this library are written for use on a Raspberry Pi and use the spi_dev interface.

IO Callback (HAL)

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:

  • Atmel ASF
  • BareBox
  • Espressif ESP-IDF
  • Infineon TriCore
  • Linux
  • STM32 CubeMX
  • wolfHAL
  • Xilinx

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.

Hardware

Tested with:

  • Infineon OPTIGA (TM) Trusted Platform Module 2.0 SLB9670, SLB9672 and SLB9673 (I2C).
    • LetsTrust: Vendor for TPM development boards http://letstrust.de.
  • STMicro STSAFE-TPM, ST33TPHF2XSPI/2XI2C and ST33KTPM2X (SPI and I2C)
  • Microchip ATTPM20 module
  • Nuvoton NPCT65X or NPCT75x TPM2.0 modules
  • Nations Technologies Z32H330 or NS350 TPM 2.0 modules
  • SealSQ QVault TPM 2.0 module (SPI, post-quantum ML-DSA / ML-KEM)
  • NVIDIA Jetson Orin (Tegra234) firmware TPM - a TPM 2.0 running as an OP-TEE trusted application, reached through the Linux kernel driver rather than a bus. See docs/DEVTPM.md.

Device Identification

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ccryptographyeccembeddedfwtpm

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库