Product SiteDocumentation Site

14.2. Randomness

The following facilities can be used to generate unpredictable and non-repeating values. When these functions are used without special safeguards, each individual random value should be at least 12 bytes long.
All these functions should be non-blocking, and they should not wait until physical randomness becomes available. (Some cryptography providers for Java can cause to block, however.) Those functions which do not obtain all bits directly from /dev/urandom are suitable for high data rates because they do not deplete the system-wide entropy pool.

Difficult to use API

Both RAND_bytes and PK11_GenerateRandom have three-state return values (with conflicting meanings). Careful error checking is required. Please review the documentation when using these functions.
Other sources of randomness should be considered predictable.
Generating randomness for cryptographic keys in long-term use may need different steps and is best left to cryptographic libraries.