### 17.6 Random-Number Subsystem Architecture ¶

Libgcrypt provides 3 levels or random quality: The level `GCRY_VERY_STRONG_RANDOM` usually used for key generation, the level `GCRY_STRONG_RANDOM` for all other strong random requirements and the function `gcry_create_nonce` which is used for weaker usages like nonces. There is also a level `GCRY_WEAK_RANDOM` which in general maps to `GCRY_STRONG_RANDOM` except when used with the function `gcry_mpi_randomize`, where it randomizes a multi-precision integer using the `gcry_create_nonce` function.

There are three distinct random generators available:

- The Continuously Seeded Pseudo Random Number Generator (CSPRNG), which is based on the classic GnuPG derived big pool implementation. Implemented in `random/random-csprng.c` and used by default.
- The Deterministic Random Bits Generator (DRBG), based on the specification by NIST SP800-90A. Implemented in `random/random-drbg.c` and used if Libgcrypt is in FIPS mode, or Libgcrypt is configured by GCRYCTL_SET_PREFERRED_RNG_TYPE with GCRY_RNG_TYPE_FIPS.
- Direct access to native RNG on the system. Implemented in `random/random-system.c` and used if Libgcrypt is configured by GCRYCTL_SET_PREFERRED_RNG_TYPE with GCRY_RNG_TYPE_SYSTEM.

All generators make use of so-called entropy gathering modules:

rndgetentropy

  Uses the operating system provided `getentropy` function.

rndoldlinux

  Uses the operating system provided `/dev/random` and `/dev/urandom` devices. The `/dev/gcrypt/random.conf` config option `only-urandom` can be used to inhibit the use of the blocking `/dev/random` device.

rndunix

  Runs several operating system commands to collect entropy from sources like virtual machine and process statistics. It is a kind of poor-man’s `/dev/random` implementation. It is not available in FIPS mode.

rndegd

  Uses the operating system provided Entropy Gathering Daemon (EGD). The EGD basically uses the same algorithms as rndunix does. However as a system daemon it keeps on running and thus can serve several processes requiring entropy input and does not waste collected entropy if the application does not need all the collected entropy.

rndw32

  Targeted for the Microsoft Windows OS. It uses certain properties of that system and is the only gathering module available for that OS.

rndhw

  Extra module to collect additional entropy by utilizing a hardware random number generator. As of now the supported hardware RNG is the Padlock engine of VIA (Centaur) CPUs and x86 CPUs with the RDRAND instruction.

rndjent

  Extra module to collect additional entropy using a CPU jitter based approach. The `/dev/gcrypt/random.conf` config option `disable-jent` can be used to inhibit the use of this module.