-
Notifications
You must be signed in to change notification settings - Fork 2
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
4 changed files
with
49 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/target | ||
/Cargo.lock | ||
/.idea | ||
/.idea | ||
/fuzz/corpus/ | ||
/fuzz/Cargo.lock | ||
/fuzz/target/ |
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,27 @@ | ||
[package] | ||
name = "fips203-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
|
||
[dependencies.fips203] | ||
path = ".." | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[profile.release] | ||
debug = 1 | ||
|
||
[[bin]] | ||
name = "fuzz_all" | ||
path = "fuzz_targets/fuzz_all.rs" | ||
test = false | ||
doc = false |
Binary file not shown.
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,18 @@ | ||
#![no_main] | ||
// rustup default nightly | ||
// head -c 3200 </dev/urandom > seed1 | ||
// cargo fuzz run fuzz_all -j 4 | ||
|
||
use fips203::ml_kem_512; | ||
use fips203::traits::{Decaps, Encaps, SerDes}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: [u8; 1632+800+768]| { // dk_len + ek+len + ct_len = 3200 | ||
|
||
let ek = ml_kem_512::EncapsKey::try_from_bytes(data[0..800].try_into().unwrap()).unwrap(); | ||
let dk = ml_kem_512::DecapsKey::try_from_bytes(data[800..800+1632].try_into().unwrap()).unwrap(); | ||
let ct = ml_kem_512::CipherText::try_from_bytes(data[800+1632..800+1632+768].try_into().unwrap()).unwrap(); | ||
|
||
let _result = ek.try_encaps_vt(); | ||
let _result = dk.try_decaps_vt(&ct); | ||
}); |