diff --git a/openssl-sys/src/handwritten/evp.rs b/openssl-sys/src/handwritten/evp.rs index e9a7413c2..9e277453e 100644 --- a/openssl-sys/src/handwritten/evp.rs +++ b/openssl-sys/src/handwritten/evp.rs @@ -470,8 +470,11 @@ extern "C" { pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int; pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA; + pub fn EVP_PKEY_set1_DSA(k: *mut EVP_PKEY, k: *mut DSA) -> c_int; pub fn EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA; + pub fn EVP_PKEY_set1_DH(k: *mut EVP_PKEY, k: *mut DH) -> c_int; pub fn EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH; + pub fn EVP_PKEY_set1_EC_KEY(k: *mut EVP_PKEY, k: *mut EC_KEY) -> c_int; pub fn EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY; pub fn EVP_PKEY_new() -> *mut EVP_PKEY; diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs index 544eefdad..40cf29b8a 100644 --- a/openssl/src/pkey.rs +++ b/openssl/src/pkey.rs @@ -407,38 +407,35 @@ impl Clone for PKey { impl PKey { /// Creates a new `PKey` containing an RSA key. - #[corresponds(EVP_PKEY_assign_RSA)] + #[corresponds(EVP_PKEY_set1_RSA)] pub fn from_rsa(rsa: Rsa) -> Result, ErrorStack> { unsafe { let evp = cvt_p(ffi::EVP_PKEY_new())?; let pkey = PKey::from_ptr(evp); - cvt(ffi::EVP_PKEY_assign_RSA(pkey.0, rsa.as_ptr()))?; - mem::forget(rsa); + cvt(ffi::EVP_PKEY_set1_RSA(pkey.0, rsa.as_ptr()))?; Ok(pkey) } } /// Creates a new `PKey` containing a DSA key. - #[corresponds(EVP_PKEY_assign_DSA)] + #[corresponds(EVP_PKEY_set1_DSA)] pub fn from_dsa(dsa: Dsa) -> Result, ErrorStack> { unsafe { let evp = cvt_p(ffi::EVP_PKEY_new())?; let pkey = PKey::from_ptr(evp); - cvt(ffi::EVP_PKEY_assign_DSA(pkey.0, dsa.as_ptr()))?; - mem::forget(dsa); + cvt(ffi::EVP_PKEY_set1_DSA(pkey.0, dsa.as_ptr()))?; Ok(pkey) } } /// Creates a new `PKey` containing a Diffie-Hellman key. - #[corresponds(EVP_PKEY_assign_DH)] + #[corresponds(EVP_PKEY_set1_DH)] #[cfg(not(boringssl))] pub fn from_dh(dh: Dh) -> Result, ErrorStack> { unsafe { let evp = cvt_p(ffi::EVP_PKEY_new())?; let pkey = PKey::from_ptr(evp); - cvt(ffi::EVP_PKEY_assign_DH(pkey.0, dh.as_ptr()))?; - mem::forget(dh); + cvt(ffi::EVP_PKEY_set1_DH(pkey.0, dh.as_ptr()))?; Ok(pkey) } } @@ -460,13 +457,12 @@ impl PKey { } /// Creates a new `PKey` containing an elliptic curve key. - #[corresponds(EVP_PKEY_assign_EC_KEY)] + #[corresponds(EVP_PKEY_set1_EC_KEY)] pub fn from_ec_key(ec_key: EcKey) -> Result, ErrorStack> { unsafe { let evp = cvt_p(ffi::EVP_PKEY_new())?; let pkey = PKey::from_ptr(evp); - cvt(ffi::EVP_PKEY_assign_EC_KEY(pkey.0, ec_key.as_ptr()))?; - mem::forget(ec_key); + cvt(ffi::EVP_PKEY_set1_EC_KEY(pkey.0, ec_key.as_ptr()))?; Ok(pkey) } }