Skip to content

Commit

Permalink
Created get_round_const method in AESKey
Browse files Browse the repository at this point in the history
  • Loading branch information
nsmlzl committed Jan 1, 2021
1 parent b81e5ce commit 3e20c01
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 3e20c01

Please sign in to comment.