aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/pkey.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-13 15:02:38 +0000
committerSteven Fackler <[email protected]>2016-11-13 15:02:38 +0000
commit08e0c4ca9061c3dc0c951db0c08909689b04a310 (patch)
tree117d95bb3cc28cf88cdedb97c985bbe9db436415 /openssl/src/pkey.rs
parentNo need to use a raw string anymore (diff)
downloadrust-openssl-08e0c4ca9061c3dc0c951db0c08909689b04a310.tar.xz
rust-openssl-08e0c4ca9061c3dc0c951db0c08909689b04a310.zip
Some serialization support for EcKey
Diffstat (limited to 'openssl/src/pkey.rs')
-rw-r--r--openssl/src/pkey.rs23
1 files changed, 4 insertions, 19 deletions
diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs
index 43eadd43..a56633a2 100644
--- a/openssl/src/pkey.rs
+++ b/openssl/src/pkey.rs
@@ -10,7 +10,7 @@ use dsa::Dsa;
use ec_key::EcKey;
use rsa::Rsa;
use error::ErrorStack;
-use util::{CallbackState, invoke_passwd_cb};
+use util::{CallbackState, invoke_passwd_cb_old};
use types::{OpenSslType, OpenSslTypeRef};
type_!(PKey, PKeyRef, ffi::EVP_PKEY, ffi::EVP_PKEY_free);
@@ -166,24 +166,9 @@ impl PKey {
}
}
- /// Reads a private key from PEM.
- pub fn private_key_from_pem(buf: &[u8]) -> Result<PKey, ErrorStack> {
- ffi::init();
- let mem_bio = try!(MemBioSlice::new(buf));
- unsafe {
- let evp = try!(cvt_p(ffi::PEM_read_bio_PrivateKey(mem_bio.as_ptr(),
- ptr::null_mut(),
- None,
- ptr::null_mut())));
- Ok(PKey::from_ptr(evp))
- }
- }
+ private_key_from_pem!(PKey, ffi::PEM_read_bio_PrivateKey);
- /// Read a private key from PEM, supplying a password callback to be invoked if the private key
- /// is encrypted.
- ///
- /// The callback will be passed the password buffer and should return the number of characters
- /// placed into the buffer.
+ #[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<PKey, ErrorStack>
where F: FnOnce(&mut [c_char]) -> usize
{
@@ -193,7 +178,7 @@ impl PKey {
unsafe {
let evp = try!(cvt_p(ffi::PEM_read_bio_PrivateKey(mem_bio.as_ptr(),
ptr::null_mut(),
- Some(invoke_passwd_cb::<F>),
+ Some(invoke_passwd_cb_old::<F>),
&mut cb as *mut _ as *mut c_void)));
Ok(PKey::from_ptr(evp))
}