pub struct IV { /* private fields */ }
Expand description
Initialization vector for a Blake3 hasher, if BlockHasher::new()
or HashTreeBuilder::new()
are not sufficient for you and you need more customization on the IV, such as keyed hash
function, you can achieve it by constructing the IV
first using a method like
IV::new_keyed
and convert it to either of these by simply using the Into
trait.
Implementations§
Source§impl IV
impl IV
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new IV
from the default configurations. This is the equivalent
IV of creating a Hasher::new()
.
Sourcepub fn new_keyed(key: &[u8; 32]) -> Self
pub fn new_keyed(key: &[u8; 32]) -> Self
The keyed hash function.
This is suitable for use as a message authentication code, for example to
replace an HMAC instance. In that use case, the constant-time equality
checking provided by Hash
is almost always a security
requirement, and callers need to be careful not to compare MACs as raw
bytes.
Sourcepub fn new_derive_key(context: &str) -> Self
pub fn new_derive_key(context: &str) -> Self
The key derivation function.
Given cryptographic key material of any length and a context string of any
length, this function outputs a 32-byte derived subkey. The context string
should be hardcoded, globally unique, and application-specific. A good
default format for such strings is "[application] [commit timestamp] [purpose]"
, e.g., "example.com 2019-12-25 16:18:03 session tokens v1"
.
Key derivation is important when you want to use the same key in multiple algorithms or use cases. Using the same key with different cryptographic algorithms is generally forbidden, and deriving a separate subkey for each use case protects you from bad interactions. Derived keys also mitigate the damage from one part of your application accidentally leaking its key.
Trait Implementations§
Source§impl From<IV> for BlockHasher
impl From<IV> for BlockHasher
Source§impl From<IV> for HashTreeBuilder
impl From<IV> for HashTreeBuilder
impl Copy for IV
Auto Trait Implementations§
impl Freeze for IV
impl RefUnwindSafe for IV
impl Send for IV
impl Sync for IV
impl Unpin for IV
impl UnwindSafe for IV
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more