tpm2_load(1)
π
tpm2_load(1) π
okay bestie, listen up β this whole page comes straight out of the General Commands Manual, and it's giving "load stuff into your TPM" energy. let's get into it π«Ά
πΈ NAME πΈ
tpm2_load(1) β Load an object into the TPM. π
β¨ SYNOPSIS β¨
tpm2_load [OPTIONS]
π¦ DESCRIPTION π¦
okay so tpm2_load(1) has two whole jobs and honestly it slays both: it loads both the private and the public portions of an object into the TPM, or it loads the object in the TSS2-Private-Key PEM format. you can do this by specifying the private as well as the public section, or via a pem file using the -r option. no cap. β¨
the tool outputs the name of the loaded object in a YAML dictionary format, with the key name β and the value for that key is the name of the object in hex format, for example:
name: 000bac25cb8743111c8e1f52f2ee7279d05d3902a18dd1af694db5d1afa7adf1c8b3
it also saves a context file for future interactions with the object. π
β οΈ NOTE: Both private and public portions of the tpm key must be specified. The exception to this is if a TSS2-Private-Key formatted PEM object is to be loaded which does not need the public specified.
π OPTIONS π
-C,--parent-context=OBJECTβ The parent object. π-P,--auth=AUTHβ The authorization value of the parent object specified by-C. π-u,--public=FILEβ A file containing the public portion of the object. π-r,--private=FILEβ A file containing the sensitive portion of the object. π-n,--name=FILEβ An optional file to save the name structure of the object. β-c,--key-context=FILEβ The file name of the saved object context, required. π--cphash=FILEβ File path to record the hash of the command parameters. This is commonly termed ascpHash. NOTE: When this option is selected, the tool will not actually execute the command, it simply returns acpHash. π§
π References π
π§Έ Context Object Format
the type of a context object β whether it's a handle or a file name β is determined according to the following logic, in order:
- If the argument is a file path, then the file is loaded as a restored TPM transient object. ποΈ
- If the argument is a prefix match on one of:
owner: the owner hierarchyplatform: the platform hierarchyendorsement: the endorsement hierarchylockout: the lockout control persistent object
- If the argument argument can be loaded as a number it will be treat as a handle, e.g.
0x81010013and used directly._OBJECT_. π’
π Authorization Formatting
authorization for use of an object in TPM2.0 can come in 3 different forms:
- Password
- HMAC
- Sessions
π¬ NOTE: "Authorizations default to the EMPTY PASSWORD when not specified".
for authentication with auth values, the tool commands implicitly generate an HMAC session. thus passwords are not transmitted unencrypted. this does not apply to passwords defined for objects β in that case, an HMAC session should be used (see tpm2_startauthsession(1)). π«Ά
π Passwords
passwords are interpreted in the following forms below using prefix identifiers.
Note: by default passwords are assumed to be in the string form when they do not have a prefix.
π String
a string password, specified by prefix str: or it's absence (raw string without prefix), is not interpreted, and is directly used for authorization. β¨
πΈ Examples
foobar
str:foobar
π Hex-string
a hex-string password, specified by prefix hex:, is converted from a hexadecimal form into a byte array form β thus allowing passwords with non-printable and/or terminal un-friendly characters. iconic. π
β Example
hex:1122334455667788
ποΈ File
a file based password, specified be prefix file:, should be the path of a file containing the password to be read by the tool β or a - to use stdin. storing passwords in files prevents information leakage; passwords passed as options can be read from the process list or common shell history features. π₯
π Examples
# to use stdin and be prompted
file:-
# to use a file from a path
file:path/to/password/file
# to echo a password via stdin:
echo foobar | tpm2_tool -p file:-
# to use a bash here-string via stdin:
tpm2_tool -p file:- <<< foobar
π§ Sessions
when using a policy session to authorize the use of an object, prefix the option argument with the session keyword. then indicate a path to a session file that was created with tpm2_startauthsession(1). optionally, if the session requires an auth value to be sent with the session handle (eg policy password), then append a + and a string as described in the Passwords section. π
π Examples
to use a session context file called session.ctx.
session:session.ctx
to use a session context file called session.ctx AND send the authvalue mypassword.
session:session.ctx+mypassword
to use a session context file called session.ctx AND send the HEX authvalue 0x11223344.
session:session.ctx+hex:11223344
𧬠PCR Authorizations
you can satisfy a PCR policy using the pcr: prefix and the PCR minilanguage. the PCR minilanguage is as follows:
<pcr-spec>=<raw-pcr-file>
the PCR spec is documented in the section "PCR bank specifiers".
the raw-pcr-file is an optional argument that contains the output of the raw PCR contents as returned by tpm2_pcrread(1).
π§ͺ PCR bank specifiers
β¨ Examples
to satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifier of:
pcr:sha256:0,1,2,3
specifying AUTH.
π οΈ COMMON OPTIONS π οΈ
this collection of options are common to many programs and provide information that many users may expect. π
-h,--help=[man|no-man]β Display the tools manpage. By default, it attempts to invoke the manpager for the tool, however, on failure will output a short tool summary. This is the same behavior if the "man" option argument is specified, however if explicit "man" is requested, the tool will provide errors from man on stderr. If the "no-man" option if specified, or the manpager fails, the short options will be output to stdout. To successfully use the manpages feature requires the manpages to be installed or onMANPATH, Seeman(1)for more details.-v,--versionβ Display version information for this tool, supported tctis and exit. π-V,--verboseβ Increase the information that the tool prints to the console during its execution. When using this option the file and line number are printed. π-Q,--quietβ Silence normal tool output to stdout. π€«-Z,--enable-errataβ Enable the application of errata fixups. Useful if an errata fixup needs to be applied to commands sent to the TPM. Defining the environmentTPM2TOOLS_ENABLE_ERRATAis equivalent. π©Ή-z,--pwd-sessionβ Use password session instead of a HMAC session for authentication. A clear text password is passed to the TPM to authorize the action. This option can be used to avoid problems when unsalted sessions are used in OpenSSL FIPS mode. If auth values are used a salted session should be used for authentication. π-R,--autoflushβ Enable autoflush for transient objects created by the command. If a parent object is loaded from a context file also the transient parent object will be flushed. Autoflush can also be activated if the environment variableTPM2TOOLS_AUTOFLUSHis is set toyesortrue. information many users may expect. πΏ
π‘ TCTI Configuration π‘
the TCTI or "Transmission Interface" is the communication mechanism with the TPM. TCTIs can be changed for communication with TPMs across different mediums. π
to control the TCTI, the tools respect:
- The command line option
-Tor--tcti - The environment variable:
TPM2TOOLS_TCTI.
Note: the command line option always overrides the environment variable. π
the current known TCTIs are:
tabrmdβ The resource manager, calledtabrmd. Note thattabrmdandabrmdas a tcti name are synonymous.mssimβ Typically used for communicating to the TPM software simulator. π§ͺdeviceβ Used when talking directly to a TPM device file. πnoneβ Do not initialize a connection with the TPM. Some tools allow for off-tpm options and thus support not using a TCTI. Tools that do not support it will error when attempted to be used without a TCTI connection. Does not support ANY options and MUST BE presented as the exact text of "none". π
the arguments to either the command line option or the environment variable are in the form:
<tcti-name>:<tcti-option-config>
specifying an empty string for either the <tcti-name> or <tcti-option-config> results in the default being used for that portion respectively. β¨
π TCTI Defaults
when a TCTI is not specified, the default TCTI is searched for using dlopen(3) semantics. the tools will search for tabrmd, device and mssim TCTIs IN THAT ORDER and USE THE FIRST ONE FOUND. you can query what TCTI will be chosen as the default by using the -v option to print the version information. the "default-tcti" key-value pair will indicate which of the aforementioned TCTIs is the default. π―
π§ Custom TCTIs
any TCTI that implements the dynamic TCTI interface can be loaded. the tools internally use dlopen(3), and the raw tcti-name value is used for the lookup. thus, this could be a path to the shared library, or a library name as understood by dlopen(3) semantics. π¦
βοΈ TCTI OPTIONS βοΈ
this collection of options are used to configure the various known TCTI modules available:
device: For the device TCTI, the TPM character device file for use by the device TCTI can be specified. The default is/dev/tpm0. π Example:-T device:/dev/tpm0orexport TPM2TOOLS_TCTI="device:/dev/tpm0"mssim: For the mssim TCTI, the domain name or IP address and port number used by the simulator can be specified. The default are127.0.0.1and2321. π§ͺ Example:-T mssim:host=localhost,port=2321orexport TPM2TOOLS_TCTI="mssim:host=localhost,port=2321"abrmd: For the abrmd TCTI, the configuration string format is a series of simple key value pairs separated by a,character. Each key and value string are separated by a=character. π- TCTI abrmd supports two keys:
bus_name: The name of the tabrmd service on the bus (a string).bus_type: The type of the dbus instance (a string) limited tosessionandsystem.
- Specify the tabrmd tcti name and a config string of
bus_name=com.example.FooBar:
- TCTI abrmd supports two keys:
\--tcti=tabrmd:bus_name=com.example.FooBar
- Specify the default (abrmd) tcti and a config string of
bus_type=session:
\--tcti:bus_type=session
- NOTE:
abrmdandtabrmdare synonymous. the various known TCTI modules. π«
π EXAMPLES π
πΈ Setup
okay bestie, so before you can load literally anything, you need something to load it under. like, the TPM doesn't just accept random objects, it wants a parent, y'know? so step one is making the primary object π
tpm2_createprimary -c primary.ctx
Step 2, queen: create an object under the primary object π¦
tpm2_create -C primary.ctx -u key.pub -r key.priv
this is the part where you get the private and public portions of the TPM object β the two halves of the whole thing, fr fr. and with those object portions in your hands, you can now load that object into the TPM for whatever you need it for next. slay.
β¨ Loading an Object into the TPM
the final step, the main character moment π«Ά β you take the public and private portions of the object and load them into the TPM:
tpm2_load -C primary.ctx -u key.pub -r key.priv -c key.ctx
name: 000bac25cb8743111c8e1f52f2ee7279d05d3902a18dd1af694db5d1afa7adf1c8b3
that name: line is your receipt, and it is iconic. keep it π
π Returns
tools can return any of the following codes, no cap:
0β success. we love to see it π1β general non-specific error. just... a vibe, unfortunately π2β options handling error. something about your flags was giving wrong π©3β authentication error. wrong password energy, and it hurts π4β TCTI related error. the transport layer said no ma'am πΈ5β non supported scheme. applicable totpm2_testparams.
π¦ BUGS
Github Issues β that's where the bugs live, bestie π
π HELP
See the Mailing List β the group chat for when you're stuck π
β License
This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). very generous of them, honestly π
and that's the whole page, bestie!! π she's a tpm2-tools production, page tpm2_load(1), and she ate. now go load some objects β you got this, iykyk β¨π«Ά
π¦ where this page comes from
- arch rolling: tpm2-tools 5.8-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms