Loading openssl-sys/src/crypto.rs +27 −1 Original line number Diff line number Diff line use libc::*; use *; cfg_if! { if #[cfg(ossl110)] { #[inline] #[track_caller] pub unsafe fn OPENSSL_malloc(num: usize) -> *mut c_void { CRYPTO_malloc(num, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } #[inline] #[track_caller] pub unsafe fn OPENSSL_free(addr: *mut c_void) { CRYPTO_free(addr, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } } else { #[inline] #[track_caller] pub unsafe fn OPENSSL_malloc(num: c_int) -> *mut c_void { CRYPTO_malloc(num, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } #[inline] pub unsafe fn CRYPTO_free(addr: *mut c_void) { CRYPTO_free(addr) } } } #[cfg(not(ossl110))] pub const CRYPTO_LOCK_X509: c_int = 3; #[cfg(not(ossl110))] Loading openssl/src/encrypt.rs +2 −13 Original line number Diff line number Diff line Loading @@ -169,11 +169,7 @@ impl<'a> Encrypter<'a> { #[cfg(any(ossl102, libressl310))] pub fn set_rsa_oaep_label(&mut self, label: &[u8]) -> Result<(), ErrorStack> { unsafe { let p = cvt_p(ffi::CRYPTO_malloc( label.len() as _, concat!(file!(), "\0").as_ptr() as *const _, line!() as c_int, ))?; let p = cvt_p(ffi::OPENSSL_malloc(label.len() as _))?; ptr::copy_nonoverlapping(label.as_ptr(), p as *mut u8, label.len()); cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label( Loading @@ -183,14 +179,7 @@ impl<'a> Encrypter<'a> { )) .map(|_| ()) .map_err(|e| { #[cfg(not(ossl110))] ::ffi::CRYPTO_free(p as *mut c_void); #[cfg(ossl110)] ::ffi::CRYPTO_free( p as *mut c_void, concat!(file!(), "\0").as_ptr() as *const _, line!() as c_int, ); ffi::OPENSSL_free(p); e }) } Loading openssl/src/md.rs +1 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,7 @@ impl Md { unsafe { MdRef::from_ptr(ffi::EVP_ripemd160() as *mut _) } } #[cfg(not(osslconf = "OPENSSL_NO_SM3"))] #[cfg(all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3")))] #[inline] pub fn sm3() -> &'static MdRef { unsafe { MdRef::from_ptr(ffi::EVP_sm3() as *mut _) } Loading openssl/src/pkey.rs +2 −0 Original line number Diff line number Diff line Loading @@ -40,11 +40,13 @@ //! println!("{:?}", str::from_utf8(pub_key.as_slice()).unwrap()); //! ``` use crate::bio::{MemBio, MemBioSlice}; #[cfg(ossl110)] use crate::cipher::CipherRef; use crate::dh::Dh; use crate::dsa::Dsa; use crate::ec::EcKey; use crate::error::ErrorStack; #[cfg(ossl110)] use crate::pkey_ctx::PkeyCtx; use crate::rsa::Rsa; use crate::symm::Cipher; Loading openssl/src/pkey_ctx.rs +3 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,8 @@ use crate::error::ErrorStack; use crate::md::MdRef; use crate::pkey::{HasPrivate, HasPublic, Id, PKey, PKeyRef, Private}; use crate::rsa::Padding; #[cfg(any(ossl102, libressl310))] use crate::util; use crate::{cvt, cvt_p}; use foreign_types::{ForeignType, ForeignTypeRef}; #[cfg(any(ossl102, libressl310))] use libc::c_int; use std::convert::TryFrom; use std::ptr; Loading Loading @@ -354,12 +351,12 @@ impl<T> PkeyCtxRef<T> { let len = c_int::try_from(label.len()).unwrap(); unsafe { let p = util::crypto_malloc(label.len())?; let p = ffi::OPENSSL_malloc(label.len() as _); ptr::copy_nonoverlapping(label.as_ptr(), p as *mut _, label.len()); let r = cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label(self.as_ptr(), p, len)); if r.is_err() { util::crypto_free(p); ffi::OPENSSL_free(p); } r?; } Loading Loading @@ -428,6 +425,7 @@ mod test { use super::*; use crate::cipher::Cipher; use crate::ec::{EcGroup, EcKey}; #[cfg(any(ossl102, libressl310))] use crate::md::Md; use crate::nid::Nid; use crate::pkey::PKey; Loading Loading
openssl-sys/src/crypto.rs +27 −1 Original line number Diff line number Diff line use libc::*; use *; cfg_if! { if #[cfg(ossl110)] { #[inline] #[track_caller] pub unsafe fn OPENSSL_malloc(num: usize) -> *mut c_void { CRYPTO_malloc(num, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } #[inline] #[track_caller] pub unsafe fn OPENSSL_free(addr: *mut c_void) { CRYPTO_free(addr, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } } else { #[inline] #[track_caller] pub unsafe fn OPENSSL_malloc(num: c_int) -> *mut c_void { CRYPTO_malloc(num, concat!(file!(), "\0").as_ptr() as *const _, line!() as _) } #[inline] pub unsafe fn CRYPTO_free(addr: *mut c_void) { CRYPTO_free(addr) } } } #[cfg(not(ossl110))] pub const CRYPTO_LOCK_X509: c_int = 3; #[cfg(not(ossl110))] Loading
openssl/src/encrypt.rs +2 −13 Original line number Diff line number Diff line Loading @@ -169,11 +169,7 @@ impl<'a> Encrypter<'a> { #[cfg(any(ossl102, libressl310))] pub fn set_rsa_oaep_label(&mut self, label: &[u8]) -> Result<(), ErrorStack> { unsafe { let p = cvt_p(ffi::CRYPTO_malloc( label.len() as _, concat!(file!(), "\0").as_ptr() as *const _, line!() as c_int, ))?; let p = cvt_p(ffi::OPENSSL_malloc(label.len() as _))?; ptr::copy_nonoverlapping(label.as_ptr(), p as *mut u8, label.len()); cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label( Loading @@ -183,14 +179,7 @@ impl<'a> Encrypter<'a> { )) .map(|_| ()) .map_err(|e| { #[cfg(not(ossl110))] ::ffi::CRYPTO_free(p as *mut c_void); #[cfg(ossl110)] ::ffi::CRYPTO_free( p as *mut c_void, concat!(file!(), "\0").as_ptr() as *const _, line!() as c_int, ); ffi::OPENSSL_free(p); e }) } Loading
openssl/src/md.rs +1 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,7 @@ impl Md { unsafe { MdRef::from_ptr(ffi::EVP_ripemd160() as *mut _) } } #[cfg(not(osslconf = "OPENSSL_NO_SM3"))] #[cfg(all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3")))] #[inline] pub fn sm3() -> &'static MdRef { unsafe { MdRef::from_ptr(ffi::EVP_sm3() as *mut _) } Loading
openssl/src/pkey.rs +2 −0 Original line number Diff line number Diff line Loading @@ -40,11 +40,13 @@ //! println!("{:?}", str::from_utf8(pub_key.as_slice()).unwrap()); //! ``` use crate::bio::{MemBio, MemBioSlice}; #[cfg(ossl110)] use crate::cipher::CipherRef; use crate::dh::Dh; use crate::dsa::Dsa; use crate::ec::EcKey; use crate::error::ErrorStack; #[cfg(ossl110)] use crate::pkey_ctx::PkeyCtx; use crate::rsa::Rsa; use crate::symm::Cipher; Loading
openssl/src/pkey_ctx.rs +3 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,8 @@ use crate::error::ErrorStack; use crate::md::MdRef; use crate::pkey::{HasPrivate, HasPublic, Id, PKey, PKeyRef, Private}; use crate::rsa::Padding; #[cfg(any(ossl102, libressl310))] use crate::util; use crate::{cvt, cvt_p}; use foreign_types::{ForeignType, ForeignTypeRef}; #[cfg(any(ossl102, libressl310))] use libc::c_int; use std::convert::TryFrom; use std::ptr; Loading Loading @@ -354,12 +351,12 @@ impl<T> PkeyCtxRef<T> { let len = c_int::try_from(label.len()).unwrap(); unsafe { let p = util::crypto_malloc(label.len())?; let p = ffi::OPENSSL_malloc(label.len() as _); ptr::copy_nonoverlapping(label.as_ptr(), p as *mut _, label.len()); let r = cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label(self.as_ptr(), p, len)); if r.is_err() { util::crypto_free(p); ffi::OPENSSL_free(p); } r?; } Loading Loading @@ -428,6 +425,7 @@ mod test { use super::*; use crate::cipher::Cipher; use crate::ec::{EcGroup, EcKey}; #[cfg(any(ossl102, libressl310))] use crate::md::Md; use crate::nid::Nid; use crate::pkey::PKey; Loading