quasor 6.1.6

A high-security AEAD based on a Duplex Sponge construction with SHAKE256, Argon2id, and BLAKE3.
Documentation
// crates/quasor/src/keccak.rs

#![allow(non_snake_case)]

const RHO: [u32; 24] = [
    1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44,
];

const PI: [usize; 24] = [
    10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1,
];

const RC: [u64; 24] = [
    0x0000000000000001,
    0x0000000000008082,
    0x800000000000808a,
    0x8000000080008000,
    0x000000000000808b,
    0x0000000080000001,
    0x8000000080008081,
    0x8000000000008009,
    0x000000000000008a,
    0x0000000000000088,
    0x0000000080008009,
    0x000000008000000a,
    0x000000008000808b,
    0x800000000000008b,
    0x8000000000008089,
    0x8000000000008003,
    0x8000000000008002,
    0x8000000000000080,
    0x000000000000800a,
    0x800000008000000a,
    0x8000000080008081,
    0x8000000000008080,
    0x0000000080000001,
    0x8000000080008008,
];

pub fn keccak_f1600(state: &mut [u64; 25]) {
    let mut C = [0u64; 5];
    let mut B = [0u64; 5];

    for i in 0..24 {
        // Theta
        for x in 0..5 {
            C[x] = state[x] ^ state[x + 5] ^ state[x + 10] ^ state[x + 15] ^ state[x + 20];
        }

        for x in 0..5 {
            let D = C[(x + 4) % 5] ^ C[(x + 1) % 5].rotate_left(1);
            for y in 0..5 {
                state[x + 5 * y] ^= D;
            }
        }

        // Rho and Pi
        let mut temp = state[1];
        for idx in 0..24 {
            let j = PI[idx];
            let bc = temp;
            temp = state[j];
            state[j] = bc.rotate_left(RHO[idx]);
        }

        // Chi
        for y in (0..25).step_by(5) {
            for x in 0..5 {
                B[x] = state[y + x];
            }
            for x in 0..5 {
                state[y + x] = B[x] ^ ((!B[(x + 1) % 5]) & B[(x + 2) % 5]);
            }
        }

        // Iota
        state[0] ^= RC[i];
    }
}