Commit 7dbef567 authored by Steven Fackler's avatar Steven Fackler
Browse files

Remove some stray manual impls

parent ccef9e33
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -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);
+2 −10
Original line number Diff line number Diff line
@@ -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
+2 −12
Original line number Diff line number Diff line
@@ -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);