Skip to content
Merged
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
12 changes: 7 additions & 5 deletions src/rust/src/backend/kdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,17 @@ impl BaseArgon2 {
_ => None,
};

if requested_variant.is_none() {
return Err(CryptographyError::from(exceptions::InvalidKey::new_err(
let requested_variant = requested_variant.ok_or_else(|| {
CryptographyError::from(exceptions::InvalidKey::new_err(
"Invalid PHC string format.",
)));
} else if requested_variant.unwrap() != variant {
))
})?;

if requested_variant != variant {
return Err(CryptographyError::from(exceptions::InvalidKey::new_err(
format!(
"Incorrect variant in PHC string, did you mean to use {:?}?",
requested_variant.unwrap()
requested_variant
),
)));
}
Expand Down
Loading