[][src]Struct blake2b_simd::Params

pub struct Params { /* fields omitted */ }

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();

Methods

impl Params[src]

pub fn new() -> Self[src]

Equivalent to Params::default().

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

Hash an input all at once with these parameters.

Important traits for State
pub fn to_state(&self) -> State[src]

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

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

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.

Note that the b2sum command line utility expects the --length flag in bits rather than bytes, for compatibility with the b2sum implementation in coreutils. The BLAKE2 standard defines the parameter as a count of bytes, however, and this method follows the standard.

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

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.

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

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

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

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

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

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

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

From 1 (the default, meaning sequential) to 255 (meaning unlimited).

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

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

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

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

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

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

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

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

Note that the b2sum command line utility expects the --inner-hash-length flag in bits rather than bytes, to stay consistent with --length. The BLAKE2 standard defines the parameter as a count of bytes, however, and this method follows the standard.

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

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

impl Clone for Params[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Params[src]

impl Debug for Params[src]

Auto Trait Implementations

impl Send for Params

impl Sync for Params

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]