Skip to main content

HalftimeHash16

Struct HalftimeHash16 

Source
pub struct HalftimeHash16 { /* private fields */ }
Expand description

Almost-universal hash with a 16-byte tag (HalftimeHash16, Section 4).

Implementations§

Source§

impl HalftimeHash16

Source

pub const TAG_BYTES: usize = hh16::TAG_BYTES

Tag width in bytes.

Source

pub fn digest(key: &Key<Self>, data: &[u8]) -> Block<Self>

Hash data in one shot with a 32-byte RustCrypto key (NH KDF entropy).

Source

pub fn from_master_key(key: &impl MasterKey) -> Self

Construct from any supported master key ([Key32], [Key64], [Key128]).

A 32-byte key is expanded into input entropy with NH on demand (convenient KDF). Longer keys are folded to 32 bytes with NH before expansion.

Source

pub fn digest_master_key(key: &impl MasterKey, data: &[u8]) -> Block<Self>

One-shot hash with a master key of any supported length.

Source

pub fn with_entropy(entropy: &[u64]) -> Result<Self, EntropyTooShort>

Construct with caller-supplied input entropy (C++ reference style).

The buffer must hold at least Self::entropy_words_needed words for the maximum message length you will hash (defaults to 1 MiB).

Source

pub fn with_entropy_for( entropy: &[u64], max_input_bytes: usize, ) -> Result<Self, EntropyTooShort>

Like Self::with_entropy, but validate for a specific maximum message size.

Source

pub fn digest_with_entropy( entropy: &[u64], data: &[u8], ) -> Result<Block<Self>, EntropyTooShort>

One-shot hash with external entropy sized for data.len().

Source

pub fn entropy_words_needed(input_bytes: usize) -> usize

Number of u64 entropy words required to hash up to input_bytes of message data.

Trait Implementations§

Source§

impl BlockSizeUser for HalftimeHash16

Source§

type BlockSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>

Size of the block in bytes.
Source§

fn block_size() -> usize

Return block size in bytes.
Source§

impl Debug for HalftimeHash16

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl KeyInit for HalftimeHash16

Source§

fn new(key: &Key<Self>) -> Self

32-byte key; entropy is expanded on demand via NH (see Self::from_master_key).

Source§

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable size key. Read more
Source§

impl KeySizeUser for HalftimeHash16

Source§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl UniversalHash for HalftimeHash16

Source§

fn update_with_backend( &mut self, f: impl UhfClosure<BlockSize = Self::BlockSize>, )

Update hash function state using the provided rank-2 closure.
Source§

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. Read more
Source§

fn finalize(self) -> Block<Self>

Retrieve result and consume hasher instance.
Source§

fn update(&mut self, blocks: &[Array<u8, Self::BlockSize>])

Update hash function state with the provided block.
Source§

fn verify(self, expected: &Array<u8, Self::BlockSize>) -> Result<(), Error>

Verify the UniversalHash of the processed input matches a given expected value. Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.