Skip to content

Commit 866ef69

Browse files
authored
password-hash: add Error::RngFailure (#2337)
Fixes a TODO by adding a specific error variant for RNG failures
1 parent 4c2365e commit 866ef69

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

password-hash/src/error.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub enum Error {
3939
/// Invalid password.
4040
PasswordInvalid,
4141

42+
/// Random number generator failure.
43+
RngFailure,
44+
4245
/// Invalid salt.
4346
SaltInvalid,
4447

@@ -58,6 +61,7 @@ impl fmt::Display for Error {
5861
Self::ParamInvalid { name } => write!(f, "invalid parameter: {name:?}"),
5962
Self::ParamsInvalid => write!(f, "invalid parameters"),
6063
Self::PasswordInvalid => write!(f, "invalid password"),
64+
Self::RngFailure => write!(f, "rng failure"),
6165
Self::SaltInvalid => write!(f, "invalid salt"),
6266
Self::Version => write!(f, "invalid algorithm version"),
6367
}
@@ -69,8 +73,7 @@ impl core::error::Error for Error {}
6973
#[cfg(feature = "getrandom")]
7074
impl From<getrandom::Error> for Error {
7175
fn from(_: getrandom::Error) -> Self {
72-
// TODO(tarcieri): should we have a specific variant for RNGs errors?
73-
Error::Crypto
76+
Error::RngFailure
7477
}
7578
}
7679

0 commit comments

Comments
 (0)