From fe47e93f2f5b6c2b2243b15445bbfdd4e58780b1 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 5 Aug 2016 21:04:40 -0700 Subject: Fix pkey method safety --- openssl/src/crypto/pkey.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'openssl/src/crypto') diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs index ab9a4a95..9f72464b 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -63,7 +63,7 @@ impl PKey { } } - pub fn from_handle(handle: *mut ffi::EVP_PKEY, parts: Parts) -> PKey { + pub unsafe fn from_handle(handle: *mut ffi::EVP_PKEY, parts: Parts) -> PKey { ffi::init(); assert!(!handle.is_null()); @@ -587,7 +587,7 @@ impl PKey { } } - pub unsafe fn get_handle(&self) -> *mut ffi::EVP_PKEY { + pub fn handle(&self) -> *mut ffi::EVP_PKEY { return self.evp; } @@ -606,7 +606,8 @@ impl Drop for PKey { impl Clone for PKey { fn clone(&self) -> Self { - let mut pkey = PKey::from_handle(unsafe { ffi::EVP_PKEY_new() }, self.parts); + let mut pkey = unsafe { PKey::from_handle(ffi::EVP_PKEY_new(), self.parts) }; + // copy by encoding to DER and back match self.parts { Parts::Public => { -- cgit v1.2.3