File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ script:
29
29
- cargo build --verbose --no-default-features --features="serde"
30
30
- cargo build --verbose --no-default-features --features="rand"
31
31
- cargo build --verbose --no-default-features --features="rand serde recovery"
32
+ - cargo build --verbose --no-default-features --features="fuzztarget recovery"
32
33
- cargo build --verbose
33
34
- cargo test --verbose
34
35
- cargo build --release
Original file line number Diff line number Diff line change @@ -60,6 +60,13 @@ pub type EcdhHashFn = unsafe extern "C" fn(
60
60
#[ derive( Clone , Debug ) ]
61
61
#[ repr( C ) ] pub struct Context ( c_int ) ;
62
62
63
+ #[ cfg( feature = "fuzztarget" ) ]
64
+ impl Context {
65
+ pub fn flags ( & self ) -> u32 {
66
+ self . 0 as u32
67
+ }
68
+ }
69
+
63
70
/// Library-internal representation of a Secp256k1 public key
64
71
#[ repr( C ) ]
65
72
pub struct PublicKey ( [ c_uchar ; 64 ] ) ;
@@ -250,9 +257,11 @@ extern "C" {
250
257
251
258
#[ cfg( feature = "fuzztarget" ) ]
252
259
mod fuzz_dummy {
253
- use std:: os:: raw:: { c_int, c_uchar, c_uint, c_void} ;
260
+ extern crate std;
261
+ use types:: * ;
254
262
use ffi:: * ;
255
- use std:: ptr;
263
+ use self :: std:: ptr;
264
+ use self :: std:: boxed:: Box ;
256
265
257
266
extern "C" {
258
267
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn ;
Original file line number Diff line number Diff line change 133
133
#![ cfg_attr( feature = "dev" , feature( plugin) ) ]
134
134
#![ cfg_attr( feature = "dev" , plugin( clippy) ) ]
135
135
136
- #![ cfg_attr( all( not( test) , not( feature = "std" ) ) , no_std) ]
136
+ #![ cfg_attr( all( not( test) , not( fuzztarget ) , not ( feature = "std" ) ) , no_std) ]
137
137
#![ cfg_attr( all( test, feature = "unstable" ) , feature( test) ) ]
138
138
#[ cfg( all( test, feature = "unstable" ) ) ] extern crate test;
139
139
#[ cfg( any( test, feature = "rand" ) ) ] pub extern crate rand;
Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ extern "C" {
69
69
70
70
#[ cfg( feature = "fuzztarget" ) ]
71
71
mod fuzz_dummy {
72
+ extern crate std;
73
+ use types:: * ;
74
+ use ffi:: * ;
75
+ use self :: std:: ptr;
76
+ use super :: RecoverableSignature ;
77
+
72
78
pub unsafe fn secp256k1_ecdsa_recoverable_signature_parse_compact ( _cx : * const Context , _sig : * mut RecoverableSignature ,
73
79
_input64 : * const c_uchar , _recid : c_int )
74
80
-> c_int {
@@ -95,8 +101,8 @@ mod fuzz_dummy {
95
101
_noncefn : NonceFn ,
96
102
_noncedata : * const c_void )
97
103
-> c_int {
98
- assert ! ( !cx. is_null( ) && ( * cx) . 0 as u32 & !( SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN ) == 0 ) ;
99
- assert ! ( ( * cx) . 0 as u32 & SECP256K1_START_SIGN == SECP256K1_START_SIGN ) ;
104
+ assert ! ( !cx. is_null( ) && ( * cx) . flags ( ) & !( SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN ) == 0 ) ;
105
+ assert ! ( ( * cx) . flags ( ) & SECP256K1_START_SIGN == SECP256K1_START_SIGN ) ;
100
106
if secp256k1_ec_seckey_verify ( cx, sk) != 1 { return 0 ; }
101
107
if * sk. offset ( 0 ) > 0x7f {
102
108
( * sig) . 0 [ 0 ] = 2 ;
@@ -116,3 +122,5 @@ mod fuzz_dummy {
116
122
unimplemented ! ( ) ;
117
123
}
118
124
}
125
+ #[ cfg( feature = "fuzztarget" ) ]
126
+ pub use self :: fuzz_dummy:: * ;
You can’t perform that action at this time.
0 commit comments