Expand description
A Rust implementation of the Subset Counter-Based Deterministic Random Bit Generator (SC_DRBG).
Provides a deterministic random bit generator that maintains an array of seed material in its internal state (rather than a single seed), allowing each output to be generated from a configurable subset of array elements.
§Features
- Support for 32 and 64 bit unsigned integers.
- Configurable endianness.
- Can specify the number of elements (1 to N) used to produce each output.
- Commitment of array elements to their positions, lengths, and contents.
- Configurable rounds of mixing for entropy diffusion across elements.
- Provides forward security through state evolution.
- Implements
RngCorefor compatibility with the Rust random ecosystem. - Secure memory zeroization on drop.
§Example
use hex_literal::hex;
use rand_core::RngCore;
use sc_drbg::Drbg;
use sha3::Sha3_256;
fn main() {
let arr = vec![
hex!("456E64204F662054686520576F726C642053756E").to_vec(),
hex!("556E6D616B65207468652057696C64204C69676874").to_vec(),
hex!("536166652050617373616765").to_vec(),
hex!("747261636B6572706C61747A").to_vec(),
hex!("3635646179736F66737461746963").to_vec(),
];
let context = "some-random-application";
let mut drbg = Drbg::<Sha3_256, u32>::new_le(&arr, Some(context), true)
.expect("Should create new SC_DRBG instance");
let num = drbg.next_u32();
assert_eq!(num, 4076030162);
}Structs§
- Drbg
- Structure representing SC_DRBG, a Subset Counter-Based Deterministic Random Bit Generator.
Enums§
- Drbg
Error - Enum that represents all possible errors that can be returned by
Drbgconstructors. - Endian
- Byte order for integer encoding and decoding.
Traits§
- Unsigned
Int - A trait for unsigned integers, providing common arithmetic and byte conversion functionality.