Skip to content

Commit a24e27e

Browse files
authored
Merge pull request #269 from apoelstra/2021-01--rename-fuzz-feature
Rename `rust_secp_fuzz` config flag to `fuzzing`
2 parents 5f1622f + ca3caf9 commit a24e27e

File tree

8 files changed

+28
-26
lines changed

8 files changed

+28
-26
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "secp256k1"
3-
version = "0.20.0"
3+
version = "0.20.1"
44
authors = [ "Dawid Ciężarkiewicz <[email protected]>",
55
"Andrew Poelstra <[email protected]>" ]
66
license = "CC0-1.0"
@@ -56,4 +56,4 @@ required-features = ["rand"]
5656

5757
[workspace]
5858
members = ["secp256k1-sys"]
59-
exclude = ["no_std_test"]
59+
exclude = ["no_std_test"]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ If you want to fuzz this library, or any library which depends on it, you will
4242
probably want to disable the actual cryptography, since fuzzers are unable to
4343
forge signatures and therefore won't test many interesting codepaths. To instead
4444
use a trivially-broken but fuzzer-accessible signature scheme, compile with
45-
`--cfg=rust_secp_fuzz` in your `RUSTFLAGS` variable.
45+
`--cfg=fuzzing` in your `RUSTFLAGS` variable.
46+
47+
Note that `cargo hfuzz` sets this config flag automatically.
4648

contrib/test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
3434
done
3535

3636
# Other combos
37-
RUSTFLAGS='--cfg=rust_secp_fuzz' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all
38-
RUSTFLAGS='--cfg=rust_secp_fuzz' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all --features="$FEATURES"
37+
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all
38+
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all --features="$FEATURES"
3939
cargo test --all --features="rand rand-std"
4040
cargo test --all --features="rand serde"
4141

4242
if [ "$DO_BENCH" = true ]; then # proxy for us having a nightly compiler
4343
cargo test --all --all-features
44-
RUSTFLAGS='--cfg=rust_secp_fuzz' RUSTDOCFLAGS='--cfg=rust_secp_fuzz' cargo test --all --all-features
44+
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all --all-features
4545
fi
4646

4747
# Examples

secp256k1-sys/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#[cfg(any(test, feature = "std"))]
2727
extern crate core;
2828

29-
#[cfg(rust_secp_fuzz)]
29+
#[cfg(fuzzing)]
3030
const THIS_UNUSED_CONSTANT_IS_YOUR_WARNING_THAT_ALL_THE_CRYPTO_IN_THIS_LIB_IS_DISABLED_FOR_FUZZING: usize = 0;
3131

3232
#[macro_use]
@@ -480,7 +480,7 @@ extern "C" {
480480
) -> c_int;
481481
}
482482

483-
#[cfg(not(rust_secp_fuzz))]
483+
#[cfg(not(fuzzing))]
484484
extern "C" {
485485
// ECDSA
486486
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_ecdsa_verify")]
@@ -666,7 +666,7 @@ impl<T> CPtr for [T] {
666666
}
667667
}
668668

669-
#[cfg(rust_secp_fuzz)]
669+
#[cfg(fuzzing)]
670670
mod fuzz_dummy {
671671
use super::*;
672672

@@ -755,7 +755,7 @@ mod fuzz_dummy {
755755
}
756756
}
757757

758-
#[cfg(rust_secp_fuzz)]
758+
#[cfg(fuzzing)]
759759
pub use self::fuzz_dummy::*;
760760

761761
#[cfg(test)]

secp256k1-sys/src/recovery.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
-> c_int;
5353
}
5454

55-
#[cfg(not(rust_secp_fuzz))]
55+
#[cfg(not(fuzzing))]
5656
extern "C" {
5757
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_ecdsa_sign_recoverable")]
5858
pub fn secp256k1_ecdsa_sign_recoverable(cx: *const Context,
@@ -72,7 +72,7 @@ extern "C" {
7272
}
7373

7474

75-
#[cfg(rust_secp_fuzz)]
75+
#[cfg(fuzzing)]
7676
mod fuzz_dummy {
7777
use super::*;
7878
use std::slice;
@@ -146,6 +146,6 @@ mod fuzz_dummy {
146146
1
147147
}
148148
}
149-
#[cfg(rust_secp_fuzz)]
149+
#[cfg(fuzzing)]
150150
pub use self::fuzz_dummy::*;
151151

src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
//! 0xc9, 0x42, 0x8f, 0xca, 0x69, 0xc1, 0x32, 0xa2,
104104
//! ]).expect("compact signatures are 64 bytes; DER signatures are 68-72 bytes");
105105
//!
106-
//! # #[cfg(not(rust_secp_fuzz))]
106+
//! # #[cfg(not(fuzzing))]
107107
//! assert!(secp.verify(&message, &sig, &public_key).is_ok());
108108
//! ```
109109
//!
@@ -744,7 +744,7 @@ impl<C: Signing> Secp256k1<C> {
744744
entropy_p = extra_entropy.as_ptr() as *const ffi::types::c_void;
745745

746746
// When fuzzing, these checks will usually spinloop forever, so just short-circuit them.
747-
#[cfg(rust_secp_fuzz)]
747+
#[cfg(fuzzing)]
748748
return Signature::from(ret);
749749
}
750750
}
@@ -1108,12 +1108,12 @@ mod tests {
11081108
if compact[0] < 0x80 {
11091109
assert_eq!(sig, low_r_sig);
11101110
} else {
1111-
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
1111+
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
11121112
assert_ne!(sig, low_r_sig);
11131113
}
1114-
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
1114+
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
11151115
assert!(super::compact_sig_has_zero_first_bit(&low_r_sig.0));
1116-
#[cfg(not(rust_secp_fuzz))] // mocked sig generation doesn't produce low-R sigs
1116+
#[cfg(not(fuzzing))] // mocked sig generation doesn't produce low-R sigs
11171117
assert!(super::der_length_check(&grind_r_sig.0, 70));
11181118
}
11191119
}
@@ -1186,7 +1186,7 @@ mod tests {
11861186
}
11871187

11881188
#[test]
1189-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
1189+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
11901190
fn test_low_s() {
11911191
// nb this is a transaction on testnet
11921192
// txid 8ccc87b72d766ab3128f03176bb1c98293f2d1f85ebfaf07b82cc81ea6891fa9
@@ -1208,7 +1208,7 @@ mod tests {
12081208
}
12091209

12101210
#[test]
1211-
#[cfg(not(rust_secp_fuzz))] // fuzz-sigs have fixed size/format
1211+
#[cfg(not(fuzzing))] // fuzz-sigs have fixed size/format
12121212
fn test_low_r() {
12131213
let secp = Secp256k1::new();
12141214
let msg = hex!("887d04bb1cf1b1554f1b268dfe62d13064ca67ae45348d50d1392ce2d13418ac");
@@ -1223,7 +1223,7 @@ mod tests {
12231223
}
12241224

12251225
#[test]
1226-
#[cfg(not(rust_secp_fuzz))] // fuzz-sigs have fixed size/format
1226+
#[cfg(not(fuzzing))] // fuzz-sigs have fixed size/format
12271227
fn test_grind_r() {
12281228
let secp = Secp256k1::new();
12291229
let msg = hex!("ef2d5b9a7c61865a95941d0f04285420560df7e9d76890ac1b8867b12ce43167");
@@ -1237,7 +1237,7 @@ mod tests {
12371237
}
12381238

12391239
#[cfg(feature = "serde")]
1240-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
1240+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
12411241
#[test]
12421242
fn test_signature_serde() {
12431243
use serde_test::{Configure, Token, assert_tokens};

src/recovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ mod tests {
235235
}
236236

237237
#[test]
238-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
238+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
239239
fn sign() {
240240
let mut s = Secp256k1::new();
241241
s.randomize(&mut thread_rng());

src/schnorrsig.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ mod tests {
561561
}
562562

563563
#[test]
564-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
564+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
565565
fn test_schnorrsig_sign() {
566566
let secp = Secp256k1::new();
567567

@@ -583,7 +583,7 @@ mod tests {
583583
}
584584

585585
#[test]
586-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
586+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
587587
fn test_schnorrsig_verify() {
588588
let secp = Secp256k1::new();
589589

@@ -722,7 +722,7 @@ mod tests {
722722
}
723723

724724
#[cfg(feature = "serde")]
725-
#[cfg(not(rust_secp_fuzz))] // fixed sig vectors can't work with fuzz-sigs
725+
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
726726
#[test]
727727
fn test_signature_serde() {
728728
use serde_test::{assert_tokens, Configure, Token};

0 commit comments

Comments
 (0)