Trait DigestExt

Source
pub trait DigestExt<const BYTE_LEN: usize = 32>: Digest {
    // Required methods
    fn from_tag(tag: impl AsRef<[u8]>) -> Self;
    fn input_raw(&mut self, data: &[u8]);
    fn finish(self) -> [u8; BYTE_LEN];

    // Provided methods
    fn with_raw(self, data: &[u8]) -> Self
       where Self: Sized { ... }
    fn with_len<const MAX: usize>(self, data: &[u8]) -> Self
       where Self: Sized { ... }
    fn input_with_len<const MAX: usize>(&mut self, data: &[u8]) { ... }
}
Expand description

A generic cryptographic digest trait.

Required Methods§

Source

fn from_tag(tag: impl AsRef<[u8]>) -> Self

Initialize a diges with a given tag.

Source

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

Digest raw byte slice.

Source

fn finish(self) -> [u8; BYTE_LEN]

Compute the final cryptographic digest.

Provided Methods§

Source

fn with_raw(self, data: &[u8]) -> Self
where Self: Sized,

Digest raw byte slice returning self.

Source

fn with_len<const MAX: usize>(self, data: &[u8]) -> Self
where Self: Sized,

Digest bytes, adding the data length to the digest (preventing length extension attack).

Returns self.

Source

fn input_with_len<const MAX: usize>(&mut self, data: &[u8])

Digest bytes, adding the data length to the digest (preventing length extension attack).

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§