tpm2_flushcontext(1)

πŸ¦‹ tpm2_flushcontext(1)

okay so first things first β€” this page lives in the tpm2-tools manual set, and it's all about tpm2_flushcontext. Think of it as the "clear your tabs" button for your TPM. no cap, it's that simple. πŸ’…


🌸 NAME

tpm2_flushcontext β€” removes a specified handle, or all the contexts associated with a transient object, a loaded session, or a saved session, from the TPM. bye, handle. you are so flushed. 🚽✨


✨ SYNOPSIS

tpm2_flushcontext [OPTIONS] [ARGUMENT]

πŸ’– DESCRIPTION

tpm2_flushcontext(1) β€” Remove a specified handle, or all contexts associated with a transient object, loaded session or saved session from the TPM.

The thing you're yeeting is specified as the first argument to the tool, and it's in one of these forms:

  • The handle of the object you want flushed from the TPM. Gotta be a valid handle number, bestie β€” no made-up digits πŸ™ˆ
  • Flush a session via a session file. And where do session files come from? From tpm2_startauthsession(1)'s -S option. iykyk 🫢

πŸŽ€ OPTIONS

  • -t, --transient-object β€” Remove all transient objects. every last one. gone.
  • -l, --loaded-session β€” Remove all loaded sessions. clean slate energy ✨
  • -s, --saved-session β€” Remove all saved sessions. also gone. no survivors πŸ’€
  • ARGUMENT β€” the command line argument specifies the OBJECT to be removed from the TPM resident memory. so you literally just hand it a thing and it goes poof 🫧
  • --cphash=FILE β€” File path to record the hash of the command parameters. this is commonly termed cpHash. NOTE: when this option is selected, the tool will not actually execute the command β€” it simply returns a cpHash. lowkey a fake-out, but a useful one πŸ‘‘

🌈 COMMON OPTIONS

This collection of options are common to many programs and provide information that many users may expect. the shared wardrobe of the tpm2-tools world, fr fr.

  • -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 β€” BUT 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, you need the manpages installed or on MANPATH. see man(1) for more details, bestie πŸ“–
  • -v, --version β€” Display version information for this tool and supported tctis, then 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. she's chatty and we love that πŸ—£οΈ
  • -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. ⚠️ heads up on that last bit, okay?
  • -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. 🚿

🧚 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 giving "different roads, same destination" πŸ›£οΈ

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. always. no exceptions. πŸ‘‘

The current known TCTIs are:

  • tabrmd β€” The resource manager, called tabrmd. Note that tabrmd and abrmd as a tcti name are synonymous. same girl, two names πŸ’…
  • mssim β€” Typically used for communicating to the TPM software simulator. πŸ–₯️
  • device β€” Used when talking directly to a TPM device file.
  • none β€” Do not initalize 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. like, literally the exact text. 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. blanks are valid, bestie 🫢

⭐ 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 not a vibe check, it's a queue.

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 TCTI, we'll load her πŸŽ€


πŸ’œ 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. say it with me one more time πŸ“£

πŸ”₯ EXAMPLES

🫧 Flushing a Transient Object

Typically, when using the TPM, the interactions occur through a resource manager, like tpm2-abrmd(8). When the process exits, transient object handles are flushed. Thus, flushing transient objects through the command line is not required. slay, the resource manager handles it for you πŸ’…

However, when interacting with the TPM directly, this scenario is possible. The below example assumes direct TPM access not brokered by a resource manager. Specifically we will use the simulator.

tpm2_createprimary -Tmssim -c primary.ctx

tpm2_getcap -T mssim handles-transient
- 0x80000000

tpm2_flushcontext -T mssim 0x80000000

✨ Flush All the Transient Objects

tpm2_flushcontext \--transient-object

πŸŽ€ Flush a Session

tpm2_startauthsession -S session.dat

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 to tpm2_testparams.

πŸ’€ BUGS

Github Issues. go yell there (politely) 🫢


🌸 HELP

See the Mailing List. the girlies there are helpful, fr fr πŸ’Œ


πŸ‘‘ 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!! πŸŽ€ this little gem comes to you straight from the tpm2-tools crew, and you've just read the tpm2_flushcontext(1) page top to bottom. go flush something. literally anything. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from