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>
impl<U: Unit, H: DuplexHash<U>> Safe<H, U>
sourcepub fn new(io_pattern: &IOPattern<H, U>) -> Self
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.
sourcepub fn ratchet(&mut self) -> Result<(), IOPatternError>
pub fn ratchet(&mut self) -> Result<(), IOPatternError>
Finish the block and compress the state.
sourcepub fn preprocess(self) -> Result<&'static [U], IOPatternError>
pub fn preprocess(self) -> Result<&'static [U], IOPatternError>
Ratchet and return the sponge state.
sourcepub fn absorb(&mut self, input: &[U]) -> Result<(), IOPatternError>
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.
sourcepub fn squeeze(&mut self, output: &mut [U]) -> Result<(), IOPatternError>
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§
Auto Trait Implementations§
impl<H, U> RefUnwindSafe for Safe<H, U>where
H: RefUnwindSafe,
U: RefUnwindSafe,
impl<H, U> Send for Safe<H, U>
impl<H, U> Sync for Safe<H, U>
impl<H, U> Unpin for Safe<H, U>
impl<H, U> UnwindSafe for Safe<H, U>where
H: UnwindSafe,
U: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more