Struct nimue::Safe

source ·
pub struct Safe<H, U = u8>
where U: Unit, H: DuplexHash<U>,
{ /* private fields */ }
Expand description

A (slightly modified) SAFE API for sponge functions.

Operations in the SAFE API provide a secure interface for using sponges.

Implementations§

source§

impl<U: Unit, H: DuplexHash<U>> Safe<H, U>

source

pub fn new(io_pattern: &IOPattern<H, U>) -> Self

Initialise a SAFE sponge, setting up the state of the sponge function and parsing the tag string.

source

pub fn ratchet(&mut self) -> Result<(), IOPatternError>

Finish the block and compress the state.

source

pub fn preprocess(self) -> Result<&'static [U], IOPatternError>

Ratchet and return the sponge state.

source

pub fn absorb(&mut self, input: &[U]) -> Result<(), IOPatternError>

Perform secure absorption of the elements in input.

Absorb calls can be batched together, or provided separately for streaming-friendly protocols.

source

pub fn squeeze(&mut self, output: &mut [U]) -> Result<(), IOPatternError>

Perform a secure squeeze operation, filling the output buffer with uniformly random bytes.

For byte-oriented sponges, this operation is equivalent to the squeeze operation. However, for algebraic hashes, this operation is non-trivial. This function provides no guarantee of streaming-friendliness.

Trait Implementations§

source§

impl<H, U> Clone for Safe<H, U>
where U: Unit + Clone, H: DuplexHash<U> + Clone,

source§

fn clone(&self) -> Safe<H, U>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<U: Unit, H: DuplexHash<U>> Debug for Safe<H, U>

source§

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

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

impl<U: Unit, H: DuplexHash<U>> Drop for Safe<H, U>

source§

fn drop(&mut self)

Destroy the sponge state.

source§

impl<U: Unit, H: DuplexHash<U>, B: Borrow<IOPattern<H, U>>> From<B> for Safe<H, U>

source§

fn from(value: B) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<H, U> RefUnwindSafe for Safe<H, U>

§

impl<H, U> Send for Safe<H, U>
where H: Send, U: Send,

§

impl<H, U> Sync for Safe<H, U>
where H: Sync, U: Sync,

§

impl<H, U> Unpin for Safe<H, U>
where H: Unpin, U: Unpin,

§

impl<H, U> UnwindSafe for Safe<H, U>
where H: UnwindSafe, U: UnwindSafe,

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V