tpm2_get_random(9)
π 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β atpm_chipinstance. 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:
tpm2_calc_ordinal_duration(9)tpm2_pcr_read(9)tpm2_pcr_extend(9)tpm2_flush_context(9)tpm2_get_tpm_pt(9)tpm2_shutdown(9)tpm2_do_selftest(9)tpm2_probe(9)tpm2_startup(9)tpm2_auto_startup(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms