fuzz: don't fuzz hashes against RustCrypto
We should probably restore this in the future, but we need to rethink how we fuzz hashes -- right now when cfg(fuzzing) is set, we break all the hash functions in a way that won't match any other library. We should probably make this breakage opt-in but this will require buy-in from rust-lightning and maybe others.
This commit is contained in:
parent
6467728202
commit
2860aae1a5
|
@ -12,7 +12,6 @@ cargo-fuzz = true
|
|||
honggfuzz = { version = "0.5", default-features = false }
|
||||
bitcoin = { version = "0.30.0", features = [ "serde" ] }
|
||||
|
||||
rust-crypto = "0.2"
|
||||
serde = { version = "1.0.103", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
serde_cbor = "0.9"
|
||||
|
|
|
@ -33,6 +33,7 @@ listTargetNames() {
|
|||
checkWindowsFiles() {
|
||||
incorrectFilenames=$(find . -type f -name "*,*" -o -name "*:*" -o -name "*<*" -o -name "*>*" -o -name "*|*" -o -name "*\?*" -o -name "*\**" -o -name "*\"*" | wc -l)
|
||||
if [ "$incorrectFilenames" -gt 0 ]; then
|
||||
echo "Bailing early because there is a Windows-incompatible filename in the tree."
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
REPO_DIR=$(git rev-parse --show-toplevel)
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use bitcoin::hashes::{ripemd160, Hash};
|
||||
use crypto::digest::Digest;
|
||||
use crypto::ripemd160::Ripemd160;
|
||||
use bitcoin::hashes::{ripemd160, Hash, HashEngine};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let our_hash = ripemd160::Hash::hash(data);
|
||||
let mut engine = ripemd160::Hash::engine();
|
||||
engine.input(data);
|
||||
let eng_hash = ripemd160::Hash::from_engine(engine);
|
||||
|
||||
let mut rc_hash = [0u8; 20];
|
||||
let mut rc_engine = Ripemd160::new();
|
||||
rc_engine.input(data);
|
||||
rc_engine.result(&mut rc_hash);
|
||||
|
||||
assert_eq!(&our_hash[..], &rc_hash[..]);
|
||||
let hash = ripemd160::Hash::hash(data);
|
||||
assert_eq!(&hash[..], &eng_hash[..]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use bitcoin::hashes::{sha1, Hash};
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha1::Sha1;
|
||||
use bitcoin::hashes::{sha1, Hash, HashEngine};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let our_hash = sha1::Hash::hash(data);
|
||||
let mut engine = sha1::Hash::engine();
|
||||
engine.input(data);
|
||||
let eng_hash = sha1::Hash::from_engine(engine);
|
||||
|
||||
let mut rc_hash = [0u8; 20];
|
||||
let mut rc_sha1 = Sha1::new();
|
||||
rc_sha1.input(data);
|
||||
rc_sha1.result(&mut rc_hash);
|
||||
|
||||
assert_eq!(&our_hash[..], &rc_hash[..]);
|
||||
let hash = sha1::Hash::hash(data);
|
||||
assert_eq!(&hash[..], &eng_hash[..]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use bitcoin::hashes::{sha256, Hash};
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha2::Sha256;
|
||||
use bitcoin::hashes::{sha256, Hash, HashEngine};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let our_hash = sha256::Hash::hash(data);
|
||||
let mut engine = sha256::Hash::engine();
|
||||
engine.input(data);
|
||||
let eng_hash = sha256::Hash::from_engine(engine);
|
||||
|
||||
let mut rc_hash = [0u8; 32];
|
||||
let mut rc_engine = Sha256::new();
|
||||
rc_engine.input(data);
|
||||
rc_engine.result(&mut rc_hash);
|
||||
|
||||
assert_eq!(&our_hash[..], &rc_hash[..]);
|
||||
let hash = sha256::Hash::hash(data);
|
||||
assert_eq!(&hash[..], &eng_hash[..]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use bitcoin::hashes::{sha512, Hash};
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha2::Sha512;
|
||||
use bitcoin::hashes::{sha512, Hash, HashEngine};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let our_hash = sha512::Hash::hash(data);
|
||||
let mut engine = sha512::Hash::engine();
|
||||
engine.input(data);
|
||||
let eng_hash = sha512::Hash::from_engine(engine);
|
||||
|
||||
let mut rc_hash = [0u8; 64];
|
||||
let mut rc_engine = Sha512::new();
|
||||
rc_engine.input(data);
|
||||
rc_engine.result(&mut rc_hash);
|
||||
|
||||
assert_eq!(&our_hash[..], &rc_hash[..]);
|
||||
let hash = sha512::Hash::hash(data);
|
||||
assert_eq!(&hash[..], &eng_hash[..]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use bitcoin::hashes::{sha512_256, Hash};
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha2::Sha512Trunc256;
|
||||
use bitcoin::hashes::{sha512_256, Hash, HashEngine};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let our_hash = sha512_256::Hash::hash(data);
|
||||
let mut engine = sha512_256::Hash::engine();
|
||||
engine.input(data);
|
||||
let eng_hash = sha512_256::Hash::from_engine(engine);
|
||||
|
||||
let mut rc_hash = [0u8; 32];
|
||||
let mut rc_engine = Sha512Trunc256::new();
|
||||
rc_engine.input(data);
|
||||
rc_engine.result(&mut rc_hash);
|
||||
|
||||
assert_eq!(&our_hash[..], &rc_hash[..]);
|
||||
let hash = sha512_256::Hash::hash(data);
|
||||
assert_eq!(&hash[..], &eng_hash[..]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -23,7 +23,6 @@ cargo-fuzz = true
|
|||
honggfuzz = { version = "0.5", default-features = false }
|
||||
bitcoin = { version = "0.30.0", features = [ "serde" ] }
|
||||
|
||||
rust-crypto = "0.2"
|
||||
serde = { version = "1.0.103", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
serde_cbor = "0.9"
|
||||
|
|
Loading…
Reference in New Issue