swtpm_setup(8)
π swtpm_setup β the manual (section 8, bestie) π
okay so. bestie. welcome to swtpm_setup(8). this is the glow-up guide for the tool that simulates the manufacturing of a TPM 1.2 or a TPM 2.0. yes really. we're building a fake little factory for a fake little chip and it's iconic. πβ¨
β¨ NAME β¨
swtpm_setup β the Swtpm tool that simulates the manufacturing of a TPM 1.2 or 2.0. that's it, that's the whole vibe. π
π SYNOPSIS π
swtpm_setup [OPTIONS]
like. that's the whole thing. options only. no positional drama. periodt.
π¦ DESCRIPTION π¦
swtpm_setup is a tool that prepares the initial state for a libtpms-based TPM. think of it as the getting-ready-with-me of TPMs β someone has to set the state up before the real work starts, and that someone is this program. π
The following options are supported:
--runas<userid>β runswtpm_setup.shas this userid. Only'root'can use this option. everyone else, sit down. π--config<file>β path to a configuration file that holds the tool to use for creating certificates; peepswtpm_setup.conftoo. If you don't pass this parameter, the default configuration file gets used, and the search order for that default file goes like this:- if the environment variable
XDG_CONFIG_HOMEis set, then${XDG_CONFIG_HOME}/swtpm_setup.confis used if available; - otherwise, if the environment variable
HOMEis set, then${HOME}/.config/swtpm_setup.confis used if available; - if neither of the previous ones is available,
/etc/swtpm_setup.confis used.
- if the environment variable
yes it's a whole ranked list. slay. πΈ
--tpm-state<dir>or--tpmstate<dir>β path to the directory where the TPM's state will be written into. this is a mandatory argument, so no skipping it, bestie, it's literally required. π--tpm<path to executable>β path to the TPM executable. this one's optional, and by default theswtpmexecutable found in thePATHis used. π«Ά--tpm2β do the setup on a TPM 2. by default a TPM 1.2 gets set up. π--createekβ create an endorsement key (EK). ποΈ--allow-signingβ create an EK that can sign. this option requires--tpm2.
heads up bestie, this one creates a non-standard EK. when re-creating the EK, TPM 2 tools have to use the EK Template that is written at an NV index corresponding to the created EK (e.g., NV index 0x01c00004 for RS 2048 EK). otherwise the tool-created EK will not correspond to the actual key being used or the modulus shown in the EK certificate. so like. respect the template. π«
also, the TCG specification "EK Credential Profile For TPM Family 2.0; Level 0" suggests in its section on "EK Usage" that "the Endorsement Key can be a created as a decryption or signing key." however β some platforms will not accept an EK as a signing key, or as a signing and encryption key, and therefore this option should be used very carefully. like, respectfully, be careful. π
--decryptionβ create an EK that can be used for key encipherment. this is the default unless--allow-signingis passed. this option requires--tpm2. π--eccβ create elliptic curve crypto (ECC) keys; by default RSA keys are generated. curve appreciation post. π--take-ownershipβ take ownership. this option implies--createek. this option is only available for TPM 1.2. π--ownerpass<password>β provide a custom owner password; default is'ooo'. only available for TPM 1.2. π--owner-well-knownβ use a password of all zeros (20 bytes of zeros) as the owner password. only available for TPM 1.2. β--srkpass<password>β provide a custom SRK password; default is'sss'. only available for TPM 1.2. π--srk-well-knownβ use a password of all zeros (20 bytes of zeros) as the SRK password. only available for TPM 1.2. π--create-ek-certβ create an EK certificate; this implies--createek. π--create-platform-certβ create a platform certificate; this implies--create-ek-cert. π§Ύ--lock-nvramβ lock NVRAM access to all NVRAM locations that were written to. π--displayβ at the end, display as much info as possible about the configuration of the TPM. main character behavior, honestly. β¨--logfile<logfile>β the logfile to log to. by default logging goes tostdoutandstderr. π--keyfile<keyfile>β the key file contains an ASCII hex key consisting of 32 hex digits with an optional leading'0x'. this is the key to be used by the TPM emulator for encrypting the state of the TPM. π--keyfile-fd<file descriptor>β like--keyfilebut the key will be read from the file descriptor. π«Ά--pwdfile<passphrase file>β the passphrase file contains a passphrase from which the TPM emulator will derive the encryption key from and use the key for encrypting the TPM state. π€«--pwdfile-fd<file descriptor>β like--pwdfilebut the passphrase will be read from the file descriptor. π€«--ciper<cipher>β the cipher may be eitheraes-cbcoraes-128-cbcfor 128 bit AES encryption, oraes-256-cbcfor 256 bit AES encryption. the same cipher must be used on theswtpmcommand line later on. don't switch up mid-relationship. π--overwriteβ overwrite existing TPM state. all previous state will be erased. if this option is not given and an existing state file is found, an error code is returned. this one is destructive, bestie β all previous state, gone, poof. π--not-overwriteβ do not overwrite existing TPM state. if existing TPM state is found, the program ends without an error. the chill option. π--vmid<VM ID>β optional VM ID that can be used to keep track of certificates issued for VMs (or containers). this parameter will be passed through to the tool used for creating the certificates and may be required by that tool. π·οΈ--pcr-banks<PCR banks>β optional comma-separated list of PCR banks to activate. providing'-'allows a user to skip the selection and activates all PCR banks. by default thesha1andsha256banks are activated. π¦--swtpm_ioctl<executable>β pass the path to theswtpm_ioctlexecutable. by default theswtpm_ioctlin thePATHis used. ποΈ--tcsd-system-ps-file<file>β this option is deprecated and has no effect (since v0.4). it's giving ghost of options past. π»--rsa-keysize<keysize>(since v0.4) β this option allows to pass the size of a TPM 2 RSA EK key, such as2048or3072. the supported keysizes for a TPM 2 can be queried for using the--print-capabilitiesoption. the default size is2048bits for both TPM 1.2 and TPM 2. if'max'is passed, the largest possible key size is used. π--print-capabilities(since v0.2) β print capabilities that were added toswtpm_setupafter version 0.1. the output may contain the following:
{
"type": "swtpm_setup",
"features": [
"cmdarg-keyfile-fd",
"cmdarg-pwdfile-fd",
"tpm2-rsa-keysize-2048",
"tpm2-rsa-keysize-3072",
"tpm12-not-need-root"
]
}
the meaning of the feature verbs is as follows:
cmdarg-key-fdβ the--keyfile-fdoption is supported.cmdarg-pwd-fdβ the--pwdfile-fdoption is supported.tpm2-rsa-keysize-2048,...β the shown RSA key sizes are supported for a TPM 2's EK key. if none of thetpm2-rsa-keysizeverbs is shown then only RSA 2048 bit keys are supported.tpm12-not-need-root(since 0.4.0) β this option implies that any user can setup a TPM 1.2. previously onlyrootor the'tss'user, depending on configuration and availability of this account, could do that. π
--help,-hβ display the help screen. π
πΈ EXAMPLE USAGE πΈ
to simulate manufacturing of a TPM, one would typically run the following command:
#> sudo swtpm_setup --tpmstate /tmp/mytpm1/ \
--create-ek-cert --create-platform-cert --lock-nvram
note: since v0.4 TPM 1.2 setup does not require root rights anymore. π
any user can also simulate the manufacturing of a TPM using the swtpm-localca plugin. the following example assumes that the user has set the environment variable XDG_CONFIG_HOME as follows (using bash for example):
export XDG_CONFIG_HOME=~/.config
note: the XDG_CONFIG_HOME variable is part of the XDG Base Directory Specification. β¨
the following configuration files need to be created:
~/.config/swtpm_setup.conf:
# Program invoked for creating certificates
create_certs_tool= /usr/share/swtpm/swtpm-localca
create_certs_tool_config = ${XDG_CONFIG_HOME}/swtpm-localca.conf
create_certs_tool_options = ${XDG_CONFIG_HOME}/swtpm-localca.options
~/.config/swtpm-localca.conf:
statedir = ${XDG_CONFIG_HOME}/var/lib/swtpm-localca
signingkey = ${XDG_CONFIG_HOME}/var/lib/swtpm-localca/signkey.pem
issuercert = ${XDG_CONFIG_HOME}/var/lib/swtpm-localca/issuercert.pem
certserial = ${XDG_CONFIG_HOME}/var/lib/swtpm-localca/certserial
~/.config/swtpm-localca.options:
--platform-manufacturer Fedora
--platform-version 2.12
--platform-model QEMU
note: the tool swtpm-create-user-config-files can be used to create such files (with different content):
#> /usr/share/swtpm/swtpm-create-user-config-files
Writing /home/stefanb/.config/swtpm_setup.conf.
Writing /home/stefanb/.config/swtpm-localca.conf.
Writing /home/stefanb/.config/swtpm-localca.options.
the following commands now create a TPM 2 with an EK and platform certificate. the state of the TPM 2 will be stored in the directory ${XDG_CONFIG_HOME}/mytpm1.
#> mkdir -p ${XDG_CONFIG_HOME}/mytpm1
#> swtpm_setup --tpm2 --tpmstate ${XDG_CONFIG_HOME}/mytpm1 \
--create-ek-cert --create-platform-cert --lock-nvram
π SEE ALSO π
swtpm_setup.conf
π REPORTING BUGS π
report bugs to Stefan Berger <stefanb@linux.ibm.com>. he's the one who wants to hear about it, bestie. π«Ά
and that's the whole page, you ate that. this was swtpm_setup(8) from the swtpm source, dated 2024-07-30. go forth and manufacture ur lil TPM, no cap. πβ¨ππ¦πΈπ
π«Άππβππ§π
π¦ where this page comes from
- ubuntu jammy: swtpm-tools 0.6.3-0ubuntu3.3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms