[−][src]Trait universal_hash::UniversalHash
The UniversalHash trait defines a generic interface for universal hash
functions.
Associated Types
type KeySize: ArrayLength<u8>
Size of the key for the universal hash function
type BlockSize: ArrayLength<u8>
Size of the inputs to and outputs from the universal hash function
Required methods
fn new(key: &GenericArray<u8, Self::KeySize>) -> Self
Instantiate a universal hash function with the given key
fn update_block(&mut self, block: &GenericArray<u8, Self::BlockSize>)
Input a block into the universal hash function
fn reset(&mut self)
Reset UniversalHash instance.
fn result(self) -> Output<Self::BlockSize>
Obtain the Output of a UniversalHash function and consume it.
Provided methods
fn update_padded(&mut self, data: &[u8])
Input data into the universal hash function. If the length of the
data is not a multiple of the block size, the remaining data is
padded with zeroes up to the BlockSize.
This approach is frequently used by AEAD modes which use Message Authentication Codes (MACs) based on universal hashing.
fn result_reset(&mut self) -> Output<Self::BlockSize>
Obtain the Output of a UniversalHash computation and reset it back
to its initial state.
fn verify(self, other: &GenericArray<u8, Self::BlockSize>) -> Result<(), Error>
Verify the UniversalHash of the processed input matches a given Output.
This is useful when constructing Message Authentication Codes (MACs)
from universal hash functions.