[][src]Struct blake2s_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();

Implementations

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.

pub fn to_state(&self) -> State

Notable traits for State

impl Write for 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 (32). Apart from controlling the length of the final Hash, this is also associated data, and changing it will result in a totally different hash.

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 (32). An empty key is equivalent to having no key at all.

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

At most SALTBYTES (8). 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 (8). 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 0 (meaning BLAKE2X B2 hashes), through 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^48 - 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 (32).

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]

impl Debug for Params[src]

impl Default for Params[src]

Auto Trait Implementations

impl RefUnwindSafe for Params

impl Send for Params

impl Sync for Params

impl Unpin for Params

impl UnwindSafe for Params

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.