tpm2_readpublic - Man Page

Read the public area of a loaded object.

Synopsis

tpm2_readpublic [Options]

Description

tpm2_readpublic(1) - Reads the public area of a loaded object.

Options

References

Context Object Format

The type of a context object, whether it is a handle or file name, is determined according to the following logic in-order:

Common Options

This collection of options are common to many programs and provide information that 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:

  1. The command line option -T or --tcti
  2. The environment variable: TPM2TOOLS_TCTI.

Note: The command line option always overrides the environment variable.

The current known TCTIs are:

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:

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.

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:

Bugs

Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)

Help

See the Mailing List (https://lists.linuxfoundation.org/mailman/listinfo/tpm2)

Referenced By

tpm2_import(1), tpm2_policyauthorize(1), tpm2_startauthsession(1).

tpm2-tools General Commands Manual