fix(aes): From matrix Key

This commit is contained in:
Kristofers Solo 2025-12-18 18:24:30 +02:00
parent 045f49a9ef
commit 9869036bdf
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED

View File

@ -1,8 +1,7 @@
use crate::Block128;
use std::fmt::Debug;
use zeroize::ZeroizeOnDrop;
use crate::Block128;
/// 128-bit Key for AES
#[derive(ZeroizeOnDrop)]
pub struct Key([u8; 16]);
@ -42,7 +41,7 @@ impl From<[[u8; 4]; 4]> for Key {
fn from(matrix: [[u8; 4]; 4]) -> Self {
let mut bytes = [0; 16];
for (idx, row) in matrix.iter().enumerate() {
bytes[idx * 4..(idx - 1) * 4].copy_from_slice(row);
bytes[idx * 4..(idx + 1) * 4].copy_from_slice(row);
}
Self(bytes)
}