Skip to content

Commit 2e6f97b

Browse files
domenkozarbilelmoussaoui
authored andcommitted
Compare checksum slices explicitly under feature unification
When Cargo feature unification enables hybrid-array/subtle, the MD5 output has an array-specific ConstantTimeEq implementation. Method resolution then expects an array reference, but the supplied digest is a byte slice, so compilation fails. Convert the output to a slice before comparing to select the slice implementation consistently and preserve the constant-time comparison.
1 parent 1fff05f commit 2e6f97b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎client/src/crypto/native.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ pub(crate) fn verify_mac(
149149
pub(crate) fn verify_checksum_md5(digest: impl AsRef<[u8]>, content: impl AsRef<[u8]>) -> bool {
150150
let mut hasher = Md5::new();
151151
hasher.update(content.as_ref());
152-
hasher.finalize_fixed().ct_eq(digest.as_ref()).into()
152+
hasher
153+
.finalize_fixed()
154+
.as_slice()
155+
.ct_eq(digest.as_ref())
156+
.into()
153157
}
154158

155159
pub(crate) fn derive_key(

0 commit comments

Comments
 (0)