diff options
| author | Steven Fackler <[email protected]> | 2016-11-13 17:06:50 +0000 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-11-13 17:06:50 +0000 |
| commit | 48c0009418cbbf7c69c24b35d56e80edb0c80d45 (patch) | |
| tree | 21ab4cb2b259ea883a36865d0971c3ad65ea0722 /openssl/src/dsa.rs | |
| parent | Macroise to_der (diff) | |
| download | rust-openssl-48c0009418cbbf7c69c24b35d56e80edb0c80d45.tar.xz rust-openssl-48c0009418cbbf7c69c24b35d56e80edb0c80d45.zip | |
Macroise from_der
Diffstat (limited to 'openssl/src/dsa.rs')
| -rw-r--r-- | openssl/src/dsa.rs | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/openssl/src/dsa.rs b/openssl/src/dsa.rs index 0444ed9f..478272c8 100644 --- a/openssl/src/dsa.rs +++ b/openssl/src/dsa.rs @@ -1,9 +1,8 @@ use error::ErrorStack; use ffi; -use libc::{c_int, c_char, c_void, c_long}; +use libc::{c_int, c_char, c_void}; use std::fmt; use std::ptr; -use std::cmp; use bio::{MemBio, MemBioSlice}; use bn::BigNumRef; @@ -97,6 +96,8 @@ impl Dsa { } private_key_from_pem!(Dsa, ffi::PEM_read_bio_DSAPrivateKey); + private_key_from_der!(Dsa, ffi::d2i_DSAPrivateKey); + public_key_from_der!(Dsa, ffi::d2i_DSAPublicKey); #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] pub fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Dsa, ErrorStack> @@ -129,26 +130,6 @@ impl Dsa { Ok(Dsa(dsa)) } } - - /// Reads a DSA private key from DER formatted data. - pub fn private_key_from_der(buf: &[u8]) -> Result<Dsa, ErrorStack> { - unsafe { - ffi::init(); - let len = cmp::min(buf.len(), c_long::max_value() as usize) as c_long; - let dsa = try!(cvt_p(ffi::d2i_DSAPrivateKey(ptr::null_mut(), &mut buf.as_ptr(), len))); - Ok(Dsa(dsa)) - } - } - - /// Reads a DSA public key from DER formatted data. - pub fn public_key_from_der(buf: &[u8]) -> Result<Dsa, ErrorStack> { - unsafe { - ffi::init(); - let len = cmp::min(buf.len(), c_long::max_value() as usize) as c_long; - let dsa = try!(cvt_p(ffi::d2i_DSAPublicKey(ptr::null_mut(), &mut buf.as_ptr(), len))); - Ok(Dsa(dsa)) - } - } } impl fmt::Debug for Dsa { |