diff options
| author | Steven Fackler <[email protected]> | 2016-05-16 23:02:02 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-05-16 23:03:13 -0700 |
| commit | 2077449bc87b87f96c8ec6248c5c7060d4bc58bf (patch) | |
| tree | 765be2277cb3a02adc37a24b538bd0adcd86ef6c /openssl/src/crypto/pkey.rs | |
| parent | Merge pull request #360 from pingzing/master (diff) | |
| download | rust-openssl-2077449bc87b87f96c8ec6248c5c7060d4bc58bf.tar.xz rust-openssl-2077449bc87b87f96c8ec6248c5c7060d4bc58bf.zip | |
Clean up RSA signature API
Diffstat (limited to 'openssl/src/crypto/pkey.rs')
| -rw-r--r-- | openssl/src/crypto/pkey.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs index ba0a16b6..a97da55b 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -5,6 +5,8 @@ use std::iter::repeat; use std::mem; use std::ptr; use bio::MemBio; + +use crypto::HashTypeInternals; use crypto::hash; use crypto::hash::Type as HashType; use ffi; @@ -41,18 +43,6 @@ fn openssl_padding_code(padding: EncryptionPadding) -> c_int { } } -fn openssl_hash_nid(hash: HashType) -> c_int { - match hash { - HashType::MD5 => 4, // NID_md5, - HashType::SHA1 => 64, // NID_sha1 - HashType::SHA224 => 675, // NID_sha224 - HashType::SHA256 => 672, // NID_sha256 - HashType::SHA384 => 673, // NID_sha384 - HashType::SHA512 => 674, // NID_sha512 - HashType::RIPEMD160 => 117, // NID_ripemd160 - } -} - pub struct PKey { evp: *mut ffi::EVP_PKEY, parts: Parts, @@ -556,7 +546,7 @@ impl PKey { let mut r = repeat(0u8).take(len as usize + 1).collect::<Vec<_>>(); let mut len = 0; - let rv = ffi::RSA_sign(openssl_hash_nid(hash), + let rv = ffi::RSA_sign(hash.as_nid() as c_int, s.as_ptr(), s.len() as c_uint, r.as_mut_ptr(), @@ -579,7 +569,7 @@ impl PKey { panic!("Could not get RSA key for verification"); } - let rv = ffi::RSA_verify(openssl_hash_nid(hash), + let rv = ffi::RSA_verify(hash.as_nid() as c_int, h.as_ptr(), h.len() as c_uint, s.as_ptr(), |