Loading openssl/src/crypto/pkey.rs +4 −7 Original line number Diff line number Diff line Loading @@ -208,9 +208,7 @@ impl PKey { /// pass ownership of the RSA key to this pub fn set_rsa(&mut self, rsa: RSA) { unsafe { // TODO: should we do something like panic if null? this will fail silently right now let rsa_ptr = rsa.as_ptr(); if !rsa_ptr.is_null() { if ffi::EVP_PKEY_set1_RSA(self.evp, rsa_ptr) == 1 { if rsa.has_e() && rsa.has_n() { self.parts = Parts::Public; Loading @@ -218,14 +216,13 @@ impl PKey { } } } } /// get a reference to the interal RSA key for direct access to the key components pub fn get_rsa(&self) -> RSA { unsafe { let evp_pkey: *mut ffi::EVP_PKEY = self.evp; // this is safe as the ffi increments a reference counter to the internal key RSA(ffi::EVP_PKEY_get1_RSA(evp_pkey)) RSA::with_raw(ffi::EVP_PKEY_get1_RSA(evp_pkey)) } } Loading openssl/src/crypto/rsa.rs +5 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use std::io::{self, Read}; use bn::BigNum; use bio::MemBio; pub struct RSA(pub *mut ffi::RSA); pub struct RSA(*mut ffi::RSA); impl Drop for RSA { fn drop(&mut self) { Loading @@ -27,6 +27,10 @@ impl RSA { } } pub fn with_raw(rsa: *mut ffi::RSA) -> RSA { RSA(rsa) } /// Reads an RSA private key from PEM formatted data. pub fn private_key_from_pem<R>(reader: &mut R) -> Result<RSA, SslError> where R: Read Loading Loading
openssl/src/crypto/pkey.rs +4 −7 Original line number Diff line number Diff line Loading @@ -208,9 +208,7 @@ impl PKey { /// pass ownership of the RSA key to this pub fn set_rsa(&mut self, rsa: RSA) { unsafe { // TODO: should we do something like panic if null? this will fail silently right now let rsa_ptr = rsa.as_ptr(); if !rsa_ptr.is_null() { if ffi::EVP_PKEY_set1_RSA(self.evp, rsa_ptr) == 1 { if rsa.has_e() && rsa.has_n() { self.parts = Parts::Public; Loading @@ -218,14 +216,13 @@ impl PKey { } } } } /// get a reference to the interal RSA key for direct access to the key components pub fn get_rsa(&self) -> RSA { unsafe { let evp_pkey: *mut ffi::EVP_PKEY = self.evp; // this is safe as the ffi increments a reference counter to the internal key RSA(ffi::EVP_PKEY_get1_RSA(evp_pkey)) RSA::with_raw(ffi::EVP_PKEY_get1_RSA(evp_pkey)) } } Loading
openssl/src/crypto/rsa.rs +5 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use std::io::{self, Read}; use bn::BigNum; use bio::MemBio; pub struct RSA(pub *mut ffi::RSA); pub struct RSA(*mut ffi::RSA); impl Drop for RSA { fn drop(&mut self) { Loading @@ -27,6 +27,10 @@ impl RSA { } } pub fn with_raw(rsa: *mut ffi::RSA) -> RSA { RSA(rsa) } /// Reads an RSA private key from PEM formatted data. pub fn private_key_from_pem<R>(reader: &mut R) -> Result<RSA, SslError> where R: Read Loading