Skip to content

Commit d5e919f

Browse files
authored
digest: remove impl of subtle::ConstantTimeEq for CtOutput (#2292)
It's the only place where `subtle` is exposed in the public API of the crate. AFAIK downstream users do not directly rely on this impl, so this change should not cause big problems. We may return this impl in future or replace it with a `ctutils`-based impl (see #2275).
1 parent 3535f35 commit d5e919f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

digest/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- `HashReader` and `HashWriter` are moved to the `digest-io` crate ([#1809])
2828
- `io::Write/Read` implementations in favor of the `digest_io::IoWrapper` type ([#1809])
2929
- `VariableOutput` trait ([#2043])
30+
- Implementation of `subtle::ConstantTimeEq` for `CtOutput`. Note that implementation of
31+
`PartialEq`/`Eq` trait is still const time. ([#2292])
3032

3133
[#1173]: https://github.com/RustCrypto/traits/pull/1173
3234
[#1334]: https://github.com/RustCrypto/traits/pull/1334
@@ -38,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3840
[#1958]: https://github.com/RustCrypto/traits/pull/1958
3941
[#2043]: https://github.com/RustCrypto/traits/pull/2043
4042
[#2237]: https://github.com/RustCrypto/traits/pull/2237
43+
[#2292]: https://github.com/RustCrypto/traits/pull/2292
4144

4245
## 0.10.7 (2023-05-19)
4346
### Changed

digest/src/mac.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use common::{Output, OutputSizeUser, Reset};
33

44
use common::typenum::Unsigned;
55
use core::fmt;
6-
use subtle::{Choice, ConstantTimeEq};
6+
use subtle::ConstantTimeEq;
77

88
/// Marker trait for Message Authentication algorithms.
99
pub trait MacMarker {}
@@ -215,17 +215,10 @@ impl<'a, T: OutputSizeUser> From<&'a Output<T>> for CtOutput<T> {
215215
}
216216
}
217217

218-
impl<T: OutputSizeUser> ConstantTimeEq for CtOutput<T> {
219-
#[inline(always)]
220-
fn ct_eq(&self, other: &Self) -> Choice {
221-
self.bytes.ct_eq(&other.bytes)
222-
}
223-
}
224-
225218
impl<T: OutputSizeUser> PartialEq for CtOutput<T> {
226219
#[inline(always)]
227-
fn eq(&self, x: &CtOutput<T>) -> bool {
228-
self.ct_eq(x).into()
220+
fn eq(&self, other: &CtOutput<T>) -> bool {
221+
self.bytes.ct_eq(&other.bytes).into()
229222
}
230223
}
231224

0 commit comments

Comments
 (0)