tpm2-totp(3)
๐ tpm2-totp(3) โ Library Functions Manual ๐
๐ธ NAME ๐ธ
tpm2-totp โ libtpm2-totp, bestie. Thatโs the name drop, and itโs lowkey iconic.
โจ SYNOPSIS โจ
๐ Functions ๐
int tpm2totp_generateKey (uint32_t pcrs, uint32_t banks, const char *password, TSS2_TCTI_CONTEXT *tcti_context, uint8_t **secret, size_t *secret_size, uint8_t **keyBlob, size_t *keyBlob_size)
int tpm2totp_reseal (const uint8_t *keyBlob, size_t keyBlob_size, const char *password, uint32_t pcrs, uint32_t banks, TSS2_TCTI_CONTEXT *tcti_context, uint8_t **newBlob, size_t *newBlob_size)
int tpm2totp_storeKey_nv (const uint8_t *keyBlob, size_t keyBlob_size, uint32_t nv, TSS2_TCTI_CONTEXT *tcti_context)
int tpm2totp_loadKey_nv (uint32_t nv, TSS2_TCTI_CONTEXT *tcti_context, uint8_t **keyBlob, size_t *keyBlob_size)
int tpm2totp_deleteKey_nv (uint32_t nv, TSS2_TCTI_CONTEXT *tcti_context)
int tpm2totp_calculate (const uint8_t *keyBlob, size_t keyBlob_size, TSS2_TCTI_CONTEXT *tcti_context, time_t *nowp, uint64_t *otp)
int tpm2totp_getSecret (const uint8_t *keyBlob, size_t keyBlob_size, const char *password, TSS2_TCTI_CONTEXT *tcti_context, uint8_t **secret, size_t *secret_size)
๐ฆ Detailed Description ๐ฆ
The whole flex: attest the trustworthiness of a device against a human using time-based one-time passwords. Thatโs the vibe, and honestly it eats.
๐ Function Documentation ๐
๐งฎ tpm2totp_calculate
int tpm2totp_calculate (const uint8_t * keyBlob, size_t keyBlob_size, TSS2_TCTI_CONTEXT * tcti_context, time_t * nowp, uint64_t * otp)
Calculates a time-based one-time password for a key. Very main character of it.
Parameters
keyBlobโ Key to generate the TOTP.keyBlob_sizeโ Size of the key.tcti_contextโ Optional TCTI context to select TPM to use.nowpโ Current time.otpโ Calculated TOTP.
Return values
0on success.-1on undefined/general failure.TSS2_RCresponse code for failures relayed from the TSS library.
๐๏ธ tpm2totp_deleteKey_nv
int tpm2totp_deleteKey_nv (uint32_t nv, TSS2_TCTI_CONTEXT * tcti_context)
Deletes a key from a NV index. Bye-bye, key.
Parameters
nvโ NV index to delete.tcti_contextโ Optional TCTI context to select TPM to use.
Return values
0on success.-1on undefined/general failure.TSS2_RCresponse code for failures relayed from the TSS library.
๐ tpm2totp_generateKey
int tpm2totp_generateKey (uint32_t pcrs, uint32_t banks, const char * password, TSS2_TCTI_CONTEXT * tcti_context, uint8_t ** secret, size_t * secret_size, uint8_t ** keyBlob, size_t * keyBlob_size)
Generates a key. Fresh key, fresh vibes.
Parameters
pcrsโ PCRs the key should be sealed against.banksโ PCR banks the key should be sealed against.passwordโ Optional password to recover or reseal the secret.tcti_contextโ Optional TCTI context to select TPM to use.secretโ Generated secret.secret_sizeโ Size of the secret.keyBlobโ Generated key.keyBlob_sizeโ Size of the generated key.
Return values
0on success.-1on undefined/general failure.TSS2_RCresponse code for failures relayed from the TSS library.
๐ต๏ธ tpm2totp_getSecret
int tpm2totp_getSecret (const uint8_t * keyBlob, size_t keyBlob_size, const char * password, TSS2_TCTI_CONTEXT * tcti_context, uint8_t ** secret, size_t * secret_size)
Recovers a secret from a key. The secret is giving โIโm backโ energy.
Parameters
keyBlobโ Key to recover the secret from.keyBlob_sizeโ Size of the key.passwordโ Password of the key.tcti_contextโ Optional TCTI context to select TPM to use.secretโ Recovered secret.secret_sizeโ Size of the secret.
Return values
0on success.-1on undefined/general failure.-10on empty password.-20when no password-protected recovery copy of the secret has been stored.TSS2_RCresponse code for failures relayed from the TSS library.
๐ฆ tpm2totp_loadKey_nv
int tpm2totp_loadKey_nv (uint32_t nv, TSS2_TCTI_CONTEXT * tcti_context, uint8_t ** keyBlob, size_t * keyBlob_size)
Loads a key from a NV index. Fetching the key like itโs a group-chat screenshot.
Parameters
nvโ NV index of the key.tcti_contextโ Optional TCTI context to select TPM to use.keyBlobโ Loaded key.keyBlob_sizeโ Size of the key.
Return values
0on success.-1on undefined/general failure.TSS2_RCresponse code for failures relayed from the TSS library.
๐ tpm2totp_reseal
int tpm2totp_reseal (const uint8_t * keyBlob, size_t keyBlob_size, const char * password, uint32_t pcrs, uint32_t banks, TSS2_TCTI_CONTEXT * tcti_context, uint8_t ** newBlob, size_t * newBlob_size)
Reseals a key to new PCR values. Glow-up for your key, fr fr.
Parameters
keyBlobโ Original key.keyBlob_sizeโ Size of the key.passwordโ Password of the key.pcrsโ PCRs the key should be sealed against.banksโ PCR banks the key should be sealed against.tcti_contextโ Optional TCTI context to select TPM to use.newBlobโ New key.newBlob_sizeโ Size of the new key.
Return values
0on success.-1on undefined/general failure.-10on empty password.-20when no password-protected recovery copy of the secret has been stored.TSS2_RCresponse code for failures relayed from the TSS library.
๐พ tpm2totp_storeKey_nv
int tpm2totp_storeKey_nv (const uint8_t * keyBlob, size_t keyBlob_size, uint32_t nv, TSS2_TCTI_CONTEXT * tcti_context)
Stores a key in a NV index. Putting it in NVRAM like itโs the notes app.
Parameters
keyBlobโ Key to store to NVRAM.keyBlob_sizeโ Size of the key.nvโ NV index to store the key.tcti_contextโ Optional TCTI context to select TPM to use.
Return values
0on success.-1on undefined/general failure.TSS2_RCresponse code for failures relayed from the TSS library.
๐ซถ Author ๐ซถ
Generated automatically by Doxygen for tpm2-totp from the source code. So not me, bestie โ Doxygen took the aux. ๐
okay bye bestie ๐ this page is from tpm2-totp, version 20240326.33e1986 (yes, that date-ish version in the footer), and the footer page stamp is tpm2-totp(3). slay.
๐ฆ where this page comes from
- opensuse-leap 16.0: libtpm2-totp0-devel 20240326.33e1986-bp160.1.3 ยท BSD-3-Clause
- opensuse-leap 16.0: libtpm2-totp0-devel 20240326.33e1986-bp160.1.3 ยท BSD-3-Clause
- opensuse-leap 16.0: libtpm2-totp0-devel 20240326.33e1986-bp160.1.3 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms