Fix for upstream API changes

This commit is contained in:
Andrew Poelstra 2015-09-20 14:52:29 -05:00
parent cc68cf8b9e
commit 4012281a2d
3 changed files with 9 additions and 10 deletions

View File

@ -15,7 +15,7 @@
//! FFI bindings
use std::mem;
use libc::{c_int, c_uchar, c_uint, c_void};
use libc::{c_int, c_uchar, c_uint, c_void, size_t};
/// Flag for context to enable verification precomputation
pub const SECP256K1_START_VERIFY: c_uint = 0x1;
@ -134,21 +134,21 @@ extern "C" {
// Pubkeys
pub fn secp256k1_ec_pubkey_parse(cx: Context, pk: *mut PublicKey,
input: *const c_uchar, in_len: c_int)
input: *const c_uchar, in_len: size_t)
-> c_int;
pub fn secp256k1_ec_pubkey_serialize(cx: Context, output: *const c_uchar,
out_len: *mut c_int, pk: *const PublicKey
, compressed: c_int)
out_len: *mut size_t, pk: *const PublicKey
, compressed: c_uint)
-> c_int;
// Signatures
pub fn secp256k1_ecdsa_signature_parse_der(cx: Context, sig: *mut Signature,
input: *const c_uchar, in_len: c_int)
input: *const c_uchar, in_len: size_t)
-> c_int;
pub fn secp256k1_ecdsa_signature_serialize_der(cx: Context, output: *const c_uchar,
out_len: c_int, sig: *const Signature)
out_len: *const size_t, sig: *const Signature)
-> c_int;
pub fn secp256k1_ecdsa_recoverable_signature_parse_compact(cx: Context, sig: *mut RecoverableSignature,

View File

@ -146,7 +146,7 @@ impl PublicKey {
let mut pk = unsafe { ffi::PublicKey::blank() };
unsafe {
if ffi::secp256k1_ec_pubkey_parse(secp.ctx, &mut pk, data.as_ptr(),
data.len() as ::libc::c_int) == 1 {
data.len() as ::libc::size_t) == 1 {
Ok(PublicKey(pk))
} else {
Err(InvalidPublicKey)
@ -162,7 +162,7 @@ impl PublicKey {
let mut ret = ArrayVec::new();
unsafe {
let mut ret_len = ret.len() as ::libc::c_int;
let mut ret_len = ret.len() as ::libc::size_t;
debug_assert!(ffi::secp256k1_ec_pubkey_serialize(secp.ctx, ret.as_ptr(),
&mut ret_len, self.as_ptr(),
if compressed {1} else {0}) == 1);

View File

@ -45,7 +45,6 @@ extern crate rand;
use std::intrinsics::copy_nonoverlapping;
use std::{fmt, ops, ptr};
use libc::c_int;
use rand::Rng;
#[macro_use]
@ -75,7 +74,7 @@ impl Signature {
unsafe {
if ffi::secp256k1_ecdsa_signature_parse_der(secp.ctx, &mut ret,
data.as_ptr(), data.len() as libc::c_int) == 1 {
data.as_ptr(), data.len() as libc::size_t) == 1 {
Ok(Signature(ret))
} else {
Err(Error::InvalidSignature)