aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2021-02-28 17:50:06 -0500
committerJack O'Connor <[email protected]>2021-02-28 17:50:06 -0500
commit134bb24686f9a1cd02ad12fdf22a72d9c1071220 (patch)
treed53e536aa2b42da6286d7cb5d270aae227c53978
parent0359065018e2bafa31d319010ec5cebc35ad4393 (diff)
impl PartialEq<[u8]> for Hash
-rw-r--r--src/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e5f3eb6..9869ebb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -293,6 +293,14 @@ impl PartialEq<[u8; OUT_LEN]> for Hash {
}
}
+/// This implementation is constant-time if the target is 32 bytes long.
+impl PartialEq<[u8]> for Hash {
+ #[inline]
+ fn eq(&self, other: &[u8]) -> bool {
+ constant_time_eq::constant_time_eq(&self.0, other)
+ }
+}
+
impl Eq for Hash {}
impl fmt::Debug for Hash {