pub struct HashDRBG80090A<H: HashDRBG80090AParams> { /* private fields */ }Expand description
Implementation of the Hash_DRBG algorithm as specified in NIST SP 800-90Ar1.
Implementations§
Source§impl<H: HashDRBG80090AParams> HashDRBG80090A<H>
impl<H: HashDRBG80090AParams> HashDRBG80090A<H>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance using the local OS RNG as a source of seed entropy. Alias for HashDRBG80090A::new_from_os.
Sourcepub fn new_unititialized() -> Self
pub fn new_unititialized() -> Self
Creates a new, uninstantiated instance. After creating it, you must call instantiate() to seed it.
WARNING: Dangerous! This constructor does not initialize the DRBG from any entropy source, and relies on you to provide a strong seed.
Sourcepub fn new_from_os() -> Self
pub fn new_from_os() -> Self
Creates a new instance using the local OS RNG as a source of seed entropy.
Trait Implementations§
Source§impl<H: HashDRBG80090AParams> Default for HashDRBG80090A<H>
impl<H: HashDRBG80090AParams> Default for HashDRBG80090A<H>
Source§fn default() -> Self
fn default() -> Self
Creates a new instance using the local OS RNG as a source of seed entropy. Alias for HashDRBG80090A::new_from_os.
Source§impl<H: HashDRBG80090AParams> RNG for HashDRBG80090A<H>
impl<H: HashDRBG80090AParams> RNG for HashDRBG80090A<H>
fn add_seed_keymaterial( &mut self, additional_seed: impl KeyMaterial, ) -> Result<(), RNGError>
fn next_int(&mut self) -> Result<u32, RNGError>
Source§fn next_bytes(&mut self, len: usize) -> Result<Vec<u8>, RNGError>
fn next_bytes(&mut self, len: usize) -> Result<Vec<u8>, RNGError>
Returns the number of requested bytes.
Source§fn next_bytes_out(&mut self, out: &mut [u8]) -> Result<usize, RNGError>
fn next_bytes_out(&mut self, out: &mut [u8]) -> Result<usize, RNGError>
Returns the number of bytes written.
fn fill_keymaterial_out( &mut self, out: &mut impl KeyMaterial, ) -> Result<usize, RNGError>
Source§fn security_strength(&self) -> SecurityStrength
fn security_strength(&self) -> SecurityStrength
Returns the Security Strength of this RNG.
Source§impl<H: HashDRBG80090AParams> Sp80090ADrbg for HashDRBG80090A<H>
impl<H: HashDRBG80090AParams> Sp80090ADrbg for HashDRBG80090A<H>
Source§fn instantiate(
&mut self,
prediction_resistance: bool,
seed: impl KeyMaterial,
nonce: &impl KeyMaterial,
personalization_string: &[u8],
security_strength: SecurityStrength,
) -> Result<(), RNGError>
fn instantiate( &mut self, prediction_resistance: bool, seed: impl KeyMaterial, nonce: &impl KeyMaterial, personalization_string: &[u8], security_strength: SecurityStrength, ) -> Result<(), RNGError>
Output:
- initial_working_state: The initial values for V, C, and reseed_counter (see Section 10.1.1.1).
Source§fn reseed(
&mut self,
seed: &impl KeyMaterial,
additional_input: &[u8],
) -> Result<(), RNGError>
fn reseed( &mut self, seed: &impl KeyMaterial, additional_input: &[u8], ) -> Result<(), RNGError>
Reseeds the DRBG with the provided seed.
TODO: this needs to be thought out to take some sort of EntropySource object that’ll work well with DRBGs that require frequent reseeding.
Source§fn generate(
&mut self,
additional_input: &[u8],
len: usize,
) -> Result<Vec<u8>, RNGError>
fn generate( &mut self, additional_input: &[u8], len: usize, ) -> Result<Vec<u8>, RNGError>
Note that for a calling application to be in compliance with SP 800-90A, this requirement
from section 8.4 must be met:
“The pseudorandom bits returned from a DRBG shall not be used for any
application that requires a higher security strength than the DRBG is instantiated to support. The
security strength provided in these returned bits is the minimum of the security strength
supported by the DRBG and the length of the bit string returned” Read more
Source§fn generate_out(
&mut self,
additional_input: &[u8],
out: &mut [u8],
) -> Result<usize, RNGError>
fn generate_out( &mut self, additional_input: &[u8], out: &mut [u8], ) -> Result<usize, RNGError>
As per Sp80090ADrbg::generate, but writes to the provided output slice.
The output slice is filled.
Throws a RNGError::InsufficientSeedEntropy if the length of the output slice exceeds SecurityStrength.
Retruns the number of bits output.
Source§fn generate_keymaterial_out(
&mut self,
additional_input: &[u8],
out: &mut impl KeyMaterial,
) -> Result<usize, RNGError>
fn generate_keymaterial_out( &mut self, additional_input: &[u8], out: &mut impl KeyMaterial, ) -> Result<usize, RNGError>
As per Sp80090ADrbg::generate, but writes to the provided KeyMaterial.
The output KeyMaterial is filled to capacity.
Throws a RNGError::InsufficientSeedEntropy if the capacity of the output KeyMaterial exceeds SecurityStrength.
Retruns the number of bits output.
Auto Trait Implementations§
impl<H> Freeze for HashDRBG80090A<H>
impl<H> RefUnwindSafe for HashDRBG80090A<H>
impl<H> Send for HashDRBG80090A<H>
impl<H> Sync for HashDRBG80090A<H>
impl<H> Unpin for HashDRBG80090A<H>
impl<H> UnwindSafe for HashDRBG80090A<H>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more