tpm2_get_random(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– tpm2_get_random β€” get random bytes from the TPM RNG πŸ’–

okay bestie, so this is tpm2_get_random, and it lives in the Kernel API Manual (section 9, iykyk). it's a kernel-side function, not a command you type β€” think of it as the little connector between the kernel and the TPM's random number generator. so much power. πŸŽ€


✨ SYNOPSIS ✨

int tpm2_get_random (struct tpm_chip *chip , u8 *dest , size_t max );

literally the whole vibe right there β€” you hand it a chip, a destination buffer, and a maximum, and it goes and fetches you some randomness. πŸ¦‹


🌸 ARGUMENTS 🌸

  • chip β€” a tpm_chip instance. this is your TPM bestie, the actual device you're talking to. 🫢
  • dest β€” destination buffer. this is where the random bytes land, so make sure it's somewhere real and it can hold what you're asking for. πŸ’…
  • max β€” the max number of random bytes to pull. key word: max β€” that's the ceiling you're giving it, not a promise it'll come back with exactly that many. ⭐

πŸ”₯ RETURN πŸ”₯

on success you get back the size of the buffer β€” glow up, it worked ✨. otherwise you get -errno. and here's the lil detail you cannot skip, no cap: positive TPM return codes are masked to -EIO. so if the TPM hands back something positive-looking, don't get excited, it's getting squashed into -EIO. that's just how it is, periodt. πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./drivers/char/tpm/tpm2-cmd.c β€” that's where the magic's written, go read it if you're feeling main character energy 🧚

and the whole TPM2 friend group:


ngl this one's short and sweet β€” a little random-byte delivery service and nothing more. obsessed. 🌈

and that's a wrap, bestie πŸ’œ this page came from ./drivers/char/tpm, dated October 2026 β€” go get yourself some entropy, you deserve it πŸ“ slay!

πŸ“¦ where this page comes from