Skip to content

Commit

Permalink
fuzz: fix scrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Nov 1, 2024
1 parent d44ff8f commit 7c932c8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fuzz/fuzz_targets/scrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ impl<'a> Arbitrary<'a> for ScryptRandParams {
fuzz_target!(|data: (&[u8], &[u8], ScryptRandParams)| {
let (password, salt, ScryptRandParams(params)) = data;

if password.len() > 64 {
return;
}

if salt.len() < Salt::MIN_LENGTH || salt.len() > (6 * Salt::MAX_LENGTH) / 8 {
return;
}

// Check direct hashing
let mut result = [0u8; 64];
scrypt(password, salt, &params, &mut result).unwrap();

// Check PHC hashing
if salt.len() < Salt::MIN_LENGTH {
return;
}
let salt_string = SaltString::encode_b64(salt).unwrap();
let phc_hash = Scrypt
.hash_password_customized(
Expand Down

0 comments on commit 7c932c8

Please sign in to comment.