Good randomness is at the center of cryptography. It is used to generate keys, IVs, nonces, etc.
No.
Yes, but they suck.
In most languages, any math/random packages or libraries will offer APIs to generate non-cryptographically secure randomness. These libraries are not to be used to generate randomness for security purposes.
Yes and no. Historically, people have done very stupid things.
getrandom()
/dev/urandom
unless you really care about good entropy at boot time.Early during boot, it is possible that /dev/urandom
is in a state where it is not properly seeded. getrandom()
blocks if this is the case, but /dev/urandom
doesn't and might return weak random numbers.
CryptGenRandom
is said to be deprecated, but realistically it will probably never be.BCryptGenRandom
from the Cryptography API: Next Generation (CNG).Using a userland PRNG has its caveats:
Yes, but not really. Underneath the surface, they are usually generated by using an actual cryptographically secure PRNG, so don't take shortcuts and use a cryptographically secure PRNG directly.
Nobody knows, but it does solve the problem of not having good sources of entropy in headless devices. In general, a sane operating system does not rely solely on RDRAND to seed its PRNGs, and so you should be safe. In practice, if you are really paranoid, I suggest supplying additional entropy to your device