diff options
| author | Steven Fackler <[email protected]> | 2016-01-19 19:59:00 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-01-19 19:59:00 -0800 |
| commit | 50bf7a933b52785ac4b5e4621813fcf28e62ddaf (patch) | |
| tree | cabb93dce85825b5000af015124f8f5444597ee9 /openssl/src/crypto | |
| parent | Fix should_panic check (diff) | |
| parent | x509: impl Clone using references & CRYPTO_add() (diff) | |
| download | rust-openssl-50bf7a933b52785ac4b5e4621813fcf28e62ddaf.tar.xz rust-openssl-50bf7a933b52785ac4b5e4621813fcf28e62ddaf.zip | |
Merge pull request #336 from jmesmon/x509-pky-clone
impl Clone for PKey and X509 by using their 'references' member
Diffstat (limited to 'openssl/src/crypto')
| -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 9d653c13..934a93ed 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -52,6 +52,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, @@ -600,6 +604,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; |