Skip to main content

HashDRBG80090A

Struct HashDRBG80090A 

Source
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>

Source

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.

Source

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.

Source

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>

Source§

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>

Source§

fn add_seed_keymaterial( &mut self, additional_seed: impl KeyMaterial, ) -> Result<(), RNGError>

Source§

fn next_int(&mut self) -> Result<u32, RNGError>

Source§

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>

Returns the number of bytes written.
Source§

fn fill_keymaterial_out( &mut self, out: &mut impl KeyMaterial, ) -> Result<usize, RNGError>

Source§

fn security_strength(&self) -> SecurityStrength

Returns the Security Strength of this RNG.
Source§

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>

Output:

  1. 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>

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>

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>

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>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.