quasor 6.1.3

A high-security AEAD based on a Duplex Sponge construction with SHAKE256, Argon2id, and BLAKE3.
Documentation
// src/sponge.rs
use tiny_keccak::{Hasher, Shake, Xof};
use zeroize::Zeroize;

#[derive(Clone)]
pub struct Sponge {
    state: Shake,
}

impl Sponge {
    pub fn new() -> Self {
        Self {
            state: Shake::v256(),
        }
    }

    pub fn absorb(&mut self, input: &[u8]) {
        self.state.update(input);
    }

    pub fn squeeze(&mut self, out_len: usize) -> Vec<u8> {
        let mut out = vec![0u8; out_len];
        self.state.squeeze(&mut out);
        out
    }

    /// Create a new sponge with the same state for separate operations
    /// This avoids duplex transition issues in tiny-keccak
    pub fn fork(&self) -> Self {
        Self {
            state: self.state.clone(),
        }
    }
}

// Manually implement Zeroize to securely clear the sponge's state.
// This allows ZeroizeOnDrop to work on structs that contain a Sponge.
impl Zeroize for Sponge {
    fn zeroize(&mut self) {
        // Overwrite the internal state with a fresh, empty one.
        self.state = Shake::v256();
    }
}