crypto_alloc_rng(9)
π crypto_alloc_rng(9) π
ok so this is a page from the Kernel API Manual β it's crypto_alloc_rng(9), and yes it's exactly as iconic as it sounds: it's the one that gets you an RNG handle. bestie, let's get into it β¨
πΈ NAME πΈ
crypto_alloc_rng β allocate RNG handle
like, literally that's the whole job. allocate. RNG. handle. periodt π
π SYNOPSIS π
struct crypto_rng * crypto_alloc_rng (const char *alg_name , u32 type ,
u32 mask );
that's the whole signature, no cap. three args, one pointer back at you π«Ά
π¦ ARGUMENTS π¦
alg_nameβ this is thecra_name/ name or thecra_driver_name/ driver name of the message digest cipher. yep, you read that right, it says message digest cipher in the source, we don't make the rules we just report them πtypeβ specifies the type of the cipher. that's it, that's the whole lore.maskβ specifies the mask for the cipher. it's the vibe check partner oftype, fr fr.
β¨ DESCRIPTION β¨
okay so what actually happens: this call allocates a cipher handle for a random number generator π₯ the struct crypto_rng it hands back is the cipher handle you need for literally any subsequent API invocation for that random number generator. so like, hold onto it. it's your main character. π
here's the tea though: for all random number generators, this call creates a new private copy of the random number generator that does not share a state with other instances. no state sharing. none. everyone gets their own π§
the one (1) exception: the"krng"random number generator, which is a kernel crypto API use case for theget_random_bytesfunction of the/dev/randomdriver. so that one's special, iykyk π
β RETURN β
- on success? you get the allocated cipher handle π slay.
- on error?
IS_ERRis true, andPTR_ERRreturns the error code. so check it, bestie, don't just raw-dog the pointer π
π SEE ALSO π
go read these next, they're giving required reading π:
- Kernel file
./include/crypto/rng.hstruct rng_alg(9) crypto_stdrng_get_bytes(9)- Random number generator API(9)
crypto_rng_alg(9)crypto_free_rng(9)crypto_rng_generate(9)crypto_rng_get_bytes(9)crypto_rng_reset(9)crypto_rng_seedsize(9)
okay that's the whole page, you ate that π this lil number lives in ./include/crypto and it's dated October 2026 β so yeah, from the future, iconic behavior honestly πβ¨ go forth and allocate responsibly, mwah π«Άπ
π¦ 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