Trait snow::types::Hash

source ·
pub trait Hash: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn block_len(&self) -> usize;
    fn hash_len(&self) -> usize;
    fn reset(&mut self);
    fn input(&mut self, data: &[u8]);
    fn result(&mut self, out: &mut [u8]);

    // Provided methods
    fn hmac(&mut self, key: &[u8], data: &[u8], out: &mut [u8]) { ... }
    fn hkdf(
        &mut self,
        chaining_key: &[u8],
        input_key_material: &[u8],
        outputs: usize,
        out1: &mut [u8],
        out2: &mut [u8],
        out3: &mut [u8],
    ) { ... }
}
Expand description

Hashing operations

Required Methods§

source

fn name(&self) -> &'static str

The string that the Noise spec defines for the primitive

source

fn block_len(&self) -> usize

The block length for the primitive

source

fn hash_len(&self) -> usize

The final hash digest length for the primitive

source

fn reset(&mut self)

Reset the internal state

source

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

Provide input to the internal state

source

fn result(&mut self, out: &mut [u8])

Get the resulting hash

Provided Methods§

source

fn hmac(&mut self, key: &[u8], data: &[u8], out: &mut [u8])

Calculate HMAC, as specified in the Noise spec.

NOTE: This method clobbers the existing internal state

source

fn hkdf( &mut self, chaining_key: &[u8], input_key_material: &[u8], outputs: usize, out1: &mut [u8], out2: &mut [u8], out3: &mut [u8], )

Derive keys as specified in the Noise spec.

NOTE: This method clobbers the existing internal state

Implementors§