diff options
| author | Steven Fackler <[email protected]> | 2016-10-31 20:06:06 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-10-31 20:06:06 -0700 |
| commit | d6579ab058a22b8e7e2d82cd0d707fb3e670d5ec (patch) | |
| tree | 86173c93fd20b571e697e4e641b0ea937dbe666e /openssl/src/ec_key.rs | |
| parent | Update Dsa (diff) | |
| download | rust-openssl-d6579ab058a22b8e7e2d82cd0d707fb3e670d5ec.tar.xz rust-openssl-d6579ab058a22b8e7e2d82cd0d707fb3e670d5ec.zip | |
Update EcKey
Diffstat (limited to 'openssl/src/ec_key.rs')
| -rw-r--r-- | openssl/src/ec_key.rs | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/openssl/src/ec_key.rs b/openssl/src/ec_key.rs index 81b790aa..95175eaa 100644 --- a/openssl/src/ec_key.rs +++ b/openssl/src/ec_key.rs @@ -1,49 +1,15 @@ use ffi; -use std::ops::Deref; use cvt_p; use error::ErrorStack; use nid::Nid; -use opaque::Opaque; -pub struct EcKeyRef(Opaque); - -impl EcKeyRef { - pub unsafe fn from_ptr<'a>(ptr: *mut ffi::EC_KEY) -> &'a EcKeyRef { - &*(ptr as *mut _) - } - - pub fn as_ptr(&self) -> *mut ffi::EC_KEY { - self as *const _ as *mut _ - } -} - -pub struct EcKey(*mut ffi::EC_KEY); - -impl Drop for EcKey { - fn drop(&mut self) { - unsafe { - ffi::EC_KEY_free(self.0); - } - } -} +type_!(EcKey, ffi::EC_KEY, ffi::EC_KEY_free); impl EcKey { pub fn new_by_curve_name(nid: Nid) -> Result<EcKey, ErrorStack> { unsafe { cvt_p(ffi::EC_KEY_new_by_curve_name(nid.as_raw())).map(EcKey) } } - - pub unsafe fn from_ptr(ptr: *mut ffi::EC_KEY) -> EcKey { - EcKey(ptr) - } -} - -impl Deref for EcKey { - type Target = EcKeyRef; - - fn deref(&self) -> &EcKeyRef { - unsafe { EcKeyRef::from_ptr(self.0) } - } } #[cfg(test)] |