aes-project/src/main.rs
2024-04-28 15:21:16 +02:00

50 lines
1.2 KiB
Rust

mod aes;
mod square;
use crate::aes::Aes;
fn main() {
let key: [u8; 16] = [
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f,
0x3c,
];
let found_key: [u8; 16] = Aes::findroundkey(&key);
for &byte in &found_key {
print!("{:02x}", byte);
}
println!();
let found_key_origininal = Aes::reverse_key_schedule(&found_key, 4);
for &byte in &found_key_origininal {
print!("{:02x}", byte);
}
println!();
let nturn = 4;
let aescipher = Aes::new(&key, &nturn);
let mut output = [[0u8; 16]; 11];
for i in 0..11 {
for j in 0..4 {
output[i][4 * j..4 * (j + 1)].copy_from_slice(&aescipher.expanded_key[4 * i + j]);
}
}
for &key in &output {
for &byte in &key {
print!("{:02x}", byte);
}
println!();
}
println!("test");
for i in 0..11 {
for &byte in &Aes::reverse_key_schedule(&output[i], i) {
print!("{:02x}", byte);
}
println!();
println!();
}
let found = Aes::findkey(&key);
for &byte in &found {
print!("{:02x}", byte);
}
println!();
}