Skip to main content

ParallelHash128

Struct ParallelHash128 

Source
pub struct ParallelHash128;
Expand description

SP 800-185 ParallelHash128: hashes fixed-size blocks independently, then hashes their digests.

The structure is designed so the per-block work can be spread across cores. This implementation does them in order — the workspace has no threading and no_std targets have no threads to spread onto — so what it buys here is interoperability with implementations that do, not speed. The output is identical either way.

Implementations§

Source§

impl ParallelHash128

Source

pub const CHAINING_LEN: usize = 32

Width of each block’s inner digest, in bytes.

Source

pub fn hash(custom: &[u8], block_size: usize, data: &[u8], out: &mut [u8])

Hash data in blocks of block_size bytes.

block_size must be at least one. SP 800-185 places no upper bound on it, and neither does this.

Source

pub fn hash_xof(custom: &[u8], block_size: usize, data: &[u8], out: &mut [u8])

As Self::hash, in XOF mode.

Trait Implementations§

Source§

impl Algorithm for ParallelHash128

Source§

const ID: &'static str = "parallelhash128"

Stable ontology identifier for this algorithm.
Source§

const NAME: &'static str = "ParallelHash128"

Human-facing display name (for example "SHA-256").
Source§

impl SelfTest for ParallelHash128

Source§

fn self_test() -> Result<()>

The block size is bound into the result, and the whole thing is deterministic. A build that dropped left_encode(B) would give the same answer for every block size, which is what this catches.

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