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

View File

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

View File

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