Crate drbg

source ·
Expand description

An implementation of the crypographic random number generator CTR_DRBG as defined by NIST SP 800-90A Rev. 1.

CTR_DRBG is a Cryptographically Secure Pseudorandom Number Generator (CSPRNG) that may be used for generating sensitive data such as encryption keys. The implementation uses the AES-256 block cipher and derivation function to generate random bytes.

Quick Example

A simple way to obtain crypographic random random data is to use the LocalCtrDrbg::default() function. This returns a handle to a thread-local instance of CtrDrbg pre-allocated to use entropy supplied by the OS.

use drbg::thread::LocalCtrDrbg;

let drbg = LocalCtrDrbg::default();
let mut random_data = [0u8; 32];
drbg.fill_bytes(&mut random_data, None)?;

Otherwise an instance may be constructed by hand using the CtrBuilder class. This approach allows the caller to configure the instance with different input parameters.

Modules

  • A module to facilitate the CTR_DRBG algorithm.
  • Traits and types for defining entropy sources.
  • A thread-local interface for the CTR_DRBG algorithm.