Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ opt-level = 2

[patch.crates-io]
password-hash = { git = "https://github.com/RustCrypto/traits.git" }
crypto-common = { git = "https://github.com/RustCrypto/traits.git" }
digest = { git = "https://github.com/RustCrypto/traits.git" }

blake2 = { git = "https://github.com/RustCrypto/hashes.git" }
streebog = { git = "https://github.com/RustCrypto/hashes.git" }
sha1 = { git = "https://github.com/RustCrypto/hashes.git" }
sha2 = { git = "https://github.com/RustCrypto/hashes.git" }

hmac = { git = "https://github.com/RustCrypto/MACs.git" }
38 changes: 13 additions & 25 deletions pbkdf2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ use rayon::prelude::*;
use digest::{FixedOutput, InvalidLength, KeyInit, Update, typenum::Unsigned};

#[cfg(feature = "hmac")]
use digest::{
HashMarker,
block_buffer::Eager,
core_api::{BlockSizeUser, BufferKindUser, FixedOutputCore, UpdateCore},
typenum::{IsLess, Le, NonZero, U256},
use {
digest::{
HashMarker,
block_api::BlockSizeUser,
typenum::{IsLess, NonZero, True, U256},
},
hmac::block_api::EagerHash,
};

#[inline(always)]
Expand Down Expand Up @@ -230,16 +232,9 @@ where
#[cfg_attr(docsrs, doc(cfg(feature = "hmac")))]
pub fn pbkdf2_hmac<D>(password: &[u8], salt: &[u8], rounds: u32, res: &mut [u8])
where
D: hmac::EagerHash,
D::Core: Sync
+ HashMarker
+ UpdateCore
+ FixedOutputCore
+ BufferKindUser<BufferKind = Eager>
+ Default
+ Clone,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
D: EagerHash + HashMarker + Update + FixedOutput + Default + Clone,
<D as EagerHash>::Core: Sync,
<D as BlockSizeUser>::BlockSize: IsLess<U256, Output = True> + NonZero,
{
crate::pbkdf2::<hmac::Hmac<D>>(password, salt, rounds, res)
.expect("HMAC can be initialized with any key length");
Expand All @@ -262,16 +257,9 @@ where
#[cfg_attr(docsrs, doc(cfg(feature = "hmac")))]
pub fn pbkdf2_hmac_array<D, const N: usize>(password: &[u8], salt: &[u8], rounds: u32) -> [u8; N]
where
D: hmac::EagerHash,
D::Core: Sync
+ HashMarker
+ UpdateCore
+ FixedOutputCore
+ BufferKindUser<BufferKind = Eager>
+ Default
+ Clone,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
D: EagerHash + HashMarker + Update + FixedOutput + Default + Clone,
<D as EagerHash>::Core: Sync,
<D as BlockSizeUser>::BlockSize: IsLess<U256, Output = True> + NonZero,
{
let mut buf = [0u8; N];
pbkdf2_hmac::<D>(password, salt, rounds, &mut buf);
Expand Down