diff --git a/hashes/src/hmac/mod.rs b/hashes/src/hmac/mod.rs index 2d70253fc..d69c3ccc2 100644 --- a/hashes/src/hmac/mod.rs +++ b/hashes/src/hmac/mod.rs @@ -15,8 +15,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::{Hash, HashEngine}; /// A hash computed from a RFC 2104 HMAC. Parameterized by the underlying hash function. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, PartialOrd, Ord, Hash)] #[repr(transparent)] +#[allow(clippy::derived_hash_with_manual_eq)] pub struct Hmac(T); impl str::FromStr for Hmac { @@ -24,6 +25,14 @@ impl str::FromStr for Hmac { fn from_str(s: &str) -> Result { Ok(Hmac(str::FromStr::from_str(s)?)) } } +impl PartialEq for Hmac { + fn eq(&self, other: &Self) -> bool { + crate::cmp::fixed_time_eq(self.as_ref(), other.as_ref()) + } +} + +impl Eq for Hmac {} + /// Pair of underlying hash engines, used for the inner and outer hash of HMAC. #[derive(Debug, Clone)] pub struct HmacEngine {