Trait Hash

Source
pub trait Hash: Default {
    type Block: U8Array;
    type Output: U8Array;

    // Required methods
    fn name() -> &'static str;
    fn input(&mut self, data: &[u8]);
    fn result(&mut self) -> Self::Output;

    // Provided methods
    fn block_len() -> usize { ... }
    fn hash_len() -> usize { ... }
    fn reset(&mut self) { ... }
    fn hash(data: &[u8]) -> Self::Output { ... }
    fn hmac_many(key: &[u8], data: &[&[u8]]) -> Self::Output { ... }
    fn hmac(key: &[u8], data: &[u8]) -> Self::Output { ... }
    fn hkdf(
        chaining_key: &[u8],
        input_key_material: &[u8],
    ) -> (Self::Output, Self::Output) { ... }
    fn hkdf3(
        chaining_key: &[u8],
        input_key_material: &[u8],
    ) -> (Self::Output, Self::Output, Self::Output) { ... }
}
Expand description

A hash function.

Required Associated Types§

Source

type Block: U8Array

Type of a block.

Source

type Output: U8Array

Type of output.

Required Methods§

Source

fn name() -> &'static str

Name of the hash function.

Source

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

Update hash context with some input.

Source

fn result(&mut self) -> Self::Output

Get hash result.

Provided Methods§

Source

fn block_len() -> usize

Length of block.

Source

fn hash_len() -> usize

Length of hash output, in number of bytes.

Source

fn reset(&mut self)

Reset state of hash context.

Source

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

Calculate hash of some data.

Source

fn hmac_many(key: &[u8], data: &[&[u8]]) -> Self::Output

Calculate HMAC-THIS-HASH, with some key and several messages.

Source

fn hmac(key: &[u8], data: &[u8]) -> Self::Output

Calculate HMAC-THIS-HASH, with some key and a message.

Source

fn hkdf( chaining_key: &[u8], input_key_material: &[u8], ) -> (Self::Output, Self::Output)

Calculate HKDF, as specified in the noise spec.

Source

fn hkdf3( chaining_key: &[u8], input_key_material: &[u8], ) -> (Self::Output, Self::Output, Self::Output)

Triple output HKDF.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§