TPMLIB_SetState(3)
π TPMLIB_SetState(3) β bestie, weβre managing TPM state now π
okay so this is the libtpms page for TPMLIB_SetState and TPMLIB_GetState. Itβs giving βstate blobs have rules,β and honestly? Weβre gonna respect them. π«Ά
πΈ NAME πΈ
TPMLIB_SetStateβ set the TPMβs volatile, permanent, or save stateTPMLIB_GetStateβ get the TPMβs volatile, permanent, or save state
π LIBRARY π
TPM library (libtpms, -ltpms) β yes, link it like that, bestie. β¨
β¨ SYNOPSIS β¨
Include the header first, obviously:
#include <libtpms/tpm_library.h>
TPM_RESULT TPMLIB_SetState(enum TPMLIB_StateType st,
const unsigned char *buffer, uint32_t buflen);
TPM_RESULT TPMLIB_GetState(enum TPMLIB_StateType st,
unsigned char **buffer, uint32_t *buflen);
π DESCRIPTION π
π TPMLIB_SetState() β the setter π
So TPMLIB_SetState() lets you set one of the state blobs of the TPM. The state blob you pass in gets tested to see whether it can be accepted, and if it canβt be accepted, you get a TPM error code back. No cap. π
If it is accepted, that state blob will be passed to the TPM upon TPM_MainInit(). Also, setting a state blob hides a file that may contain the same type of blob and would be read otherwise. And hereβs the required bit: you have to call this function with a NULL pointer for the buffer parameter to hide a state blob in a file. Thatβs not a suggestion, bestie β itβs required. π
You can only set the state blobs after TPMLIB_ChooseTPMVersion() has been called. Also, all state blobs are cleared when a different version of TPM is chosen using TPMLIB_ChooseTPMVersion, or when a call to TPMLIB_SetState() fails because a state blob could not be accepted. So yeah, failure has consequences. π
β οΈ The order in which state blobs are set is important. The first state blob has to be the one representing the TPMβs permanent state. Only after that can either the volatile or save state blobs be set. Do not freestyle this order, okay? π
π¦ TPMLIB_GetState() β the getter π¦
TPMLIB_GetState() lets you get the current state of the TPM. For as long as the TPM has not been started, this function either returns the state blob previously set with TPMLIB_SetState() or the state is read from a file. Once the TPM has been started, the state of the running TPM is returned. Slay. β¨
About TPMLIB_STATE_SAVE_STATE (the save state type): this type of TPM state can be set with this function. The same state blob will be returned until TPM_Startup(ST_STATE) has been called, after which an empty blob will be returned. This blob can also only be read after TPM_SaveState() has been sent to the TPM. iykyk. π§
π SEE ALSO π
signed, sealed, delivered by libtpms on 2026-01-02 β thatβs the whole page, 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