tpm2_policylocality(1)
π
NAME β tpm2_policylocality(1)
Okay bestie, this is the tpm2_policylocality(1) page from the General Commands Manual β the Unix tool that restricts TPM object authorization to specific localities. It's giving very specific-access-control energy, and honestly? Obsessed.
β¨ SYNOPSIS β¨
tpm2_policylocality [OPTIONS] [ARGUMENT]
π¦ DESCRIPTION π¦
tpm2_policylocality(1) restricts TPM object authorization to a specific TPM locality. It's useful when you want to allow only a specific locality with the TPM object. A locality indicates the source of the command β for example, it could be from the application layer or the driver layer, and each would have its own locality integer.
Localities are hints to the TPM and are enforced by the software communicating to the TPM. So they are not trusted inputs on their own and are implemented in platform-specific ways. No cap.
As an argument it takes the LOCALITY as an integer or friendly name.
Localities are fixed to a byte in size and have two representations: locality and extended locality.
Localities 0 through 4 are the normal locality representation and are represented as set bit indexes. Thus locality 0 is indicated by 1<<0 and locality 4 is indicated by 1<<4. Rather than using raw numbers, these localities can also be specified by the friendly names of:
zero: locality0or1<<0one: locality1or1<<1two: locality2or1<<2three: locality3or1<<3four: locality4or1<<4
Anything from the range 32 - 255 are extended localities. π
π OPTIONS π
-S,--session=FILEβ a session file fromtpm2_startauthsession(1)βs-Soption.-L,--policy=FILEβ file to save the policy digest.ARGUMENTβ the command line argument specifies the locality number.--cphash=FILEβ file path to record the hash of the command parameters. This is commonly termed as cpHash.
β οΈ NOTE: when --cphash=FILE is selected, the tool will not actually execute the command β it simply returns a cpHash. Very demure, very mindful, very non-executing.
π References
The original has a References section right here with no listed references, bestie β weβre keeping the slot so the section order stays iconic and intact.
π COMMON OPTIONS π
This collection of options are common to many programs and provide information that many users may expect.
-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 themanoption argument is specified, however if explicitmanis requested, the tool will provide errors from man on stderr. If theno-manoption 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.-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.-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 variableTPM2TOOLS_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.β yes, the original leaves that littleis istypo and stray tail right there, and we are preserving the artifact. π
π 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.
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.
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 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 ofnone.
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. 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.
π§΅ 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 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.
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. The original also ends this section with the stray phrasethe various known TCTI modules.β keeping it, bestie.
π₯ EXAMPLES π₯
Start a policy session and extend it with a specific locality number (like 3). Attempts to perform other operations would fail.
π Create an policy restricted by locality 3
tpm2_startauthsession -S session.dat
tpm2_policylocality -S session.dat -L policy.dat three
tpm2_flushcontext session.dat
π Create the object with auth policy
tpm2_createprimary -C o -c prim.ctx
tpm2_create -C prim.ctx -u sealkey.pub -r sealkey.priv -L policy.dat \
-i- <<< "SEALED-SECRET"
π Try unseal operation
tpm2_load -C prim.ctx -u sealkey.pub -r sealkey.priv -n sealkey.name \
-c sealkey.ctx
tpm2_startauthsession \--policy-session -S session.dat
tpm2_policylocality -S session.dat -L policy.dat three
# Change to locality 3, Note: this operation varies on different platforms
tpm2_unseal -p session:session.dat -c sealkey.ctx
tpm2_flushcontext session.dat
π 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.
π§ 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. π
π BUGS π
Github Issues.
π HELP π
See the Mailing List.
π License π
This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
π Thatβs the whole page, bestie. Source/version vibes: tpm2-tools; manual page: tpm2_policylocality(1); date: not printed in the original footer, so no invented date drama. Mwah. π
π¦ 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