Skip to content

Commit f349989

Browse files
authored
Add generic H param to traits (#756)
Companion PR to RustCrypto/traits#2110
1 parent 2915b86 commit f349989

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The following code example shows how to verify a password when stored using one
2525
of many possible password hashing algorithms implemented in this repository.
2626

2727
```rust
28-
use password_hash::{PasswordHash, PasswordVerifier};
28+
use password_hash::{phc, PasswordVerifier};
2929

3030
use argon2::Argon2;
3131
use pbkdf2::Pbkdf2;
@@ -35,10 +35,10 @@ use scrypt::Scrypt;
3535
let hash_string = "$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQAAAAAAAAAAA$+r0d29hqEB0yasKr55ZgICsQGSkl0v0kgwhd+U3wyRo";
3636
let input_password = "password";
3737

38-
let password_hash = PasswordHash::new(&hash_string).expect("invalid password hash");
38+
let password_hash = phc::PasswordHash::new(&hash_string).expect("invalid password hash");
3939

4040
// Trait objects for algorithms to support
41-
let algs: &[&dyn PasswordVerifier] = &[&Argon2::default(), &Pbkdf2, &Scrypt];
41+
let algs: &[&dyn PasswordVerifier<phc::PasswordHash>] = &[&Argon2::default(), &Pbkdf2, &Scrypt];
4242

4343
password_hash.verify_password(algs, input_password).expect("invalid password");
4444
```

argon2/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl<'key> Argon2<'key> {
620620
}
621621

622622
#[cfg(all(feature = "alloc", feature = "password-hash"))]
623-
impl CustomizedPasswordHasher for Argon2<'_> {
623+
impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_> {
624624
type Params = Params;
625625

626626
fn hash_password_customized(
@@ -654,7 +654,7 @@ impl CustomizedPasswordHasher for Argon2<'_> {
654654
}
655655

656656
#[cfg(all(feature = "alloc", feature = "password-hash"))]
657-
impl PasswordHasher for Argon2<'_> {
657+
impl PasswordHasher<PasswordHash> for Argon2<'_> {
658658
fn hash_password(&self, password: &[u8], salt: &[u8]) -> password_hash::Result<PasswordHash> {
659659
let salt = Salt::new(salt)?;
660660

balloon-hash/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ where
212212
}
213213

214214
#[cfg(all(feature = "alloc", feature = "password-hash"))]
215-
impl<D> CustomizedPasswordHasher for Balloon<'_, D>
215+
impl<D> CustomizedPasswordHasher<PasswordHash> for Balloon<'_, D>
216216
where
217217
D: Digest + FixedOutputReset,
218218
Array<u8, D::OutputSize>: ArrayDecoding,
@@ -243,7 +243,7 @@ where
243243
}
244244

245245
#[cfg(all(feature = "alloc", feature = "password-hash"))]
246-
impl<D> PasswordHasher for Balloon<'_, D>
246+
impl<D> PasswordHasher<PasswordHash> for Balloon<'_, D>
247247
where
248248
D: Digest + FixedOutputReset,
249249
Array<u8, D::OutputSize>: ArrayDecoding,

password-auth/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn generate_phc_hash(password: &[u8], salt: &[u8]) -> password_hash::Result<Pass
8080
pub fn verify_password(password: impl AsRef<[u8]>, hash: &str) -> Result<(), VerifyError> {
8181
let hash = PasswordHash::new(hash).map_err(ParseError::new)?;
8282

83-
let algs: &[&dyn PasswordVerifier] = &[
83+
let algs: &[&dyn PasswordVerifier<PasswordHash>] = &[
8484
#[cfg(feature = "argon2")]
8585
&Argon2::default(),
8686
#[cfg(feature = "pbkdf2")]

pbkdf2/src/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use sha1::Sha1;
2020
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2121
pub struct Pbkdf2;
2222

23-
impl CustomizedPasswordHasher for Pbkdf2 {
23+
impl CustomizedPasswordHasher<PasswordHash> for Pbkdf2 {
2424
type Params = Params;
2525

2626
fn hash_password_customized(
@@ -65,7 +65,7 @@ impl CustomizedPasswordHasher for Pbkdf2 {
6565
}
6666
}
6767

68-
impl PasswordHasher for Pbkdf2 {
68+
impl PasswordHasher<PasswordHash> for Pbkdf2 {
6969
fn hash_password(&self, password: &[u8], salt: &[u8]) -> Result<PasswordHash> {
7070
self.hash_password_customized(password, salt, None, None, Params::default())
7171
}

scrypt/src/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub const ALG_ID: Ident = Ident::new_unwrap(ALG_NAME);
1919
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2020
pub struct Scrypt;
2121

22-
impl CustomizedPasswordHasher for Scrypt {
22+
impl CustomizedPasswordHasher<PasswordHash> for Scrypt {
2323
type Params = Params;
2424

2525
fn hash_password_customized(
@@ -68,7 +68,7 @@ impl CustomizedPasswordHasher for Scrypt {
6868
}
6969
}
7070

71-
impl PasswordHasher for Scrypt {
71+
impl PasswordHasher<PasswordHash> for Scrypt {
7272
fn hash_password(&self, password: &[u8], salt: &[u8]) -> Result<PasswordHash> {
7373
self.hash_password_customized(password, salt, None, None, Params::default())
7474
}

0 commit comments

Comments
 (0)