diff --git a/password-hash/src/error.rs b/password-hash/src/error.rs index 811072bc..d6229432 100644 --- a/password-hash/src/error.rs +++ b/password-hash/src/error.rs @@ -18,6 +18,9 @@ pub enum Error { /// Encoding errors (e.g. Base64). EncodingInvalid, + /// Internal error within a password hashing library. + Internal, + /// Out of memory (heap allocation failure). OutOfMemory, @@ -49,6 +52,7 @@ impl fmt::Display for Error { Self::Algorithm => write!(f, "unsupported algorithm"), Self::Crypto => write!(f, "cryptographic error"), Self::EncodingInvalid => write!(f, "invalid encoding"), + Self::Internal => write!(f, "internal password hashing algorithm error"), Self::OutOfMemory => write!(f, "out of memory"), Self::OutputSize => write!(f, "password hash output size invalid"), Self::ParamInvalid { name } => write!(f, "invalid parameter: {name:?}"), diff --git a/password-hash/src/lib.rs b/password-hash/src/lib.rs index b99320d6..63b2e481 100644 --- a/password-hash/src/lib.rs +++ b/password-hash/src/lib.rs @@ -77,7 +77,7 @@ pub trait PasswordHasher { /// Generic around a password hash to be returned (typically [`PasswordHash`]) pub trait CustomizedPasswordHasher { /// Algorithm-specific parameters. - type Params: Clone + Debug + Default + Display + FromStr; + type Params: Clone + Debug + Default + Display + FromStr; /// Compute a [`PasswordHash`] from the provided password using an /// explicit set of customized algorithm parameters as opposed to the @@ -110,7 +110,11 @@ pub trait PasswordVerifier { } #[cfg(feature = "phc")] -impl> PasswordVerifier for T { +impl, E> PasswordVerifier for T +where + T::Params: FromStr, + Error: From, +{ fn verify_password(&self, password: &[u8], hash: &phc::PasswordHash) -> Result<()> { #[allow(clippy::single_match)] match (&hash.salt, &hash.hash) {