tpm2_policyauthorize(1)

πŸ’… tpm2_policyauthorize(1) β€” General Commands Manual, bestie edition πŸ’…

🌸 NAME 🌸

tpm2_policyauthorize(1) β€” allows for mutable policies by tethering to a signing authority. That’s the whole assignment, no cap. πŸ’–

✨ SYNOPSIS ✨

tpm2_policyauthorize [OPTIONS]

πŸ¦‹ DESCRIPTION πŸ¦‹

tpm2_policyauthorize(1) is literally how policies get to change: you associate the policy with a signing authority and let the policy contents change. Iconic behavior. πŸ‘‘

  1. If the input session is a trial session, this tool generates a policy digest that associates a signing authority’s public key name with the policy being authorized. So the name + policy are tethered together, slay. πŸ”—
  2. If the input session is a real policy session, tpm2_policyauthorize(1) looks for a verification ticket from the TPM to attest that the TPM has verified the signature on the policy digest before authorizing the policy in the policy digest. Basically: ticket says the TPM checked the signature, and then we authorize. 🎟️

πŸ’– OPTIONS πŸ’–

  • -L, --policy=FILE β€” file to save the policy digest. πŸ’Ύ
  • -S, --session=FILE β€” the policy session file generated via the -S option to tpm2_startauthsession(1). πŸ—‚οΈ
  • -i, --input=FILE β€” the policy digest that has to be authorized. This is the digest in question, bestie. πŸ”
  • -q, --qualification=FILE_OR_HEX β€” the policy qualifier data signed in conjunction with the input policy digest. It’s unique data that the signer can choose to include in the signature, and it can either be a path or a hex string. 🧾✨
  • -n, --name=FILE β€” file containing the name of the verifying public key. This ties the final policy digest with a signer. You can get this with tpm2_readpublic(1). πŸ”‘
  • -t, --ticket=FILE β€” the ticket file to record the validation structure. This is generated with tpm2_verifysignature(1). 🎫
  • --cphash=FILE β€” file path to record the hash of the command parameters. This is commonly termed cpHash.
NOTE: when this option is selected, the tool will not actually execute the command, it simply returns a cpHash. So don’t expect the command to run, bestie. 🫢

πŸ“š References πŸ“š

The original page has this References heading right here with no extra reference entries listed under it, so I’m not inventing any links. Heading present, chaos preserved. πŸ’€

🌟 COMMON OPTIONS 🌟

This collection of options is common to many programs and provides information that many users may expect. Group-chat classics, basically. πŸ’¬

  • -h, --help=[man|no-man] β€” display the tool’s manpage. By default it attempts to invoke the manpager for the tool, but on failure it will output a short tool summary. 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. Version check, then bye. πŸ‘‹
  • -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. Shhh era. 🀫
  • -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 environment TPM2TOOLS_ENABLE_ERRATA is 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 variable TPM2TOOLS_AUTOFLUSH is is set to yes or true.

Also yes, the original bullet has the stray trailing phrase information many users may expect. at the end β€” keeping that little chaos goblin for the record. πŸ˜­πŸ’€

πŸ“‘ 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:

  • tabrmd β€” the resource manager, called tabrmd. Note that tabrmd and abrmd as 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 initalize 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 is 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:

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 are 127.0.0.1 and 2321.

Example: -T mssim:host=localhost,port=2321 or export:

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:
      1. bus_name : the name of the tabrmd service on the bus (a string).
      2. bus_type : the type of the dbus instance (a string) limited to session and system.

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: abrmd and tabrmd are synonymous. Also, the original page has the trailing phrase the various known TCTI modules. right there β€” keeping it for the record. πŸ’€

πŸŽ€ EXAMPLES πŸŽ€

Starts a trial session, builds a PCR policy. This PCR policy digest is then an input to tpm2_policyauthorize(1) along with policy qualifier data and a signer public. The resultant policy digest is then used in creation of objects. 🧱

Subsequently, when the PCR changes and so does the PCR policy digest, the actual policy digest from tpm2_policyauthorize(1) used in creation of the object will not change. At runtime the new PCR policy needs to be satisfied along with verification of the signature on the PCR policy digest using tpm2_policyauthorize(1). πŸ”βœ¨

πŸ” Create a signing authority πŸ”

openssl genrsa -out signing_key_private.pem 2048

openssl rsa -in signing_key_private.pem -out signing_key_public.pem -pubout

tpm2_loadexternal -G rsa -C o -u signing_key_public.pem -c signing_key.ctx -n signing_key.name

πŸ—‚οΈ Create the authorize policy digest πŸ—‚οΈ

tpm2_startauthsession -S session.ctx

tpm2_policyauthorize -S session.ctx -L authorized.policy -n signing_key.name

tpm2_flushcontext session.ctx

πŸ§ͺ Create a policy to be authorized like a PCR policy πŸ§ͺ

tpm2_pcrread -opcr0.sha256 sha256:0

tpm2_startauthsession -S session.ctx

tpm2_policypcr -S session.ctx -l sha256:0 -f pcr0.sha256 -L pcr.policy_desired

tpm2_flushcontext session.ctx

✍️ Sign the policy ✍️

openssl dgst -sha256 -sign signing_key_private.pem -out pcr.signature pcr.policy_desired

🧰 Create a TPM object like a sealing object with the authorized policy based authentication 🧰

tpm2_createprimary -C o -g sha256 -G rsa -c prim.ctx

tpm2_create -g sha256 -u sealing_pubkey.pub -r sealing_prikey.pub -i- -C prim.ctx -L authorized.policy <<< "secret to seal"

πŸ” Verify the desired policy digest comes from the signing authority, read the actual value of PCR and check that read policy and desired policy are equal πŸ”

tpm2_verifysignature -c signing_key.ctx -g sha256 -m  pcr.policy_desired -s pcr.signature -t verification.tkt -f rsassa

tpm2_startauthsession \--policy-session -S session.ctx

tpm2_policypcr -S session.ctx -l sha256:0 -L pcr.policy_read

tpm2_policyauthorize -S session.ctx -L authorized.policy -i pcr.policy_desired -n signing_key.name -t verification.tkt

tpm2_load -C prim.ctx -u sealing_pubkey.pub -r sealing_prikey.pub -c sealing_key.ctx

unsealed=$(tpm2_unseal -p"session:session.ctx" -c sealing_key.ctx)

echo $unsealed

tpm2_flushcontext session.ctx

🎯 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 to tpm2_testparams.

🚧 Limitations 🚧

It expects a session to be already established via tpm2_startauthsession(1) and requires one of the following:

  • direct device access
  • extended session support with tpm2-abrmd.

Without it, most resource managers will not save session state between command invocations. So yeah, session state is not gonna magically persist. 😬

πŸ› BUGS πŸ›

Github Issues. That’s the bug-report vibe. πŸ›

πŸ“£ HELP πŸ“£

See the Mailing List. πŸ“¬

πŸ“œ License πŸ“œ

This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). πŸ“„

Cute sign-off: this iconic page is from tpm2-tools, for tpm2_policyauthorize(1), and the footer has no date β€” so I’m not inventing one. Mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from