Struct blake2b_simd::Params

source ·
pub struct Params { /* private fields */ }
Expand description

A parameter builder that exposes all the non-default BLAKE2 features.

Apart from hash_length, which controls the length of the final Hash, all of these parameters are just associated data that gets mixed with the input. For more details, see the BLAKE2 spec.

Several of the parameters have a valid range defined in the spec and documented below. Trying to set an invalid parameter will panic.

§Example

// Create a Params object with a secret key and a non-default length.
let mut params = Params::new();
params.key(b"my secret key");
params.hash_length(16);

// Use those params to hash an input all at once.
let hash = params.hash(b"my input");

// Or use those params to build an incremental State.
let mut state = params.to_state();

Implementations§

source§

impl Params

source

pub fn new() -> Self

Equivalent to Params::default().

source

pub fn hash(&self, input: &[u8]) -> Hash

Hash an input all at once with these parameters.

source

pub fn to_state(&self) -> State

Construct a State object based on these parameters, for hashing input incrementally.

source

pub fn hash_length(&mut self, length: usize) -> &mut Self

Set the length of the final hash in bytes, from 1 to OUTBYTES (64). Apart from controlling the length of the final Hash, this is also associated data, and changing it will result in a totally different hash.

source

pub fn key(&mut self, key: &[u8]) -> &mut Self

Use a secret key, so that BLAKE2 acts as a MAC. The maximum key length is KEYBYTES (64). An empty key is equivalent to having no key at all.

source

pub fn salt(&mut self, salt: &[u8]) -> &mut Self

At most SALTBYTES (16). Shorter salts are padded with null bytes. An empty salt is equivalent to having no salt at all.

source

pub fn personal(&mut self, personalization: &[u8]) -> &mut Self

At most PERSONALBYTES (16). Shorter personalizations are padded with null bytes. An empty personalization is equivalent to having no personalization at all.

source

pub fn fanout(&mut self, fanout: u8) -> &mut Self

From 0 (meaning unlimited) to 255. The default is 1 (meaning sequential).

source

pub fn max_depth(&mut self, depth: u8) -> &mut Self

From 0 (meaning BLAKE2X B2 hashes), through 1 (the default, meaning sequential) to 255 (meaning unlimited).

source

pub fn max_leaf_length(&mut self, length: u32) -> &mut Self

From 0 (the default, meaning unlimited or sequential) to 2^32 - 1.

source

pub fn node_offset(&mut self, offset: u64) -> &mut Self

From 0 (the default, meaning first, leftmost, leaf, or sequential) to 2^64 - 1.

source

pub fn node_depth(&mut self, depth: u8) -> &mut Self

From 0 (the default, meaning leaf or sequential) to 255.

source

pub fn inner_hash_length(&mut self, length: usize) -> &mut Self

From 0 (the default, meaning sequential) to OUTBYTES (64).

source

pub fn last_node(&mut self, last_node: bool) -> &mut Self

Indicates the rightmost node in a row. This can also be changed on the State object, potentially after hashing has begun. See State::set_last_node.

Trait Implementations§

source§

impl Clone for Params

source§

fn clone(&self) -> Params

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Params

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Params

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Params

§

impl RefUnwindSafe for Params

§

impl Send for Params

§

impl Sync for Params

§

impl Unpin for Params

§

impl UnwindSafe for Params

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.