aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-01-09 10:07:03 -0800
committerSteven Fackler <[email protected]>2015-01-09 10:07:03 -0800
commit74bba7d58a6725d70e2ba4c8388c1e26fbc8cd8c (patch)
treee26eea29b731b0c6df36847923e3a51b5bb048a4 /src
parentMerge pull request #139 from vhbit/up-master (diff)
parentUpdate to rust master (diff)
downloadrust-openssl-74bba7d58a6725d70e2ba4c8388c1e26fbc8cd8c.tar.xz
rust-openssl-74bba7d58a6725d70e2ba4c8388c1e26fbc8cd8c.zip
Merge pull request #140 from alexcrichton/update
Update to rust master
Diffstat (limited to 'src')
-rw-r--r--src/asn1/mod.rs2
-rw-r--r--src/bio/mod.rs6
-rw-r--r--src/bn/mod.rs2
-rw-r--r--src/crypto/hash.rs20
-rw-r--r--src/crypto/hmac.rs6
-rw-r--r--src/crypto/pkcs5.rs26
-rw-r--r--src/crypto/pkey.rs40
-rw-r--r--src/crypto/rand.rs6
-rw-r--r--src/crypto/symm.rs41
-rwxr-xr-xsrc/lib.rs3
-rw-r--r--src/ssl/mod.rs18
-rw-r--r--src/x509/mod.rs16
12 files changed, 94 insertions, 92 deletions
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<Asn1Time, SslError> {
+ pub fn days_from_now(days: u32) -> Result<Asn1Time, SslError> {
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<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
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<u8> {
- 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<u8>, HasherContext) {
- let mut res = repeat(0u8).take(self.len).collect::<Vec<_>>();
+ let mut res = repeat(0u8).take(self.len as usize).collect::<Vec<_>>();
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<u8> {
unsafe {
- let mut res: Vec<u8> = repeat(0).take(self.len).collect();
+ let mut res: Vec<u8> = 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<u8> {
+pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: usize, keylen: usize) -> Vec<u8> {
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::<Vec<_>>();
+ let mut s = repeat(0u8).take(len as usize).collect::<Vec<_>>();
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::<Vec<_>>();
+ let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
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::<Vec<_>>();
+ let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
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::<Vec<_>>();
+ let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
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<u8> {
+pub fn rand_bytes(len: usize) -> Vec<u8> {
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<u8> {
unsafe {
- let mut res = repeat(0u8).take(data.len() + self.blocksize).collect::<Vec<_>>();
- 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::<Vec<_>>();
+ 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<u8> {
unsafe {
- let mut res = repeat(0u8).take(self.blocksize).collect::<Vec<_>>();
+ let mut res = repeat(0u8).take(self.blocksize as usize).collect::<Vec<_>>();
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<T>(&mut self, mode: SslVerifyMode,
verify: VerifyCallbackData<T>,
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<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> Option<usize> {
(&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<S: Stream> SslStream<S> {
// 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<S: Stream> SslStream<S> {
}
impl<S: Stream> Reader for SslStream<S> {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
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<S: Stream> Writer for SslStream<S> {
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<S> where S: Stream {
}
impl<S> Reader for MaybeSslStream<S> where S: Stream {
- fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
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<T> {
/// # let _ = fs::unlink(&pkey_path);
/// ```
pub struct X509Generator {
- bits: uint,
- days: uint,
+ bits: u32,
+ days: u32,
CN: String,
key_usage: Vec<KeyUsage>,
ext_key_usage: Vec<ExtKeyUsage>,
@@ -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<Vec<u8>> {
let (evp, len) = evpmd(hash_type);
- let v: Vec<u8> = repeat(0).take(len).collect();
+ let v: Vec<u8> = 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");
}
}