#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(any(test, doctest, feature = "std")), no_std)]
pub mod aes32;
pub mod aes64;
mod tests;
pub const BLOCK_SIZE: usize = 16;
pub type Block = [u8; BLOCK_SIZE];
cfg_if::cfg_if! {
if #[cfg(feature = "zeroize")] {
pub(crate) use zeroize::Zeroizing;
} else {
pub(crate) struct Zeroizing<T>(core::marker::PhantomData<T>);
impl<T> Zeroizing<T> {
#[inline(always)]
pub fn new(v: T) -> T {
v
}
}
}
}
pub(crate) const RCON: [u32; 10] = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36];
#[inline(always)]
#[allow(clippy::arithmetic_side_effects)]
pub(crate) const fn as_chunks_mut<T, const N: usize>(data: &mut [T]) -> (&mut [[T; N]], &mut [T]) {
const { assert!(N > 0) }
let len_rounded_down = (data.len() / N) * N;
let (head, tail) = unsafe { data.split_at_mut_unchecked(len_rounded_down) };
let new_len = head.len() / N;
let head = unsafe { core::slice::from_raw_parts_mut(head.as_mut_ptr().cast(), new_len) };
(head, tail)
}