Skip to content

Commit 6d24ae3

Browse files
authored
Migrate from subtle to ctutils (#845)
See RustCrypto/meta#29
1 parent f183213 commit 6d24ae3

7 files changed

Lines changed: 11 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scrypt/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ sha2 = { version = "0.11.0-rc.5", default-features = false }
2121
rayon = { version = "1.11", optional = true }
2222

2323
# optional dependencies
24+
ctutils = { version = "0.4", optional = true }
2425
kdf = { version = "0.1", optional = true }
2526
mcf = { version = "0.6", optional = true }
2627
password-hash = { version = "0.6.0-rc.12", optional = true, default-features = false }
27-
subtle = { version = "2", optional = true, default-features = false }
2828

2929
[features]
3030
alloc = ["password-hash?/alloc"]
3131

3232
getrandom = ["password-hash", "password-hash/getrandom"]
3333
kdf = ["alloc", "dep:kdf"]
34-
mcf = ["alloc", "phc", "dep:mcf", "dep:subtle"]
34+
mcf = ["alloc", "phc", "dep:ctutils", "dep:mcf"]
3535
phc = ["password-hash/phc"]
3636
rand_core = ["password-hash/rand_core"]
3737
parallel = ["dep:rayon"]

scrypt/src/mcf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl PasswordVerifier<PasswordHashRef> for Scrypt {
112112
let mut actual = vec![0u8; expected.len()];
113113
scrypt(password, salt, &params, &mut actual).map_err(|_| Error::OutputSize)?;
114114

115-
if subtle::ConstantTimeEq::ct_ne(actual.as_slice(), &expected).into() {
115+
if ctutils::CtEq::ct_ne(actual.as_slice(), &expected).into() {
116116
return Err(Error::PasswordInvalid);
117117
}
118118

sha-crypt/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ sha2 = { version = "0.11.0-rc.5", default-features = false }
2222
base64ct = { version = "1.8", default-features = false, features = ["alloc"] }
2323

2424
# optional dependencies
25+
ctutils = { version = "0.4", optional = true }
2526
mcf = { version = "0.6", optional = true, default-features = false, features = ["alloc", "base64"] }
2627
password-hash = { version = "0.6.0-rc.12", optional = true, default-features = false }
27-
subtle = { version = "2", optional = true, default-features = false }
2828

2929
[features]
3030
default = ["password-hash"]
3131
getrandom = ["password-hash/getrandom", "password-hash"]
3232
rand_core = ["password-hash/rand_core"]
33-
password-hash = ["dep:mcf", "dep:password-hash", "dep:subtle"]
33+
password-hash = ["dep:ctutils", "dep:mcf", "dep:password-hash"]
3434

3535
[package.metadata.docs.rs]
3636
all-features = true

sha-crypt/src/mcf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ pub use mcf::{PasswordHash, PasswordHashRef};
55
use crate::{BLOCK_SIZE_SHA256, BLOCK_SIZE_SHA512, Params, algorithm::Algorithm};
66
use base64ct::{Base64ShaCrypt, Encoding};
77
use core::str::FromStr;
8+
use ctutils::CtEq;
89
use mcf::Base64;
910
use password_hash::{
1011
CustomizedPasswordHasher, Error, PasswordHasher, PasswordVerifier, Result, Version,
1112
};
12-
use subtle::ConstantTimeEq;
1313

1414
/// SHA-crypt type for use with the [`PasswordHasher`] and [`PasswordVerifier`] traits, which can
1515
/// produce and verify password hashes in [`Modular Crypt Format`][`mcf`].

yescrypt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ edition = "2024"
1414
rust-version = "1.85"
1515

1616
[dependencies]
17+
ctutils = "0.4"
1718
hmac = { version = "0.13.0-rc.5", default-features = false }
1819
pbkdf2 = { version = "0.13.0-rc.9", default-features = false, features = ["hmac"] }
1920
salsa20 = { version = "0.11.0-rc.2", default-features = false }
2021
sha2 = { version = "0.11.0-rc.5", default-features = false }
21-
subtle = { version = "2", default-features = false }
2222

2323
# optional dependencies
2424
kdf = { version = "0.1", optional = true }

yescrypt/src/mcf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl PasswordVerifier<PasswordHashRef> for Yescrypt {
110110
let mut actual = vec![0u8; expected.len()];
111111
yescrypt(password, &salt, &params, &mut actual)?;
112112

113-
if subtle::ConstantTimeEq::ct_ne(actual.as_slice(), &expected).into() {
113+
if ctutils::CtEq::ct_ne(actual.as_slice(), &expected).into() {
114114
return Err(Error::PasswordInvalid);
115115
}
116116

0 commit comments

Comments
 (0)