use zeroize::Zeroizing;
pub(crate) const LEN: usize = 16;
pub(crate) fn zeroizing_copy_16(bytes: &[u8]) -> Zeroizing<[u8; LEN]> {
let mut out = Zeroizing::new([0u8; LEN]);
out.copy_from_slice(bytes);
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn copies_exactly_16_bytes_in_order() {
let src: [u8; 16] = core::array::from_fn(|i| i as u8);
let out = zeroizing_copy_16(&src);
assert_eq!(*out, src);
}
#[test]
#[should_panic]
fn panics_on_short_input() {
let _ = zeroizing_copy_16(&[0u8; 15]);
}
#[test]
#[should_panic]
fn panics_on_long_input() {
let _ = zeroizing_copy_16(&[0u8; 17]);
}
}