mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2025-12-20 11:04:38 +00:00
fix(aes): From matrix Key
This commit is contained in:
parent
045f49a9ef
commit
9869036bdf
@ -1,8 +1,7 @@
|
|||||||
|
use crate::Block128;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use zeroize::ZeroizeOnDrop;
|
use zeroize::ZeroizeOnDrop;
|
||||||
|
|
||||||
use crate::Block128;
|
|
||||||
|
|
||||||
/// 128-bit Key for AES
|
/// 128-bit Key for AES
|
||||||
#[derive(ZeroizeOnDrop)]
|
#[derive(ZeroizeOnDrop)]
|
||||||
pub struct Key([u8; 16]);
|
pub struct Key([u8; 16]);
|
||||||
@ -42,7 +41,7 @@ impl From<[[u8; 4]; 4]> for Key {
|
|||||||
fn from(matrix: [[u8; 4]; 4]) -> Self {
|
fn from(matrix: [[u8; 4]; 4]) -> Self {
|
||||||
let mut bytes = [0; 16];
|
let mut bytes = [0; 16];
|
||||||
for (idx, row) in matrix.iter().enumerate() {
|
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)
|
Self(bytes)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user