tpm2_policynv(1)
π tpm2_policynv(1) β the policy-nv girlies' manual β¨
okay so bestie, this is tpm2_policynv, and it lives in the General Commands Manual section. she's a tpm2-tools girlie and honestly she eats.
πΈ NAME πΈ
tpm2_policynv(1) β evaluates policy authorization by comparing a specified value against the contents in the specified NV Index. literally her whole personality. π
π¦ SYNOPSIS π¦
tpm2_policynv [OPTIONS] [ARGUMENT] [ARGUMENT]
two arguments, no cap. she's low maintenance like that.
β¨ DESCRIPTION β¨
okay so tpm2_policynv(1) β here's the vibe: this command evaluates policy authorization by comparing the contents written to an NV index against the one you specified in the tool options. simple as.
the tool takes two arguments, and yes you need both:
- the NV index β specified as a raw handle, or as an offset value to the nv handle range
βTPM2_HR_NV_INDEXβ - the comparison operator β for magnitude comparison and/or bit test operations
iykyk: in the spec, the NV index holding the data is called operandA, and the data you specify to compare is called operandB. main character vs. supporting character energy.
the comparison operator can be specified as follows π«Ά:
βeqβif operandA = operandBβneqβif operandA != operandBβsgtβif signed operandA > signed operandBβugtβif unsigned operandA > unsigned operandBβsltβif signed operandA < signed operandBβultβif unsigned operandA < unsigned operandBβsgeβif signed operandA >= signed operandBβugeβif unsigned operandA >= unsigned operandBβsleβif signed operandA <= unsigned operandBβuleβif unsigned operandA <= unsigned operandBβbsβif all bits set in operandA are set in operandBβbcβif all bits set in operandA are clear in operandB
twelve of them. she's thorough. periodt π
π 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).
-P,--auth=AUTHβ specifies the authorization value for the hierarchy. π-L,--policy=FILEβ file to save the policy digest. she's saving receipts bestie.-S,--session=FILEβ the policy session file generated via the-Soption totpm2_startauthsessionor saved off of a previous tool run.--offset=NATURAL_NUMBERβ the offset within the NV index to start comparing at. β heads up: the size of the data starting at offset and ending at size of NV index shall not exceed the size of the operand specified in the options. so don't be messy.--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. no cap, it's just vibes and math at that point.-i,--input=FILEβ specifies the input file with data to compare to NV Index contents. in the standard specification, this is termed as operand or operandB more specifically. it can be specified as a file input or stdin if the option value is aβ-β. π yes, just a dash. iconic.
π References
π§ COMMON OPTIONS π§
this collection of options are common to many programs and provide information that many users may expect. the group chat classics, fr fr.
-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 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. she's telling you exactly where it went down.-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 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. π yeah, FIPS mode will humble you.-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. (the original page says "is is" and honestly? we respect the typo era.) information 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. basically the aux cord between you and the TPM. π
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 always. no exceptions bestie.
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. the simulator girlies know.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. don't try to be cute with it.
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. it's giving first-come-first-served.
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. build your own, slay.
β 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:abrmdandtabrmdare synonymous. the various known TCTI modules.
π EXAMPLES π
test if NV index content value is equal to an input number. to do this we first create an NV index of size 1 byte and write a value. eg. 0xAA. next we attempt to create a policy that becomes valid if the equality comparison operation of the NV index content against the one specified in the tool options. let's gooo π₯
π Define the test NV Index and write the value 0xAA to it π
nv_test_index=0x01500001
tpm2_nvdefine -C o -p nvpass $nv_test_index -a "authread|authwrite" -s 1
echo "aa" | xxd -r -p | tpm2_nvwrite -P nvpass -i- $nv_test_index
π Attempt defining policynv with wrong comparison value specified in options π
tpm2_startauthsession -S session.ctx --policy-session
### This should fail
echo "bb" | xxd -r -p | tpm2_policynv -S session.ctx -L policy.nv -i- 0x1500001 eq -P nvpass
tpm2_flushcontext session.ctx
β¨ Attempt defining policynv with right comparison value specified in options β¨
tpm2_startauthsession -S session.ctx --policy-session
### This should pass
echo "aa" | xxd -r -p | tpm2_policynv -S session.ctx -L policy.nv -i- 0x1500001 eq -P nvpass
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... set your session up first, bestie. don't skip steps. π
π 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 π this was tpm2_policynv(1) from the lovely humans over at tpm2-tools β go forth, compare your operands, and slay β¨π¦πΈ
π¦ 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