diff options
| author | Steven Fackler <[email protected]> | 2016-01-31 20:38:36 +0000 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-01-31 20:38:36 +0000 |
| commit | 627f394d595562346187b8210b1aeeb225223914 (patch) | |
| tree | 7a5318a5a95f466bc1e445340ead2804ef605337 /openssl/src/crypto/pkey.rs | |
| parent | Fix PKey RSA constructors (diff) | |
| download | rust-openssl-627f394d595562346187b8210b1aeeb225223914.tar.xz rust-openssl-627f394d595562346187b8210b1aeeb225223914.zip | |
Revert "Revert "impl Clone for PKey and X509 by using their 'references' member""
Diffstat (limited to 'openssl/src/crypto/pkey.rs')
| -rw-r--r-- | openssl/src/crypto/pkey.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs index 7cfa1288..e556730d 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -53,6 +53,10 @@ fn openssl_hash_nid(hash: HashType) -> c_int { } } +extern "C" { + fn rust_EVP_PKEY_clone(pkey: *mut ffi::EVP_PKEY); +} + pub struct PKey { evp: *mut ffi::EVP_PKEY, parts: Parts, @@ -585,6 +589,16 @@ impl Drop for PKey { } } +impl Clone for PKey { + fn clone(&self) -> Self { + unsafe { + rust_EVP_PKEY_clone(self.evp); + } + + PKey::from_handle(self.evp, self.parts) + } +} + #[cfg(test)] mod tests { use std::path::Path; |