crypto_rng_generate(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« crypto_rng_generate(9) β€” the kernel API manual, but make it make sense

okay so bestie, welcome to the kernel API manual page for crypto_rng_generate(9). yes it's a real kernel thing. yes i'm gonna explain it. no you don't have to be scared. 🫢


✨ NAME ✨

crypto_rng_generate β€” get random number πŸ”₯

✨ SYNOPSIS ✨

int crypto_rng_generate (struct crypto_rng *tfm , const u8 *src ,
unsigned int slen , u8 *dst , unsigned int dlen );

like, that's the whole vibe. one function. five args. no cap. ✨

✨ ARGUMENTS ✨

  • tfm β€” the cipher handle πŸ’… this is your main character, the thing that actually knows which random number generator you're talking to.
  • src β€” an input buffer holding additional data. it's allowed to be NULL, so if you got nothing to add, that's lowkey fine πŸ“
  • slen β€” length of that additional data.
  • dst β€” the output buffer that will hold the random numbers. this is the one you actually care about πŸ‘‘
  • dlen β€” length of the output buffer.

✨ DESCRIPTION ✨

so what does it do? it fills the caller-allocated buffer with random numbers, using the random number generator referenced by the cipher handle. that's it. that's the whole job. πŸ¦‹

the way that it just... hands you randomness. iconic honestly.

quick reminder bestie: you allocate the buffer, not the function. dst comes from you, dlen is how big it is, and the RNG attached to tfm does the filling. that's the deal πŸ’–

✨ RETURN ✨

  • 0 β€” function was successful πŸŽ‰ slay.
  • < 0 β€” an error occurred 😭 (note it's strictly less than zero, not just "nonzero", okay? keep that detail, it's giving precision.)

✨ SEE ALSO ✨

go read these next, i promise they're relevant 🧚:


and that's the page!! πŸ’œ this little beauty lives in ./include/crypto and the whole thing is dated October 2026 β€” so like, from the future or whatever, we stan a timeless classic 🌈⭐ bye bestie, go generate some entropy! πŸŽ€πŸ’…

πŸ“¦ where this page comes from