tpm2_pcrread(1)

πŸ’… tpm2_pcrread(1) β€” General Commands Manual πŸŽ€

okay bestie, buckle up, because this is tpm2_pcrread(1) and it's literally the tool that shows you your PCR values. yes, those PCRs. the platform configuration registers. the vibe check of your TPM, fr fr. ✨


🌸 NAME 🌸

tpm2_pcrread(1) β€” List PCR values. that's it. that's the whole job. iconic. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

tpm2_pcrread [OPTIONS] PCR_LIST_OR_ALG

πŸ’– DESCRIPTION πŸ’–

tpm2_pcrread(1) displays PCR values. and like, if you run it with no arguments at all? it outputs all the PCRs and all their hash banks. everything. the whole closet. no cap. 🫢

but you can filter, because you're a main character with preferences:

if you want to only see PCR banks with a given algorithm, just specify the hashing algorithm as the argument. algorithms follow the β€œformatting standards” (iykyk), so peek at the section β€œAlgorithm Specifiers”. also, the section β€œSupported Hash Algorithms” has the full list of what's supported. πŸ”₯

if instead you want a list of PCR banks (sha1, sha256, etc) and ids (0, 1, 2 etc), then you specify a PCR selection list as the argument, exactly as laid out in the section β€œPCR Bank Specifiers”. πŸ’…

also β€” please, please read the NOTES section below. it's there for a reason. πŸ™ˆ

the output gets written in a YAML format to stdout, with each algorithm followed by a PCR index and its value. so like, say you've only got sha1 and sha256 support and only 1 PCR. the output would be:

$ tpm2_pcrread sha1:0+sha256:0
sha1 :
  0  : 0000000000000000000000000000000000000003
sha256 :
  0  : 0000000000000000000000000000000000000000000000000000000000000003

look at those zeroes. gorgeous. 🌈


✨ OPTIONS ✨

  • -o, --output=FILE β€” the output file to write the PCR values in binary format. optional, bestie. πŸ’œ
  • --cphash=FILE β€” a 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. so like, it's giving window shopping, not actual shopping. πŸ’€
  • -S, --session=FILE β€” specifies the auxiliary sessions for the command. πŸŽ€
  • -F, --pcrs_format=FORMAT β€” format selection for the binary blob in the PCR output file. here's the tea:
    • values will output a binary blob of the PCR values.
    • serialized will write or read a binary blob of the PCR values in the form of serialized data structure in little endian format.
    • marshaled will read or write a binary blob in the binary format used by the TSS2 marshaling and unmarshaling functions. if marshaled is used, the data is serialized in the following order: TPML_PCR_SELECTION, UINT32 (the number of following TPML_DIGEST elements) TPML_DIGEST [number of TPML_DIGEST elements].

optional. default is values. πŸ¦‹


🌼 COMMON OPTIONS 🌼

this collection of options are common to many programs and provide information that many users may expect. the shared starter pack, basically. πŸ“

  • -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. 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. quick little flex. πŸ’…
  • -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. it's giving receipts. 🧾
  • -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 environment TPM2TOOLS_ENABLE_ERRATA is 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 variable TPM2TOOLS_AUTOFLUSH is set to yes or true. clean girl aesthetic, but for objects. 🧹

🌈 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 how-do-we-talk-to-the-TPM situation. πŸ’¬

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 exceptions. the CLI said what it said. πŸ‘‘

the current known TCTIs are:

  • tabrmd β€” the resource manager, called tabrmd. note that tabrmd and abrmd as a tcti name are synonymous. same girl, different name. πŸŽ€
  • 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 exactly none. all lowercase. no extras. that's the whole assignment. πŸ’€

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. so blank is fine, it'll just default on you. πŸ™ˆ

πŸ’œ 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. (caps lock because it's serious. that's the priority list, periodt.) πŸ”₯

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. bring your own, bestie. ✨


🌸 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. πŸ’…

πŸŽ€ PCR bank specifiers πŸŽ€


⭐ Supported Hash Algorithms ⭐

supported hash algorithms are:

  • 0x4 or sha1 for TPM_ALG_SHA1
  • 0xB or sha256 for TPM_ALG_SHA256 (default)
  • 0xC or sha384 for TPM_ALG_SHA384
  • 0xD or sha512 for TPM_ALG_SHA512
  • 0x12 or sm3_256 for TPM_ALG_SM3_256
NOTE: your TPM may not support all algorithms. sad but true. check before you commit. 😭

🌈 Algorithm Specifiers

Okay bestie, this is the part where the manual teaches you how to talk algorithm ✨ Any option that takes an algorithm is lowkey fluent in β€œnice-names”, so you don't have to hand-write some cursed little struct every time. Slay.

There are two major algorithm specification string classes: simple and complex. And heads up β€” only certain algorithms get accepted by the TPM, depending on usage and conditions. So like, not everything on the menu is available at every TPM, iykyk πŸ’…

Simple specifiers

These are strings with no extra specification data attached β€” just the bare name, no accessories. When you're creating objects, any part of the object you didn't specify is assumed to be defaults. The full list of known β€œSimple Specifiers” is right below, go off πŸ‘‘

Asymmetric

  • rsa
  • ecc

Symmetric

  • aes
  • camellia
  • sm4

Hashing Algorithms

  • sha1
  • sha256
  • sha384
  • sha512
  • sm3_256
  • sha3_256
  • sha3_384
  • sha3_512

Keyed Hash

  • hmac
  • xor

Signing Schemes

  • rsassa
  • rsapss
  • ecdsa
  • ecdaa
  • ecschnorr
  • sm2

Asymmetric Encryption Schemes

  • oaep
  • rsaes
  • ecdh

Modes

  • ctr
  • ofb
  • cbc
  • cfb
  • ecb

Misc

  • null

Complex Specifiers

So when objects get specified for creation by the TPM, they have like a whole public data situation to populate β€” type, scheme, asymmetric details, key size, all of it. The general format for spelling that out is:

<type>:<scheme>:<symmetric-details>

Type Specifiers

This part of the complex algorithm specifier is required, fr fr β€” you can't skip it. The remaining scheme and symmetric details will default based on the type you specified and the type of the object being created. Here's the whole roster:

  • aes β€” Default AES: aes128
  • aes128<mode> β€” 128 bit AES with optional mode (ctr|ofb|cbc|cfb|ecb). If mode is not specified, defaults to null.
  • aes192<mode> β€” Same as aes128<mode>, except for a 192 bit key size.
  • aes256<mode> β€” Same as aes128<mode>, except for a 256 bit key size.
  • sm4 β€” Default SM4: sm4128
  • sm4128 or sm4_128 <mode> β€” 128 bit SM4 with optional mode (ctr|ofb|cbc|cfb|ecb). If mode is not specified, defaults to null.
  • ecc β€” Elliptical Curve, defaults to ecc256.
  • ecc192 or ecc_nist_p192 β€” 192 bit ECC NIST curve
  • ecc224 or ecc_nist_p224 β€” 224 bit ECC NIST curve
  • ecc256 or ecc_nist_p256 β€” 256 bit ECC NIST curve
  • ecc384 or ecc_nist_p384 β€” 384 bit ECC NIST curve
  • ecc521 or ecc_nist_p521 β€” 521 bit ECC NIST curve
  • ecc_sm2 or ecc_sm2_p256 β€” 256 bit SM2 curve
  • rsa β€” Default RSA: rsa2048
  • rsa1024 β€” RSA with 1024 bit keysize.
  • rsa2048 β€” RSA with 2048 bit keysize.
  • rsa3072 β€” RSA with 3072 bit keysize.
  • rsa4096 β€” RSA with 4096 bit keysize.

Scheme Specifiers

Next up is an optional field β€” you can absolutely skip it, no pressure 🫢

Schemes are usually Signing Schemes or Asymmetric Encryption Schemes. Most signing schemes take a hash algorithm directly following the signing scheme. If the hash algorithm is missing, it defaults to sha256. Some take no arguments, and some take multiple arguments. Chaotic, but we deal.

Hash Optional Scheme Specifiers

These scheme specifiers get followed by a dash and a valid hash algorithm. For example: oaep-sha256.

  • oaep
  • ecdh
  • rsassa
  • rsapss
  • ecdsa
  • ecschnorr
  • sm2

Multiple Option Scheme Specifiers

This scheme specifier is followed by a count (max size UINT16), then followed by a dash (-) and a valid hash algorithm.

  • ecdaa

For example, ecdaa4-sha256. If no count is specified, it defaults to 4.

No Option Scheme Specifiers

This scheme specifier takes NO arguments. Like, zero. None.

  • rsaes

Symmetric Details Specifiers

This field is optional, and defaults based on the type of object being created and it's attributes. Generally, any valid Symmetric specifier from the Type Specifiers list should work. If it's not specified, an asymmetric object's symmetric details defaults to aes128cfb.

Examples

Create an rsa2048 key with an rsaes asymmetric encryption scheme

tpm2_create -C parent.ctx -G rsa2048:rsaes -u key.pub -r key.priv

Create an ecc256 key with an ecdaa signing scheme with a count of 4 and a sha384 hash

/tpm2_create -C parent.ctx -G ecc256:ecdaa4-sha384 -u key.pub -r key.priv
Yes bestie, that leading / is literally what the page says πŸ™ˆ copying it exactly, periodt.

πŸ¦‹ EXAMPLES

Display all PCR values

tpm2_pcrread

Display the PCR values with a specified bank

tpm2_pcrread sha1

Display the PCR values with specified banks and store in a file

tpm2_pcrread -o pcrs sha1:16,17,18+sha256:16,17,18

Display the supported PCR bank algorithms and exit

tpm2_pcrread

πŸ’œ NOTES

The maximum number of PCR that can be dumped at once is associated with the maximum length of a bank.

On most TPMs, it means that this tool can dump up to 24 PCRs at once. So like, don't come for it when your giant list gets capped at 24 β€” that's just the vibe check the hardware is giving you πŸ’€


⭐ Returns

Tools can return any of the following codes:

  • 0 β€” Success. We love to see it πŸ‘‘
  • 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 where the bugs live, bestie.


πŸŽ€ HELP

See the Mailing List β€” the elders are there and they know things 🫢


πŸ’… License

This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).


<div align=β€œcenter”>

✨ that's the whole page, you're so smart ✨

</div>

And for the cute sign-off: this gem is from the tpm2-tools package, page tpm2_pcrread(1) β€” that's literally all the footer says, no date in sight, which honestly? iconic. Go read those PCRs, main character πŸŒˆπŸ’–

πŸ“¦ where this page comes from