diff options
| author | Steven Fackler <[email protected]> | 2016-11-13 16:52:19 +0000 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-11-13 16:52:19 +0000 |
| commit | b0415f466c4b62f949b1e47e6b1e703d1b24122b (patch) | |
| tree | 4cbe8cb2d812d10f22c7ed6ae2617f8fe50ecf62 /openssl/src/pkey.rs | |
| parent | Make password callback return a Result (diff) | |
| download | rust-openssl-b0415f466c4b62f949b1e47e6b1e703d1b24122b.tar.xz rust-openssl-b0415f466c4b62f949b1e47e6b1e703d1b24122b.zip | |
Macroise to_der
Diffstat (limited to 'openssl/src/pkey.rs')
| -rw-r--r-- | openssl/src/pkey.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs index 079a04cc..05df2f4b 100644 --- a/openssl/src/pkey.rs +++ b/openssl/src/pkey.rs @@ -50,6 +50,9 @@ impl PKeyRef { 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()); @@ -59,24 +62,6 @@ impl PKeyRef { Ok(mem_bio.get_buf().to_owned()) } - /// Encodes the public key in the DER format. - pub fn public_key_to_der(&self) -> Result<Vec<u8>, ErrorStack> { - let mem_bio = try!(MemBio::new()); - unsafe { - try!(cvt(ffi::i2d_PUBKEY_bio(mem_bio.as_ptr(), self.as_ptr()))); - } - Ok(mem_bio.get_buf().to_owned()) - } - - /// Encodes the private key in the DER format - pub fn private_key_to_der(&self) -> Result<Vec<u8>, ErrorStack> { - let mem_bio = try!(MemBio::new()); - unsafe { - try!(cvt(ffi::i2d_PrivateKey_bio(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 |