Tss2_TctiLdr_Initialize(3)

πŸ“¦ version 4.2.0, in nixpkgs unstable

πŸ’… Tss2_TctiLdr_Initialize β€” Library Functions Manual ✨

okay bestie, gather round, because today we're talking about Tss2_TctiLdr_Initialize(3) from the Tss2_TctiLdr_Initialize(3) manual page, and honestly? it's giving "let me spin up a TCTI context for you" energy 🫢


πŸŽ€ NAME πŸŽ€

Tss2_TctiLdr_Initialize, Tss2_TctiLdr_Initialize_Ex β€” instantiate and initialize a TCTI context. that's it, that's the whole vibe. one job, and they ate πŸ’…


✨ SYNOPSIS ✨

#include <tss2/tss2_tctildr.h>

TSS2_RC Tss2_TctiLdr_Initialize (const char *nameConf, TSS2_TCTI_CONTEXT
**context);

TSS2_RC Tss2_TctiLdr_Initialize_Ex (const char *name, const char *conf,
TSS2_TCTI_CONTEXT **context);

two functions, both returning a TSS2_RC, both handing you back a context. iconic behavior, no notes 🌸


🌈 DESCRIPTION 🌈

so like, Tss2_TctiLdr_Initialize() and Tss2_TctiLdr_Initialize_Ex() are the girlies that initialize a TCTI context. and what's a TCTI context for, you ask? it's for communicating with the TPM2, or with some intermediate component in the TCG TPM2 software stack. that's the whole point, that's the mission 🫑

Tss2_TctiLdr_Initialize() takes one single string that encodes both the name of the TCTI library you wanna instantiate and its desired configuration, and it lives in the nameConf parameter. nameConf is a string made of two substrings: name and conf, respectively. these substrings get combined with name first, separated by a single ':' / colon character, like so: 'name:conf'. for the tea on how these strings are encoded, go read the section titled TCTI CONFIG (it's right below, bestie, I got you πŸ’–). the context parameter is what returns a reference to the TCTI context that the function created.

Tss2_TctiLdr_Initialize_Ex() behaves identically to Tss2_TctiLdr_Initialize(), except β€” and this is the only plot twist β€” the TCTI name and the configuration get passed as separate strings. the encoding of those strings is described in section TCTI_CONFIG. yes it's spelled slightly differently there, no I did not do that, the original did πŸ™ˆ


πŸ¦‹ TCTI CONFIG πŸ¦‹

okay this is the part where it gets juicy. if the name string is NULL or the emptry string (yes, "emptry", that's canon, I don't make the rules), then the initialization functions will select a default TCTI appropriate for the platform. on Linux this means it first tries to load a library named libtss2-tcti-default.so. this is a placeholder for distros to provide a distro specific default. it is recommended that this be a symlink to another installed TCTI library. if attempts to load this shared object fail, the implementation will attempt known TCTIs in the following order:

  • libtss2-tcti-tabrmd.so.0
  • libtss2-tcti-device.so.0
  • libtss2-tcti-mssim.so.0

when the name string is neither NULL nor the empty string, the implementation will attempt to dlopen a library with the given name. and if that fails, the implementation assumes it's been passed a shortened name and will attempt to load libraries by name with the following permutations:

  • <name>
  • libtss2-tcti-<name>.so.0
  • libtss2-tcti-<name>.so

the config string is not interpreted by the TctiLdr init functions at all β€” it's passed unaltered to the initialization function for the selected TCTI. the format for this string is TCTI specific. so like, not our problem, respectfully πŸ’…

the Tss2_TctiLdr_Initialize function is passed the name and conf strings as a single parameter. in this case the name and conf strings are concatinated with a single ':' / colon character separating them. (again: "concatinated". the original said it. I'm just the messenger 🫢)

for a more thorough discussion of the TCTILDR API see the β€œTCG TSS 2.0 TPM Command Transmission Interface (TCTI) API Specification”. go read it, it's giving academic baddie πŸ“š


πŸ’– RETURN VALUE πŸ’–

a successful call to this function will return TSS2_RC_SUCCESS. an unsuccessful call will produce a response code described in section ERRORS. that's the deal, take it or leave it ✨


😭 ERRORS 😭

  • TSS2_TCTI_RC_MEMORY is returned if memory allocation fails
  • TSS2_TCTI_RC_NOT_SUPPORTED is returned when the loader is unable to locate a TCTI library with the provided name
  • TSS2_TCTI_RC_IO_ERROR is returned if a failure occurs in the underlying library loading mechanism
  • TSS2_TCTI_RC_BAD_REFERENCE is returned if the tctiContext parameter is NULL
bestie if you're seeing TSS2_TCTI_RC_BAD_REFERENCE you literally passed a NULL context. we've all been there. no judgement. fix it though πŸ’€

πŸ“ EXAMPLE πŸ“

example code. look at her go:

#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <tss2/tss2_tctildr.h>

TSS2_TCTI_CONTEXT *ctx = NULL;
TSS2_RC rc = Tss2_TctiLdr_Initialize (NULL, &ctx);
if (rc != TSS2_RC_SUCCESS) {
    fprintf (stderr, "Initialization of default TCTI context failed with "
             "response code: 0x%" PRIx32 "0, rc);
    exit (EXIT_FAILURE);
}
exit (EXIT_SUCCESS);

(that's verbatim, quote marks and all, don't come for me 😭)


πŸ‘‘ AUTHOR πŸ‘‘

TPM2 Software Project <https://github.com/tpm2-software/tpm2-tss>


🌟 SEE ALSO 🌟

Tss2_Tcti_Device_Init(3), Tss2_Tcti_Socket_Init(3), Tss2_TctiLdr_Initialize(3), Tss2_TctiLdr_Finalize(3), tcti-device(7), tcti-socket(7), tcti-tabrmd(7), tpm2-abrmd(8)

iykyk, go read all of them, slay 🧚


🧚 COLOPHON 🧚

this page is part of release 4.2.0 of Open Source implementation of the TCG TPM2 Software Stack (TSS2). a description of the project, information about reporting bugs, and the latest version of this page can be found at https://github.com/tpm2-software/tpm2-tss/.


πŸ’œ LICENSE πŸ’œ

this work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). for more information visit https://creativecommons.org/licenses/by/4.0/


and that's the whole page, bestie!! πŸ’– this lil masterpiece came to you from the TPM2 Software Stack, dated MARCH 2019, and it's page Tss2_TctiLdr_Initialize(3) β€” go forth and initialize your contexts, you main character πŸ‘‘βœ¨

πŸ“¦ where this page comes from