summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Feickert <66188213+AaronFeickert@users.noreply.github.com>2024-08-22 13:15:24 -0500
committerJack O'Connor <oconnor663@gmail.com>2024-08-27 16:47:20 -0700
commit8e2e07e0222851a7f071eee9ffaca4c17fb7872c (patch)
tree4fa4b639017882c9c6a47ac4d14d114e4f73f676
parent08cb01cfc60d592d7c9d098a7fddd169416596e0 (diff)
Remove Miri equality workaround function
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs24
2 files changed, 1 insertions, 25 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8531305..c5f8c99 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -97,7 +97,7 @@ features = ["mmap", "rayon", "serde", "zeroize"]
[dependencies]
arrayref = "0.3.5"
arrayvec = { version = "0.7.4", default-features = false }
-constant_time_eq = "0.3.0"
+constant_time_eq = { version = "0.3.1", default-features = false }
cfg-if = "1.0.0"
digest = { version = "0.10.1", features = [ "mac" ], optional = true }
memmap2 = { version = "0.9", optional = true }
diff --git a/src/lib.rs b/src/lib.rs
index 52a7b42..37c2c0b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -315,28 +315,10 @@ impl Zeroize for Hash {
}
}
-// A proper implementation of constant time equality is tricky, and we get it from the
-// constant_time_eq crate instead of rolling our own. However, that crate isn't compatible with
-// Miri, so we roll our own just for that.
-#[cfg(miri)]
-fn constant_time_eq_miri(a: &[u8], b: &[u8]) -> bool {
- if a.len() != b.len() {
- return false;
- }
- let mut x = 0;
- for i in 0..a.len() {
- x |= a[i] ^ b[i];
- }
- x == 0
-}
-
/// This implementation is constant-time.
impl PartialEq for Hash {
#[inline]
fn eq(&self, other: &Hash) -> bool {
- #[cfg(miri)]
- return constant_time_eq_miri(&self.0, &other.0);
- #[cfg(not(miri))]
constant_time_eq::constant_time_eq_32(&self.0, &other.0)
}
}
@@ -345,9 +327,6 @@ impl PartialEq for Hash {
impl PartialEq<[u8; OUT_LEN]> for Hash {
#[inline]
fn eq(&self, other: &[u8; OUT_LEN]) -> bool {
- #[cfg(miri)]
- return constant_time_eq_miri(&self.0, other);
- #[cfg(not(miri))]
constant_time_eq::constant_time_eq_32(&self.0, other)
}
}
@@ -356,9 +335,6 @@ impl PartialEq<[u8; OUT_LEN]> for Hash {
impl PartialEq<[u8]> for Hash {
#[inline]
fn eq(&self, other: &[u8]) -> bool {
- #[cfg(miri)]
- return constant_time_eq_miri(&self.0, other);
- #[cfg(not(miri))]
constant_time_eq::constant_time_eq(&self.0, other)
}
}