password_hash: reject an empty PBKDF2 hash/salt — a stored 'pbkdf2:iters:salt:' (empty hash) made ct_eq(&[],&[]) return true, verifying ANY password; refuse empty want/salt before computing
This commit is contained in:
parent
6bc299f286
commit
1a5c41871c
1 changed files with 3 additions and 0 deletions
|
|
@ -94,6 +94,9 @@ pub fn verify(stored: &str, plaintext: &str) -> bool {
|
|||
if !(1..=MAX_PBKDF2_ITERS).contains(&iters) {
|
||||
return false; // absurd/zero work factor — refuse, don't compute
|
||||
}
|
||||
if want.is_empty() || salt.is_empty() {
|
||||
return false; // an empty hash/salt would make ct_eq(&[],&[]) accept any password
|
||||
}
|
||||
if let Some(got) = pbkdf2(plaintext, &salt, iters, want.len()) {
|
||||
return ct_eq(&got, &want);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue