Loading openssl/src/macros.rs +25 −25 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ macro_rules! private_key_from_pem { pub fn $n2(pem: &[u8], passphrase: &[u8]) -> Result<$t, ::error::ErrorStack> { unsafe { ffi::init(); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; let passphrase = ::std::ffi::CString::new(passphrase).unwrap(); cvt_p($f(bio.as_ptr(), ptr::null_mut(), Loading @@ -23,7 +23,7 @@ macro_rules! private_key_from_pem { unsafe { ffi::init(); let mut cb = ::util::CallbackState::new(callback); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; cvt_p($f(bio.as_ptr(), ptr::null_mut(), Some(::util::invoke_passwd_cb::<F>), Loading @@ -39,14 +39,14 @@ macro_rules! private_key_to_pem { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); try!(cvt($f(bio.as_ptr(), let bio = ::bio::MemBio::new()?; cvt($f(bio.as_ptr(), self.as_ptr(), ptr::null(), ptr::null_mut(), -1, None, ptr::null_mut()))); ptr::null_mut()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -58,15 +58,15 @@ macro_rules! private_key_to_pem { passphrase: &[u8] ) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); let bio = ::bio::MemBio::new()?; assert!(passphrase.len() <= ::libc::c_int::max_value() as usize); try!(cvt($f(bio.as_ptr(), cvt($f(bio.as_ptr(), self.as_ptr(), cipher.as_ptr(), passphrase.as_ptr() as *const _ as *mut _, passphrase.len() as ::libc::c_int, None, ptr::null_mut()))); ptr::null_mut()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -78,8 +78,8 @@ macro_rules! to_pem { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); try!(cvt($f(bio.as_ptr(), self.as_ptr()))); let bio = ::bio::MemBio::new()?; cvt($f(bio.as_ptr(), self.as_ptr()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -91,11 +91,11 @@ macro_rules! to_der { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let len = try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ptr::null_mut()))); let len = ::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ptr::null_mut()))?; let mut buf = vec![0; len as usize]; try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), &mut buf.as_mut_ptr()))); ::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), &mut buf.as_mut_ptr()))?; Ok(buf) } } Loading @@ -122,7 +122,7 @@ macro_rules! from_pem { pub fn $n(pem: &[u8]) -> Result<$t, ::error::ErrorStack> { unsafe { ::init(); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; cvt_p($f(bio.as_ptr(), ::std::ptr::null_mut(), None, ::std::ptr::null_mut())) .map(|p| ::foreign_types::ForeignType::from_ptr(p)) } Loading Loading
openssl/src/macros.rs +25 −25 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ macro_rules! private_key_from_pem { pub fn $n2(pem: &[u8], passphrase: &[u8]) -> Result<$t, ::error::ErrorStack> { unsafe { ffi::init(); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; let passphrase = ::std::ffi::CString::new(passphrase).unwrap(); cvt_p($f(bio.as_ptr(), ptr::null_mut(), Loading @@ -23,7 +23,7 @@ macro_rules! private_key_from_pem { unsafe { ffi::init(); let mut cb = ::util::CallbackState::new(callback); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; cvt_p($f(bio.as_ptr(), ptr::null_mut(), Some(::util::invoke_passwd_cb::<F>), Loading @@ -39,14 +39,14 @@ macro_rules! private_key_to_pem { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); try!(cvt($f(bio.as_ptr(), let bio = ::bio::MemBio::new()?; cvt($f(bio.as_ptr(), self.as_ptr(), ptr::null(), ptr::null_mut(), -1, None, ptr::null_mut()))); ptr::null_mut()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -58,15 +58,15 @@ macro_rules! private_key_to_pem { passphrase: &[u8] ) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); let bio = ::bio::MemBio::new()?; assert!(passphrase.len() <= ::libc::c_int::max_value() as usize); try!(cvt($f(bio.as_ptr(), cvt($f(bio.as_ptr(), self.as_ptr(), cipher.as_ptr(), passphrase.as_ptr() as *const _ as *mut _, passphrase.len() as ::libc::c_int, None, ptr::null_mut()))); ptr::null_mut()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -78,8 +78,8 @@ macro_rules! to_pem { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let bio = try!(::bio::MemBio::new()); try!(cvt($f(bio.as_ptr(), self.as_ptr()))); let bio = ::bio::MemBio::new()?; cvt($f(bio.as_ptr(), self.as_ptr()))?; Ok(bio.get_buf().to_owned()) } } Loading @@ -91,11 +91,11 @@ macro_rules! to_der { $(#[$m])* pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { let len = try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ptr::null_mut()))); let len = ::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ptr::null_mut()))?; let mut buf = vec![0; len as usize]; try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), &mut buf.as_mut_ptr()))); ::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), &mut buf.as_mut_ptr()))?; Ok(buf) } } Loading @@ -122,7 +122,7 @@ macro_rules! from_pem { pub fn $n(pem: &[u8]) -> Result<$t, ::error::ErrorStack> { unsafe { ::init(); let bio = try!(::bio::MemBioSlice::new(pem)); let bio = ::bio::MemBioSlice::new(pem)?; cvt_p($f(bio.as_ptr(), ::std::ptr::null_mut(), None, ::std::ptr::null_mut())) .map(|p| ::foreign_types::ForeignType::from_ptr(p)) } Loading