Skip to content

Commit

Permalink
Reconcile exdata and version functions between libraries/versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwin committed Apr 25, 2019
1 parent 98f9176 commit d79090a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions openssl-sys/build/cfgs.rs
Expand Up @@ -13,6 +13,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
if libressl_version >= 0x2_07_00_00_0 {
cfgs.push("libressl270");
}
if libressl_version >= 0x2_07_01_00_0 {
cfgs.push("libressl271");
}
if libressl_version >= 0x2_07_03_00_0 {
cfgs.push("libressl273");
}
Expand Down
10 changes: 8 additions & 2 deletions openssl-sys/src/crypto.rs
Expand Up @@ -15,7 +15,13 @@ cfg_if! {
if #[cfg(ossl110)] {
pub const CRYPTO_EX_INDEX_SSL: c_int = 0;
pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 1;

} else if #[cfg(libressl)] {
pub const CRYPTO_EX_INDEX_SSL: c_int = 1;
pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 2;
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl271))] {
extern "C" {
pub fn OpenSSL_version_num() -> c_ulong;
pub fn OpenSSL_version(key: c_int) -> *const c_char;
Expand Down Expand Up @@ -64,7 +70,7 @@ pub type CRYPTO_EX_free = unsafe extern "C" fn(
argp: *mut c_void,
);
extern "C" {
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl))]
pub fn CRYPTO_get_ex_new_index(
class_index: c_int,
argl: c_long,
Expand Down
4 changes: 4 additions & 0 deletions openssl/build.rs
Expand Up @@ -46,6 +46,10 @@ fn main() {
println!("cargo:rustc-cfg=libressl270");
}

if version >= 0x2_07_01_00_0 {
println!("cargo:rustc-cfg=libressl271");
}

if version >= 0x2_07_03_00_0 {
println!("cargo:rustc-cfg=libressl273");
}
Expand Down
9 changes: 6 additions & 3 deletions openssl/src/ssl/mod.rs
Expand Up @@ -3833,7 +3833,12 @@ cfg_if! {
cfg_if! {
if #[cfg(any(ossl110, libressl291))] {
use ffi::{TLS_method, DTLS_method};

} else {
use ffi::{SSLv23_method as TLS_method, DTLSv1_method as DTLS_method};
}
}
cfg_if! {
if #[cfg(ossl110)] {
unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int {
ffi::CRYPTO_get_ex_new_index(
ffi::CRYPTO_EX_INDEX_SSL_CTX,
Expand All @@ -3856,8 +3861,6 @@ cfg_if! {
)
}
} else {
use ffi::{SSLv23_method as TLS_method, DTLSv1_method as DTLS_method};

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))
}
Expand Down
2 changes: 1 addition & 1 deletion openssl/src/version.rs
Expand Up @@ -14,7 +14,7 @@
use std::ffi::CStr;

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl271))] {
use ffi::{
OPENSSL_VERSION, OPENSSL_CFLAGS, OPENSSL_BUILT_ON, OPENSSL_PLATFORM, OPENSSL_DIR,
OpenSSL_version_num, OpenSSL_version,
Expand Down

0 comments on commit d79090a

Please sign in to comment.