From d6579ab058a22b8e7e2d82cd0d707fb3e670d5ec Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 31 Oct 2016 20:06:06 -0700 Subject: Update EcKey --- openssl/src/ec_key.rs | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'openssl/src/ec_key.rs') 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 { 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)] -- cgit v1.2.3