Skip to main content

Crate bouncycastle_rng

Crate bouncycastle_rng 

Source
Expand description

RNG objects for cryptographically secure random number generation.

This crate provides the implementations of the deterministic random bit generator (DRBG) algorithms which, together with a strong entropy source, form the basis of cryptographic random number generation.

Here’s the basic way to get some random bytes:

use core_interface::traits::RNG;
use rng;
let random_bytes = rng::DefaultRNG::default().next_bytes(32);

This is secure because ::default() seeds the RNG from the OS, configured for general use.

WARNING: most people should stop reading here and should not be mucking around with the internals of RNGs. This crate contains dragons and other horrible things. 🐉🐍🐜

§🚨🚨🚨Security Warning 🚨🚨🚨

Misuse of the objects in this crate can lead to output which may appear random, but is in fact completely deterministic (ie multiple runs of your application will give the same outputs) and will therefore compromise any cryptographic operation built on top of those outputs. You should only be here if your application requires direct control over configuring the internals of the DRBG.

This crate contains the Sp80090ADrbg trait, which is intentionally defined here and not in [core-interface::traits] since misuse of Sp80090ADrbg::instantiate can completely undermine the security of your entire cryptographic application.

Modules§

hash_drbg80090a
Implements Hash_DRBG (Deterministic Random Bit Generator) from NIST SP 800-90Ar1.

Constants§

HASH_DRBG_SHA256_NAME
HASH_DRBG_SHA512_NAME

Traits§

Sp80090ADrbg
Implements the five functions specified in SP 800-90A section 7.4 are instantate, generate, reseed, uninstantiate, and health_test. Note: this function implements Rust’s Drop on the sensitive working state in place of the explicit Uninstantiate function listed in SP 800-90Ar1.

Type Aliases§

Default128BitRNG
Default256BitRNG
DefaultRNG
HashDRBG_SHA256
HashDRBG_SHA512