Skip to main content

Shake256

Struct Shake256 

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

SHAKE256 extendable-output function (FIPS 202, Section 6.2).

Rate = 136 bytes (1088 bits), capacity = 64 bytes (512 bits).

Implementations§

Source§

impl Shake256

Source

pub const fn new() -> Self

Creates a new SHAKE256 instance in the absorbing phase.

Source

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

Absorbs data into the XOF state.

Source

pub fn finalize_xof(self) -> Shake256Reader

Finalizes absorption and transitions to a streaming Shake256Reader.

Finalizes self.sponge in place via &mut, constructs the returned reader directly in the caller’s return slot, and zeroizes the original self.sponge (state + buffer) on drop.

Source

pub fn xof_reader_from_chunks(chunks: &[&[u8]]) -> Shake256Reader

Absorbs chunks and returns a finalized Shake256Reader.

Inputs shorter than one rate block (< 136 bytes) absorb directly into an in-place Keccak state (zeroized on drop) without allocating an intermediate byte buffer.

Source

pub fn finalize_xof_into(&mut self, out: &mut [u8])

Finalizes absorption in place and squeezes out.len() bytes directly into out.

Unlike Self::finalize_xof, this takes &mut self so the sponge is never copied by value onto a callee’s stack frame before Drop zeroizes it.

Source

pub fn xof(data: &[u8], out: &mut [u8])

Computes SHAKE256(data, out.len() * 8) in one shot, writing into out.

Source

pub fn xof_chunks(chunks: &[&[u8]], out: &mut [u8])

Computes SHAKE256(chunks[0] || chunks[1] || ..., out.len() * 8) in one shot.

Inputs shorter than one rate block (< 136 bytes) absorb directly into an in-place Keccak state without allocating an intermediate byte buffer or copying the state on return.

Trait Implementations§

Source§

impl Default for Shake256

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Zeroize for Shake256

Source§

fn zeroize(&mut self)

Overwrites all sensitive memory owned by self with zeros.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.