aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-10-31 20:15:12 -0700
committerSteven Fackler <[email protected]>2016-10-31 20:15:12 -0700
commite9d78181c334bb0398f65b30f6165ec1b54fe623 (patch)
tree6d566ea49f2547245e3b7d4db43f9367c2b15916 /openssl/src
parentUpdate PKey (diff)
downloadrust-openssl-e9d78181c334bb0398f65b30f6165ec1b54fe623.tar.xz
rust-openssl-e9d78181c334bb0398f65b30f6165ec1b54fe623.zip
Update Rsa
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/pkey.rs4
-rw-r--r--openssl/src/rsa.rs36
2 files changed, 4 insertions, 36 deletions
diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs
index 2561ab29..6236b642 100644
--- a/openssl/src/pkey.rs
+++ b/openssl/src/pkey.rs
@@ -6,7 +6,7 @@ use ffi;
use {cvt, cvt_p};
use bio::{MemBio, MemBioSlice};
use dsa::Dsa;
-use rsa::{Rsa, RsaRef};
+use rsa::Rsa;
use error::ErrorStack;
use util::{CallbackState, invoke_passwd_cb};
use types::{OpenSslType, Ref};
@@ -139,7 +139,7 @@ impl PKey {
}
/// Assign an RSA key to this pkey.
- pub fn set_rsa(&mut self, rsa: &RsaRef) -> Result<(), ErrorStack> {
+ pub fn set_rsa(&mut self, rsa: &Ref<Rsa>) -> Result<(), ErrorStack> {
unsafe {
// this needs to be a reference as the set1_RSA ups the reference count
let rsa_ptr = rsa.as_ptr();
diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs
index a12dc4d1..57a07bd1 100644
--- a/openssl/src/rsa.rs
+++ b/openssl/src/rsa.rs
@@ -2,7 +2,6 @@ use ffi;
use std::fmt;
use std::ptr;
use std::mem;
-use std::ops::Deref;
use libc::{c_int, c_void, c_char};
use {cvt, cvt_p, cvt_n};
@@ -11,7 +10,6 @@ use bio::{MemBio, MemBioSlice};
use error::ErrorStack;
use util::{CallbackState, invoke_passwd_cb};
use types::{OpenSslType, Ref};
-use opaque::Opaque;
/// Type of encryption padding to use.
#[derive(Copy, Clone)]
@@ -21,17 +19,9 @@ pub const NO_PADDING: Padding = Padding(ffi::RSA_NO_PADDING);
pub const PKCS1_PADDING: Padding = Padding(ffi::RSA_PKCS1_PADDING);
pub const PKCS1_OAEP_PADDING: Padding = Padding(ffi::RSA_PKCS1_OAEP_PADDING);
-pub struct RsaRef(Opaque);
-
-impl RsaRef {
- pub unsafe fn from_ptr<'a>(ptr: *mut ffi::RSA) -> &'a RsaRef {
- &*(ptr as *mut _)
- }
-
- pub fn as_ptr(&self) -> *mut ffi::RSA {
- self as *const _ as *mut _
- }
+type_!(Rsa, ffi::RSA, ffi::RSA_free);
+impl Ref<Rsa> {
/// Writes an RSA private key as unencrypted PEM formatted data
pub fn private_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack> {
let mem_bio = try!(MemBio::new());
@@ -219,16 +209,6 @@ impl RsaRef {
}
}
-pub struct Rsa(*mut ffi::RSA);
-
-impl Drop for Rsa {
- fn drop(&mut self) {
- unsafe {
- ffi::RSA_free(self.0);
- }
- }
-}
-
impl Rsa {
/// only useful for associating the key material directly with the key, it's safer to use
/// the supplied load and save methods for DER formatted keys.
@@ -266,10 +246,6 @@ impl Rsa {
}
}
- pub unsafe fn from_ptr(rsa: *mut ffi::RSA) -> Rsa {
- Rsa(rsa)
- }
-
/// Generates a public/private key pair with the specified size.
///
/// The public exponent will be 65537.
@@ -330,14 +306,6 @@ impl fmt::Debug for Rsa {
}
}
-impl Deref for Rsa {
- type Target = RsaRef;
-
- fn deref(&self) -> &RsaRef {
- unsafe { RsaRef::from_ptr(self.0) }
- }
-}
-
#[cfg(ossl110)]
mod compat {
use std::ptr;