crypto_stdrng_get_bytes(9)
π crypto_stdrng_get_bytes β bestie's guide to cryptographically secure random bytes π
okay so this is a page from the Kernel API Manual (section 9, kernel-API girlies rise π«Ά) and it's literally all about grabbing some top-tier random bytes. no cap, this one's short and sweet, so let's get into it β¨
πΈ NAME πΈ
crypto_stdrng_get_bytes β get cryptographically secure random bytes π
like, actually secure. not your cousin's rand(). the real deal.
β¨ SYNOPSIS β¨
int crypto_stdrng_get_bytes (void *buf , unsigned int len );
that's the whole signature, bestie β copy it exactly, she's particular about her types π₯
π ARGUMENTS π
bufβ your output buffer, aka where the random numbers go to live. it's caller-allocated, so yes, you're bringing the container, the function's just bringing the goodies πlenβ the length of that output buffer. how much randomness are we talking here π
π¦ DESCRIPTION π¦
okay so here's the vibe check π: this function fills the caller-allocated buffer with random numbers. easy enough. but which random numbers? that's the fun part:
- if
fips_enabled=0, it uses the normal Linux RNG β the classic, the icon, the main character π - if
fips_enabled=1, it switches to the highest-priority"stdrng"algorithm in thecrypto_rngsubsystem β FIPS mode has entered the chat, we're being β¨responsibleβ¨ now
so it's giving "one function, two moods," and the mood is decided entirely by that fips_enabled flag. iykyk π§
π«Ά CONTEXT π«Ά
May sleep. π΄
that's it, that's the whole section. so don't go calling this from somewhere that can't take a nap β noted, respected, moving on πΈ
β RETURN β
0β the function was successful, we ate, no crumbs π< 0β an error occurred π something went wrong, check that value fr fr
π SEE ALSO π
- Kernel file
./include/crypto/rng.hstruct rng_alg(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)
like, the whole crypto_rng friend group honestly. go say hi to all of them π¦
ngl this one's genuinely simple β fill buffer, respect fips_enabled, check the return value. but do check the return value, bestie, don't leave me hanging π
and that's the page! π
brought to you from the ./include/crypto corner of the kernel, dated October 2026 β so mark your calendar, she's from the future β¨π stay random, stay secure, 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