Update for vec API changes

This commit is contained in:
Steven Fackler 2014-03-20 19:09:39 -07:00
parent 53acce7a98
commit 761901d0e4
9 changed files with 19 additions and 21 deletions

View File

@ -1,7 +1,7 @@
use std::libc::c_uint;
use std::libc;
use std::ptr;
use std::vec;
use std::slice;
pub enum HashType {
MD5,
@ -78,7 +78,7 @@ impl Hasher {
*/
pub fn final(&self) -> ~[u8] {
unsafe {
let mut res = vec::from_elem(self.len, 0u8);
let mut res = slice::from_elem(self.len, 0u8);
EVP_DigestFinal(self.ctx, res.as_mut_ptr(), ptr::null());
res
}

View File

@ -16,7 +16,7 @@
use std::libc::{c_uchar, c_int, c_uint};
use std::ptr;
use std::vec;
use std::slice;
use crypto::hash;
#[allow(non_camel_case_types)]
@ -72,7 +72,7 @@ impl HMAC {
pub fn final(&mut self) -> ~[u8] {
unsafe {
let mut res = vec::from_elem(self.len, 0u8);
let mut res = slice::from_elem(self.len, 0u8);
let mut outlen = 0;
HMAC_Final(&mut self.ctx, res.as_mut_ptr(), &mut outlen);
assert!(self.len == outlen as uint)

View File

@ -1,5 +1,5 @@
use std::libc::c_int;
use std::vec;
use std::slice;
#[link(name = "crypto")]
extern {
@ -15,7 +15,7 @@ pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint, keylen: uint) -> ~[
assert!(iter >= 1);
assert!(keylen >= 1);
let mut out = vec::with_capacity(keylen);
let mut out = slice::with_capacity(keylen);
let r = PKCS5_PBKDF2_HMAC_SHA1(
pass.as_ptr(), pass.len() as c_int,

View File

@ -2,7 +2,7 @@ use std::cast;
use std::libc::{c_char, c_int, c_uint};
use std::libc;
use std::ptr;
use std::vec;
use std::slice;
use crypto::hash::{HashType, MD5, SHA1, SHA224, SHA256, SHA384, SHA512};
#[allow(non_camel_case_types)]
@ -94,7 +94,7 @@ impl PKey {
unsafe {
let len = f(self.evp, ptr::null());
if len < 0 as c_int { return ~[]; }
let mut s = vec::from_elem(len as uint, 0u8);
let mut s = slice::from_elem(len as uint, 0u8);
let r = f(self.evp, &s.as_mut_ptr());
@ -219,7 +219,7 @@ impl PKey {
assert!(s.len() < self.max_data());
let mut r = vec::from_elem(len as uint + 1u, 0u8);
let mut r = slice::from_elem(len as uint + 1u, 0u8);
let rv = RSA_public_encrypt(
s.len() as c_uint,
@ -244,7 +244,7 @@ impl PKey {
assert_eq!(s.len() as c_uint, RSA_size(rsa));
let mut r = vec::from_elem(len as uint + 1u, 0u8);
let mut r = slice::from_elem(len as uint + 1u, 0u8);
let rv = RSA_private_decrypt(
s.len() as c_uint,
@ -289,7 +289,7 @@ impl PKey {
unsafe {
let rsa = EVP_PKEY_get1_RSA(self.evp);
let mut len = RSA_size(rsa);
let mut r = vec::from_elem(len as uint + 1u, 0u8);
let mut r = slice::from_elem(len as uint + 1u, 0u8);
let rv = RSA_sign(
openssl_hash_nid(hash),

View File

@ -1,5 +1,5 @@
use std::libc::c_int;
use std::vec;
use std::slice;
#[link(name = "crypto")]
extern {
@ -8,7 +8,7 @@ extern {
pub fn rand_bytes(len: uint) -> ~[u8] {
unsafe {
let mut out = vec::with_capacity(len);
let mut out = slice::with_capacity(len);
let r = RAND_bytes(out.as_mut_ptr(), len as c_int);
if r != 1 as c_int { fail!() }

View File

@ -1,6 +1,6 @@
use std::libc::{c_int, c_uint};
use std::libc;
use std::vec;
use std::slice;
#[allow(non_camel_case_types)]
pub type EVP_CIPHER_CTX = *libc::c_void;
@ -126,7 +126,7 @@ impl Crypter {
*/
pub fn update(&self, data: &[u8]) -> ~[u8] {
unsafe {
let mut res = vec::from_elem(data.len() + self.blocksize, 0u8);
let mut res = slice::from_elem(data.len() + self.blocksize, 0u8);
let mut reslen = (data.len() + self.blocksize) as u32;
EVP_CipherUpdate(
@ -147,7 +147,7 @@ impl Crypter {
*/
pub fn final(&self) -> ~[u8] {
unsafe {
let mut res = vec::from_elem(self.blocksize, 0u8);
let mut res = slice::from_elem(self.blocksize, 0u8);
let mut reslen = self.blocksize as c_int;
EVP_CipherFinal(self.ctx,

View File

@ -1,6 +1,5 @@
use std::libc::c_ulong;
use std::io::IoError;
use std::vec_ng::Vec;
use ssl::ffi;

View File

@ -124,7 +124,7 @@ extern "C" {
pub fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX;
pub fn SSL_CTX_free(ctx: *SSL_CTX);
pub fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int,
verify_callback: Option<extern "C" fn(c_int, *X509_STORE_CTX) -> c_int>);
verify_callback: Option<extern fn(c_int, *X509_STORE_CTX) -> c_int>);
pub fn SSL_CTX_load_verify_locations(ctx: *SSL_CTX, CAfile: *c_char,
CApath: *c_char) -> c_int;
pub fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *c_void,

View File

@ -2,9 +2,8 @@ use sync::one::{Once, ONCE_INIT};
use std::cast;
use std::libc::{c_int, c_void, c_char};
use std::ptr;
use std::io::{IoResult, IoError, OtherIoError, EndOfFile, Stream, Reader, Writer};
use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer};
use std::unstable::mutex::NativeMutex;
use std::vec_ng::Vec;
use ssl::error::{SslError, SslSessionClosed, StreamError};
@ -91,7 +90,7 @@ pub enum SslVerifyMode {
}
extern fn locking_function(mode: c_int, n: c_int, _file: *c_char,
_line: c_int) {
_line: c_int) {
unsafe { inner_lock(mode, (*MUTEXES).get_mut(n as uint)); }
}