pub struct HashDrbg<H: Digest> { /* private fields */ }Expand description
Hash_DRBG internal state (SP 800-90A §10.1.1.1): the value V, the
constant C (both seedlen octets), and the reseed_counter.
V and C are secret. H fixes the hash and thereby seedlen.
Implementations§
Source§impl<H: Digest> HashDrbg<H>
impl<H: Digest> HashDrbg<H>
Sourcepub fn instantiate(
entropy_input: &[u8],
nonce: &[u8],
personalization: &[u8],
) -> Result<Self, Error>
pub fn instantiate( entropy_input: &[u8], nonce: &[u8], personalization: &[u8], ) -> Result<Self, Error>
Instantiate a Hash_DRBG (SP 800-90A §10.1.1.2).
entropy_input— at leastsecurity_strengthbits (§8.6.3); the caller owns the entropy source. Enforced here as8·len ≥ security_strength.nonce— at leastsecurity_strength/2bits (§8.6.7).personalization— optional, may be empty (§8.7.1).
seed_material = entropy_input || nonce || personalization_string
V = Hash_df(seed_material, seedlen)
C = Hash_df(0x00 || V, seedlen)
reseed_counter = 1Sourcepub fn reseed(
&mut self,
entropy_input: &[u8],
additional_input: &[u8],
) -> Result<(), Error>
pub fn reseed( &mut self, entropy_input: &[u8], additional_input: &[u8], ) -> Result<(), Error>
Reseed a Hash_DRBG (SP 800-90A §10.1.1.3).
seed_material = 0x01 || V || entropy_input || additional_input
V = Hash_df(seed_material, seedlen)
C = Hash_df(0x00 || V, seedlen)
reseed_counter = 1Sourcepub fn generate(
&mut self,
out: &mut [u8],
additional_input: &[u8],
) -> Result<(), Error>
pub fn generate( &mut self, out: &mut [u8], additional_input: &[u8], ) -> Result<(), Error>
Generate pseudorandom bits (SP 800-90A §10.1.1.4).
Fills out with 8·out.len() pseudorandom bits.
if reseed_counter > reseed_interval: return "Reseed required"
if additional_input != Null:
w = Hash(0x02 || V || additional_input)
V = (V + w) mod 2^seedlen
returned_bits = Hashgen(requested_bits, V)
H = Hash(0x03 || V)
V = (V + H + C + reseed_counter) mod 2^seedlen
reseed_counter += 1Auto Trait Implementations§
impl<H> Freeze for HashDrbg<H>
impl<H> RefUnwindSafe for HashDrbg<H>where
H: RefUnwindSafe,
impl<H> Send for HashDrbg<H>where
H: Send,
impl<H> Sync for HashDrbg<H>where
H: Sync,
impl<H> Unpin for HashDrbg<H>where
H: Unpin,
impl<H> UnsafeUnpin for HashDrbg<H>
impl<H> UnwindSafe for HashDrbg<H>where
H: UnwindSafe,
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