aes-project/src/main.rs

35 lines
1009 B
Rust
Raw Normal View History

2024-04-26 18:47:30 +02:00
mod aes;
use aes::Aes;
2024-04-12 18:52:42 +02:00
fn main() {
2024-04-26 18:47:30 +02:00
let key: [u8; 16] = [
2024-04-27 22:42:53 +02:00
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f,
0x3c,
2024-04-26 18:47:30 +02:00
];
2024-04-27 22:42:53 +02:00
let mut found_key: [u8; 16] = Aes::findroundkey(&key);
for &byte in &found_key {
print!("{:02x}", byte);
2024-04-26 18:47:30 +02:00
}
2024-04-27 22:42:53 +02:00
println!();
// should be
// ef44a541
// a8525b7f
// b671253b
// db0bad00
2024-04-27 22:42:53 +02:00
let found_key_origininal = Aes::reverse_key_schedule(&mut found_key, 4);
for &byte in &found_key_origininal {
print!("{:02x}", byte);
}
println!();
// 247e156b 22aed2a6 a7f71588 01cf4f3c
// 2b7e1516, 28aed2a6, abf71588, 09cf4f3c, EXPECTED
// 2b7e1574 27aed2a6 a4f71588 00cf4f3c
// 2b7e1516 28aed2a6 abf71588 09cf4f3c
// 2b7e1516, 28aed2a6, abf71588, 09cf4f3c,
// a0fafe17, 88542cb1, 23a33939, 2a6c7605,
// f2c295f2, 7a96b943, 5935807a, 7359f67f,
// 3d80477d, 4716fe3e, 1e237e44, 6d7a883b,
// ef44a541, a8525b7f, b671253b, db0bad00
2024-04-12 18:52:42 +02:00
}