Loading openssl/src/bn/mod.rs +1 −7 Original line number Diff line number Diff line use libc::{c_int, c_ulong, c_void}; use std::ffi::{CStr, CString}; use std::cmp::Ordering; use std::{fmt, ptr, mem}; use std::{fmt, ptr}; use std::marker::PhantomData; use std::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub, Deref, DerefMut}; Loading Loading @@ -677,12 +677,6 @@ impl BigNum { }) } } pub fn into_raw(self) -> *mut ffi::BIGNUM { let ptr = self.as_ptr(); mem::forget(self); ptr } } impl Drop for BigNum { Loading openssl/src/crypto/rsa.rs +21 −10 Original line number Diff line number Diff line use ffi; use std::fmt; use std::ptr; use std::mem; use libc::{c_int, c_void, c_char, c_ulong}; use bn::{BigNum, BigNumRef}; Loading @@ -26,8 +27,10 @@ impl RSA { pub fn from_public_components(n: BigNum, e: BigNum) -> Result<RSA, ErrorStack> { unsafe { let rsa = try_ssl_null!(ffi::RSA_new()); (*rsa).n = n.into_raw(); (*rsa).e = e.into_raw(); (*rsa).n = n.as_ptr(); (*rsa).e = e.as_ptr(); mem::forget(n); mem::forget(e); Ok(RSA(rsa)) } } Loading @@ -43,14 +46,22 @@ impl RSA { -> Result<RSA, ErrorStack> { unsafe { let rsa = try_ssl_null!(ffi::RSA_new()); (*rsa).n = n.into_raw(); (*rsa).e = e.into_raw(); (*rsa).d = d.into_raw(); (*rsa).p = p.into_raw(); (*rsa).q = q.into_raw(); (*rsa).dmp1 = dp.into_raw(); (*rsa).dmq1 = dq.into_raw(); (*rsa).iqmp = qi.into_raw(); (*rsa).n = n.as_ptr(); (*rsa).e = e.as_ptr(); (*rsa).d = d.as_ptr(); (*rsa).p = p.as_ptr(); (*rsa).q = q.as_ptr(); (*rsa).dmp1 = dp.as_ptr(); (*rsa).dmq1 = dq.as_ptr(); (*rsa).iqmp = qi.as_ptr(); mem::forget(n); mem::forget(e); mem::forget(d); mem::forget(p); mem::forget(q); mem::forget(dp); mem::forget(dq); mem::forget(qi); Ok(RSA(rsa)) } } Loading openssl/src/dh/mod.rs +6 −3 Original line number Diff line number Diff line Loading @@ -10,8 +10,11 @@ impl DH { #[cfg(feature = "dh_from_params")] pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result<DH, ErrorStack> { let dh = unsafe { try_ssl_null!(::c_helpers::rust_DH_new_from_params(p.into_raw(), g.into_raw(), q.into_raw())) try_ssl_null!(::c_helpers::rust_DH_new_from_params(p.as_ptr(), g.as_ptr(), q.as_ptr())) }; mem::forget(p); mem::forget(g); mem::forget(q); Ok(DH(dh)) } Loading Loading @@ -42,7 +45,7 @@ impl DH { Ok(DH(dh)) } pub unsafe fn raw(&self) -> *mut ffi::DH { pub unsafe fn as_ptr(&self) -> *mut ffi::DH { let DH(n) = *self; n } Loading @@ -51,7 +54,7 @@ impl DH { impl Drop for DH { fn drop(&mut self) { unsafe { ffi::DH_free(self.raw()) ffi::DH_free(self.as_ptr()) } } } Loading openssl/src/ssl/mod.rs +1 −1 Original line number Diff line number Diff line Loading @@ -466,7 +466,7 @@ impl<'a> SslContextRef<'a> { } pub fn set_tmp_dh(&mut self, dh: &DH) -> Result<(), ErrorStack> { wrap_ssl_result(unsafe { ffi::SSL_CTX_set_tmp_dh(self.as_ptr(), dh.raw()) as i32 }) wrap_ssl_result(unsafe { ffi::SSL_CTX_set_tmp_dh(self.as_ptr(), dh.as_ptr()) as i32 }) } /// Use the default locations of trusted certificates for verification. Loading Loading
openssl/src/bn/mod.rs +1 −7 Original line number Diff line number Diff line use libc::{c_int, c_ulong, c_void}; use std::ffi::{CStr, CString}; use std::cmp::Ordering; use std::{fmt, ptr, mem}; use std::{fmt, ptr}; use std::marker::PhantomData; use std::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub, Deref, DerefMut}; Loading Loading @@ -677,12 +677,6 @@ impl BigNum { }) } } pub fn into_raw(self) -> *mut ffi::BIGNUM { let ptr = self.as_ptr(); mem::forget(self); ptr } } impl Drop for BigNum { Loading
openssl/src/crypto/rsa.rs +21 −10 Original line number Diff line number Diff line use ffi; use std::fmt; use std::ptr; use std::mem; use libc::{c_int, c_void, c_char, c_ulong}; use bn::{BigNum, BigNumRef}; Loading @@ -26,8 +27,10 @@ impl RSA { pub fn from_public_components(n: BigNum, e: BigNum) -> Result<RSA, ErrorStack> { unsafe { let rsa = try_ssl_null!(ffi::RSA_new()); (*rsa).n = n.into_raw(); (*rsa).e = e.into_raw(); (*rsa).n = n.as_ptr(); (*rsa).e = e.as_ptr(); mem::forget(n); mem::forget(e); Ok(RSA(rsa)) } } Loading @@ -43,14 +46,22 @@ impl RSA { -> Result<RSA, ErrorStack> { unsafe { let rsa = try_ssl_null!(ffi::RSA_new()); (*rsa).n = n.into_raw(); (*rsa).e = e.into_raw(); (*rsa).d = d.into_raw(); (*rsa).p = p.into_raw(); (*rsa).q = q.into_raw(); (*rsa).dmp1 = dp.into_raw(); (*rsa).dmq1 = dq.into_raw(); (*rsa).iqmp = qi.into_raw(); (*rsa).n = n.as_ptr(); (*rsa).e = e.as_ptr(); (*rsa).d = d.as_ptr(); (*rsa).p = p.as_ptr(); (*rsa).q = q.as_ptr(); (*rsa).dmp1 = dp.as_ptr(); (*rsa).dmq1 = dq.as_ptr(); (*rsa).iqmp = qi.as_ptr(); mem::forget(n); mem::forget(e); mem::forget(d); mem::forget(p); mem::forget(q); mem::forget(dp); mem::forget(dq); mem::forget(qi); Ok(RSA(rsa)) } } Loading
openssl/src/dh/mod.rs +6 −3 Original line number Diff line number Diff line Loading @@ -10,8 +10,11 @@ impl DH { #[cfg(feature = "dh_from_params")] pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result<DH, ErrorStack> { let dh = unsafe { try_ssl_null!(::c_helpers::rust_DH_new_from_params(p.into_raw(), g.into_raw(), q.into_raw())) try_ssl_null!(::c_helpers::rust_DH_new_from_params(p.as_ptr(), g.as_ptr(), q.as_ptr())) }; mem::forget(p); mem::forget(g); mem::forget(q); Ok(DH(dh)) } Loading Loading @@ -42,7 +45,7 @@ impl DH { Ok(DH(dh)) } pub unsafe fn raw(&self) -> *mut ffi::DH { pub unsafe fn as_ptr(&self) -> *mut ffi::DH { let DH(n) = *self; n } Loading @@ -51,7 +54,7 @@ impl DH { impl Drop for DH { fn drop(&mut self) { unsafe { ffi::DH_free(self.raw()) ffi::DH_free(self.as_ptr()) } } } Loading
openssl/src/ssl/mod.rs +1 −1 Original line number Diff line number Diff line Loading @@ -466,7 +466,7 @@ impl<'a> SslContextRef<'a> { } pub fn set_tmp_dh(&mut self, dh: &DH) -> Result<(), ErrorStack> { wrap_ssl_result(unsafe { ffi::SSL_CTX_set_tmp_dh(self.as_ptr(), dh.raw()) as i32 }) wrap_ssl_result(unsafe { ffi::SSL_CTX_set_tmp_dh(self.as_ptr(), dh.as_ptr()) as i32 }) } /// Use the default locations of trusted certificates for verification. Loading