The problem is not about randomness itself (we have rand), but in cryptographically secure PRNG. What can be used on Linux, or ideally POSIX? Does NSS have something useful?
Clarification: I know about /dev/random, but it may run out of entropy pool. And I’m not sure whether /dev/urandom is guaranteed to be cryptographically secure.
Use
/dev/random(requires user input, eg mouse movements) or/dev/urandom. The latter has an entropy pool and doesn’t require any user input unless the pool is empty.You can read from the pool like this:
Or something like that.