Skip to content

Commit 0a8fead

Browse files
authored
pbkdf2: remove the parallel crate feature (#702)
1 parent dd15f84 commit 0a8fead

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

Cargo.lock

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

pbkdf2/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.13.0 (UNRELEASED)
9+
### Removed
10+
- The `parallel` crate feature ([#702])
11+
12+
[#702]: https://github.com/RustCrypto/password-hashes/pull/702
13+
814
## 0.12.2 (2023-07-08)
915
### Fixed
1016
- Use `RECOMMENDED_ROUNDS` in `Default` impl for `Params` ([#442])

pbkdf2/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ rust-version = "1.85"
1717
digest = { version = "0.11.0-rc.1", features = ["mac"] }
1818

1919
# optional dependencies
20-
rayon = { version = "1.7", optional = true }
2120
password-hash = { version = "0.6.0-rc.0", default-features = false, optional = true, features = ["rand_core"] }
2221
hmac = { version = "0.13.0-rc.1", default-features = false, optional = true }
2322
sha1 = { version = "0.11.0-rc.2", default-features = false, optional = true }
@@ -34,8 +33,6 @@ belt-hash = "0.2.0-rc.1"
3433
[features]
3534
default = ["hmac"]
3635
std = ["password-hash/os_rng"]
37-
38-
parallel = ["rayon", "std"]
3936
simple = ["hmac", "password-hash", "sha2"]
4037

4138
[package.metadata.docs.rs]

pbkdf2/src/lib.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
//!
44
//! # Examples
55
//!
6-
//! PBKDF2 is defined in terms of a keyed pseudo-random function (PRF). Most
7-
//! commonly HMAC is used as this PRF. In such cases you can use [`pbkdf2_hmac`]
8-
//! and [`pbkdf2_hmac_array`] functions. The former accepts a byte slice which
9-
//! gets filled with generated key, while the latter returns an array with
10-
//! generated key of requested length.
6+
//! PBKDF2 is defined in terms of a keyed pseudo-random function (PRF).
7+
//! The most commonly used PRF for this purpose is HMAC. In such cases
8+
//! you can use [`pbkdf2_hmac`] and [`pbkdf2_hmac_array`] functions.
9+
//! The former accepts a byte slice which gets filled with generated key,
10+
//! while the latter returns an array with generated key of requested length.
11+
//!
12+
//! Note that it is not recommended to generate keys using PBKDF2 that exceed
13+
//! the output size of the PRF (equal to the hash size in the case of HMAC).
14+
//! If you need to generate a large amount of cryptographic material,
15+
//! consider using a separate [key derivation function][KDF].
16+
//!
17+
//! [KDF]: https://github.com/RustCrypto/KDFs
1118
//!
1219
//! ```
1320
//! # #[cfg(feature = "hmac")] {
@@ -96,9 +103,6 @@ pub use hmac;
96103
#[cfg(feature = "simple")]
97104
pub use crate::simple::{Algorithm, Params, Pbkdf2};
98105

99-
#[cfg(feature = "parallel")]
100-
use rayon::prelude::*;
101-
102106
use digest::{FixedOutput, InvalidLength, KeyInit, Update, typenum::Unsigned};
103107

104108
#[cfg(feature = "hmac")]
@@ -162,21 +166,10 @@ where
162166
PRF: KeyInit + Update + FixedOutput + Clone + Sync,
163167
{
164168
let n = PRF::OutputSize::to_usize();
165-
// note: HMAC can be initialized with keys of any size,
166-
// so this panic never happens with it
167169
let prf = PRF::new_from_slice(password)?;
168170

169-
#[cfg(not(feature = "parallel"))]
170-
{
171-
for (i, chunk) in res.chunks_mut(n).enumerate() {
172-
pbkdf2_body(i as u32, chunk, &prf, salt, rounds);
173-
}
174-
}
175-
#[cfg(feature = "parallel")]
176-
{
177-
res.par_chunks_mut(n).enumerate().for_each(|(i, chunk)| {
178-
pbkdf2_body(i as u32, chunk, &prf, salt, rounds);
179-
});
171+
for (i, chunk) in res.chunks_mut(n).enumerate() {
172+
pbkdf2_body(i as u32, chunk, &prf, salt, rounds);
180173
}
181174

182175
Ok(())

0 commit comments

Comments
 (0)