Tss2_Tcti_Device_Init(3)
π Tss2_Tcti_Device_Init(3) π
okay bestie, welcome to the Library Functions Manual β¨ this is the page for Tss2_Tcti_Device_Init, and yes it's a mouthful but we're gonna get through it together, no cap π«Ά
β¨ NAME β¨
Tss2_Tcti_Device_init β the initialization function for the device TCTI library. that's it, that's the vibe πΈ
β¨ SYNOPSIS β¨
#include <tcti/tcti_device.h>
TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t
*size, const char *conf);
so like. Tss2_Tcti_Device_Init() sets up a TCTI context that you use to talk to the TPM device driver π
that's the whole job, she's simple like that.
β¨ DESCRIPTION β¨
so here's the tea π Tss2_Tcti_Device_Init() tries to initialize a tctiContext that you allocated, of size size. and because the tctiContext has to be a caller-allocated buffer, you the caller need to know how big the TCTI library wants it to be. iconic little chicken-and-egg moment π
the way you find out the minimum size? you pass NULL for the tctiContext and a non-NULL size parameter. then the init function will populate the size parameter with the minimum size of the tctiContext buffer. then you allocate a buffer of that size (or bigger, live your truth) and call Tss2_Tcti_Device_Init() again, this time handing over the freshly allocated tctiContext and its size in the size parameter. this whole pattern is common to all TCTI initialization functions, so once you learn it you're set for life, iykyk. we literally wrote out an example of this pattern using Tss2_Tcti_Device_Init() in the section titled EXAMPLE π
the conf parameter is a C string. if that string is NULL, the library will use a default configuration string for you, no stress. or, alternatively, you can provide your own config string β and it must contain the path to the device node exposed by the TPM device driver. that part is not optional bestie, it's giving required π
once it's initialized, the TCTI context you get back exposes the Trusted Computing Group (TCG) defined API for the lowest level communication with the TPM. using this API you can exchange (send / receive) TPM2 command and response buffers with the TPM device driver π₯ but like, in nearly all cases? you're gonna initialize a context with this function, pass it to a higher level API like the System API (SAPI), and then never touch it again. main character hands-off energy π
TCG TSS 2.0 TPM Command Transmission Interface (TCTI) API Specification π
for a more thorough discussion of the TCTI API, go read the βTCG TSS 2.0 TPM Command Transmission Interface (TCTI) API Specificationβ as published by the TCG:
β¨ RETURN VALUE β¨
a successful call to Tss2_Tcti_Device_Init() returns TSS2_RC_SUCCESS β an unsuccessful call will produce a response code described in the section ERRORS. that's the deal π
β¨ ERRORS β¨
TSS2_TCTI_RC_BAD_VALUEβ comes back if any parameters contain unexpected values. rude of them tbh πTSS2_TCTI_RC_BAD_REFERENCEβ comes back if any parameters areNULLwhen they should not be. like girl why is that empty πTSS2_TCTI_RC_BAD_CONTEXTβ comes back if the size of the providedtctiContextis insufficient. not enough room, she can't fit π
β¨ EXAMPLE β¨
TCTI initialization fragment:
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <tcti/tcti_device.h>
TSS2_RC rc;
TSS2_TCTI_CONTEXT *tcti_context;
size_t size;
char *conf = "/dev/tpm0",
rc = Tss2_Tcti_Device_Init (NULL, &size, NULL);
if (rc != TSS2_RC_SUCCESS) {
fprintf (stderr, "Failed to get allocation size for device 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_Device_Init (&tcti_context, &size, &conf);
if (rc != TSS2_RC_SUCCESS) {
fprintf (stderr, "Failed to initialize device TCTI context: "
"0x%" PRIx32 "0, rc);
free (tcti_context);
exit (EXIT_FAILURE);
}
exit (EXIT_SUCCESS);
look at her go π¦ two calls to Tss2_Tcti_Device_Init() β one to get the size, one to actually init. that's the whole pattern, you got this πͺ
β¨ AUTHOR β¨
TPM2 Software Project <https://github.com/tpm2-software/tpm2-tss> β absolute legends π
β¨ 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 those too bestie, one page is never enough πβ¨
β¨ 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, info about reporting bugs, and the latest version of this page all live at https://github.com/tpm2-software/tpm2-tss/. slay.
β¨ LICENSE β¨
this work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). for more info visit https://creativecommons.org/licenses/by/4.0/ π
okay that's the whole page bestie, we ate and left no crumbs π
TPM2 Software Stack, MARCH 2018, and this was Tss2_Tcti_Device_Init(3) β mwah, periodt π«Άβ¨π
π¦ 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