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 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. 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 environment TPM2TOOLS_ENABLE_ERRATA is 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 variable TPM2TOOLS_AUTOFLUSH is set to yes or true. 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:

  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 arguing, that's the rule πŸ‘‘

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 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.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. 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 pinCount that increments on a PIN authorization failure and a pinLimit.
  • pinpass β€” PIN Pass contains an 8-octet pinCount that increments on a PIN authorization success and a pinLimit.

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 to tpm2_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