From 9dfeea6ca9f8527e8be56c208e21a1a48f22f6cf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Jan 2015 08:07:39 -0800 Subject: [PATCH] Update to rust master --- openssl-sys/src/build.rs | 2 ++ openssl-sys/src/lib.rs | 12 ++++++------ src/asn1/mod.rs | 2 +- src/bio/mod.rs | 6 +++--- src/bn/mod.rs | 2 +- src/crypto/hash.rs | 20 ++++++++++---------- src/crypto/hmac.rs | 6 +++--- src/crypto/pkcs5.rs | 26 ++++++++++++------------- src/crypto/pkey.rs | 40 +++++++++++++++++++-------------------- src/crypto/rand.rs | 6 +++--- src/crypto/symm.rs | 41 ++++++++++++++++++++-------------------- src/lib.rs | 3 ++- src/ssl/mod.rs | 18 +++++++++--------- src/x509/mod.rs | 16 ++++++++-------- 14 files changed, 102 insertions(+), 98 deletions(-) diff --git a/openssl-sys/src/build.rs b/openssl-sys/src/build.rs index ca71f791..3f3053f0 100644 --- a/openssl-sys/src/build.rs +++ b/openssl-sys/src/build.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + extern crate "pkg-config" as pkg_config; use std::os; diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index fb1ecb78..7384340c 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -1,5 +1,5 @@ #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] -#![allow(dead_code)] +#![allow(dead_code, unstable)] extern crate libc; @@ -197,12 +197,12 @@ static mut GUARDS: *mut Vec>> = 0 as *mut Vec>(); + let mutexes = Box::new(range(0, num_locks).map(|_| MUTEX_INIT).collect::>()); MUTEXES = mem::transmute(mutexes); let guards: Box>>> = - box range(0, num_locks).map(|_| None).collect(); + Box::new(range(0, num_locks).map(|_| None).collect()); GUARDS = mem::transmute(guards); CRYPTO_set_locking_callback(locking_function); diff --git a/src/asn1/mod.rs b/src/asn1/mod.rs index 89c79f74..c250096f 100644 --- a/src/asn1/mod.rs +++ b/src/asn1/mod.rs @@ -30,7 +30,7 @@ impl Asn1Time { } /// Creates a new time on specified interval in days from now - pub fn days_from_now(days: uint) -> Result { + pub fn days_from_now(days: u32) -> Result { Asn1Time::new_with_period(days as u64 * 60 * 60 * 24) } diff --git a/src/bio/mod.rs b/src/bio/mod.rs index 7172b009..a354ed86 100644 --- a/src/bio/mod.rs +++ b/src/bio/mod.rs @@ -58,7 +58,7 @@ impl MemBio { } impl Reader for MemBio { - fn read(&mut self, buf: &mut [u8]) -> IoResult { + fn read(&mut self, buf: &mut [u8]) -> IoResult { let ret = unsafe { ffi::BIO_read(self.bio, buf.as_ptr() as *mut c_void, buf.len() as c_int) @@ -81,7 +81,7 @@ impl Reader for MemBio { }; Err(err) } else { - Ok(ret as uint) + Ok(ret as usize) } } } @@ -92,7 +92,7 @@ impl Writer for MemBio { ffi::BIO_write(self.bio, buf.as_ptr() as *const c_void, buf.len() as c_int) }; - if buf.len() != ret as uint { + if buf.len() != ret as usize { Err(IoError { kind: OtherIoError, desc: "MemBio write error", diff --git a/src/bn/mod.rs b/src/bn/mod.rs index 7577f0e9..84a57c4a 100644 --- a/src/bn/mod.rs +++ b/src/bn/mod.rs @@ -408,7 +408,7 @@ impl BigNum { } pub fn to_vec(&self) -> Vec { - let size = self.num_bytes() as uint; + let size = self.num_bytes() as usize; let mut v = Vec::with_capacity(size); unsafe { ffi::BN_bn2bin(self.raw(), v.as_mut_ptr()); diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs index 1f8a3936..602a7d08 100644 --- a/src/crypto/hash.rs +++ b/src/crypto/hash.rs @@ -16,16 +16,16 @@ pub enum HashType { RIPEMD160 } -pub fn evpmd(t: HashType) -> (*const ffi::EVP_MD, uint) { +pub fn evpmd(t: HashType) -> (*const ffi::EVP_MD, u32) { unsafe { match t { - HashType::MD5 => (ffi::EVP_md5(), 16u), - HashType::SHA1 => (ffi::EVP_sha1(), 20u), - HashType::SHA224 => (ffi::EVP_sha224(), 28u), - HashType::SHA256 => (ffi::EVP_sha256(), 32u), - HashType::SHA384 => (ffi::EVP_sha384(), 48u), - HashType::SHA512 => (ffi::EVP_sha512(), 64u), - HashType::RIPEMD160 => (ffi::EVP_ripemd160(), 20u), + HashType::MD5 => (ffi::EVP_md5(), 16), + HashType::SHA1 => (ffi::EVP_sha1(), 20), + HashType::SHA224 => (ffi::EVP_sha224(), 28), + HashType::SHA256 => (ffi::EVP_sha256(), 32), + HashType::SHA384 => (ffi::EVP_sha384(), 48), + HashType::SHA512 => (ffi::EVP_sha512(), 64), + HashType::RIPEMD160 => (ffi::EVP_ripemd160(), 20), } } } @@ -56,7 +56,7 @@ impl Drop for HasherContext { pub struct Hasher { evp: *const ffi::EVP_MD, ctx: HasherContext, - len: uint, + len: u32, } impl io::Writer for Hasher { @@ -102,7 +102,7 @@ impl Hasher { * initialization and its context for reuse */ pub fn finalize_reuse(self) -> (Vec, HasherContext) { - let mut res = repeat(0u8).take(self.len).collect::>(); + let mut res = repeat(0u8).take(self.len as usize).collect::>(); unsafe { ffi::EVP_DigestFinal_ex(self.ctx.ptr, res.as_mut_ptr(), ptr::null_mut()) }; diff --git a/src/crypto/hmac.rs b/src/crypto/hmac.rs index 6de0b1e7..4a0c3e77 100644 --- a/src/crypto/hmac.rs +++ b/src/crypto/hmac.rs @@ -22,7 +22,7 @@ use ffi; pub struct HMAC { ctx: ffi::HMAC_CTX, - len: uint, + len: u32, } #[allow(non_snake_case)] @@ -53,10 +53,10 @@ impl HMAC { pub fn finalize(&mut self) -> Vec { unsafe { - let mut res: Vec = repeat(0).take(self.len).collect(); + let mut res: Vec = repeat(0).take(self.len as usize).collect(); let mut outlen = 0; ffi::HMAC_Final(&mut self.ctx, res.as_mut_ptr(), &mut outlen); - assert!(self.len == outlen as uint); + assert!(self.len == outlen as u32); res } } diff --git a/src/crypto/pkcs5.rs b/src/crypto/pkcs5.rs index 6efd23ff..b101c3ed 100644 --- a/src/crypto/pkcs5.rs +++ b/src/crypto/pkcs5.rs @@ -2,7 +2,7 @@ use libc::c_int; use ffi; /// Derives a key from a password and salt using the PBKDF2-HMAC-SHA1 algorithm. -pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint, keylen: uint) -> Vec { +pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: usize, keylen: usize) -> Vec { unsafe { assert!(iter >= 1); assert!(keylen >= 1); @@ -35,8 +35,8 @@ mod tests { super::pbkdf2_hmac_sha1( "password", "salt".as_bytes(), - 1u, - 20u + 1, + 20 ), vec!( 0x0c_u8, 0x60_u8, 0xc8_u8, 0x0f_u8, 0x96_u8, 0x1f_u8, 0x0e_u8, @@ -49,8 +49,8 @@ mod tests { super::pbkdf2_hmac_sha1( "password", "salt".as_bytes(), - 2u, - 20u + 2, + 20 ), vec!( 0xea_u8, 0x6c_u8, 0x01_u8, 0x4d_u8, 0xc7_u8, 0x2d_u8, 0x6f_u8, @@ -63,8 +63,8 @@ mod tests { super::pbkdf2_hmac_sha1( "password", "salt".as_bytes(), - 4096u, - 20u + 4096, + 20 ), vec!( 0x4b_u8, 0x00_u8, 0x79_u8, 0x01_u8, 0xb7_u8, 0x65_u8, 0x48_u8, @@ -77,8 +77,8 @@ mod tests { super::pbkdf2_hmac_sha1( "password", "salt".as_bytes(), - 16777216u, - 20u + 16777216, + 20 ), vec!( 0xee_u8, 0xfe_u8, 0x3d_u8, 0x61_u8, 0xcd_u8, 0x4d_u8, 0xa4_u8, @@ -91,8 +91,8 @@ mod tests { super::pbkdf2_hmac_sha1( "passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt".as_bytes(), - 4096u, - 25u + 4096, + 25 ), vec!( 0x3d_u8, 0x2e_u8, 0xec_u8, 0x4f_u8, 0xe4_u8, 0x1c_u8, 0x84_u8, @@ -106,8 +106,8 @@ mod tests { super::pbkdf2_hmac_sha1( "pass\x00word", "sa\x00lt".as_bytes(), - 4096u, - 16u + 4096, + 16 ), vec!( 0x56_u8, 0xfa_u8, 0x6a_u8, 0xa7_u8, 0x55_u8, 0x48_u8, 0x09_u8, diff --git a/src/crypto/pkey.rs b/src/crypto/pkey.rs index 2264e192..14144dc0 100644 --- a/src/crypto/pkey.rs +++ b/src/crypto/pkey.rs @@ -72,11 +72,11 @@ impl PKey { let rsa = ffi::EVP_PKEY_get1_RSA(self.evp); let len = f(rsa, ptr::null()); if len < 0 as c_int { return vec!(); } - let mut s = repeat(0u8).take(len as uint).collect::>(); + let mut s = repeat(0u8).take(len as usize).collect::>(); let r = f(rsa, &s.as_mut_ptr()); - s.truncate(r as uint); + s.truncate(r as usize); s } } @@ -89,11 +89,11 @@ impl PKey { } } - pub fn gen(&mut self, keysz: uint) { + pub fn gen(&mut self, keysz: usize) { unsafe { let rsa = ffi::RSA_generate_key( keysz as c_uint, - 65537u as c_uint, + 65537 as c_uint, ptr::null(), ptr::null() ); @@ -155,9 +155,9 @@ impl PKey { /** * Returns the size of the public key modulus. */ - pub fn size(&self) -> uint { + pub fn size(&self) -> usize { unsafe { - ffi::RSA_size(ffi::EVP_PKEY_get1_RSA(self.evp)) as uint + ffi::RSA_size(ffi::EVP_PKEY_get1_RSA(self.evp)) as usize } } @@ -193,13 +193,13 @@ impl PKey { * Returns the maximum amount of data that can be encrypted by an encrypt() * call. */ - pub fn max_data(&self) -> uint { + pub fn max_data(&self) -> usize { unsafe { let rsa = ffi::EVP_PKEY_get1_RSA(self.evp); let len = ffi::RSA_size(rsa); // 41 comes from RSA_public_encrypt(3) for OAEP - len as uint - 41u + len as usize - 41 } } @@ -210,7 +210,7 @@ impl PKey { assert!(s.len() < self.max_data()); - let mut r = repeat(0u8).take(len as uint + 1).collect::>(); + let mut r = repeat(0u8).take(len as usize + 1).collect::>(); let rv = ffi::RSA_public_encrypt( s.len() as c_uint, @@ -222,7 +222,7 @@ impl PKey { if rv < 0 as c_int { vec!() } else { - r.truncate(rv as uint); + r.truncate(rv as usize); r } } @@ -235,7 +235,7 @@ impl PKey { assert_eq!(s.len() as c_uint, ffi::RSA_size(rsa)); - let mut r = repeat(0u8).take(len as uint + 1).collect::>(); + let mut r = repeat(0u8).take(len as usize + 1).collect::>(); let rv = ffi::RSA_private_decrypt( s.len() as c_uint, @@ -247,7 +247,7 @@ impl PKey { if rv < 0 as c_int { vec!() } else { - r.truncate(rv as uint); + r.truncate(rv as usize); r } } @@ -280,7 +280,7 @@ impl PKey { unsafe { let rsa = ffi::EVP_PKEY_get1_RSA(self.evp); let mut len = ffi::RSA_size(rsa); - let mut r = repeat(0u8).take(len as uint + 1).collect::>(); + let mut r = repeat(0u8).take(len as usize + 1).collect::>(); let rv = ffi::RSA_sign( openssl_hash_nid(hash), @@ -293,7 +293,7 @@ impl PKey { if rv < 0 as c_int { vec!() } else { - r.truncate(len as uint); + r.truncate(len as usize); r } } @@ -337,7 +337,7 @@ mod tests { fn test_gen_pub() { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); - k0.gen(512u); + k0.gen(512); k1.load_pub(k0.save_pub().as_slice()); assert_eq!(k0.save_pub(), k1.save_pub()); assert_eq!(k0.size(), k1.size()); @@ -355,7 +355,7 @@ mod tests { fn test_gen_priv() { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); - k0.gen(512u); + k0.gen(512); k1.load_priv(k0.save_priv().as_slice()); assert_eq!(k0.save_priv(), k1.save_priv()); assert_eq!(k0.size(), k1.size()); @@ -374,7 +374,7 @@ mod tests { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); let msg = vec!(0xdeu8, 0xadu8, 0xd0u8, 0x0du8); - k0.gen(512u); + k0.gen(512); k1.load_pub(k0.save_pub().as_slice()); let emsg = k1.encrypt(msg.as_slice()); let dmsg = k0.decrypt(emsg.as_slice()); @@ -386,7 +386,7 @@ mod tests { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); let msg = vec!(0xdeu8, 0xadu8, 0xd0u8, 0x0du8); - k0.gen(512u); + k0.gen(512); k1.load_pub(k0.save_pub().as_slice()); let emsg = k1.encrypt_with_padding(msg.as_slice(), super::EncryptionPadding::PKCS1v15); let dmsg = k0.decrypt_with_padding(emsg.as_slice(), super::EncryptionPadding::PKCS1v15); @@ -398,7 +398,7 @@ mod tests { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); let msg = vec!(0xdeu8, 0xadu8, 0xd0u8, 0x0du8); - k0.gen(512u); + k0.gen(512); k1.load_pub(k0.save_pub().as_slice()); let sig = k0.sign(msg.as_slice()); let rv = k1.verify(msg.as_slice(), sig.as_slice()); @@ -410,7 +410,7 @@ mod tests { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); let msg = vec!(0xdeu8, 0xadu8, 0xd0u8, 0x0du8); - k0.gen(512u); + k0.gen(512); k1.load_pub(k0.save_pub().as_slice()); let sig = k0.sign_with_hash(msg.as_slice(), MD5); diff --git a/src/crypto/rand.rs b/src/crypto/rand.rs index 92d38f2c..dc338a3d 100644 --- a/src/crypto/rand.rs +++ b/src/crypto/rand.rs @@ -1,7 +1,7 @@ use libc::c_int; use ffi; -pub fn rand_bytes(len: uint) -> Vec { +pub fn rand_bytes(len: usize) -> Vec { unsafe { let mut out = Vec::with_capacity(len); @@ -21,7 +21,7 @@ mod tests { #[test] fn test_rand_bytes() { - let bytes = rand_bytes(32u); - println!("{}", bytes); + let bytes = rand_bytes(32); + println!("{:?}", bytes); } } diff --git a/src/crypto/symm.rs b/src/crypto/symm.rs index 9478bc4a..ccff62bb 100644 --- a/src/crypto/symm.rs +++ b/src/crypto/symm.rs @@ -31,24 +31,24 @@ pub enum Type { RC4_128, } -fn evpc(t: Type) -> (*const ffi::EVP_CIPHER, uint, uint) { +fn evpc(t: Type) -> (*const ffi::EVP_CIPHER, u32, u32) { unsafe { match t { - Type::AES_128_ECB => (ffi::EVP_aes_128_ecb(), 16u, 16u), - Type::AES_128_CBC => (ffi::EVP_aes_128_cbc(), 16u, 16u), + Type::AES_128_ECB => (ffi::EVP_aes_128_ecb(), 16, 16), + Type::AES_128_CBC => (ffi::EVP_aes_128_cbc(), 16, 16), #[cfg(feature = "aes_xts")] - Type::AES_128_XTS => (ffi::EVP_aes_128_xts(), 32u, 16u), - // AES_128_CTR => (EVP_aes_128_ctr(), 16u, 0u), - //AES_128_GCM => (EVP_aes_128_gcm(), 16u, 16u), + Type::AES_128_XTS => (ffi::EVP_aes_128_xts(), 32, 16), + // AES_128_CTR => (EVP_aes_128_ctr(), 16, 0), + //AES_128_GCM => (EVP_aes_128_gcm(), 16, 16), - Type::AES_256_ECB => (ffi::EVP_aes_256_ecb(), 32u, 16u), - Type::AES_256_CBC => (ffi::EVP_aes_256_cbc(), 32u, 16u), + Type::AES_256_ECB => (ffi::EVP_aes_256_ecb(), 32, 16), + Type::AES_256_CBC => (ffi::EVP_aes_256_cbc(), 32, 16), #[cfg(feature = "aes_xts")] - Type::AES_256_XTS => (ffi::EVP_aes_256_xts(), 64u, 16u), - // AES_256_CTR => (EVP_aes_256_ctr(), 32u, 0u), - //AES_256_GCM => (EVP_aes_256_gcm(), 32u, 16u), + Type::AES_256_XTS => (ffi::EVP_aes_256_xts(), 64, 16), + // AES_256_CTR => (EVP_aes_256_ctr(), 32, 0), + //AES_256_GCM => (EVP_aes_256_gcm(), 32, 16), - Type::RC4_128 => (ffi::EVP_rc4(), 16u, 0u), + Type::RC4_128 => (ffi::EVP_rc4(), 16, 0), } } } @@ -57,8 +57,8 @@ fn evpc(t: Type) -> (*const ffi::EVP_CIPHER, uint, uint) { pub struct Crypter { evp: *const ffi::EVP_CIPHER, ctx: *mut ffi::EVP_CIPHER_CTX, - keylen: uint, - blocksize: uint + keylen: u32, + blocksize: u32, } impl Crypter { @@ -92,7 +92,7 @@ impl Crypter { Mode::Encrypt => 1 as c_int, Mode::Decrypt => 0 as c_int, }; - assert_eq!(key.len(), self.keylen); + assert_eq!(key.len(), self.keylen as usize); ffi::EVP_CipherInit( self.ctx, @@ -110,8 +110,9 @@ impl Crypter { */ pub fn update(&self, data: &[u8]) -> Vec { unsafe { - let mut res = repeat(0u8).take(data.len() + self.blocksize).collect::>(); - let mut reslen = (data.len() + self.blocksize) as u32; + let sum = data.len() + (self.blocksize as usize); + let mut res = repeat(0u8).take(sum).collect::>(); + let mut reslen = sum as u32; ffi::EVP_CipherUpdate( self.ctx, @@ -121,7 +122,7 @@ impl Crypter { data.len() as c_int ); - res.truncate(reslen as uint); + res.truncate(reslen as usize); res } } @@ -131,14 +132,14 @@ impl Crypter { */ pub fn finalize(&self) -> Vec { unsafe { - let mut res = repeat(0u8).take(self.blocksize).collect::>(); + let mut res = repeat(0u8).take(self.blocksize as usize).collect::>(); let mut reslen = self.blocksize as c_int; ffi::EVP_CipherFinal(self.ctx, res.as_mut_ptr(), &mut reslen); - res.truncate(reslen as uint); + res.truncate(reslen as usize); res } } diff --git a/src/lib.rs b/src/lib.rs index 074337e8..bb11f34b 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ -#![feature(unsafe_destructor, old_orphan_check)] +#![feature(unsafe_destructor)] +#![allow(unstable)] #![crate_name="openssl"] #![crate_type="rlib"] #![crate_type="dylib"] diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs index 4d11ae4a..d97f35c3 100644 --- a/src/ssl/mod.rs +++ b/src/ssl/mod.rs @@ -215,7 +215,7 @@ impl SslContext { pub fn set_verify_with_data(&mut self, mode: SslVerifyMode, verify: VerifyCallbackData, data: T) { - let data = box data; + let data = Box::new(data); unsafe { ffi::SSL_CTX_set_ex_data(self.ctx.0, VERIFY_IDX, mem::transmute(Some(verify))); @@ -228,7 +228,7 @@ impl SslContext { } /// Sets verification depth - pub fn set_verify_depth(&mut self, depth: uint) { + pub fn set_verify_depth(&mut self, depth: u32) { unsafe { ffi::SSL_CTX_set_verify_depth(self.ctx.0, depth as c_int); } @@ -280,7 +280,7 @@ struct MemBioRef<'ssl> { } impl<'ssl> MemBioRef<'ssl> { - fn read(&mut self, buf: &mut [u8]) -> Option { + fn read(&mut self, buf: &mut [u8]) -> Option { (&mut self.bio as &mut Reader).read(buf).ok() } @@ -350,7 +350,7 @@ impl Ssl { fn get_error(&self, ret: c_int) -> LibSslError { let err = unsafe { ffi::SSL_get_error(self.ssl.0, ret) }; - match FromPrimitive::from_int(err as int) { + match FromPrimitive::from_int(err as isize) { Some(err) => err, None => unreachable!() } @@ -421,7 +421,7 @@ impl SslStream { // We're just using this as a buffer, so there's no reason to pay // to memset it buf: { - const CAP: uint = 16 * 1024; + const CAP: usize = 16 * 1024; let mut v = Vec::with_capacity(CAP); unsafe { v.set_len(CAP); } v @@ -529,9 +529,9 @@ impl SslStream { } impl Reader for SslStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult { + fn read(&mut self, buf: &mut [u8]) -> IoResult { match self.in_retry_wrapper(|ssl| { ssl.read(buf) }) { - Ok(len) => Ok(len as uint), + Ok(len) => Ok(len as usize), Err(SslSessionClosed) => Err(IoError { kind: EndOfFile, @@ -552,7 +552,7 @@ impl Writer for SslStream { ssl.write(buf.split_at(start).1) }); match ret { - Ok(len) => start += len as uint, + Ok(len) => start += len as usize, _ => unreachable!() } try!(self.write_through()); @@ -575,7 +575,7 @@ pub enum MaybeSslStream where S: Stream { } impl Reader for MaybeSslStream where S: Stream { - fn read(&mut self, buf: &mut [u8]) -> IoResult { + fn read(&mut self, buf: &mut [u8]) -> IoResult { match *self { MaybeSslStream::Ssl(ref mut s) => s.read(buf), MaybeSslStream::Normal(ref mut s) => s.read(buf), diff --git a/src/x509/mod.rs b/src/x509/mod.rs index 2792ca1c..54b77ffb 100644 --- a/src/x509/mod.rs +++ b/src/x509/mod.rs @@ -173,8 +173,8 @@ impl<'a, T: AsStr<'a>> ToStr for Vec { /// # let _ = fs::unlink(&pkey_path); /// ``` pub struct X509Generator { - bits: uint, - days: uint, + bits: u32, + days: u32, CN: String, key_usage: Vec, ext_key_usage: Vec, @@ -203,13 +203,13 @@ impl X509Generator { } /// Sets desired bit length - pub fn set_bitlength(mut self, bits: uint) -> X509Generator { + pub fn set_bitlength(mut self, bits: u32) -> X509Generator { self.bits = bits; self } /// Sets certificate validity period in days since today - pub fn set_valid_period(mut self, days: uint) -> X509Generator { + pub fn set_valid_period(mut self, days: u32) -> X509Generator { self.days = days; self } @@ -288,7 +288,7 @@ impl X509Generator { ffi::init(); let mut p_key = PKey::new(); - p_key.gen(self.bits); + p_key.gen(self.bits as usize); unsafe { let x509 = ffi::X509_new(); @@ -386,7 +386,7 @@ impl<'ctx> X509<'ctx> { /// Returns certificate fingerprint calculated using provided hash pub fn fingerprint(&self, hash_type: HashType) -> Option> { let (evp, len) = evpmd(hash_type); - let v: Vec = repeat(0).take(len).collect(); + let v: Vec = repeat(0).take(len as usize).collect(); let act_len: c_uint = 0; let res = unsafe { ffi::X509_digest(self.handle, evp, mem::transmute(v.as_ptr()), @@ -396,7 +396,7 @@ impl<'ctx> X509<'ctx> { match res { 0 => None, _ => { - let act_len = act_len as uint; + let act_len = act_len as u32; match len.cmp(&act_len) { Ordering::Greater => None, Ordering::Equal => Some(v), @@ -514,7 +514,7 @@ make_validation_error!(X509_V_OK, #[test] fn test_negative_serial() { // I guess that's enough to get a random negative number - for _ in range(0u, 1000) { + for _ in range(0, 1000) { assert!(X509Generator::random_serial() > 0, "All serials should be positive"); } }