Tss2_Tcti_Cmd_Init(3)
π Tss2_Tcti_Cmd_Init(3) β Library Functions Manual π
okay bestie, welcome to the TCTI Cmd glow-up page π¦ this is from the Library Functions Manual and it's literally the origin story of how you spin up a TCTI context that talks to a subprocess. let's get into it β¨
πΈ NAME πΈ
Tss2_Tcti_Cmd_Init β the initialization function for the Cmd TCTI library. it's giving "hello, let's set this up" energy π
β¨ SYNOPSIS β¨
#include <tss2/tss2_tcti_cmd.h>
TSS2_RC Tss2_Tcti_Cmd_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t
*contextSize, const char *conf);
so the Tss2_Tcti_Cmd_Init() function initializes a TCTI context that you use to communicate with a subprocess β and that subprocess is specified in the conf string. π«Ά TCTI send and receive utilize the sub-process's stdio and stdout respectively. that's the whole vibe, no cap.
π DESCRIPTION π
Tss2_Tcti_Cmd_Init() attempts to initialize a caller allocated tcti_context of size size using the caller provided configuration string conf. π and because the tcti_context must be a caller allocated buffer, the caller needs to know the buffer size the TCTI library requires. no guessing, bestie.
the minimum size of this context can be discovered by providing NULL for the tcti_context and a non-NULL size parameter. then the initialization function will populate the size parameter with the minimum size of the tcti_context buffer. π
then the caller must allocate a buffer of this size (or larger, no gatekeeping) and call Tss2_Tcti_Cmd_Init() again, providing the newly allocated tcti_context and the size of this context in the size parameter. this pattern is common to all TCTI initialization functions β it's the family trait, iykyk. π and we provide an example of this pattern using the Tss2_Tcti_Cmd_Init() function in the section titled EXAMPLE. go look, it's right there.
the conf parameter is a C string used to configure the TCTI context. this configuration string is the command used for popen(3). π₯ and listen β the conf string cannot be NULL for this TCTI. periodt.
once initialized, the TCTI context returned exposes the Trusted Computing Group (TCG) defined API for the lowest level communication with the TPM. β using this API the caller can exchange (send / receive) TPM2 command and response buffers with a service that can excahnge TPM2 command and response buffers. (yes, "excahnge" β we keep it exactly as it is, that's the original spelling, we don't fix history π)
in nearly all cases though? the caller will initialize a context using this function before passing the context to a higher level API like the System API (SAPI), Enhanced System API (ESAPI) or Feature API (FAPI) β and then never touch it again. literally set it and forget it. π
for a more thorough discussion of the TCTI API, see the βTSS System Level API and TPM Command Transmission Interface Specificationβ as published by the TCG: https://trustedcomputinggroup.org/tss-system-level-api-tpm-command-transmission-interface-specification/
π RETURN VALUE π
a successful call to Tss2_Tcti_Cmd_Init() will return TSS2_RC_SUCCESS. π an unsuccessful call will produce a response code described in the section ERRORS. slay responsibly.
π¨ ERRORS π¨
TSS2_TCTI_RC_BAD_VALUE is returned if both the tcti_context and the size parameters are NULL, or if the config parameter is NULL. π yeah, double NULL is a no from us.
π§ EXAMPLE π§
TCTI initialization fragment:
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <tcti/tcti_mssim.h>
TSS2_RC rc;
TSS2_TCTI_CONTEXT *tcti_context;
size_t size;
const char *conf = "XXX TODO SAMPLE"
rc = Tss2_Tcti_Cmd_Init (NULL, &size, NULL);
if (rc != TSS2_RC_SUCCESS) {
fprintf (stderr, "Failed to get allocation size for mssim TCTI "
" context: 0x%" PRIx32 "0, rc);
exit (EXIT_FAILURE);
}
tcti_context = calloc (1, size);
if (tcti_context == NULL) {
fprintf (stderr, "Allocation for TCTI context failed: %s0,
strerror (errno));
exit (EXIT_FAILURE);
}
rc = Tss2_Tcti_Cmd_Init (&tcti_context, &size, conf);
if (rc != TSS2_RC_SUCCESS) {
fprintf (stderr, "Failed to initialize mssim TCTI context: "
"0x%" PRIx32 "0, rc);
free (tcti_context);
exit (EXIT_FAILURE);
}
ngl, that fragment is reproduced character for character β quirks and all β because that's the rules of the game. π
π AUTHOR π
TPM2 Software Project <https://github.com/tpm2-software/tpm2-tss>
the icons who made this. we stan. π
π¦ 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)
go read the whole friend group, they all ate. π₯
π 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 π«Ά TPM2 Software Stack, from MAY 2020, and yes the page name is Tss2_Tcti_Cmd_Init(3) β go forth and initialize your context. πβ¨π
π¦ where this page comes from
- arch rolling: tpm2-tss 4.2.0-2 Β· BSD-2-Clause
- nixos 26.05: tpm2-tss 4.2.0
- nixpkgs unstable: tpm2-tss 4.2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms