Skip to content

Commit

Permalink
fuzz: disable sig-grinding tests, prevent spin-looping
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Dec 28, 2020
1 parent 96862b6 commit d1714ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,10 @@ impl<C: Signing> Secp256k1<C> {
}

entropy_p = extra_entropy.as_ptr() as *const ffi::types::c_void;

// When fuzzing, these checks will usually spinloop forever, so just short-circuit them.
#[cfg(rust_secp_fuzz)]
return Signature::from(ret);
}
}
}
Expand Down Expand Up @@ -1098,9 +1102,12 @@ mod tests {
if compact[0] < 0x80 {
assert_eq!(sig, low_r_sig);
} else {
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
assert_ne!(sig, low_r_sig);
}
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
assert!(super::compact_sig_has_zero_first_bit(&low_r_sig.0));
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
assert!(super::der_length_check(&grind_r_sig.0, 70));
}
}
Expand Down Expand Up @@ -1195,6 +1202,7 @@ mod tests {
}

#[test]
#[cfg(not(rust_secp_fuzz))] // fuzz-sigs have fixed size/format
fn test_low_r() {
let secp = Secp256k1::new();
let msg = hex!("887d04bb1cf1b1554f1b268dfe62d13064ca67ae45348d50d1392ce2d13418ac");
Expand All @@ -1209,6 +1217,7 @@ mod tests {
}

#[test]
#[cfg(not(rust_secp_fuzz))] // fuzz-sigs have fixed size/format
fn test_grind_r() {
let secp = Secp256k1::new();
let msg = hex!("ef2d5b9a7c61865a95941d0f04285420560df7e9d76890ac1b8867b12ce43167");
Expand Down

0 comments on commit d1714ce

Please sign in to comment.