From 5b10d1b226d106fe892e82225293838fd6be74e6 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Sat, 14 Sep 2019 21:05:26 +0300 Subject: [PATCH 1/2] Fix bad ffi declarations --- src/ffi.rs | 7 ++++--- src/recovery/ffi.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ffi.rs b/src/ffi.rs index ca8fb1c..21bcaf6 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -41,8 +41,9 @@ pub type NonceFn = unsafe extern "C" fn(nonce32: *mut c_uchar, msg32: *const c_uchar, key32: *const c_uchar, algo16: *const c_uchar, + data: *mut c_void, attempt: c_uint, - data: *const c_void); +); /// Hash function to use to post-process an ECDH point to get /// a shared secret. @@ -50,7 +51,7 @@ pub type EcdhHashFn = unsafe extern "C" fn( output: *mut c_uchar, x: *const c_uchar, y: *const c_uchar, - data: *const c_void, + data: *mut c_void, ); /// A Secp256k1 context, containing various precomputed values and such @@ -186,7 +187,7 @@ extern "C" { out_len: *mut usize, sig: *const Signature) -> c_int; - pub fn secp256k1_ecdsa_signature_serialize_compact(cx: *const Context, output64: *const c_uchar, + pub fn secp256k1_ecdsa_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar, sig: *const Signature) -> c_int; diff --git a/src/recovery/ffi.rs b/src/recovery/ffi.rs index 6b6e1f9..5a84b46 100644 --- a/src/recovery/ffi.rs +++ b/src/recovery/ffi.rs @@ -45,7 +45,7 @@ extern "C" { input64: *const c_uchar, recid: c_int) -> c_int; - pub fn secp256k1_ecdsa_recoverable_signature_serialize_compact(cx: *const Context, output64: *const c_uchar, + pub fn secp256k1_ecdsa_recoverable_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar, recid: *mut c_int, sig: *const RecoverableSignature) -> c_int; @@ -82,7 +82,7 @@ mod fuzz_dummy { unimplemented!(); } - pub unsafe fn secp256k1_ecdsa_recoverable_signature_serialize_compact(_cx: *const Context, _output64: *const c_uchar, + pub unsafe fn secp256k1_ecdsa_recoverable_signature_serialize_compact(_cx: *const Context, _output64: *mut c_uchar, _recid: *mut c_int, _sig: *const RecoverableSignature) -> c_int { unimplemented!(); From 06b2bebce83edc234f0e9cd1b54054d3a2322d66 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Sat, 14 Sep 2019 21:09:23 +0300 Subject: [PATCH 2/2] Add a test for the types --- src/types.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/types.rs b/src/types.rs index 3e79cac..f0e761b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -23,4 +23,19 @@ impl fmt::Debug for c_void { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("c_void") } +} + +#[cfg(test)] +mod tests { + use std::os::raw; + use std::any::TypeId; + use types; + + #[test] + fn verify_types() { + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(TypeId::of::(), TypeId::of::()); + } } \ No newline at end of file