diff options
| author | Steven Fackler <[email protected]> | 2016-10-15 15:02:02 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-10-15 15:02:02 -0700 |
| commit | 6609a81685bfd205da024523ccc395750c3fd7f3 (patch) | |
| tree | 711d819b1db7d68007899edf49230b44671c54e0 /openssl/src/crypto/pkey.rs | |
| parent | Correctly bind BIO_new_mem_buf (diff) | |
| download | rust-openssl-6609a81685bfd205da024523ccc395750c3fd7f3.tar.xz rust-openssl-6609a81685bfd205da024523ccc395750c3fd7f3.zip | |
Migrate DSA sign/verify to EVP APIs
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 { |