Skip to content

Commit f1e34bf

Browse files
committed
Skip context randomization in fuzzing to improve performance
1 parent 8e5faa5 commit f1e34bf

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

secp256k1-sys/src/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ extern "C" {
278278
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_context_preallocated_destroy")]
279279
pub fn secp256k1_context_preallocated_destroy(cx: *mut Context);
280280

281-
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_context_randomize")]
282-
pub fn secp256k1_context_randomize(cx: *mut Context,
283-
seed32: *const c_uchar)
284-
-> c_int;
285281
// Signatures
286282
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_ecdsa_signature_parse_der")]
287283
pub fn secp256k1_ecdsa_signature_parse_der(cx: *const Context, sig: *mut Signature,
@@ -369,6 +365,10 @@ extern "C" {
369365
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_context_preallocated_clone")]
370366
pub fn secp256k1_context_preallocated_clone(cx: *const Context, prealloc: *mut c_void) -> *mut Context;
371367

368+
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_context_randomize")]
369+
pub fn secp256k1_context_randomize(cx: *mut Context,
370+
seed32: *const c_uchar)
371+
-> c_int;
372372
// Pubkeys
373373
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_0_ec_pubkey_parse")]
374374
pub fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey,
@@ -738,6 +738,14 @@ mod fuzz_dummy {
738738
rustsecp256k1_v0_4_0_context_preallocated_clone(cx, prealloc)
739739
}
740740

741+
pub unsafe fn secp256k1_context_randomize(cx: *mut Context,
742+
_seed32: *const c_uchar)
743+
-> c_int {
744+
// This function is really slow, and unsuitable for fuzzing
745+
check_context_flags(cx, 0);
746+
1
747+
}
748+
741749
unsafe fn check_context_flags(cx: *const Context, required_flags: c_uint) {
742750
assert!(!cx.is_null());
743751
let cx_flags = if cx == secp256k1_context_no_precomp {

0 commit comments

Comments
 (0)