crypto_stdrng_get_bytes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 the crypto_rng subsystem β€” 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 πŸ’œ

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