tpm2_pcrallocate(1)
๐ tpm2_pcrallocate(1) ๐
okay so this is a General Commands Manual page for tpm2_pcrallocate(1) and honestly? it's giving main character energy for your TPM config. let's get into it bestie โจ
๐ธ NAME ๐ธ
tpm2_pcrallocate(1) โ configure PCRs and bank algorithms. that's literally it, that's the whole vibe ๐
๐ฆ SYNOPSIS ๐ฆ
tpm2_pcrallocate [OPTIONS] [*ARGUMENT]
๐ DESCRIPTION ๐
okay so tpm2_pcrallocate(1) is the tool that lets you (yes you, bestie) specify a PCR allocation for the TPM. an allocation is just the enabling or disabling of PCRs and their banks โ no cap. a PCR can have multiple banks, and each bank is tied to a specific hashing algorithm. you tell it what you want through the argument, iykyk.
if you give it no allocation at all, it'll default to SHA1 and SHA256 banks with PCRs 0 - 23 allocated. defaults are cute like that ๐
so the allocation is basically a list of banks plus the pcrs you picked. the values should follow the PCR bank specifiers standards โ check that section below, it's iconic ๐
heads up: the new allocations don't kick in until the next reboot. so like, don't panic when nothing changes immediately ๐ญ
also note: this command requires platform authorization. periodt. ๐
โจ OPTIONS โจ
-P,--auth=AUTHโ optional authorization value. these should follow the authorization formatting standards โ see the Authorization Formatting section below ๐ซถARGUMENTโ the command line argument that specifies the PCR allocation. this is where you tell it what you want, bestie.--cphash=FILEโ file path to record the hash of the command parameters. this is commonly called cpHash.
NOTE: when you pick this option, the tool won't actually execute the command โ it just returns a cpHash. like it's just here for the vibes ๐
๐ฅ References ๐ฅ
๐ง Context Object Format ๐ง
the type of a context object (whether it's a handle or a file name) gets figured out by this logic, in order:
- if the argument is a file path, then the file gets loaded as a restored TPM transient object โจ
- if the argument is a prefix match on one of:
owner:the owner hierarchy ๐platform:the platform hierarchy ๐๏ธendorsement:the endorsement hierarchy ๐lockout:the lockout control persistent object ๐
- if the argument can be loaded as a number, it'll be treated as a handle, e.g.
0x81010013, and used directly._OBJECT_ ๐ฏ
๐ Authorization Formatting ๐
authorization for use of an object in TPM2.0 can come in 3 different forms:
- Password
- HMAC
- Sessions
NOTE: "Authorizations default to the EMPTY PASSWORD when not specified". so like, no auth = empty password, that's the default bestie ๐
for authentication with auth values, the tool commands implicitly generate an HMAC session. so passwords aren't transmitted unencrypted โ slay ๐. BUT this does not apply to passwords defined for objects. in that case, an HMAC session should be used (see tpm2_startauthsession(1)).
๐ Passwords ๐
passwords get interpreted in the following forms below, using prefix identifiers:
Note: by default, passwords are assumed to be in the string form when they don't have a prefix. easy peasy ๐
๐ String ๐
a string password, specified by the prefix str: or its absence (raw string, no prefix), is not interpreted โ it's used directly for authorization.
Examples
foobar
str:foobar
๐ Hex-string ๐
a hex-string password, specified by the prefix hex:, gets converted from hexadecimal form into a byte array form. this is how you do passwords with non-printable and/or terminal un-friendly characters ๐โจ
Example
hex:1122334455667788
๐ File ๐
a file-based password, specified by the prefix file:, should be the path of a file containing the password to be read by the tool โ or a - to use stdin. storing passwords in files prevents information leakage, ok? passwords passed as options can be read from the process list or from common shell history features. protect yourself bestie ๐ซถ
Examples
# to use stdin and be prompted
file:-
# to use a file from a path
file:path/to/password/file
# to echo a password via stdin:
echo foobar | tpm2_tool -p file:-
# to use a bash here-string via stdin:
tpm2_tool -p file:- <<< foobar
๐ซ Sessions ๐ซ
when you're using a policy session to authorize the use of an object, prefix the option argument with the session keyword. then point to a path to a session file that was created with tpm2_startauthsession(1). optionally, if the session requires an auth value to be sent with the session handle (e.g. policy password), then append a + and a string as described in the Passwords section.
Examples
to use a session context file called session.ctx:
session:session.ctx
to use a session context file called session.ctx AND send the authvalue mypassword:
session:session.ctx+mypassword
to use a session context file called session.ctx AND send the HEX authvalue 0x11223344:
session:session.ctx+hex:11223344
๐ธ PCR Authorizations ๐ธ
you can satisfy a PCR policy using the pcr: prefix and the PCR minilanguage. the PCR minilanguage is as follows:
<pcr-spec>=<raw-pcr-file>
the PCR spec is documented in the section PCR bank specifiers.
the raw-pcr-file is an optional argument that contains the output of the raw PCR contents as returned by tpm2_pcrread(1).
๐ฆ PCR bank specifiers ๐ฆ
Examples
to satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3, use a specifier of:
pcr:sha256:0,1,2,3
specifying AUTH. yes queen ๐
๐ฎ Algorithm Specifiers ๐ฎ
options that take algorithms support "nice-names". ngl this is lowkey the best part.
there are two major algorithm specification string classes: simple and complex. only certain algorithms get accepted by the TPM, based on usage and conditions. so like, read the room ๐ซ
โญ Simple specifiers โญ
these are strings with no additional specification data. when creating objects, non-specified portions of an object are assumed to defaults. you can find the list of known "Simple Specifiers" below ๐
๐งธ Asymmetric ๐งธ
rsaecc
๐ Symmetric ๐
aescamelliasm4
๐ฏ Hashing Algorithms ๐ฏ
sha1sha256sha384sha512sm3_256sha3_256sha3_384sha3_512
๐ Keyed Hash ๐
hmacxor
โ๏ธ Signing Schemes โ๏ธ
rsassarsapssecdsaecdaaecschnorrsm2
๐ Asymmetric Encryption Schemes ๐
oaeprsaesecdh
๐ Modes ๐
ctrofbcbccfbecb
๐ฒ Misc ๐ฒ
null
๐ Complex Specifiers ๐
objects, when specified for creation by the TPM, have numerous algorithms to populate in the public data. things like type, scheme and asymmetric details, key size, etc. the general format for specifying this data is:
<type>:<scheme>:<symmetric-details>
๐ Type Specifiers ๐
this portion of the complex algorithm specifier is required. the remaining scheme and symmetric details will default based on the type specified and the type of the object being created. so the rest is optional, bestie ๐โโ๏ธ
aesโ default AES:aes128aes128<mode>โ 128 bit AES with optional mode (ctr|ofb|cbc|cfb|ecb). if mode is not specified, defaults tonull.aes192<mode>โ same asaes128<mode>, except for a 192 bit key size.aes256<mode>โ same asaes128<mode>, except for a 256 bit key size.sm4โ default SM4:sm4128sm4128orsm4_128 <mode>โ 128 bit SM4 with optional mode (ctr|ofb|cbc|cfb|ecb). if mode is not specified, defaults tonull.eccโ Elliptical Curve, defaults toecc256.ecc192orecc_nist_p192โ 192 bit ECC NIST curveecc224orecc_nist_p224โ 224 bit ECC NIST curveecc256orecc_nist_p256โ 256 bit ECC NIST curveecc384orecc_nist_p384โ 384 bit ECC NIST curveecc521orecc_nist_p521โ 521 bit ECC NIST curveecc_sm2orecc_sm2_p256โ 256 bit SM2 curversaโ default RSA:rsa2048rsa1024โ 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 skip it if you want, 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.
๐บ Hash Optional Scheme Specifiers ๐บ
these scheme specifiers are followed by a dash and a valid hash algorithm. for example: oaep-sha256.
oaepecdhrsassarsapssecdsaecschnorrsm2
๐ผ 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.
rsaes
๐ Symmetric Details Specifiers ๐
this field is optional, and defaults based on the type of object being created and its attributes. generally, any valid Symmetric specifier from the Type Specifiers list should work. if not specified, an asymmetric object's symmetric details default 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 sha384 hash
/tpm2_create -C parent.ctx -G ecc256:ecdaa4-sha384 -u key.pub -r key.priv
cryptographic algorithms ALGORITHM. iconic ๐ฅ
๐จ Object Attributes ๐จ
Object Attributes are used to control various properties of created objects. when specified as an option, either the raw bitfield mask or "nice-names" may be used. the values can be found in Table 31 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 31 and removing the prefix TPMA_OBJECT_ and lowercasing the result. so TPMA_OBJECT_FIXEDTPM becomes fixedtpm. slay ๐ nice names can be joined using the bitwise or | symbol.
for instance, to set the fields TPMA_OBJECT_FIXEDTPM, TPMA_OBJECT_NODA, and TPMA_OBJECT_SIGN_ENCRYPT, the argument would be:
fixedtpm|noda|sign
specifying the object attributes ATTRIBUTES.
๐งฌ PCR Bank Specifiers ๐งฌ
PCR Bank Selection lists follow the below specification:
<BANK>:<PCR>[,<PCR>] or <BANK>:all
multiple banks may be separated by +. so like, stack 'em ๐
for example:
sha1:3,4+sha256:all
will select PCRs 3 and 4 from the SHA1 bank and PCRs 0 to 23 from the SHA256 bank. ate and left no crumbs ๐ฝ๏ธ
certain commands support specifying forward sealing values as well:
sha1:0,1=da39a3ee5e6b4b0d3255bfef95601890afd80709,2
this will select the current values for PCRs 0 and 2, but use the specified value for PCR 1. digest lengths must match the bank size. an optional 0x prefix will be stripped off โ๏ธ
๐ Note ๐
PCR Selections allow for up to 5 hash to pcr selection mappings. this is a limitation in design in the single call to the TPM to get the pcr values. not me being limited by the spec ๐ญ
๐ COMMON OPTIONS
Okay bestie, this is the little grab-bag of options that basically every tool in the family supports โ the stuff users just expect to be there. No cap. โจ
-h,--help=[man|no-man]โ shows you the tool's manpage. By default it tries to fire up the manpager for the tool, and if that flops it'll just spit out a short tool summary instead. Same deal if you pass themanargument โ except if you explicitly ask forman, the tool will hand you the errors from man on stderr (so you actually see what went wrong). If you passno-man, or the manpager just isn't having it, the short options go to stdout. ๐ซถ To actually make the manpages feature work you need the manpages installed or sitting onMANPATHโ go peek at man(1) for the deets.-v,--versionโ prints version info for this tool plus the tctis it supports, then dips. ๐-V,--verboseโ turns up the volume on what the tool prints to the console while it runs. When this is on, the file and line number get printed too. ๐-Q,--quietโ silences normal tool output to stdout. shhh ๐คซ-Z,--enable-errataโ enables the application of errata fixups. Super useful if an errata fixup needs to be applied to the commands being sent to the TPM. Defining the env varTPM2TOOLS_ENABLE_ERRATAdoes the exact same thing. ๐ฉน-z,--pwd-sessionโ uses a password session instead of a HMAC session for authentication. A clear text password gets passed to the TPM to authorize the action. This option is your bestie when you're dodging problems with unsalted sessions under OpenSSL FIPS mode. > Heads up though: if auth values are used, a salted session should be used for authentication. ๐-R,--autoflushโ enables autoflush for transient objects created by the command. If a parent object is loaded from a context file, the transient parent object gets flushed too. You can also switch autoflush on by setting the env varTPM2TOOLS_AUTOFLUSHtoyesortrue. ๐ฝโจ
๐ฆ TCTI Configuration
The TCTI โ aka the "Transmission Interface" โ is literally just the communication mechanism with the TPM. You can swap TCTIs around to talk to TPMs across all kinds of different mediums. iconic.
To control the TCTI, the tools respect, in order:
- The command line option
-Tor--tcti - The environment variable:
TPM2TOOLS_TCTI.
Note: the command line option always overrides the environment variable. always always. ๐
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.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 don't support it will error when you try to use them without a TCTI connection. Does not support ANY options and MUST BE presented as the exact text ofnone. no extras, no vibes, justnone. โ ๏ธ
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. easy. ๐
๐ธ TCTI Defaults
When a TCTI isn't 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 tell you which of the aforementioned TCTIs is the default. iykyk ๐ง
โญ 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. So like โ this could be a path to the shared library, or a library name as understood by dlopen(3) semantics. slay, flexible. ๐
๐ TCTI OPTIONS
This collection of options configures the various known TCTI modules available:
device: for the device TCTI, you can specify the TPM character device file for the device TCTI to use. The default is/dev/tpm0.
Example: -T device:/dev/tpm0 or export TPM2TOOLS_TCTI=โdevice:/dev/tpm0โ
mssim: for the mssim TCTI, you can specify the domain name or IP address and port number used by the simulator. 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. ๐งฉ
The 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.
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. ๐ซ
โจ EXAMPLES
To allocate the two default banks (SHA1 and SHA256)
tpm2_pcrallocate
To make a custom allocation with a platform authorization
tpm2_pcrallocate -P abc sha1:7,8,9,10,16,17,18,19+sha256:all
To completly switch from SHA1 bank to SHA256 with a platform authorization
tpm2_pcrallocate -P abc sha1:none+sha256:all
look at her go ๐ญ๐
๐ฅ 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 โ take it to the issues, bestie. ๐
๐ซถ HELP
See the Mailing List.
๐ License
This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
and that's the whole page, bestie โ sourced from tpm2-tools and dated on the tpm2_pcrallocate(1) manpage footer. go allocate some PCRs, you absolute legend ๐ โจ๐
๐ฆ 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