From 5813ca371dee64c1b2a8da53924be733c82a9421 Mon Sep 17 00:00:00 2001
From: Daniel Albert <albert_daniel@t-online.de>
Date: Fri, 1 Jan 2016 19:33:49 +0000
Subject: [PATCH] Add RSA structs

---
 openssl-sys/src/lib.rs     | 43 ++++++++++++++++++++++++++++++++++++--
 openssl/src/crypto/mod.rs  |  1 +
 openssl/src/crypto/pkey.rs |  4 ++--
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index f780b6d9c..b6d2225b3 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -22,9 +22,7 @@ pub type ENGINE = c_void;
 pub type EVP_CIPHER = c_void;
 pub type EVP_CIPHER_CTX = c_void;
 pub type EVP_MD = c_void;
-pub type EVP_PKEY = c_void;
 pub type EVP_PKEY_CTX = c_void;
-pub type RSA = c_void;
 pub type SSL = c_void;
 pub type SSL_CTX = c_void;
 pub type SSL_METHOD = c_void;
@@ -65,6 +63,47 @@ pub struct BIO_METHOD {
 // so we can create static BIO_METHODs
 unsafe impl Sync for BIO_METHOD {}
 
+#[repr(C)]
+pub struct RSA {
+    pad: c_int,
+    version: c_long,
+    meth: *const c_void,
+
+    pub engine: *mut c_void,
+    pub n: *mut BIGNUM,
+    pub e: *mut BIGNUM,
+    pub d: *mut BIGNUM,
+    pub p: *mut BIGNUM,
+    pub q: *mut BIGNUM,
+    pub dmp1: *mut BIGNUM,
+    pub dmq1: *mut BIGNUM,
+    pub iqmp: *mut BIGNUM,
+
+    ex_data: *mut c_void,
+    references: c_int,
+    flags: c_int,
+
+    _method_mod_n: *mut c_void,
+    _method_mod_p: *mut c_void,
+    _method_mod_q: *mut c_void,
+
+    bignum_data: *mut c_char,
+    blinding: *mut c_void,
+    mt_blinding: *mut c_void,
+}
+
+#[repr(C)]
+pub struct EVP_PKEY {
+    pub type_: c_int,
+    pub save_type: c_int,
+    pub references: c_int,
+    pub ameth: *const c_void,
+    engine: *mut ENGINE,
+    pub pkey: *mut c_void,
+    save_parameters: c_int,
+    attributes: *mut c_void,
+}
+
 #[repr(C)]
 pub struct BIO {
     pub method: *mut BIO_METHOD,
diff --git a/openssl/src/crypto/mod.rs b/openssl/src/crypto/mod.rs
index 0868ee95a..bb77453f6 100644
--- a/openssl/src/crypto/mod.rs
+++ b/openssl/src/crypto/mod.rs
@@ -21,5 +21,6 @@ pub mod pkey;
 pub mod rand;
 pub mod symm;
 pub mod memcmp;
+pub mod rsa;
 
 mod symm_internal;
diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs
index 108912249..25ce28e81 100644
--- a/openssl/src/crypto/pkey.rs
+++ b/openssl/src/crypto/pkey.rs
@@ -93,7 +93,7 @@ impl PKey {
                                                                  None,
                                                                  ptr::null_mut()));
             Ok(PKey {
-                evp: evp,
+                evp: evp as *mut ffi::EVP_PKEY,
                 parts: Parts::Both,
             })
         }
@@ -112,7 +112,7 @@ impl PKey {
                                                              None,
                                                              ptr::null_mut()));
             Ok(PKey {
-                evp: evp,
+                evp: evp as *mut ffi::EVP_PKEY,
                 parts: Parts::Public,
             })
         }
-- 
GitLab