tpm2_policynamehash(1)
π¦ tpm2_policynamehash β the manual page, but make it a group chat π¦
Okay bestie, so this is tpm2_policynamehash(1) from the General Commands Manual and it is literally the tool that "couples a policy with names of specific objects" π
β yes, that's the actual NAME line, I'm not being cute, that's what it does.
β¨ SYNOPSIS β¨
tpm2_policynamehash [OPTIONS]
That's it. That's the whole vibe check. Options go in, magic comes out π
π DESCRIPTION π
So tpm2_policynamehash(1) couples a policy with the names of specific objects. Think of it like matching bestie bracelets, except the bracelets are cryptographic hashes and if they don't match, everything falls apart π
The tea is: this is a deferred assertion. What that means is β the hash of the names of all object handles in a TPM command gets checked against the one you specified in the policy. Not right now, not at the moment you run this, but later. Deferred. Like when you say "we'll talk about it later" and then you actually do talk about it later. Iconic behaviour honestly π
πΈ OPTIONS πΈ
-L,--policy=_FILE_ β the file where the compounded policy digest gets saved. This is your main character file, the one the whole policy hinges on π«-S,--session=_FILE_ β the policy session file, the one you generated earlier with the-Soption totpm2_startauthsession(1). Gotta have the session already going, no cap.-n,--name=_FILE_ β the file containing the name hash of the referenced objects. This is the "which objects are we talking about" receipt π§Ύ
π«Ά References
(yes, it's just sitting here being a heading with nothing under it, we don't ask questions, we just accept π)
π§ COMMON OPTIONS π§
This lil collection of options is common to lots of these programs and gives you info that many users just kinda expect to be there. Reliable king energy π
-h,--help=[man|no-man]β displays the tool's manpage. By default it tries to invoke the manpager for the tool, but if that fails it'll output a short tool summary instead. Same behaviour if you pass themanoption argument β but if you explicitly ask forman, the tool will give you errors from man on stderr. If you specify theno-manoption, or the manpager just isn't working, the short options get output to stdout.
To actually use the manpages feature you need the manpages installed or on MANPATH. Peep man(1) for the full details, iykyk.
-v,--versionβ displays version info for this tool, the supported tctis, and exits. Quick lil flex πββοΈ-V,--verboseβ turns up how much info the tool prints to the console while it's doing its thing. When you use this option, the file and line number get printed too. Detective mode π-Q,--quietβ silences normal tool output to stdout. Shhh π€«-Z,--enable-errataβ enables the application of errata fixups. Useful if an errata fixup needs to be applied to commands sent to the TPM. Defining the environment variableTPM2TOOLS_ENABLE_ERRATAis equivalent. Same energy, different door πͺ-z,--pwd-sessionβ use a 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β enables autoflush for transient objects created by the command. If a parent object is loaded from a context file, then the transient parent object will also get flushed. Autoflush can also be activated if the environment variableTPM2TOOLS_AUTOFLUSHis set toyesortrue(yes, the original says "is is set", we're keeping the typo's soul, it's part of the lore π). And then there's this trailing bit of info that many users may expect.
π TCTI Configuration π
The TCTI, aka the "Transmission Interface", is the communication mechanism with the TPM. TCTIs can be changed so you can talk to TPMs across different mediums. Interoperable queen π
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. No exceptions. Periodt.
The current known TCTIs are:
tabrmdβ the resource manager, called tabrmd. Note thattabrmdandabrmdas a tcti name are synonymous. Same girl, two nicknames π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β lowercase, exact, don't get creative π
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. Loud and clear π’
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 lil 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. So this could be a path to the shared library, or a library name as understood by dlopen(3) semantics. Build your own, bestie, we support you π«Ά
β TCTI OPTIONS β
This collection of options is 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 defaults 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.
- The 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. (And then the manpage just says "the various known TCTI modules." and leaves us hanging π we're keeping it, it's canon.)
π₯ EXAMPLES π₯
The mission: restrict key duplication to a specific new parent and a specific duplicable key. Let's get into it π
π Generate a duplicable object π
openssl genrsa -out signing_key_private.pem 2048
openssl rsa -in signing_key_private.pem -out signing_key_public.pem -pubout
tpm2_loadexternal -G rsa -C o -u signing_key_public.pem -c signing_key.ctx \
-n signing_key.name
tpm2_startauthsession -S session.ctx -g sha256
tpm2_policyauthorize -S session.ctx -L authorized.policy -n signing_key.name
tpm2_policycommandcode -S session.ctx -L policy.dat TPM2_CC_Duplicate
tpm2_flushcontext session.ctx
tpm2_createprimary -C o -g sha256 -G rsa -c primary.ctx -Q
## The duplicable key
tpm2_create -Q -C primary.ctx -g sha256 -G rsa -r key.prv -u key.pub \
-L policy.dat -a "sensitivedataorigin|sign|decrypt"
tpm2_load -Q -C primary.ctx -r key.prv -u key.pub -c key.ctx
π Create the new parent π
tpm2_create -Q -C primary.ctx -g sha256 -G rsa -r new_parent.prv \
-u new_parent.pub \
-a "decrypt|fixedparent|fixedtpm|restricted|sensitivedataorigin"
tpm2_loadexternal -Q -C o -u new_parent.pub -c new_parent.ctx
π Modify the duplicable key policy to namehash policy to restrict parent and key π
tpm2_readpublic -Q -c new_parent.ctx -n new_parent.name
tpm2_readpublic -Q -c key.ctx -n key.name
cat key.name new_parent.name | openssl dgst -sha256 -binary > name.hash
tpm2_startauthsession -S session.ctx -g sha256
tpm2_policynamehash -L policy.namehash -S session.ctx -n name.hash
tpm2_flushcontext session.ctx
openssl dgst -sha256 -sign signing_key_private.pem \
-out policynamehash.signature policy.namehash
tpm2_startauthsession -S session.ctx -g sha256
tpm2_policyauthorize -S session.ctx -L authorized.policy -i policy.namehash \
-n signing_key.name
tpm2_policycommandcode -S session.ctx -L policy.dat TPM2_CC_Duplicate
tpm2_flushcontext session.ctx
π Satisfy the policy and attempt key duplication π
tpm2_verifysignature -c signing_key.ctx -g sha256 -m policy.namehash \
-s policynamehash.signature -t verification.tkt -f rsassa
tpm2_startauthsession -S session.ctx --policy-session -g sha256
tpm2_policynamehash -S session.ctx -n name.hash
tpm2_policyauthorize -S session.ctx -i policy.namehash -n signing_key.name \
-t verification.tkt
tpm2_policycommandcode -S session.ctx TPM2_CC_Duplicate
tpm2_duplicate -C new_parent.ctx -c key.ctx -G null -p "session:session.ctx" \
-r dupprv.bin -s dupseed.dat
tpm2_flushcontext session.ctx
π Returns π
Tools can return any of the following codes, so keep this cheat sheet handy π
0β success. Slay π1β general non-specific error. The vague "something's off" text π2β options handling error. Bestie, check your flags.3β authentication error. Not you, not today π«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, don't come crying when your session's gone, the manpage warned you β οΈ
π BUGS π
Github Issues. That's the whole section. Go file one π
π«Ά 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, you're officially educated β¨ This lil beauty comes to you from tpm2-tools, manual page tpm2_policynamehash(1) β no date on this one, so consider this your timeless bestie π Go forth and name your hashes, queen ππ
π¦ 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