tpm2_policycountertimer(1)

πŸ’… tpm2_policycountertimer β€” the policy gatekeeper of TPM time, clock, resets & restarts

okay so you're reading the General Commands Manual for tpm2_policycountertimer(1), bestie, and honestly? She's a queen. Let's go.


✨ NAME ✨

tpm2_policycountertimer(1) β€” she enables policy authorization by evaluating a comparison operation on the TPM parameters time, clock, reset count, restart count and the TPM clock safe flag. That's the whole vibe.


πŸŽ€ SYNOPSIS πŸŽ€

tpm2_policycountertimer [OPTIONS] [ARGUMENT]

πŸ¦‹ DESCRIPTION πŸ¦‹

So tpm2_policycountertimer(1) enables policy authorization by evaluating the comparison operation on those five TPM parameters β€” time, clock, reset count, restart count, and the TPM clock safe flag. If it's time/clock, you feed it in as a milliseconds value. The parameter and the value get handed over as a command line argument, like this:

tpm2_policycountertimer -S session.ctx safe
tpm2_policycountertimer -S session.ctx clock=<N ms>
tpm2_policycountertimer -S session.ctx time=<N ms>
tpm2_policycountertimer -S session.ctx resets=<N>
tpm2_policycountertimer -S session.ctx restarts=<N>

ngl, the defaults here are doing a lot of quiet work: by default the comparison tests for equality, and also by default it tests for time. periodt.


⭐ OPTIONS ⭐

  • -L, --policy=_FILE_ β€” the file you save the policy digest into. πŸŽ€
  • -S, --session=_FILE_ β€” the policy session file. She's the one generated via the -S option to tpm2_startauthsession, or saved off from a previous tool run. ykyk.
  • --eq β€” if value of current time in the TPM = value of specified input time.
  • --neq β€” if value of current time in the TPM != value of specified input time.
  • --sgt β€” if signed value of current time in the TPM > signed value of specified input time.
  • --ugt β€” if unsigned value of current time in the TPM > unsigned value of specified input time.
  • --slt β€” if signed value of current time in the TPM < signed value of specified input time.
  • --ult β€” if unsigned value of current time in the TPM < unsigned value of specified input time.
  • --sge β€” if signed value of current time in the TPM >= signed value of specified input time.
  • --uge β€” if unsigned value of current time in the TPM >= unsigned value of specified input time.
  • --sle β€” if signed value of current time in the TPM <= unsigned value of specified input time. (yes bestie, the manual literally says signed on the left and unsigned on the right for this one β€” I'm just reporting what she wrote πŸ™ˆ)
  • --ule β€” if unsigned value of current time in the TPM <= unsigned value of specified input time.
  • --bs β€” if all bits set in value of current time in the TPM are set in value of specified input time.
  • --bc β€” if all bits set in value of current time in the TPM are clear in value of specified input time.
  • --cphash=_FILE_ β€” file path to record the hash of the command parameters. This is commonly termed as cpHash. NOTE: when this option is selected, the tool will not actually execute the command β€” it simply returns a cpHash. Not me, that's just the deal. πŸ’€

πŸ“š References πŸ“š

(so the manpage drops a "References" heading right here and then… says absolutely nothing. main character silence. iconic.)


πŸ‘‘ COMMON OPTIONS πŸ‘‘

This collection of options are common to many programs and provide information that many users may expect. basically the shared starter pack, bestie.

  • -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. Same behavior if the man option argument is specified β€” BUT 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.
  • -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 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. information many users may expect. (that trailing bit is verbatim, she's a little chaotic, we love her 🫢)

🌈 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. no cap.

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

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:
      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. the various known TCTI modules.

πŸ’– EXAMPLES πŸ’–

Create a sealing object with an authorization policy that evaluates only for first minute of TPM restart. obsessed with this use case tbh.

πŸŽ€ Create the policy and the sealing object πŸŽ€

tpm2_startauthsession -S session.ctx

tpm2_policycountertimer -S session.ctx -L policy.countertimer --ult 60000

tpm2_flushcontext session.ctx

tpm2_createprimary -C o -c prim.ctx -Q

echo "SUPERSECRET" | \
tpm2_create -Q -u key.pub -r key.priv -i- -C prim.ctx \
-L policy.countertimer -a "fixedtpm|fixedparent" -c key.ctx

πŸ¦‹ Unsealing should work in the first minute after TPM restart πŸ¦‹

tpm2_startauthsession -S session.ctx --policy-session

tpm2_policycountertimer -S session.ctx --ult 60000

tpm2_unseal -c key.ctx -p session:session.ctx

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 like, plan accordingly bestie. 😭


πŸ› BUGS πŸ›

Github Issues


🫢 HELP 🫢

See the Mailing List


πŸ’œ License πŸ’œ

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


okay that's the whole page, you ate that πŸ’… and to sign off properly: this gorgeous thing lives in the tpm2-tools family, and it's tpm2_policycountertimer(1) β€” mwah, go forth and gate your policies, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from