Skip to content

Commit 0e0c621

Browse files
authored
password-hash: deprecate toplevel PasswordHash(String) (#2112)
Changes the re-exports to deprecated type aliases, noting that the relevant types should be imported via `password_hash::phc` going forward
1 parent 37977df commit 0e0c621

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Cargo.lock

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

password-hash/src/lib.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ pub mod phc;
3838

3939
pub use crate::errors::{Error, Result};
4040

41+
/// DEPRECATED: import this as `password_hash::phc::PasswordHash`.
4142
#[cfg(feature = "phc")]
42-
pub use phc::PasswordHash;
43+
#[deprecated(
44+
since = "0.6.0",
45+
note = "import as `password_hash::phc::PasswordHash` instead"
46+
)]
47+
pub type PasswordHash = phc::PasswordHash;
48+
49+
/// DEPRECATED: import this as `password_hash::phc::PasswordHashString`.
4350
#[cfg(all(feature = "alloc", feature = "phc"))]
44-
pub use phc::PasswordHashString;
51+
#[deprecated(
52+
since = "0.6.0",
53+
note = "import as `password_hash::phc::PasswordHashString` instead"
54+
)]
55+
pub type PasswordHashString = phc::PasswordHashString;
4556

4657
use core::{
4758
fmt::{Debug, Display},
@@ -101,8 +112,8 @@ pub trait PasswordVerifier<H> {
101112
}
102113

103114
#[cfg(feature = "phc")]
104-
impl<T: CustomizedPasswordHasher<PasswordHash>> PasswordVerifier<PasswordHash> for T {
105-
fn verify_password(&self, password: &[u8], hash: &PasswordHash) -> Result<()> {
115+
impl<T: CustomizedPasswordHasher<phc::PasswordHash>> PasswordVerifier<phc::PasswordHash> for T {
116+
fn verify_password(&self, password: &[u8], hash: &phc::PasswordHash) -> Result<()> {
106117
#[allow(clippy::single_match)]
107118
match (&hash.salt, &hash.hash) {
108119
(Some(salt), Some(expected_output)) => {
@@ -142,12 +153,12 @@ pub trait McfHasher {
142153
///
143154
/// MCF hashes are otherwise largely unstructured and parsed according to
144155
/// algorithm-specific rules so hashers must parse a raw string themselves.
145-
fn upgrade_mcf_hash(&self, hash: &str) -> Result<PasswordHash>;
156+
fn upgrade_mcf_hash(&self, hash: &str) -> Result<phc::PasswordHash>;
146157

147158
/// Verify a password hash in MCF format against the provided password.
148159
fn verify_mcf_hash(&self, password: &[u8], mcf_hash: &str) -> Result<()>
149160
where
150-
Self: PasswordVerifier<PasswordHash>,
161+
Self: PasswordVerifier<phc::PasswordHash>,
151162
{
152163
self.verify_password(password, &self.upgrade_mcf_hash(mcf_hash)?)
153164
}

0 commit comments

Comments
 (0)