TPMLIB_MainInit(3)
okay bestie, welcome to the libtpms manual page for TPMLIB_MainInit(3) β this is the init/terminate page and itβs literally essential β¨
β¨ NAME β¨
TPMLIB_MainInit β initialize the TPM, bestie π
TPMLIB_Terminate β terminate the TPM, byeee π
π LIBRARY π
TPM library (libtpms, -ltpms) β yes, link it like that π«Ά
π οΈ SYNOPSIS π οΈ
#include <libtpms/tpm_types.h>
#include <libtpms/tpm_library.h>
#include <libtpms/tpm_error.h>
TPM_RESULT TPMLIB_MainInit(void);
TPM_RESULT TPMLIB_Terminate(void);
π¬ DESCRIPTION π¬
Okay so TPMLIB_MainInit() and TPMLIB_Terminate() are the two functions that initialize and terminate the TPM, respectively β theyβre literally the start-and-stop girlies of this whole thing π
TPMLIB_MainInit() has to be called before the TPM processes any TPM command. No skipping ahead, bestie β init first, command later, periodt.
TPMLIB_Terminate() is the one you call to free all the internal resources (memory allocations) the TPM has used. It must be called after the last TPM command was processed by the TPM. Then, after that, TPMLIB_MainInit() can be called again. Cleanup queen behavior β¨
Use TPMLIB_RegisterCallbacks() to set callback functions for initialization and writing and restoring the internal state in a portable format. Thatβs the move if you need those callbacks hooked up π
π¨ ERRORS π¨
TPM_SUCCESSβ the function completed successfully. slay πTPM_FAILβ general failure. not slay π
For a complete list of TPM error codes please consult the include file libtpms/tpm_error.h β itβs all in there, iykyk π
πΈ EXAMPLE πΈ
#include <stdio.h>
#include <libtpms/tpm_types.h>
#include <libtpms/tpm_library.h>
#include <libtpms/tpm_error.h>
int main(void) {
TPM_RESULT res;
unsigned char *respbuffer = NULL;
uint32_t resp_size = 0;
uint32_t respbufsize = 0;
unsigned char *command;
uint32_t command_size;
[...]
if (TPMLIB_MainInit() != TPM_SUCCESS) {
fprintf(stderr, "Could not start the TPM.\n");
return 1;
}
[...]
/* build TPM command */
[...]
res = TPMLIB_Process(&respbuffer, &resp_size,
&respbufsize,
command, command_size);
[...]
TPMLIB_Terminate();
return 0;
}
π SEE ALSO π
TPMLIB_Process(3)TPMLIB_RegisterCallbacks(3)TPMLIB_GetVersion(3)TPMLIB_GetTPMProperty(3)TPMLIB_DecodeBlob(3)
okay thatβs the whole TPMLIB_MainInit(3) page! this iconic manual comes from libtpms, dated 2026-01-02, and itβs literally the TPMLIB_MainInit(3) man page β now go init that TPM, bestie π
β¨
π¦ where this page comes from
- alpine 3.24: libtpms-doc 0.10.2-r0 Β· BSD-3-Clause
- arch rolling: libtpms 0.10.2-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