aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-13 18:00:42 +0000
committerSteven Fackler <[email protected]>2016-11-13 18:00:42 +0000
commit7dbef567e6cec78adb1d7ec55735935ca7de20fd (patch)
treedc168002d2e5100caf22fbde01bc120e81cc5101 /openssl/src
parentMacroise from_pem (diff)
downloadrust-openssl-7dbef567e6cec78adb1d7ec55735935ca7de20fd.tar.xz
rust-openssl-7dbef567e6cec78adb1d7ec55735935ca7de20fd.zip
Remove some stray manual impls
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/dsa.rs12
-rw-r--r--openssl/src/pkey.rs12
-rw-r--r--openssl/src/rsa.rs14
3 files changed, 6 insertions, 32 deletions
diff --git a/openssl/src/dsa.rs b/openssl/src/dsa.rs
index fbef2c18..a4a8bf30 100644
--- a/openssl/src/dsa.rs
+++ b/openssl/src/dsa.rs
@@ -4,7 +4,7 @@ use libc::{c_int, c_char, c_void};
use std::fmt;
use std::ptr;
-use bio::{MemBio, MemBioSlice};
+use bio::MemBioSlice;
use bn::BigNumRef;
use {cvt, cvt_p};
use types::OpenSslTypeRef;
@@ -14,15 +14,7 @@ type_!(Dsa, DsaRef, ffi::DSA, ffi::DSA_free);
impl DsaRef {
private_key_to_pem!(ffi::PEM_write_bio_DSAPrivateKey);
-
- /// Encodes a DSA public key as PEM formatted data.
- pub fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack> {
- let mem_bio = try!(MemBio::new());
- unsafe {
- try!(cvt(ffi::PEM_write_bio_DSA_PUBKEY(mem_bio.as_ptr(), self.as_ptr())));
- }
- Ok(mem_bio.get_buf().to_owned())
- }
+ public_key_to_pem!(ffi::PEM_write_bio_DSA_PUBKEY);
private_key_to_der!(ffi::i2d_DSAPrivateKey);
public_key_to_der!(ffi::i2d_DSAPublicKey);
diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs
index b5ccd3cc..ee564836 100644
--- a/openssl/src/pkey.rs
+++ b/openssl/src/pkey.rs
@@ -4,7 +4,7 @@ use std::mem;
use ffi;
use {cvt, cvt_p};
-use bio::{MemBio, MemBioSlice};
+use bio::MemBioSlice;
use dh::Dh;
use dsa::Dsa;
use ec_key::EcKey;
@@ -48,20 +48,12 @@ impl PKeyRef {
}
}
+ public_key_to_pem!(ffi::PEM_write_bio_PUBKEY);
private_key_to_pem!(ffi::PEM_write_bio_PKCS8PrivateKey);
private_key_to_der!(ffi::i2d_PrivateKey);
public_key_to_der!(ffi::i2d_PUBKEY);
- /// Encodes the public key in the PEM format.
- pub fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack> {
- let mem_bio = try!(MemBio::new());
- unsafe {
- try!(cvt(ffi::PEM_write_bio_PUBKEY(mem_bio.as_ptr(), self.as_ptr())));
- }
- Ok(mem_bio.get_buf().to_owned())
- }
-
/// Returns the size of the key.
///
/// This corresponds to the bit length of the modulus of an RSA key, and the bit length of the
diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs
index 68fc9584..8c3507f4 100644
--- a/openssl/src/rsa.rs
+++ b/openssl/src/rsa.rs
@@ -6,7 +6,7 @@ use libc::{c_int, c_void, c_char};
use {cvt, cvt_p, cvt_n};
use bn::{BigNum, BigNumRef};
-use bio::{MemBio, MemBioSlice};
+use bio::MemBioSlice;
use error::ErrorStack;
use util::{CallbackState, invoke_passwd_cb_old};
use types::OpenSslTypeRef;
@@ -23,17 +23,7 @@ type_!(Rsa, RsaRef, ffi::RSA, ffi::RSA_free);
impl RsaRef {
private_key_to_pem!(ffi::PEM_write_bio_RSAPrivateKey);
-
- /// Writes an RSA public key as PEM formatted data
- pub fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack> {
- let mem_bio = try!(MemBio::new());
-
- unsafe {
- try!(cvt(ffi::PEM_write_bio_RSA_PUBKEY(mem_bio.as_ptr(), self.as_ptr())));
- }
-
- Ok(mem_bio.get_buf().to_owned())
- }
+ public_key_to_pem!(ffi::PEM_write_bio_RSA_PUBKEY);
private_key_to_der!(ffi::i2d_RSAPrivateKey);
public_key_to_der!(ffi::i2d_RSA_PUBKEY);