tpm2_readpublic(1)
π tpm2_readpublic(1) β like, the whole manual page, but make it make sense π«Ά
okay so real talk: this is tpm2_readpublic from the General Commands Manual, one of the tpm2-tools girlies, and she's here to spill the tea on reading the public area of a loaded object. no cap, that's the whole vibe. let's get into it β¨
πΈ NAME πΈ
tpm2_readpublic(1) β Read the public area of a loaded object. that's it, that's the girl. π
π¦ SYNOPSIS π¦
tpm2_readpublic [OPTIONS]
π DESCRIPTION π
tpm2_readpublic(1) β literally just reads the public area of a loaded object. iconic behavior, honestly. π
β¨ OPTIONS β¨
-c,--object-context=OBJECTβ the context object for the object you wanna read. like, which one, bestie? π-n,--name=FILEβ an optional file to save the name structure of the object into. optional but like, why wouldn't you π-f,--formatβ format selection for the public key output file. here's the menu:tss(the default) will output a binary blob according to the TPM 2.0 Specification.pemwill output an OpenSSL compatible PEM encoded public key.derwill output an OpenSSL compatible DER encoded public key.tpmtwill output a binary blob of theTPMT_PUBLICstruct referenced by TPM 2.0 specs.
tl;dr: public key format. pick your fighter π₯
-o,--output=FILEβ the output file path, recording the public portion of the object. yes, it writes the public bit to a file. groundbreaking, i know π¦-t,--serialized-handle=HANDLEβ if the object you're reading is a persistent object specified by a raw handle, you can optionally save the serialized handle for use later. β οΈ but hear me: this routine does NOT verify the name of the object being read. callers should ensure that the contents of name match the expected object's name. so like, do your own vibe check, fr fr π-q,--qualified-name=FILEβ saves the qualified name of the object toFILE. the qualified name of the object is the name algorithm hash of the parent's qualified name and the object's name. so basically the qualified name of the object serves as proof of the object's parents. genealogy but for TPM objects π
π References π
π§ Context Object Format π§
the type of a context object β whether it's a handle or a file name β gets figured out 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_. (yes that's how it's written, i don't make the rules π« )
π COMMON OPTIONS π
this collection of options are common to many programs and provide information that many users may expect. the shared bestie starter pack, basically π
-h,--help=[man|no-man]β display the tool's manpage. by default, it attempts to invoke the manpager for the tool, however on failure it 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 is 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 on MANPATH, see man(1) for more details. π
-v,--versionβ display version information for this tool, supported tctis and exit. cute AND informative β¨-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. she's chatty and i respect it π£οΈ-Q,--quietβ silence normal tool output to stdout. shhh π€«-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 a 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. it's giving... networking but make it TPM π
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. always. no exceptions. periodt. π
the current known TCTIs are:
tabrmdβ the resource manager, called tabrmd. 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. bring your own TCTI, i guess π«Ά
π 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/tpm0 or export 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 defaults are127.0.0.1and2321.
example: -T mssim:host=localhost,port=2321 or export 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.
- TCTI abrmd supports two keys:
specify the tabrmd tcti name and a config string of bus_name=com.example.FooBar:
\--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 (that's literally how the page transitions, i'm not fixing it, i'm just reporting it π)
π EXAMPLES π
π Create a primary object and read the public structure in an openssl compliant format π
tpm2_createprimary -c primary.ctx
tpm2_readpublic -c primary.ctx -o output.dat -f pem
π Serialize an existing persistent object handle to disk for later use π
this work-flow is primarily intended for existing persistent TPM objects. β οΈ this work-flow does not verify that the name of the serialized object matches the expected, and thus the serialized handle could be pointing to an attacker controlled object if no verification is done. if you are creating an object from scratch, save the serialized handle when making the object persistent. like, protect yourself bestie π
we assume that an object has already been persisted, for example via:
# We assume that an object has already been persisted, for example
tpm2_createprimary -c primary.ctx
# context files have all the information for the TPM to verify the object
tpm2_evictcontrol -c primary.ctx
persistent-handle: 0x81000001
action: persisted
next, use the persistent handle to get a serialized handle:
# The persistent handle output could be at an attacker controlled object,
# best practice is to use the option "-o: for tpm2_evictcontrol to get a
# serialized handle instead.
tpm2_readpublic -c 0x81000001 -o output.dat -f pem -t primary.handle
# use this verified handle in an encrypted session with the tpm
tpm2_startauthsession --policy-session -S session.ctx -c primary.handle
for new objects, its best to use all serialized handles. π«‘
β Returns β
tools can return any of the following codes:
0β Success. π1β General non-specific error. π¬2β Options handling error. π€3β Authentication error. π4β TCTI related error. π‘5β Non supported scheme. applicable totpm2_testparams. π«
π BUGS π
Github Issues. (go off, file them π )
π HELP π
See the Mailing List.
π License π
this work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). π
and that's the whole page, bestie β no skips, no summaries, every flag accounted for π«Ά
okay bye ily! this page came to you from the tpm2-tools girlies (that's the source/version, mwah π) β enjoy your public area reading era, you're gonna slay it β¨π π
π¦ 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