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
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ crypto-common = { version = "0.1", default-features = false }
aead = { version = "0.5", optional = true, path = "../aead" }
cipher = { version = "0.4", optional = true }
digest = { version = "0.10", optional = true, features = ["mac"] }
elliptic-curve = { version = "0.12", optional = true } # TODO(tarcieri): path = "../elliptic-curve"
password-hash = { version = "0.4", optional = true, path = "../password-hash" }
elliptic-curve = { version = "=0.13.0-pre", optional = true, path = "../elliptic-curve" }
password-hash = { version = "=0.5.0-pre", optional = true, path = "../password-hash" }
signature = { version = "=2.0.0-rc.1", optional = true, default-features = false, path = "../signature" }
universal-hash = { version = "0.5", optional = true, path = "../universal-hash" }

Expand Down
2 changes: 1 addition & 1 deletion password-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Traits which describe the functionality of password hashing algorithms,
as well as a `no_std`-friendly implementation of the PHC string format
(a well-defined subset of the Modular Crypt Format a.k.a. MCF)
"""
version = "0.4.2"
version = "0.5.0-pre"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion password-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a> PasswordHash<'a> {
pub fn generate(
phf: impl PasswordHasher,
password: impl AsRef<[u8]>,
salt: &'a str,
salt: impl Into<Salt<'a>>,
) -> Result<Self> {
phf.hash_password(password.as_ref(), salt)
}
Expand Down
17 changes: 6 additions & 11 deletions password-hash/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ pub trait PasswordHasher {
/// salt value.
///
/// Uses the default recommended parameters for a given algorithm.
fn hash_password<'a, S>(&self, password: &[u8], salt: &'a S) -> Result<PasswordHash<'a>>
where
S: AsRef<str> + ?Sized,
{
self.hash_password_customized(
password,
None,
None,
Self::Params::default(),
Salt::try_from(salt.as_ref())?,
)
fn hash_password<'a>(
&self,
password: &[u8],
salt: impl Into<Salt<'a>>,
) -> Result<PasswordHash<'a>> {
self.hash_password_customized(password, None, None, Self::Params::default(), salt)
}
}

Expand Down
4 changes: 2 additions & 2 deletions password-hash/tests/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ impl<'a> TryFrom<StubParams> for ParamsString {
#[test]
fn verify_password_hash() {
let valid_password = "test password";
let salt = "test-salt";
let salt = Salt::new("test-salt").unwrap();
let hash = PasswordHash::generate(StubPasswordHasher, valid_password, salt).unwrap();

// Sanity tests for StubFunction impl above
assert_eq!(hash.algorithm, ALG);
assert_eq!(hash.salt.unwrap().as_str(), salt);
assert_eq!(hash.salt.unwrap(), salt);

// Tests for generic password verification logic
assert_eq!(
Expand Down