A Trusted Platform Module (TPM 2.0) is a dedicated hardware chip that generates and stores cryptographic keys in tamper-resistant hardware. When you use a TPM for your strongSwan private key, the key material never leaves the chip — even a privileged process on the host cannot export it.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/strongswan/strongswan/llms.txt
Use this file to discover all available pages before exploring further.
What TPM 2.0 offers
- Hardware-bound key storage — private keys are generated inside the TPM and cannot be extracted
- Platform binding via PCRs — keys can be sealed to specific Platform Configuration Register (PCR) values, so they are only usable when the platform is in a trusted boot state
- Attestation — the TPM can sign a quote over PCR values, proving the platform’s software state to a remote verifier
- No software key file — eliminates the risk of private key theft from the filesystem
Requirements
| Dependency | Purpose |
|---|---|
libtss2 (TPM2 Software Stack) | TSS2 ESAPI library for communicating with the TPM |
tpm2-tools | Command-line tools for TPM provisioning (tpm2_createprimary, tpm2_create, etc.) |
| Linux kernel TPM driver | /dev/tpm0 or /dev/tpmrm0 (resource manager) |
strongSwan libtpmtss plugin | strongSwan’s TSS2 integration layer |
Use
/dev/tpmrm0 (the kernel resource manager device) rather than /dev/tpm0 directly. The resource manager handles concurrent access and flushes contexts automatically.The tpm and libtpmtss plugins
strongSwan’s TPM support is provided by two components:
libtpmtss— a shared library that wraps the TSS2 ESAPI and FAPI interfaces; linked by thetpmplugintpmplugin — integrates TPM-resident keys into strongSwan’s credential framework so they can be used for IKEv2 authentication
Provisioning a TPM 2.0 key
Create a primary key (storage root)
The primary key is the root of a key hierarchy under the Owner hierarchy. This context is regenerated deterministically from the TPM’s seed — you do not need to persist it permanently.
Create an RSA child key under the primary
Generate a 2048-bit RSA key sealed under the primary context. The private blob stays inside the TPM.
Load the key and persist it at a permanent handle
Load the key into the TPM and write it to a persistent handle (NV index in the owner hierarchy). The handle After this step, the key is available at handle
0x81000001 is a common choice for the first user key.0x81000001 across reboots without needing primary.ctx or rsa.ctx on disk.Loading a TPM key via swanctl
Once the key is at a persistent handle, instruct swanctl to load it using the token interface:tpm plugin is loaded and a persistent handle is referenced in swanctl.conf.
Configuration in swanctl.conf
Reference the TPM key in thesecrets section using a token subsection. The handle field takes the hex-encoded CKA_ID (for PKCS#11) or TPM persistent handle, and module names the PKCS#11 module or TSS integration:
secrets.token<n> subsection tells strongSwan to load the private key from a token (smartcard or TPM) rather than from a file on disk. The handle is the hex-encoded CKA_ID of the private key on the token.
The certificate referenced in
certs must correspond to the public key stored at the TPM handle. Generate the certificate using the public key exported in the provisioning steps above.PCR binding
You can seal a TPM key to specific PCR values so the key is only available when the platform has booted in a trusted state. This is done duringtpm2_create using a policy:
Attestation use cases
TPM 2.0 attestation lets a remote verifier confirm what software is running on the platform:- The verifier sends a nonce to the platform.
- The platform uses an Attestation Key (AK) to sign a quote over a set of PCR values and the nonce.
- The verifier checks the quote signature against the AK certificate (issued by the TPM manufacturer or a local CA) and validates the PCR values against a known-good reference.