diff options
| author | Steven Fackler <[email protected]> | 2016-10-15 17:03:17 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-10-15 17:03:17 -0700 |
| commit | fdb4131064412cdd0542e55cc1187cebb52bcc58 (patch) | |
| tree | 80d538b8002fbc9574a21201a39af4bdff0c1cb9 /openssl/src/crypto/pkey.rs | |
| parent | Correctly bind BIO_new_mem_buf (diff) | |
| parent | Fix set_read_ahead signature (diff) | |
| download | rust-openssl-fdb4131064412cdd0542e55cc1187cebb52bcc58.tar.xz rust-openssl-fdb4131064412cdd0542e55cc1187cebb52bcc58.zip | |
Merge pull request #475 from sfackler/no-enums
Turn enums into structs
Diffstat (limited to 'openssl/src/crypto/pkey.rs')
| -rw-r--r-- | openssl/src/crypto/pkey.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs index 8b408d29..67ff7520 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -4,6 +4,7 @@ use std::mem; use ffi; use bio::{MemBio, MemBioSlice}; +use crypto::dsa::DSA; use crypto::rsa::RSA; use error::ErrorStack; use crypto::util::{CallbackState, invoke_passwd_cb}; @@ -26,6 +27,17 @@ impl PKey { } } + /// Create a new `PKey` containing a DSA key. + pub fn from_dsa(dsa: DSA) -> Result<PKey, ErrorStack> { + unsafe { + let evp = try_ssl_null!(ffi::EVP_PKEY_new()); + let pkey = PKey(evp); + try_ssl!(ffi::EVP_PKEY_assign(pkey.0, ffi::EVP_PKEY_DSA, dsa.as_ptr() as *mut _)); + mem::forget(dsa); + Ok(pkey) + } + } + /// Create a new `PKey` containing an HMAC key. pub fn hmac(key: &[u8]) -> Result<PKey, ErrorStack> { unsafe { |