period finder update
This commit is contained in:
+3
-19
@@ -140,24 +140,8 @@ fn period_h(start: Reg5) -> u64 {
|
||||
|
||||
/// paper method, decomposition key register
|
||||
/// (Observations on TETRA Encryption Algorithm TEA-3)
|
||||
/// key 5 bytes, (10 bytes but first 5 bytes are padding with 0)
|
||||
pub fn period_paper(key: Vec<u8>) -> u64 {
|
||||
let start = Decomposed::from_key(&key);
|
||||
|
||||
let p = period_h(start.h);
|
||||
|
||||
for mult in [1u64, 2, 5, 10] {
|
||||
let target = p * mult;
|
||||
|
||||
let mut cur = start;
|
||||
|
||||
for _ in 0..target {
|
||||
cur.step();
|
||||
}
|
||||
|
||||
if cur == start {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
panic!("No valid period found");
|
||||
let start = Decomposed::from_key(&[0, 0, 0, 0, 0, key[0], key[1], key[2], key[3], key[4]]);
|
||||
period_h(start.h) // p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user