pub struct HkdfSha256 { /* private fields */ }Expand description
HKDF-SHA-256 (RFC 5869).
Built on HmacSha256, so it is served by whichever driver is
registered for it; see driver.
§Example
ⓘ
let hk = HkdfSha256::new(b"salt", b"input key material");
let mut okm = [0u8; 42];
hk.expand(b"context", &mut okm)?;
// Or keep the pseudorandom key to expand later:
let (prk, _) = HkdfSha256::extract(b"salt", b"input key material");
HkdfSha256::from_prk(&prk)?.expand(b"context", &mut okm)?;Implementations§
Source§impl HkdfSha256
impl HkdfSha256
Sourcepub const MAX_OUTPUT_SIZE: usize
pub const MAX_OUTPUT_SIZE: usize
Largest output expand can produce, in bytes.
Sourcepub fn new(salt: &[u8], ikm: &[u8]) -> Self
pub fn new(salt: &[u8], ikm: &[u8]) -> Self
Extract a pseudorandom key from ikm with salt.
An empty salt is equivalent to the RFC’s default of PRK_SIZE zeros.
Sourcepub fn extract(salt: &[u8], ikm: &[u8]) -> ([u8; 32], Self)
pub fn extract(salt: &[u8], ikm: &[u8]) -> ([u8; 32], Self)
Like new, also returning the pseudorandom key.
Trait Implementations§
Source§impl Clone for HkdfSha256
impl Clone for HkdfSha256
Source§fn clone(&self) -> HkdfSha256
fn clone(&self) -> HkdfSha256
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HkdfSha256
impl !Unpin for HkdfSha256
impl !UnwindSafe for HkdfSha256
impl Freeze for HkdfSha256
impl Send for HkdfSha256
impl Sync for HkdfSha256
impl UnsafeUnpin for HkdfSha256
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