Merge remote-tracking branch 'manishearth/fuzz' into develop

This commit is contained in:
Isis Lovecruft 2017-05-25 21:50:48 +00:00
commit 8772e863e7
Failed to extract signature
4 changed files with 50 additions and 1 deletions

4
fuzz/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
target
corpus
artifacts

24
fuzz/Cargo.toml Normal file
View file

@ -0,0 +1,24 @@
[package]
name = "curve25519-dalek-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies.curve25519-dalek]
path = ".."
features = ["yolocrypto"]
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "decaf"
path = "fuzzers/decaf.rs"

21
fuzz/fuzzers/decaf.rs Normal file
View file

@ -0,0 +1,21 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate curve25519_dalek;
use curve25519_dalek::curve::ValidityCheck;
use curve25519_dalek::decaf::DecafPoint;
use curve25519_dalek::field::FieldElement;
fuzz_target!(|data: &[u8]| {
if data.len() != 32 {
return;
}
let mut field_bytes = [0u8; 32];
for (by, data) in field_bytes.iter_mut().zip(data.iter()) {
*by = *data;
}
let fe = FieldElement::from_bytes(&field_bytes);
let p = DecafPoint::elligator_decaf_flavour(&fe);
assert!(p.0.is_valid());
p.compress();
});

View file

@ -265,7 +265,7 @@ impl DecafPoint {
///
/// This method is not public because it's just used for hashing
/// to a point -- proper elligator support is deferred for now.
fn elligator_decaf_flavour(r_0: &FieldElement) -> DecafPoint {
pub fn elligator_decaf_flavour(r_0: &FieldElement) -> DecafPoint {
// Follows Appendix C of the Decaf paper.
// Use n = 2 as the quadratic nonresidue so that n*x = x + x.
let minus_one = -&FieldElement::one();