tpm2_policyauthorizenv(1)
π tpm2_policyauthorizenv(1) β General Commands Manual
okay so bestie, this is tpm2_policyauthorizenv(1), and honestly? it's giving "mutable policies" main character energy. it lives in the General Commands Manual, and it's here to let your policy change by pointing at an NV index. let's get into it π«Ά
β¨ NAME β¨
tpm2_policyauthorizenv(1) β allows for mutable policies by referencing to a policy from an NV index. no cap, that's literally the whole job π
π¦ SYNOPSIS π¦
tpm2_policyauthorizenv [OPTIONS] [ARGUMENT]
πΈ DESCRIPTION πΈ
tpm2_policyauthorizenv(1) β so the way this works: this command allows for policies to change by referencing the authorization policy written to an NV index. iconic behavior tbh.
The NV index containing the authorization policy should remain readable even for trial session. and the index can be specified as raw handle or an offset value to the nv handle range βTPM2_HR_NV_INDEXβ. iykyk π
β¨ OPTIONS β¨
-C,--hierarchy=OBJECT β specifies the hierarchy used to authorize. supported options are:oforTPM_RH_OWNERpforTPM_RH_PLATFORM- <num> where a hierarchy handle or nv-index may be used.
when -C isn't explicitly passed the index handle will be used to authorize against the index. the index auth value is set via the -p option to tpm2_nvdefine(1). periodt π₯
-P,--auth=AUTH β specifies the authorization value for the hierarchy.-L,--policy=FILE β file to save the policy digest. slay.-S,--session=FILE β the policy session file generated via the-Soption totpm2_startauthsession(1).--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. π
References
(this heading exists in the original with nothing under it β just a cute lil empty section, no notes π)
π COMMON OPTIONS π
this collection of options are common to many programs and provide information that many users may expect. classics!
-h,--help=[man|no-man] β display the tool's manpage. by default, it attempts to invoke the manpager for the tool, however, on failure 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 if 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. 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 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 set toyesortrue. this is the information many users may expect, bestie π
π 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. always. no exceptions π
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β. like, exact exact π
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. detective work but make it TPM π΅οΈββοΈ
π¦ 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 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: abrmd and tabrmd are synonymous. the various known TCTI modules. π
π₯ EXAMPLES π₯
create a policypassword and write the policy digest to an NV Index. build a policyauthorizenv policy referencing the NV index in a trial session. the resultant policy digest is then used in creation of objects.
in a policy authorization session, first satisfy the policy written to the NV index. then run the policyauthorizenv which satisfies the authorization for the object. it's a whole little pipeline and it ate π
Define the test NV Index to store the auth policy
nv_test_index=0x01500001
tpm2_nvdefine -C o -p nvpass $nv_test_index -a "authread|authwrite" -s 34
Define the auth policy
tpm2_startauthsession -S session.ctx
tpm2_policypassword -S session.ctx -L policy.pass
tpm2_flushcontext session.ctx
Write the auth policy to the NV Index
echo "000b" | xxd -p -r | cat - policy.pass | \
tpm2_nvwrite -C $nv_test_index -P nvpass $nv_test_index -i-
Define the policyauthorizenv
tpm2_startauthsession -S session.ctx
tpm2_policyauthorizenv -S session.ctx -C $nv_test_index -P nvpass \
-L policyauthorizenv.1500001 $nv_test_index
tpm2_flushcontext session.ctx
Create and load a sealing object with auth policy = policyauthorizenv
tpm2_createprimary -C o -c prim.ctx
echo "secretdata" | \
tpm2_create -C prim.ctx -u key.pub -r key.priv \
-a "fixedtpm|fixedparent|adminwithpolicy" -L policyauthorizenv.1500001 -i-
tpm2_load -C prim.ctx -u key.pub -r key.priv -c key.ctx
Satisfy the auth policy stored in the NV Index and thus policyauthorizenv
tpm2_startauthsession -S session.ctx --policy-session
tpm2_policypassword -S session.ctx
tpm2_policyauthorizenv -S session.ctx -C $nv_test_index -P nvpass $nv_test_index
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 thing, you're so welcome π this page is brought to you by tpm2-tools (that's the source/version, mwah) and the man page goes by tpm2_policyauthorizenv(1) β no date on this one, so consider this your timestamp: now, bestie πβ¨ slay responsibly and flush your contexts π¦
π¦ 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