tpm2_nvreadpublic(1)
π tpm2_nvreadpublic(1) π
okay so bestie, you've landed on the tpm2_nvreadpublic(1) page from the General Commands Manual, and honestly? it's a little icon. this tool spills the tea on every Non-Volatile (NV) index your TPM has defined, and it does it in YAML, which is giving organized queen energy. no cap, it's the easiest TPM tool to love. let's get into it π«Ά
β¨ NAME β¨
tpm2_nvreadpublic(1) β display all defined Non-Volatile (NV)s indices. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
tpm2_nvreadpublic [OPTIONS]
no positional args, no drama. just options, slay π
π¦ DESCRIPTION π¦
tpm2_nvreadpublic(1) displays all defined Non-Volatile (NV) indices to stdout in a YAML format. literally exactly what it says on the tin.
so it displays metadata for all defined NV indices. and that metadata includes, hold on:
- the size of the defined region π
- the hash algorithm used to compute the name of the index π
- the auth policy π
- the NV attributes as defined in section "NV Attributes" (yes, there's a whole section for that below, keep scrolling bestie) π·οΈ
π Example Output π
here's what it actually looks like when it pops off:
0x1500015:
hash algorithm:
friendly: sha256
value: 0xB
attributes:
friendly: ownerwrite|ownerread
value: 0x2000200
size: 32
authorization policy:
0x1500017:
hash algorithm:
friendly: sha256
value: 0xB
attributes:
friendly: ownerwrite|ownerread
value: 0x2000200
size: 32
authorization policy:
look at that. friendly names AND raw value hex. the duality of woman β¨
π OPTIONS π
--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 unless rphash is also required. so don't be out here thinking it did the thing, because it did not do the thing π--rphash=FILEβ file path to record the hash of the response parameters. this is commonly termed as rpHash. cute pair with the one above π«Ά-S,--session=POLICY_SESSIONβ specify an auxiliary session for auditing and or encryption/decryption of the parameters. it's giving extra security, we love her π-n,--name=FILEβ the name of the NV index that must be provided when only calculating the cpHash without actually dispatching the command to the TPM. so if you're just math-ing, you gotta hand over the name π§
π COMMON OPTIONS π
this collection of options are common to many programs and provide information that many users may expect. so they're not special to this tool, they're like, the friend group everyone shares π
-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 frommanon 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. short and sweet β¨-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 chatty and we respect it π£οΈ-Q,--quietβ silence normal tool output to stdout. shhhh π€«-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. iykyk π§-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. β οΈ heads up on that clear text password bit, bestie π-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. cleanliness is next to godliness β¨
π« 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. it's the whole vibe of how we're talking to the chip π¦
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 arguing, that's the rule π
the current known TCTIs are:
- tabrmd β the resource manager, called tabrmd. note that
tabrmdandabrmdas 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 initialize 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. π literally spell it exactly like that or it's not happening.
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. leaving a blank is valid, we love a low-effort moment π
π§ 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. so order matters, bestie, don't forget it π
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. cute little peek behind the curtain β¨
π¦ 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. bring your own TCTI, we'll load her π
π 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.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. same girl, two names π
π·οΈ NV Attributes π·οΈ
NV Attributes are used to control various properties of the NV defined space. when specified as an option, either the raw bitfield mask or "nice-names" may be used. the values can be found in Table 204 Part 2 of the TPM2.0 specification, which can be found here:
https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf
nice names are calculated by taking the name field of table 204 and removing the prefix TPMA_NV_ and lowercasing the result. thus, TPMA_NV_PPWRITE becomes ppwrite. nice names can be joined using the bitwise or | symbol. β¨
note that the TPM_NT field is 4 bits wide, and thus can be set via nt= format. for instance, to set The fields TPMA_NV_OWNERREAD, TPMA_NV_OWNERWRITE, TPMA_NV_POLICYWRITE, and TPMA_NT = 0x2, the argument would be:
ownerread|ownerwrite|policywrite|nt=0x2
additionally, the NT field, which denotes the type of the NV index, can also be specified via friendly names:
- ordinary β Ordinary contains data that is opaque to the TPM that can only be modified using
TPM2_NV_Write. - extend β Extend is used similarly to a PCR and can only be modified with
TPM2_NV_Extend. Its size is determined by the length of the hash algorithm used. - counter β Counter contains an 8-octet value that is to be used as a counter and can only be modified with
TPM2_NV_Increment - bits β Bit Field contains an 8-octet value to be used as a bit field and can only be modified with
TPM2_NV_SetBits. - pinfail β PIN Fail contains an 8-octet
pinCountthat increments on a PIN authorization failure and apinLimit. - pinpass β PIN Pass contains an 8-octet
pinCountthat increments on a PIN authorization success and apinLimit.
for instance, to set The fields TPMA_NV_OWNERREAD, TPMA_NV_OWNERWRITE, TPMA_NV_POLICYWRITE, and TPMA_NT = bits, the argument would be:
ownerread|ownerwrite|policywrite|nt=bits
see how much nicer that reads than raw hex? she ate π
π₯ EXAMPLES π₯
List the defined NV indices to stdout
tpm2_nvreadpublic
that's it. that's the example. one command, zero flags, full YAML dump. iconic π
β 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. π
π BUGS π
Github Issues. that's the whole section, go open one if something's cursed π
π£ HELP π£
See the Mailing List. the girlies are there, they know things π«Ά
π License π
this work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). share away, just give credit bestie β¨
okay that's the whole page! this one ships with tpm2-tools (source vibes: tpm2-tools, section tpm2_nvreadpublic(1)) β so go forth, run tpm2_nvreadpublic, and read your NV indices like the main character you are. mwah πππ
π¦ 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