aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-06-09 21:33:35 -0700
committerSteven Fackler <[email protected]>2018-06-09 21:49:36 -0700
commit115cb730b0ec9a2010d7a803586a7fcce214cb83 (patch)
treea9559c3a76b3b8e1ce43f065eb571eb48e742d0e /openssl/src
parentMerge pull request #936 from sfackler/windows-static (diff)
downloadrust-openssl-115cb730b0ec9a2010d7a803586a7fcce214cb83.tar.xz
rust-openssl-115cb730b0ec9a2010d7a803586a7fcce214cb83.zip
Switch to accessors in libressl where possible
Some accessors are mysteriously still macros so we can't make everything opaque yet, unfortunately. cc #909
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/asn1.rs2
-rw-r--r--openssl/src/dh.rs2
-rw-r--r--openssl/src/dsa.rs2
-rw-r--r--openssl/src/ecdsa.rs2
-rw-r--r--openssl/src/rsa.rs2
-rw-r--r--openssl/src/ssl/bio.rs2
-rw-r--r--openssl/src/ssl/mod.rs77
-rw-r--r--openssl/src/symm.rs2
-rw-r--r--openssl/src/x509/mod.rs52
9 files changed, 75 insertions, 68 deletions
diff --git a/openssl/src/asn1.rs b/openssl/src/asn1.rs
index 03546a4d..633407ea 100644
--- a/openssl/src/asn1.rs
+++ b/openssl/src/asn1.rs
@@ -297,7 +297,7 @@ impl fmt::Display for Asn1ObjectRef {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::ASN1_STRING_get0_data;
} else {
#[allow(bad_style)]
diff --git a/openssl/src/dh.rs b/openssl/src/dh.rs
index 730a5180..478e794f 100644
--- a/openssl/src/dh.rs
+++ b/openssl/src/dh.rs
@@ -107,7 +107,7 @@ impl Dh<Params> {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::DH_set0_pqg;
} else {
#[allow(bad_style)]
diff --git a/openssl/src/dsa.rs b/openssl/src/dsa.rs
index abc2e297..e8d78dcb 100644
--- a/openssl/src/dsa.rs
+++ b/openssl/src/dsa.rs
@@ -188,7 +188,7 @@ impl<T> fmt::Debug for Dsa<T> {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::DSA_get0_pqg;
} else {
#[allow(bad_style)]
diff --git a/openssl/src/ecdsa.rs b/openssl/src/ecdsa.rs
index d07dfda4..4edbbf50 100644
--- a/openssl/src/ecdsa.rs
+++ b/openssl/src/ecdsa.rs
@@ -105,7 +105,7 @@ impl EcdsaSig {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::{ECDSA_SIG_set0, ECDSA_SIG_get0};
} else {
#[allow(bad_style)]
diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs
index 92a5799e..d2131d28 100644
--- a/openssl/src/rsa.rs
+++ b/openssl/src/rsa.rs
@@ -645,7 +645,7 @@ impl<T> fmt::Debug for Rsa<T> {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::{
RSA_get0_key, RSA_get0_factors, RSA_get0_crt_params, RSA_set0_key, RSA_set0_factors,
RSA_set0_crt_params,
diff --git a/openssl/src/ssl/bio.rs b/openssl/src/ssl/bio.rs
index 1a149b6d..c1c5f871 100644
--- a/openssl/src/ssl/bio.rs
+++ b/openssl/src/ssl/bio.rs
@@ -175,7 +175,7 @@ unsafe extern "C" fn destroy<S>(bio: *mut BIO) -> c_int {
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::{BIO_get_data, BIO_set_data, BIO_set_flags, BIO_set_init};
#[allow(bad_style)]
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index e5a31e63..cd808829 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -3307,44 +3307,9 @@ pub enum ShutdownResult {
}
cfg_if! {
- if #[cfg(ossl110)] {
- use ffi::{
- SSL_CTX_up_ref,
- SSL_SESSION_get_master_key, SSL_SESSION_up_ref, SSL_is_server, TLS_method, DTLS_method,
- };
-
- pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int {
- ffi::CRYPTO_get_ex_new_index(
- ffi::CRYPTO_EX_INDEX_SSL_CTX,
- 0,
- ptr::null_mut(),
- None,
- None,
- Some(f),
- )
- }
-
- pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int {
- ffi::CRYPTO_get_ex_new_index(
- ffi::CRYPTO_EX_INDEX_SSL,
- 0,
- ptr::null_mut(),
- None,
- None,
- Some(f),
- )
- }
+ if #[cfg(any(ossl110, libressl273))] {
+ use ffi::{SSL_CTX_up_ref, SSL_SESSION_get_master_key, SSL_SESSION_up_ref, SSL_is_server};
} else {
- use ffi::{SSLv23_method as TLS_method, DTLSv1_method as DTLS_method};
-
- pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int {
- ffi::SSL_CTX_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f))
- }
-
- pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int {
- ffi::SSL_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f))
- }
-
#[allow(bad_style)]
pub unsafe fn SSL_CTX_up_ref(ssl: *mut ffi::SSL_CTX) -> c_int {
ffi::CRYPTO_add_lock(
@@ -3391,3 +3356,41 @@ cfg_if! {
}
}
}
+
+cfg_if! {
+ if #[cfg(ossl110)] {
+ use ffi::{TLS_method, DTLS_method};
+
+ pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int {
+ ffi::CRYPTO_get_ex_new_index(
+ ffi::CRYPTO_EX_INDEX_SSL_CTX,
+ 0,
+ ptr::null_mut(),
+ None,
+ None,
+ Some(f),
+ )
+ }
+
+ pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int {
+ ffi::CRYPTO_get_ex_new_index(
+ ffi::CRYPTO_EX_INDEX_SSL,
+ 0,
+ ptr::null_mut(),
+ None,
+ None,
+ Some(f),
+ )
+ }
+ } else {
+ use ffi::{SSLv23_method as TLS_method, DTLSv1_method as DTLS_method};
+
+ pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int {
+ ffi::SSL_CTX_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f))
+ }
+
+ pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int {
+ ffi::SSL_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f))
+ }
+ }
+}
diff --git a/openssl/src/symm.rs b/openssl/src/symm.rs
index 33655874..0eab884b 100644
--- a/openssl/src/symm.rs
+++ b/openssl/src/symm.rs
@@ -719,7 +719,7 @@ pub fn decrypt_aead(
}
cfg_if! {
- if #[cfg(ossl110)] {
+ if #[cfg(any(ossl110, libressl273))] {
use ffi::{EVP_CIPHER_block_size, EVP_CIPHER_iv_length, EVP_CIPHER_key_length};
} else {
#[allow(bad_style)]
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs
index 5c1bb23f..a07fc1f1 100644
--- a/openssl/src/x509/mod.rs
+++ b/openssl/src/x509/mod.rs
@@ -1245,21 +1245,9 @@ impl X509AlgorithmRef {
}
cfg_if! {
- if #[cfg(ossl110)] {
- use ffi::{
- X509_ALGOR_get0, X509_REQ_get_subject_name, X509_REQ_get_version,
- X509_get0_signature, X509_getm_notAfter, X509_getm_notBefore, X509_up_ref,
- ASN1_STRING_get0_data, X509_STORE_CTX_get0_chain, X509_set1_notAfter,
- X509_set1_notBefore,
- };
+ if #[cfg(any(ossl110, libressl273))] {
+ use ffi::{X509_getm_notAfter, X509_getm_notBefore, X509_up_ref, X509_get0_signature};
} else {
- use ffi::{
- ASN1_STRING_data as ASN1_STRING_get0_data,
- X509_STORE_CTX_get_chain as X509_STORE_CTX_get0_chain,
- X509_set_notAfter as X509_set1_notAfter,
- X509_set_notBefore as X509_set1_notBefore,
- };
-
#[allow(bad_style)]
unsafe fn X509_getm_notAfter(x: *mut ffi::X509) -> *mut ffi::ASN1_TIME {
(*(*(*x).cert_info).validity).notAfter
@@ -1282,16 +1270,6 @@ cfg_if! {
}
#[allow(bad_style)]
- unsafe fn X509_REQ_get_version(x: *mut ffi::X509_REQ) -> ::libc::c_long {
- ffi::ASN1_INTEGER_get((*(*x).req_info).version)
- }
-
- #[allow(bad_style)]
- unsafe fn X509_REQ_get_subject_name(x: *mut ffi::X509_REQ) -> *mut ::ffi::X509_NAME {
- (*(*x).req_info).subject
- }
-
- #[allow(bad_style)]
unsafe fn X509_get0_signature(
psig: *mut *const ffi::ASN1_BIT_STRING,
palg: *mut *const ffi::X509_ALGOR,
@@ -1304,6 +1282,32 @@ cfg_if! {
*palg = (*x).sig_alg;
}
}
+ }
+}
+
+cfg_if! {
+ if #[cfg(ossl110)] {
+ use ffi::{
+ X509_ALGOR_get0, ASN1_STRING_get0_data, X509_STORE_CTX_get0_chain, X509_set1_notAfter,
+ X509_set1_notBefore, X509_REQ_get_version, X509_REQ_get_subject_name,
+ };
+ } else {
+ use ffi::{
+ ASN1_STRING_data as ASN1_STRING_get0_data,
+ X509_STORE_CTX_get_chain as X509_STORE_CTX_get0_chain,
+ X509_set_notAfter as X509_set1_notAfter,
+ X509_set_notBefore as X509_set1_notBefore,
+ };
+
+ #[allow(bad_style)]
+ unsafe fn X509_REQ_get_version(x: *mut ffi::X509_REQ) -> ::libc::c_long {
+ ffi::ASN1_INTEGER_get((*(*x).req_info).version)
+ }
+
+ #[allow(bad_style)]
+ unsafe fn X509_REQ_get_subject_name(x: *mut ffi::X509_REQ) -> *mut ::ffi::X509_NAME {
+ (*(*x).req_info).subject
+ }
#[allow(bad_style)]
unsafe fn X509_ALGOR_get0(