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-Soption totpm2_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 themanoption argument is specified β BUT if explicitmanis requested, the tool will provide errors from man onstderr. If theno-manoption is specified, or the manpager fails, the short options will be output tostdout.
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 tostdout.-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. (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:
- The command line option
-Tor--tcti - 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 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 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 ofnone.
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 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
abrmdsupports 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
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 π
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 totpm2_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
- 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