crypto_rng_generate(9)
π« 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 beNULL, 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.dstcomes from you,dlenis how big it is, and the RNG attached totfmdoes 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 π§:
- Kernel file
./include/crypto/rng.hstruct rng_alg(9) crypto_stdrng_get_bytes(9)Random number generator API(9)crypto_alloc_rng(9)crypto_rng_alg(9)crypto_free_rng(9)crypto_rng_get_bytes(9)crypto_rng_reset(9)crypto_rng_seedsize(9)
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
- 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