tpm2_nvdefine(1)
π¦ tpm2_nvdefine(1) π¦
okay so bestie, welcome to the manual page for tpm2_nvdefine(1) out of the General Commands Manual β it lives in your terminal, it's your new obsession, and we're gonna go through it together line by line because nothing is getting skipped. grab a snack, this one's long. π
β¨ NAME β¨
tpm2_nvdefine(1) β literally just here to Define a TPM Non-Volatile (NV) index. that's the whole job. slay. π
β¨ SYNOPSIS β¨
tpm2_nvdefine [OPTIONS] [ARGUMENT]
πΈ DESCRIPTION πΈ
tpm2_nvdefine(1) β it defines an NV index with the auth value you give it. the index itself gets specified as an argument, and you've got options for how: either a raw handle or an offset value into the nv handle range "TPM2_HR_NV_INDEX". if you don't specify an index at all, the tool is like "no worries, i got you" and uses the first free index. and on success it outputs the nv index it just defined. main character behavior ngl. π
π OPTIONS π
-C,--hierarchy=OBJECTβ specifies the handle used to authorize. defaults too,TPM_RH_OWNER, when no value has been specified. supported options are:oforTPM_RH_OWNERpforTPM_RH_PLATFORM<num>where a hierarchy handle or nv-index may be used
-s,--size=NATURAL_NUMBERβ specifies the size of the data area in bytes. defaults toMAX_NV_INDEX_SIZE, which is typically2048.-g,--hash-algorithm=ALGORITHMβ the hash algorithm used to compute the name of the Index and also used for the authorization policy. and if the index is an extend index, this hash algorithm is what gets used for the extend. multitasking icon. β¨-a,--attributes=ATTRIBUTESβ specifies the attribute values for the nv region used when creating the entity. you can use either the raw bitfield mask or the "nice-names" (yes that's really what they're called, see the "NV Attributes" section for the full tea β). if you don't specify anything, the attributes default to various selections based on the hierarchy the index is defined in:- for the owner hiearchy the defaults are:
TPMA_NV_OWNERWRITETPMA_NV_OWNERREAD
- for the platform hiearchy, the defaults are:
TPMA_NV_PPWRITETPMA_NV_PPREAD
- if a policy file is specified, the hiearchy chosen default attributes are bitwise or'd with:
TPMA_NV_POLICYWRITETPMA_NV_POLICYREAD
- if a policy file is NOT specified, the hiearchy chosen default attributes are bitwise or'd with:
TPMA_NV_AUTHWRITETPMA_NV_AUTHREAD
- for the owner hiearchy the defaults are:
-P,--hierarchy-auth=AUTHβ specifies the authorization value for the hierarchy. authorization values should follow the "authorization formatting standards", see the "Authorization Formatting" section. π«Ά-p,--index-auth=AUTHβ specifies the password of the NV Index when it's created. HMAC and Password authorization values should follow the "authorization formatting standards", see the "Authorization Formatting" section.-L,--policy=FILEβ specifies the policy digest file for policy based authorizations.--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 like, it's giving "i'm just here for the paperwork" π--rphash=FILEβ file path to record the hash of the response parameters. this is commonly termed as rpHash.-S,--session=FILEβ the session created usingtpm2_startauthsession. multiple of these can be specified. for example, you can have one session for auditing and another for encryption/decryption of the parameters. two sessions, two vibes. πARGUMENTβ the command line argument specifies the NV index or offset number.
π§ References π§
π Context Object Format π
the type of a context object β whether it's a handle or a file name β is determined according to the following logic, in order:
- if the argument is a file path, then the file is loaded as a restored TPM transient object.
- if the argument is a prefix match on one of:
owner:the owner hierarchyplatform:the platform hierarchyendorsement:the endorsement hierarchylockout:the lockout control persistent object
- if the argument argument (yes, "argument argument", i don't make the rules π) can be loaded as a number it will be treat as a handle, e.g.
0x81010013and 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".
for authentication with auth values, the tool commands implicitly generate an HMAC session. thus passwords are not transmitted unencrypted. this does not apply to passwords defined for objects β in that case, an HMAC session should be used (see tpm2_startauthsession(1)).
π Passwords π
passwords are interpreted in the following forms below using prefix identifiers.
Note: by default passwords are assumed to be in the string form when they do not have a prefix.
π String
a string password, specified by prefix "str:" or its absence (raw string without prefix) is not interpreted, and is directly used for authorization.
Examples
foobar
str:foobar
π§ͺ Hex-string
a hex-string password, specified by prefix "hex:" is converted from a hexidecimal form into a byte array form β thus allowing passwords with non-printable and/or terminal un-friendly characters. genuinely iconic of it. β¨
Example
hex:1122334455667788
π File
a file based password, specified be 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 β passwords passed as options can be read from the process list or common shell history features. so like, keep it off the timeline 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 using a policy session to authorize the use of an object, prefix the option argument with the session keyword. then indicate 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 (eg 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 in the section "PCR bank specifiers". (yes, "in in". we love a typo moment π)
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.
π 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. thus, TPMA_OBJECT_FIXEDTPM becomes fixedtpm. 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 nv attributes ATTRIBUTES.
β COMMON OPTIONS β
this collection of options are common to many programs and provide information that many users may expect. group-chat classics, basically. π«Ά
-h,--help=[man|no-man]β Display the tools 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 if 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.-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. π-Q,--quietβ Silence normal tool output to stdout. shh. π€«-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.-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 variableTPM2TOOLS_AUTOFLUSHis is set toyesortrue. information many users may expect. π
TCTI Configuration
Okay bestie, real talk: the TCTI β aka the βTransmission Interfaceβ β is literally just how we talk to the TPM. It's the communication mechanism. Different mediums, different TPMs, different TCTIs. That's the whole vibe. π
So to control which TCTI gets used, the tools respect these two things, in order:
- The command line option
-Tor--tcti - The environment variable
TPM2TOOLS_TCTI.
Note: the command line option always overrides the environment variable. No cap. π
The current known TCTIs are:
tabrmdβ the resource manager, called tabrmd. Heads up:tabrmdandabrmdas a tcti name are synonymous. Same girl, different name tag π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. It does not support ANY options and it MUST BE presented as the exact textnone. Like, exactly. Don't get cute with it π
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 the <tcti-option-config> results in the default being used for that portion respectively. Empty = default, it's giving "no thoughts, head empty, still slays" β¨
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. It's giving first-come-first-served at the club π«Ά
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. So cute, so informative.
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, the doors are open π¦
β¨ 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 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.- 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. the various known TCTI modules.
π EXAMPLES π
Observe, bestie. Two little masterpieces:
tpm2_nvdefine 0x1500016 -C o -s 32 -a 0x2000A
tpm2_nvdefine 0x1500016 -C o -s 32 -a ownerread|ownerwrite|policywrite -p 1a1b
First one's the minimalist icon. Second one? Full glam with the attribute list and a password. Both ate. π
π Returns π
Tools can return any of the following codes:
0β Success. (the slay ending π)1β General non-specific error.2β Options handling error.3β Authentication error.4β TCTI related error.5β Non supported scheme. Applicable totpm2_testparams.
If you see anything that isn't 0, it's not you, it's the error π go read the code.
π BUGS π
Github Issues β that's the whole section, she's lowkey mysterious like that. Take your bugs there, bestie.
π«Ά HELP π«Ά
See the Mailing List. The community's got you.
π License π
This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). Share it, remix it, credit it β iconic behavior only β¨
And that's a wrap on tpm2_nvdefine(1)! Source: tpm2-tools, dated with that footer date of its very own β the full tpm2-tools / tpm2_nvdefine(1) lineup at the bottom of the page, bestie. Go forth and define some NV space ππΈπ§
π¦ 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