Skip to main content

HmacDrbg

Struct HmacDrbg 

Source
pub struct HmacDrbg<H: Digest> { /* private fields */ }
Expand description

HMAC_DRBG internal state (SP 800-90A §10.1.2.1): (K, V) each outlen octets, plus the reseed_counter. K and V are secret.

Implementations§

Source§

impl<H: Digest> HmacDrbg<H>

Source

pub fn instantiate( entropy_input: &[u8], nonce: &[u8], personalization: &[u8], ) -> Result<Self, Error>

Instantiate an HMAC_DRBG (SP 800-90A §10.1.2.3).

  seed_material = entropy_input || nonce || personalization_string
  K = 0x00 00 … 00   (outlen octets)
  V = 0x01 01 … 01   (outlen octets)
  (K, V) = Update(seed_material, K, V)
  reseed_counter = 1
Source

pub fn reseed( &mut self, entropy_input: &[u8], additional_input: &[u8], ) -> Result<(), Error>

Reseed an HMAC_DRBG (SP 800-90A §10.1.2.4).

  seed_material = entropy_input || additional_input
  (K, V) = Update(seed_material, K, V)
  reseed_counter = 1
Source

pub fn generate( &mut self, out: &mut [u8], additional_input: &[u8], ) -> Result<(), Error>

Generate pseudorandom bits (SP 800-90A §10.1.2.5).

  if reseed_counter > reseed_interval: return "Reseed required"
  if additional_input != Null: (K, V) = Update(additional_input, K, V)
  temp = ""
  while len(temp) < requested_bits:
      V = HMAC(K, V); temp = temp || V
  returned_bits = leftmost requested_bits of temp
  (K, V) = Update(additional_input, K, V)
  reseed_counter += 1

Auto Trait Implementations§

§

impl<H> Freeze for HmacDrbg<H>

§

impl<H> RefUnwindSafe for HmacDrbg<H>
where H: RefUnwindSafe,

§

impl<H> Send for HmacDrbg<H>
where H: Send,

§

impl<H> Sync for HmacDrbg<H>
where H: Sync,

§

impl<H> Unpin for HmacDrbg<H>
where H: Unpin,

§

impl<H> UnsafeUnpin for HmacDrbg<H>

§

impl<H> UnwindSafe for HmacDrbg<H>
where H: UnwindSafe,

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.