diff options
| author | Steven Fackler <[email protected]> | 2016-10-31 20:04:55 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-10-31 20:04:55 -0700 |
| commit | fe5fb75d45c69a2cfca87982e57ea14876d1b795 (patch) | |
| tree | 43cc848c29634ae5e0d100765977f120d2b3a0a2 /openssl | |
| parent | Convert Dh (diff) | |
| download | rust-openssl-fe5fb75d45c69a2cfca87982e57ea14876d1b795.tar.xz rust-openssl-fe5fb75d45c69a2cfca87982e57ea14876d1b795.zip | |
Update Dsa
Diffstat (limited to 'openssl')
| -rw-r--r-- | openssl/src/dsa.rs | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/openssl/src/dsa.rs b/openssl/src/dsa.rs index c98d9c35..6efa7050 100644 --- a/openssl/src/dsa.rs +++ b/openssl/src/dsa.rs @@ -2,27 +2,17 @@ use error::ErrorStack; use ffi; use libc::{c_int, c_char, c_void}; use std::fmt; -use std::ops::Deref; use std::ptr; use bio::{MemBio, MemBioSlice}; use bn::BigNum; use {cvt, cvt_p}; -use opaque::Opaque; use types::Ref; use util::{CallbackState, invoke_passwd_cb}; -pub struct DsaRef(Opaque); - -impl DsaRef { - pub unsafe fn from_ptr<'a>(ptr: *mut ffi::DSA) -> &'a DsaRef { - &*(ptr as *mut _) - } - - pub fn as_ptr(&self) -> *mut ffi::DSA { - self as *const _ as *mut _ - } +type_!(Dsa, ffi::DSA, ffi::DSA_free); +impl Ref<Dsa> { /// Writes an DSA private key as unencrypted PEM formatted data pub fn private_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack> { assert!(self.has_private_key()); @@ -96,21 +86,7 @@ impl DsaRef { } } -pub struct Dsa(*mut ffi::DSA); - -impl Drop for Dsa { - fn drop(&mut self) { - unsafe { - ffi::DSA_free(self.0); - } - } -} - impl Dsa { - pub unsafe fn from_ptr(dsa: *mut ffi::DSA) -> Dsa { - Dsa(dsa) - } - /// Generate a DSA key pair. pub fn generate(bits: u32) -> Result<Dsa, ErrorStack> { unsafe { @@ -122,7 +98,7 @@ impl Dsa { ptr::null_mut(), ptr::null_mut(), ptr::null_mut()))); - try!(cvt(ffi::DSA_generate_key(dsa .0))); + try!(cvt(ffi::DSA_generate_key(dsa.0))); Ok(dsa) } } @@ -178,11 +154,9 @@ impl Dsa { } } -impl Deref for Dsa { - type Target = DsaRef; - - fn deref(&self) -> &DsaRef { - unsafe { DsaRef::from_ptr(self.0) } +impl fmt::Debug for Dsa { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "DSA") } } @@ -217,12 +191,6 @@ mod compat { } } -impl fmt::Debug for Dsa { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "DSA") - } -} - #[cfg(test)] mod test { use libc::c_char; |