find key + test
This commit is contained in:
parent
c8d65fbd27
commit
5ba752d95b
@ -41,4 +41,9 @@ fn main() {
|
|||||||
println!();
|
println!();
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
let found = Aes::findkey(&key);
|
||||||
|
for &byte in &found {
|
||||||
|
print!("{:02x}", byte);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,10 @@ impl Aes {
|
|||||||
}
|
}
|
||||||
found_key
|
found_key
|
||||||
}
|
}
|
||||||
// pub fn findkey(&key: &[u8; 16]) -> [u8; 16] {
|
pub fn findkey(&key: &[u8; 16]) -> [u8; 16] {
|
||||||
//
|
let roundkey: [u8; 16] = Self::findroundkey(&key);
|
||||||
// }
|
Self::reverse_key_schedule(&roundkey, 4)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -176,4 +177,12 @@ mod tests {
|
|||||||
assert_eq!(Aes::reverse_key_schedule(&round_keys[i], i), key);
|
assert_eq!(Aes::reverse_key_schedule(&round_keys[i], i), key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn find_key_test() {
|
||||||
|
let key: [u8; 16] = [
|
||||||
|
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf,
|
||||||
|
0x4f, 0x3c,
|
||||||
|
];
|
||||||
|
assert_eq!(key, Aes::findkey(&key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user