diff options
| author | Gleb Kozyrev <[email protected]> | 2015-01-21 18:33:48 +0200 |
|---|---|---|
| committer | Gleb Kozyrev <[email protected]> | 2015-01-21 21:56:56 +0200 |
| commit | cb0898df37374ac99b56d40f6e933a8c4bb4cec8 (patch) | |
| tree | 1eee10dde3a4c86ecd773e0da1d8bc8e2759763c /src/crypto/pkey.rs | |
| parent | Release v0.2.16 (diff) | |
| download | rust-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/crypto/pkey.rs')
| -rw-r--r-- | src/crypto/pkey.rs | 15 |
1 files changed, 8 insertions, 7 deletions
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(), |