Skip to main content

Blake3

Struct Blake3 

Source
pub struct Blake3 { /* private fields */ }
Expand description

BLAKE3 hash function.

Implements the Hasher trait. See the module documentation for examples and backend details.

When the zeroize feature is enabled, the internal state (key words, chunk buffer and chaining-value stack) is overwritten with zeros when the hasher is dropped, so key material does not linger in memory.

Implementations§

Source§

impl Blake3

Source

pub fn new_keyed(key: &[u8; 32]) -> Self

Create a keyed hasher (MAC) from a 32-byte key.

Source

pub fn new_derive_key(context: &str) -> Self

Create a key-derivation hasher from a context string.

The context string should be hardcoded, globally unique and application-specific; see derive_key.

Source

pub fn derive_key(context: &str, key_material: &[u8]) -> [u8; 32]

Derive a 32-byte subkey from key_material and a context string.

The context string should be hardcoded, globally unique and application-specific, e.g. "example.com 2019-12-25 16:18:03 session tokens v1". This function is not a password hash.

Source

pub fn keyed_hash(key: &[u8; 32], input: &[u8]) -> Hash

One-shot keyed hash (MAC).

Source

pub fn finalize_xof(self) -> Blake3XofReader

Finalize the hasher and return an extendable-output reader.

Trait Implementations§

Source§

impl Clone for Blake3

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Blake3

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Hasher for Blake3

Source§

const BLOCK_SIZE: usize = 64

The internal block size of the hash function
Source§

const OUTPUT_SIZE: usize = 32

The output size of the hash function. Read more
Source§

fn new() -> Self

Source§

fn update(&mut self, data: &[u8])

Source§

fn sum(self) -> Hash

Source§

fn hash(data: &[u8]) -> Hash

Source§

impl Zeroize for Blake3

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Zeroize for T
where T: Zeroize,