aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGleb Kozyrev <[email protected]>2015-01-21 18:33:48 +0200
committerGleb Kozyrev <[email protected]>2015-01-21 21:56:56 +0200
commitcb0898df37374ac99b56d40f6e933a8c4bb4cec8 (patch)
tree1eee10dde3a4c86ecd773e0da1d8bc8e2759763c /src
parentRelease v0.2.16 (diff)
downloadrust-openssl-cb0898df37374ac99b56d40f6e933a8c4bb4cec8.tar.xz
rust-openssl-cb0898df37374ac99b56d40f6e933a8c4bb4cec8.zip
Bring ffi definitions closer to the originals
Add missing return types and fix imprecise type translations. Repair the fallout in the openssl crate.
Diffstat (limited to 'src')
-rw-r--r--src/crypto/hash.rs2
-rw-r--r--src/crypto/hmac.rs2
-rw-r--r--src/crypto/pkey.rs15
-rw-r--r--src/crypto/symm.rs4
4 files changed, 12 insertions, 11 deletions
diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs
index 602a7d08..638a2254 100644
--- a/src/crypto/hash.rs
+++ b/src/crypto/hash.rs
@@ -84,7 +84,7 @@ impl Hasher {
/// Update this hasher with more input bytes
pub fn update(&mut self, data: &[u8]) {
unsafe {
- ffi::EVP_DigestUpdate(self.ctx.ptr, data.as_ptr(), data.len() as c_uint)
+ ffi::EVP_DigestUpdate(self.ctx.ptr, data.as_ptr(), data.len() as c_uint);
}
}
diff --git a/src/crypto/hmac.rs b/src/crypto/hmac.rs
index 4a0c3e77..cad96fa4 100644
--- a/src/crypto/hmac.rs
+++ b/src/crypto/hmac.rs
@@ -47,7 +47,7 @@ pub fn HMAC(ht: hash::HashType, key: &[u8]) -> HMAC {
impl HMAC {
pub fn update(&mut self, data: &[u8]) {
unsafe {
- ffi::HMAC_Update(&mut self.ctx, data.as_ptr(), data.len() as c_uint)
+ ffi::HMAC_Update(&mut self.ctx, data.as_ptr(), data.len() as c_uint);
}
}
diff --git a/src/crypto/pkey.rs b/src/crypto/pkey.rs
index 14144dc0..f2ba89dc 100644
--- a/src/crypto/pkey.rs
+++ b/src/crypto/pkey.rs
@@ -1,4 +1,4 @@
-use libc::{c_int, c_uint};
+use libc::{c_int, c_uint, c_ulong};
use std::iter::repeat;
use std::mem;
use std::ptr;
@@ -92,8 +92,8 @@ impl PKey {
pub fn gen(&mut self, keysz: usize) {
unsafe {
let rsa = ffi::RSA_generate_key(
- keysz as c_uint,
- 65537 as c_uint,
+ keysz as c_int,
+ 65537 as c_ulong,
ptr::null(),
ptr::null()
);
@@ -213,7 +213,7 @@ impl PKey {
let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
let rv = ffi::RSA_public_encrypt(
- s.len() as c_uint,
+ s.len() as c_int,
s.as_ptr(),
r.as_mut_ptr(),
rsa,
@@ -233,12 +233,12 @@ impl PKey {
let rsa = ffi::EVP_PKEY_get1_RSA(self.evp);
let len = ffi::RSA_size(rsa);
- assert_eq!(s.len() as c_uint, ffi::RSA_size(rsa));
+ assert_eq!(s.len() as c_int, ffi::RSA_size(rsa));
let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
let rv = ffi::RSA_private_decrypt(
- s.len() as c_uint,
+ s.len() as c_int,
s.as_ptr(),
r.as_mut_ptr(),
rsa,
@@ -279,9 +279,10 @@ impl PKey {
pub fn sign_with_hash(&self, s: &[u8], hash: HashType) -> Vec<u8> {
unsafe {
let rsa = ffi::EVP_PKEY_get1_RSA(self.evp);
- let mut len = ffi::RSA_size(rsa);
+ let len = ffi::RSA_size(rsa);
let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>();
+ let mut len = 0;
let rv = ffi::RSA_sign(
openssl_hash_nid(hash),
s.as_ptr(),
diff --git a/src/crypto/symm.rs b/src/crypto/symm.rs
index ccff62bb..922137c0 100644
--- a/src/crypto/symm.rs
+++ b/src/crypto/symm.rs
@@ -100,7 +100,7 @@ impl Crypter {
key.as_ptr(),
iv.as_ptr(),
mode
- )
+ );
}
}
@@ -112,7 +112,7 @@ impl Crypter {
unsafe {
let sum = data.len() + (self.blocksize as usize);
let mut res = repeat(0u8).take(sum).collect::<Vec<_>>();
- let mut reslen = sum as u32;
+ let mut reslen = sum as c_int;
ffi::EVP_CipherUpdate(
self.ctx,