Break down the lines in hmac_validate() for better structure
@@ -124,12 +124,25 @@ impl Hmac {
pub fn hmac_validate(&self, received_hmac: &[u8]) -> bool {
let own_hmac = self.hmac_compute();
-
let rand_key = util::gen_rand_key(64);
- let second_round_own = Hmac { secret_key: rand_key.clone(), message: own_hmac, sha2: self.sha2 };
- let second_round_received = Hmac { secret_key: rand_key.clone(), message: received_hmac.to_vec(), sha2: self.sha2 };
- util::compare_ct(&second_round_own.hmac_compute(), &second_round_received.hmac_compute(), (self.sha2 / 8))
+ let nd_round_own = Hmac {
+ secret_key: rand_key.clone(),
+ message: own_hmac,
+ sha2: self.sha2
+ };
+
+ let nd_round_received = Hmac {
+ secret_key: rand_key.clone(),
+ message: received_hmac.to_vec(),
+ sha2: self.sha2
+ };
+
+ util::compare_ct(
+ &nd_round_own.hmac_compute(),
+ &nd_round_received.hmac_compute(),
+ (self.sha2 / 8)
+ )
}
}
