IoResult -> io::Result, copy_nonoverlapping_memory -> copy_nonoverlapping

This commit is contained in:
Andrew Poelstra 2015-03-25 14:10:02 -05:00
parent 1e24549ef5
commit d0519f0b3a
3 changed files with 26 additions and 26 deletions

View File

@ -15,7 +15,7 @@
//! Public/Private keys
use std::intrinsics::copy_nonoverlapping_memory;
use std::intrinsics::copy_nonoverlapping;
use std::cmp;
use std::fmt;
use std::rand::Rng;
@ -67,9 +67,9 @@ fn random_32_bytes<R:Rng>(rng: &mut R) -> [u8; 32] {
fn bits2octets(data: &[u8]) -> [u8; 32] {
let mut ret = [0; 32];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
cmp::min(data.len(), 32));
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
cmp::min(data.len(), 32));
}
ret
}
@ -88,9 +88,9 @@ impl Nonce {
constants::NONCE_SIZE => {
let mut ret = [0; constants::NONCE_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
Ok(Nonce(ret))
}
@ -182,9 +182,9 @@ impl SecretKey {
if ffi::secp256k1_ec_seckey_verify(data.as_ptr()) == 0 {
return Err(InvalidSecretKey);
}
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
Ok(SecretKey(ret))
}
@ -276,18 +276,18 @@ impl PublicKey {
data.len() as ::libc::c_int) == 0 {
return Err(InvalidPublicKey);
}
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
Ok(PublicKey(PublicKeyData::Compressed(ret)))
}
constants::UNCOMPRESSED_PUBLIC_KEY_SIZE => {
let mut ret = [0; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
Ok(PublicKey(PublicKeyData::Uncompressed(ret)))
}

View File

@ -79,12 +79,12 @@ macro_rules! impl_array_newtype {
#[inline]
fn clone(&self) -> $thing {
unsafe {
use std::intrinsics::copy_nonoverlapping_memory;
use std::intrinsics::copy_nonoverlapping;
use std::mem;
let mut ret: $thing = mem::uninitialized();
copy_nonoverlapping_memory(ret.as_mut_ptr(),
self.as_ptr(),
mem::size_of::<$thing>());
copy_nonoverlapping(ret.as_mut_ptr(),
self.as_ptr(),
mem::size_of::<$thing>());
ret
}
}

View File

@ -41,8 +41,8 @@ extern crate libc;
extern crate serialize;
extern crate test;
use std::intrinsics::copy_nonoverlapping_memory;
use std::io::IoResult;
use std::intrinsics::copy_nonoverlapping;
use std::io;
use std::rand::{OsRng, Rng, SeedableRng};
use std::sync::{Once, ONCE_INIT};
use libc::c_int;
@ -103,9 +103,9 @@ impl Signature {
if data.len() <= constants::MAX_SIGNATURE_SIZE {
let mut ret = [0; constants::MAX_SIGNATURE_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
Ok(Signature(data.len(), ret))
} else {
@ -158,7 +158,7 @@ pub fn init() {
impl Secp256k1 {
/// Constructs a new secp256k1 engine.
pub fn new() -> IoResult<Secp256k1> {
pub fn new() -> io::Result<Secp256k1> {
init();
let mut osrng = try!(OsRng::new());
let mut seed = [0; 2048];