Tspi_TPM_GetRandom(3)

πŸ’– Tspi_TPM_GetRandom(3) πŸ’–

okay bestie, welcome to the TCG Software Stack Developer's Reference β€” this one's from the TSS 1.1 era of the library functions manual, and she is serving random bytes. no cap. πŸŽ€


✨ NAME ✨

Tspi_TPM_GetRandom β€” generate a random number on the TPM 🎲


🌸 SYNOPSIS 🌸

#include <tss/platform.h>
#include <tss/tcpa_defines.h>
#include <tss/tcpa_typedef.h>
#include <tss/tcpa_struct.h>
#include <tss/tss_typedef.h>
#include <tss/tss_structs.h>
#include <tss/tspi.h>

TSS_RESULT Tspi_TPM_GetRandom(TSS_HTPM hTPM, UINT32 size, BYTE** random);

like, all those includes first, then the one actual call. she's lowkey a lot of headers for one function but that's just the vibe πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Tspi_TPM_GetRandom gets you a good random number, and she's doing it for the purpose of generating symmetric keys, nonces, or seeding a random number generator. that's literally her whole job. main character energy fr fr ✨


πŸŽ€ PARAMETERS πŸŽ€

hTPM

the hTPM parameter is used to specify the handle of the TPM object. and get this β€” the command to get the TPM to test itself will be sent here. yep, that's what the page says, i don't make the rules 🫢

size

the size parameter is the number of random bytes requested. tell her how many, she delivers that many. πŸ’œ

random

the random parameter is a pointer to memory containing the random data. this is where the generated number goes. and because this internally allocates memory, Tspi_Context_FreeMemory should also be used. do not forget the free, bestie, that's the whole point 😭

not me reminding you again: internally allocated memory β†’ Tspi_Context_FreeMemory. it's giving "clean up after yourself." 🧚

πŸ”₯ RETURN CODES πŸ”₯

Tspi_TPM_GetRandom returns TSS_SUCCESS on success, otherwise one of the following values is returned:

  • TSS_E_INVALID_HANDLE β€” hTPM is not a valid handle. πŸ’€
  • TSS_E_INTERNAL_ERROR β€” an internal SW error has been detected. πŸ™ˆ
  • TSS_E_BAD_PARAMETER β€” one or more parameters is bad. πŸ‘‘

πŸ‘‘ CONFORMING TO πŸ‘‘

Tspi_TPM_GetRandom conforms to the Trusted Computing Group Software Specification version 1.1 Golden. iconic. she's certified. ⭐


🌈 SEE ALSO 🌈


and that's the whole page, periodt. πŸ’…

this was TSS 1.1, dated 2004-05-25 β€” yeah she's an elder but she ate and left no crumbs. bye bestie, go get your random bytes πŸ¦‹πŸ’–