OpenSSL:Random
lastmod 2026-11-10created 2017-12-073 edits
OpenSSL's Random (random number) functionality provides a cryptographically secure pseudorandom number generator (CSPRNG) through the RAND_bytes() function. It is used to create values that must be unpredictable, such as keys, IVs, salts, and nonces, and it is seeded automatically from the operating system's entropy sources (/dev/urandom, getrandom, etc.). Standard C's rand() is predictable, so it must not be used for cryptographic purposes, and you should check the return value to handle random number generation failures.