STRUCT RNG_ALG(9)
πΈ struct rng_alg(9) β the Kernel API Manual, bestie edition πΈ
okay so this is struct rng_alg(9) from the ./include/crypto part of the kernel API docs, and it's literally the blueprint for a random number generator. no cap. if you've ever wondered "where do the random bytes come from," it's this. π
β¨ NAME β¨
struct rng_alg β random number generator definition
like, the definition-definition. the whole personality of your RNG lives here. π
π¦ SYNOPSIS π¦
struct rng_alg {
int (*generate)(struct crypto_rng *tfm, const u8 *src, unsigned int slen, u8 *dst, unsigned int dlen);
int (*seed)(struct crypto_rng *tfm, const u8 *seed, unsigned int slen);
void (*set_ent)(struct crypto_rng *tfm, const u8 *data, unsigned int len);
unsigned int seedsize;
struct crypto_alg base;
};
look at her. five fields. main character energy fr fr. π₯
π Members π
π generate
The function defined by this variable obtains a random number. The random number generator transform must generate the random number out of the context provided with this call, plus any additional data if provided to the call.
so this is the one that actually delivers the goods β it pulls a random number out of the context you hand it, plus anything extra you pass in along with the call. it's giving "i got you, bestie." β¨
π seed
Seed or reseed the random number generator. With the invocation of this function call, the random number generator shall become ready for generation. If the random number generator requires a seed for setting up a new state, the seed must be provided by the consumer while invoking this function. The required size of the seed is defined with seedsize.
the glow-up function. call it and the generator becomes ready to generate, periodt. π
and listen β if your RNG needs a seed to set up a new state, you (the consumer) have to hand it over when you call this. how big should that seed be? that's what seedsize is for, iykyk.
π§ set_ent
Set entropy that would otherwise be obtained from entropy source. Internal use only.
entropy injection, but make it internal. internal use only, so don't come for her unless you're the kernel itself. π
πΈ seedsize
The seed size required for a random number generator initialization defined with this variable. Some random number generators does not require a seed as the seeding is implemented internally without the need of support by the consumer. In this case, the seed size is set to zero.
how many seed bytes the RNG needs to initialize β defined right here. some generators don't need a seed at all because they handle seeding internally and don't need any help from the consumer, and in that case seedsize is just 0. no thoughts, zero seed, iconic. β
π base
Common crypto API algorithm data structure.
the shared crypto API algorithm struct that everybody in the crypto family uses. the group chat everyone's in. π«Ά
π SEE ALSO π
Kernel file ./include/crypto/rng.h β plus all these besties:
crypto_stdrng_get_bytes(9)Random number generator API(9)crypto_alloc_rng(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 came out of ./include/crypto, from the October 2026 vintage of the manual β go be random 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