-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
81 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use scrypt::scrypt; | ||
|
||
use fuzz::ScryptRandParams; | ||
|
||
fuzz_target!(|data: (&[u8], &[u8], ScryptRandParams)| { | ||
let (password, salt, ScryptRandParams(params)) = data; | ||
let mut result = [0u8; 64]; | ||
scrypt(password, salt, ¶ms, &mut result).unwrap(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use scrypt::password_hash::{Ident, PasswordHasher, Salt, SaltString}; | ||
use scrypt::Scrypt; | ||
|
||
use fuzz::ScryptRandParams; | ||
|
||
fuzz_target!(|data: (&[u8], &[u8], ScryptRandParams)| { | ||
let (password, salt, ScryptRandParams(params)) = data; | ||
if salt.len() < Salt::MIN_LENGTH { | ||
return; | ||
} | ||
let salt_string = SaltString::encode_b64(salt).unwrap(); | ||
let res = Scrypt.hash_password_customized( | ||
password, | ||
Some(Ident::new_unwrap("scrypt")), | ||
None, | ||
params, | ||
&salt_string, | ||
); | ||
assert!(res.is_ok()) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use scrypt::password_hash::{PasswordHash, PasswordVerifier}; | ||
use scrypt::Scrypt; | ||
|
||
const SAMPLE_HASH: &str = "$scrypt$ln=16,r=8,p=1$\ | ||
aM15713r3Xsvxbi31lqr1Q$nFNh2CVHVjNldFVKDHDlm4CbdRSCdEBsjjJxD+iCs5E"; | ||
|
||
fuzz_target!(|password: &[u8]| { | ||
let hash = PasswordHash::new(SAMPLE_HASH).expect("SAMPLE_HASH is valid"); | ||
let res = Scrypt.verify_password(password, &hash); | ||
assert!(res.is_err()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured}; | ||
|
||
#[derive(Debug)] | ||
pub struct ScryptRandParams(pub scrypt::Params); | ||
|
||
impl<'a> Arbitrary<'a> for ScryptRandParams { | ||
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { | ||
let log_n = u.int_in_range(0..=15)?; | ||
let r = u.int_in_range(1..=32)?; | ||
let p = u.int_in_range(1..=16)?; | ||
let len = u.int_in_range(10..=64)?; | ||
|
||
let params = scrypt::Params::new(log_n, r, p, len).unwrap(); | ||
Ok(Self(params)) | ||
} | ||
} |