File tree Expand file tree Collapse file tree 6 files changed +20
-15
lines changed Expand file tree Collapse file tree 6 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,6 @@ endomorphism = ["secp256k1-sys/endomorphism"]
2626lowmemory = [" secp256k1-sys/lowmemory" ]
2727global-context = [" std" , " rand-std" ]
2828
29- # Do not use this feature! HAZMAT. (meant for Fuzzing only. this is *BROKEN CRYPTOGRAPHY*)
30- fuzztarget = [" secp256k1-sys/fuzztarget" ]
31-
3229[dependencies ]
3330secp256k1-sys = { version = " 0.3.1" , default-features = false , path = " ./secp256k1-sys" }
3431bitcoin_hashes = { version = " 0.9" , optional = true }
Original file line number Diff line number Diff line change @@ -35,3 +35,12 @@ before_script:
3535 cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose;
3636 fi
3737` ` `
38+
39+ ## Fuzzing
40+
41+ If you want to fuzz this library, or any library which depends on it, you will
42+ probably want to disable the actual cryptography, since fuzzers are unable to
43+ forge signatures and therefore won't test many interesting codepaths. To instead
44+ use a trivially-broken but fuzzer-accessible signature scheme, compile with
45+ ` --cfg=rust_secp_fuzz` in your `RUSTFLAGS` variable.
46+
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
3131 done
3232
3333 # Other combos
34- cargo test --no-run --verbose --features= " fuzztarget "
35- cargo test --no-run --verbose --features=" fuzztarget recovery"
34+ RUSTFLAGS= ' --cfg=rust_secp_fuzz ' cargo test --no-run --verbose
35+ RUSTFLAGS= ' --cfg=rust_secp_fuzz ' cargo test --no-run --verbose --features=" recovery"
3636 cargo test --verbose --features=" rand rand-std"
3737 cargo test --verbose --features=" rand serde"
3838
Original file line number Diff line number Diff line change @@ -31,5 +31,3 @@ endomorphism = []
3131lowmemory = []
3232std = []
3333
34- # Do not use this feature! HAZMAT. (meant for Fuzzing only. this is *BROKEN CRYPTOGRAPHY*)
35- fuzztarget = []
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ pub type SchnorrNonceFn = unsafe extern "C" fn(
9393#[ derive( Clone , Debug ) ]
9494#[ repr( C ) ] pub struct Context ( c_int ) ;
9595
96- #[ cfg( feature = "fuzztarget" ) ]
96+ #[ cfg( rust_secp_fuzz ) ]
9797impl Context {
9898 pub fn flags ( & self ) -> u32 {
9999 self . 0 as u32
@@ -260,7 +260,7 @@ impl hash::Hash for KeyPair {
260260 }
261261}
262262
263- #[ cfg( not( feature = "fuzztarget" ) ) ]
263+ #[ cfg( not( rust_secp_fuzz ) ) ]
264264extern "C" {
265265 /// Default ECDH hash function
266266 #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_3_1_ecdh_hash_function_default" ) ]
@@ -674,7 +674,7 @@ impl<T> CPtr for [T] {
674674
675675
676676
677- #[ cfg( feature = "fuzztarget" ) ]
677+ #[ cfg( rust_secp_fuzz ) ]
678678mod fuzz_dummy {
679679 extern crate std;
680680 use self :: std:: { ptr, mem} ;
@@ -1156,7 +1156,8 @@ mod fuzz_dummy {
11561156 unimplemented ! ( ) ;
11571157 }
11581158}
1159- #[ cfg( feature = "fuzztarget" ) ]
1159+
1160+ #[ cfg( rust_secp_fuzz) ]
11601161pub use self :: fuzz_dummy:: * ;
11611162
11621163
Original file line number Diff line number Diff line change 1616//! # FFI of the recovery module
1717
1818use :: types:: * ;
19- #[ cfg( not( feature = "fuzztarget" ) ) ]
19+ #[ cfg( not( rust_secp_fuzz ) ) ]
2020use :: { Context , Signature , NonceFn , PublicKey } ;
2121
2222/// Library-internal representation of a Secp256k1 signature + recovery ID
@@ -36,7 +36,7 @@ impl Default for RecoverableSignature {
3636 }
3737}
3838
39- #[ cfg( not( feature = "fuzztarget" ) ) ]
39+ #[ cfg( not( rust_secp_fuzz ) ) ]
4040extern "C" {
4141 #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_3_1_ecdsa_recoverable_signature_parse_compact" ) ]
4242 pub fn secp256k1_ecdsa_recoverable_signature_parse_compact ( cx : * const Context , sig : * mut RecoverableSignature ,
@@ -70,7 +70,7 @@ extern "C" {
7070}
7171
7272
73- #[ cfg( feature = "fuzztarget" ) ]
73+ #[ cfg( rust_secp_fuzz ) ]
7474mod fuzz_dummy {
7575 extern crate std;
7676 use self :: std:: ptr;
@@ -126,6 +126,6 @@ mod fuzz_dummy {
126126 unimplemented ! ( ) ;
127127 }
128128}
129- #[ cfg( feature = "fuzztarget" ) ]
129+ #[ cfg( rust_secp_fuzz ) ]
130130pub use self :: fuzz_dummy:: * ;
131131
You can’t perform that action at this time.
0 commit comments