pub struct GenericHkdf<H: HmacImpl> {
pub(crate) hmac: H,
}Expand description
Structure representing the HKDF, capable of HKDF-Expand and HKDF-Extract operations. Recommendations for the correct usage of the parameters can be found in the crate root.
This type is generic over HMAC implementation. Most users should use
Hkdf or SimpleHkdf type aliases.
Fields§
§hmac: HImplementations§
Source§impl<H: HmacImpl> GenericHkdf<H>
impl<H: HmacImpl> GenericHkdf<H>
Sourcepub fn new(salt: Option<&[u8]>, ikm: &[u8]) -> Self
pub fn new(salt: Option<&[u8]>, ikm: &[u8]) -> Self
Convenience method for extract when the generated
pseudorandom key can be ignored and only HKDF-Expand operation is needed. This is the most
common constructor.
Sourcepub fn from_prk(prk: &[u8]) -> Result<Self, InvalidPrkLength>
pub fn from_prk(prk: &[u8]) -> Result<Self, InvalidPrkLength>
Create Hkdf from an already cryptographically strong pseudorandom key
as per section 3.3 from RFC5869.
§Errors
Returns InvalidPrkLength if prk is shorter than the output size of H.
Sourcepub fn extract(salt: Option<&[u8]>, ikm: &[u8]) -> (Output<H>, Self)
pub fn extract(salt: Option<&[u8]>, ikm: &[u8]) -> (Output<H>, Self)
The RFC5869 HKDF-Extract operation returning both the generated
pseudorandom key and Hkdf struct for expanding.
Sourcepub fn expand_multi_info(
&self,
info_components: &[&[u8]],
okm: &mut [u8],
) -> Result<(), InvalidLength>
pub fn expand_multi_info( &self, info_components: &[&[u8]], okm: &mut [u8], ) -> Result<(), InvalidLength>
The RFC5869 HKDF-Expand operation. This is equivalent to calling
expand with the info argument set equal to the
concatenation of all the elements of info_components.
§Errors
Returns InvalidLength in the event okm is too large.
Sourcepub fn expand(&self, info: &[u8], okm: &mut [u8]) -> Result<(), InvalidLength>
pub fn expand(&self, info: &[u8], okm: &mut [u8]) -> Result<(), InvalidLength>
The RFC5869 HKDF-Expand operation
If you don’t have any info to pass, use an empty slice.
§Errors
Returns InvalidLength in the event okm is too large.
Trait Implementations§
Source§impl<H: Clone + HmacImpl> Clone for GenericHkdf<H>
impl<H: Clone + HmacImpl> Clone for GenericHkdf<H>
Source§fn clone(&self) -> GenericHkdf<H>
fn clone(&self) -> GenericHkdf<H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more