Skip to content

Commit d1714ce

Browse files
committed
fuzz: disable sig-grinding tests, prevent spin-looping
1 parent 96862b6 commit d1714ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ impl<C: Signing> Secp256k1<C> {
736736
}
737737

738738
entropy_p = extra_entropy.as_ptr() as *const ffi::types::c_void;
739+
740+
// When fuzzing, these checks will usually spinloop forever, so just short-circuit them.
741+
#[cfg(rust_secp_fuzz)]
742+
return Signature::from(ret);
739743
}
740744
}
741745
}
@@ -1098,9 +1102,12 @@ mod tests {
10981102
if compact[0] < 0x80 {
10991103
assert_eq!(sig, low_r_sig);
11001104
} else {
1105+
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
11011106
assert_ne!(sig, low_r_sig);
11021107
}
1108+
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
11031109
assert!(super::compact_sig_has_zero_first_bit(&low_r_sig.0));
1110+
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
11041111
assert!(super::der_length_check(&grind_r_sig.0, 70));
11051112
}
11061113
}
@@ -1195,6 +1202,7 @@ mod tests {
11951202
}
11961203

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

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

0 commit comments

Comments
 (0)