From 3e20c011d94f26790ed837d0c680cb4b8a7ed38e Mon Sep 17 00:00:00 2001 From: Niklas Schmelzle Date: Sat, 2 Jan 2021 00:03:46 +0100 Subject: [PATCH] Created get_round_const method in AESKey --- src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index e767d76..e2e3473 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,8 +104,12 @@ mod aes_ciy { for b in out.iter_mut() { b.sub_bytes(); } - // TODO: create method for rc generation - let u: u8 = match round { + let rc = AESKey::get_round_const(round); + out[0] ^= rc; + out + } + fn get_round_const(round: u8) -> AESByte { + let constant: u8 = match round { 1 => 0x01, 2 => 0x02, 3 => 0x04, @@ -118,9 +122,7 @@ mod aes_ciy { 10 => 0x36, _ => panic!("key round out of range"), }; - let rc = AESByte::new(u); - out[0] ^= rc; - out + AESByte::new(constant) } } // TODO: Rename AESData