Remove ossl110 gate

This commit is contained in:
Ivan Nikulin 2020-11-11 14:08:37 +00:00
parent 7d9a77e916
commit 9bd7645701
42 changed files with 198 additions and 1976 deletions

View File

@ -185,14 +185,6 @@ fn main() {
let build_dir = format!("{}/build/{}", bssl_dir, build_path); let build_dir = format!("{}/build/{}", bssl_dir, build_path);
println!("cargo:rustc-link-search=native={}", build_dir); println!("cargo:rustc-link-search=native={}", build_dir);
let mut cfgs = vec![];
cfgs.push("ossl110");
for cfg in cfgs {
println!("cargo:rustc-cfg={}", cfg);
}
println!("cargo:rustc-link-lib=static=crypto"); println!("cargo:rustc-link-lib=static=crypto");
println!("cargo:rustc-link-lib=static=ssl"); println!("cargo:rustc-link-lib=static=ssl");

View File

@ -26,7 +26,6 @@ stack!(stack_st_ASN1_OBJECT);
extern "C" { extern "C" {
pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING; pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING;
#[cfg(any(ossl110, libressl273))]
pub fn ASN1_STRING_get0_data(x: *const ASN1_STRING) -> *const c_uchar; pub fn ASN1_STRING_get0_data(x: *const ASN1_STRING) -> *const c_uchar;
pub fn ASN1_BIT_STRING_free(x: *mut ASN1_BIT_STRING); pub fn ASN1_BIT_STRING_free(x: *mut ASN1_BIT_STRING);

View File

@ -36,51 +36,22 @@ pub const BIO_FLAGS_SHOULD_RETRY: c_int = 0x08;
pub type bio_info_cb = pub type bio_info_cb =
Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long)>; Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long)>;
cfg_if! { pub enum BIO_METHOD {}
if #[cfg(any(ossl110, libressl280))] {
pub enum BIO_METHOD {}
} else {
#[repr(C)]
pub struct BIO_METHOD {
pub type_: c_int,
pub name: *const c_char,
pub bwrite: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char, c_int) -> c_int>,
pub bread: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>,
pub bputs: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char) -> c_int>,
pub bgets: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>,
pub ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, c_long, *mut c_void) -> c_long>,
pub create: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>,
pub destroy: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>,
pub callback_ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, ::bio_info_cb) -> c_long>,
}
}
}
pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long { pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void) BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void)
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn BIO_s_file() -> *const BIO_METHOD; pub fn BIO_s_file() -> *const BIO_METHOD;
pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO; pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
}
} else {
extern "C" {
pub fn BIO_s_file() -> *mut BIO_METHOD;
pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO;
}
}
} }
extern "C" { extern "C" {
#[cfg(not(osslconf = "OPENSSL_NO_STDIO"))] #[cfg(not(osslconf = "OPENSSL_NO_STDIO"))]
pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO; pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_set_data(a: *mut ::BIO, data: *mut c_void); pub fn BIO_set_data(a: *mut ::BIO, data: *mut c_void);
#[cfg(any(ossl110, libressl273))]
pub fn BIO_get_data(a: *mut ::BIO) -> *mut c_void; pub fn BIO_get_data(a: *mut ::BIO) -> *mut c_void;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_set_init(a: *mut ::BIO, init: c_int); pub fn BIO_set_init(a: *mut ::BIO, init: c_int);
pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int; pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int; pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
@ -88,16 +59,8 @@ extern "C" {
pub fn BIO_free_all(b: *mut BIO); pub fn BIO_free_all(b: *mut BIO);
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn BIO_s_mem() -> *const BIO_METHOD; pub fn BIO_s_mem() -> *const BIO_METHOD;
}
} else {
extern "C" {
pub fn BIO_s_mem() -> *mut BIO_METHOD;
}
}
} }
extern "C" { extern "C" {
@ -107,37 +70,29 @@ extern "C" {
extern "C" { extern "C" {
pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO; pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut BIO_METHOD; pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut BIO_METHOD;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_free(biom: *mut BIO_METHOD); pub fn BIO_meth_free(biom: *mut BIO_METHOD);
// FIXME should wrap in Option // FIXME should wrap in Option
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_write( pub fn BIO_meth_set_write(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
write: unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int, write: unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_read( pub fn BIO_meth_set_read(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
read: unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int, read: unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_puts( pub fn BIO_meth_set_puts(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
read: unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int, read: unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_ctrl( pub fn BIO_meth_set_ctrl(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
read: unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long, read: unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_create( pub fn BIO_meth_set_create(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
create: unsafe extern "C" fn(*mut BIO) -> c_int, create: unsafe extern "C" fn(*mut BIO) -> c_int,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn BIO_meth_set_destroy( pub fn BIO_meth_set_destroy(
biom: *mut BIO_METHOD, biom: *mut BIO_METHOD,
destroy: unsafe extern "C" fn(*mut BIO) -> c_int, destroy: unsafe extern "C" fn(*mut BIO) -> c_int,

View File

@ -24,7 +24,6 @@ extern "C" {
pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int); pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int);
#[cfg(ossl110)]
pub fn BN_is_negative(b: *const ::BIGNUM) -> c_int; pub fn BN_is_negative(b: *const ::BIGNUM) -> c_int;
pub fn BN_div( pub fn BN_div(

View File

@ -2,40 +2,17 @@ use libc::*;
use *; use *;
#[cfg(not(ossl110))]
pub const CRYPTO_LOCK_X509: c_int = 3;
#[cfg(not(ossl110))]
pub const CRYPTO_LOCK_EVP_PKEY: c_int = 10;
#[cfg(not(ossl110))]
pub const CRYPTO_LOCK_SSL_CTX: c_int = 12;
#[cfg(not(ossl110))]
pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14;
stack!(stack_st_void); stack!(stack_st_void);
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl271))] {
extern "C" {
pub fn OpenSSL_version_num() -> c_ulong; pub fn OpenSSL_version_num() -> c_ulong;
pub fn OpenSSL_version(key: c_int) -> *const c_char; pub fn OpenSSL_version(key: c_int) -> *const c_char;
}
pub const OPENSSL_VERSION: c_int = 0;
pub const OPENSSL_CFLAGS: c_int = 1;
pub const OPENSSL_BUILT_ON: c_int = 2;
pub const OPENSSL_PLATFORM: c_int = 3;
pub const OPENSSL_DIR: c_int = 4;
} else {
extern "C" {
pub fn SSLeay() -> c_ulong;
pub fn SSLeay_version(key: c_int) -> *const c_char;
}
pub const SSLEAY_VERSION: c_int = 0;
pub const SSLEAY_CFLAGS: c_int = 2;
pub const SSLEAY_BUILT_ON: c_int = 3;
pub const SSLEAY_PLATFORM: c_int = 4;
pub const SSLEAY_DIR: c_int = 5;
}
} }
pub const OPENSSL_VERSION: c_int = 0;
pub const OPENSSL_CFLAGS: c_int = 1;
pub const OPENSSL_BUILT_ON: c_int = 2;
pub const OPENSSL_PLATFORM: c_int = 3;
pub const OPENSSL_DIR: c_int = 4;
// FIXME should be options // FIXME should be options
pub type CRYPTO_EX_new = unsafe extern "C" fn( pub type CRYPTO_EX_new = unsafe extern "C" fn(
@ -65,27 +42,6 @@ pub type CRYPTO_EX_free = unsafe extern "C" fn(
pub const CRYPTO_LOCK: c_int = 1; pub const CRYPTO_LOCK: c_int = 1;
extern "C" {
#[cfg(not(ossl110))]
pub fn CRYPTO_num_locks() -> c_int;
#[cfg(not(ossl110))]
pub fn CRYPTO_set_locking_callback(
func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int),
);
#[cfg(not(ossl110))]
pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong);
#[cfg(not(ossl110))]
pub fn CRYPTO_add_lock(
pointer: *mut c_int,
amount: c_int,
type_: c_int,
file: *const c_char,
line: c_int,
) -> c_int;
}
extern "C" { extern "C" {
pub fn OPENSSL_malloc(num: size_t) -> *mut c_void; pub fn OPENSSL_malloc(num: size_t) -> *mut c_void;
pub fn OPENSSL_free(buf: *mut c_void); pub fn OPENSSL_free(buf: *mut c_void);

View File

@ -7,6 +7,5 @@ extern "C" {
pub fn d2i_DHparams(k: *mut *mut DH, pp: *mut *const c_uchar, length: c_long) -> *mut DH; pub fn d2i_DHparams(k: *mut *mut DH, pp: *mut *const c_uchar, length: c_long) -> *mut DH;
pub fn i2d_DHparams(dh: *const DH, pp: *mut *mut c_uchar) -> c_int; pub fn i2d_DHparams(dh: *const DH, pp: *mut *mut c_uchar) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn DH_set0_pqg(dh: *mut DH, p: *mut BIGNUM, q: *mut BIGNUM, g: *mut BIGNUM) -> c_int; pub fn DH_set0_pqg(dh: *mut DH, p: *mut BIGNUM, q: *mut BIGNUM, g: *mut BIGNUM) -> c_int;
} }

View File

@ -44,17 +44,13 @@ extern "C" {
pub fn i2d_DSAPublicKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int; pub fn i2d_DSAPublicKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int;
pub fn i2d_DSAPrivateKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int; pub fn i2d_DSAPrivateKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn DSA_get0_pqg( pub fn DSA_get0_pqg(
d: *const DSA, d: *const DSA,
p: *mut *const BIGNUM, p: *mut *const BIGNUM,
q: *mut *const BIGNUM, q: *mut *const BIGNUM,
q: *mut *const BIGNUM, q: *mut *const BIGNUM,
); );
#[cfg(any(ossl110, libressl273))]
pub fn DSA_set0_pqg(d: *mut DSA, p: *mut BIGNUM, q: *mut BIGNUM, q: *mut BIGNUM) -> c_int; pub fn DSA_set0_pqg(d: *mut DSA, p: *mut BIGNUM, q: *mut BIGNUM, q: *mut BIGNUM) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn DSA_get0_key(d: *const DSA, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM); pub fn DSA_get0_key(d: *const DSA, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM);
#[cfg(any(ossl110, libressl273))]
pub fn DSA_set0_key(d: *mut DSA, pub_key: *mut BIGNUM, priv_key: *mut BIGNUM) -> c_int; pub fn DSA_set0_key(d: *mut DSA, pub_key: *mut BIGNUM, priv_key: *mut BIGNUM) -> c_int;
} }

View File

@ -47,7 +47,6 @@ extern "C" {
pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_uint; pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_uint;
#[cfg(ossl110)]
pub fn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int; pub fn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int;
pub fn EC_GROUP_new_curve_GFp( pub fn EC_GROUP_new_curve_GFp(
@ -149,27 +148,15 @@ extern "C" {
) -> c_int; ) -> c_int;
} }
cfg_if! { pub enum ECDSA_SIG {}
if #[cfg(any(ossl110, libressl280))] {
pub enum ECDSA_SIG {}
} else {
#[repr(C)]
pub struct ECDSA_SIG {
pub r: *mut BIGNUM,
pub s: *mut BIGNUM,
}
}
}
extern "C" { extern "C" {
pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG; pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG;
pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG); pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG);
#[cfg(any(ossl110, libressl273))]
pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM); pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM);
#[cfg(any(ossl110, libressl273))]
pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int; pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int;
pub fn ECDSA_do_sign( pub fn ECDSA_do_sign(

View File

@ -40,7 +40,6 @@ extern "C" {
pub fn ERR_lib_error_string(err: c_uint) -> *const c_char; pub fn ERR_lib_error_string(err: c_uint) -> *const c_char;
pub fn ERR_func_error_string(err: c_uint) -> *const c_char; pub fn ERR_func_error_string(err: c_uint) -> *const c_char;
pub fn ERR_reason_error_string(err: c_uint) -> *const c_char; pub fn ERR_reason_error_string(err: c_uint) -> *const c_char;
#[cfg(not(ossl110))]
pub fn ERR_load_crypto_strings(); pub fn ERR_load_crypto_strings();
pub fn ERR_get_next_error_library() -> c_int; pub fn ERR_get_next_error_library() -> c_int;

View File

@ -29,18 +29,9 @@ extern "C" {
pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_uint; pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_uint;
} }
cfg_if! { extern "C" {
if #[cfg(ossl110)] {
extern "C" {
pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX;
pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX);
}
} else {
extern "C" {
pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX;
pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX);
}
}
} }
extern "C" { extern "C" {
@ -215,26 +206,16 @@ extern "C" {
pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER; pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER;
pub fn EVP_aes_256_gcm() -> *const EVP_CIPHER; pub fn EVP_aes_256_gcm() -> *const EVP_CIPHER;
pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER; pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER;
#[cfg(not(ossl110))]
pub fn OPENSSL_add_all_algorithms_noconf();
pub fn EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD; pub fn EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD;
pub fn EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER; pub fn EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER;
pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int; pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int;
} }
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { extern "C" {
extern "C" {
pub fn EVP_PKEY_bits(key: *const EVP_PKEY) -> c_int; pub fn EVP_PKEY_bits(key: *const EVP_PKEY) -> c_int;
}
} else {
extern "C" {
pub fn EVP_PKEY_bits(key: *mut EVP_PKEY) -> c_int;
}
}
} }
extern "C" { extern "C" {
pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int; pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int;
@ -246,7 +227,6 @@ extern "C" {
pub fn EVP_PKEY_new() -> *mut EVP_PKEY; pub fn EVP_PKEY_new() -> *mut EVP_PKEY;
pub fn EVP_PKEY_free(k: *mut EVP_PKEY); pub fn EVP_PKEY_free(k: *mut EVP_PKEY);
#[cfg(any(ossl110, libressl270))]
pub fn EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int; pub fn EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int;
pub fn d2i_AutoPrivateKey( pub fn d2i_AutoPrivateKey(
@ -279,7 +259,6 @@ extern "C" {
out: *mut u8, out: *mut u8,
) -> c_int; ) -> c_int;
#[cfg(ossl110)]
pub fn EVP_PBE_scrypt( pub fn EVP_PBE_scrypt(
pass: *const c_char, pass: *const c_char,
passlen: size_t, passlen: size_t,

View File

@ -2,18 +2,9 @@ use libc::*;
use *; use *;
cfg_if! { extern "C" {
if #[cfg(ossl110)] {
extern "C" {
pub fn HMAC_CTX_new() -> *mut HMAC_CTX; pub fn HMAC_CTX_new() -> *mut HMAC_CTX;
pub fn HMAC_CTX_free(ctx: *mut HMAC_CTX); pub fn HMAC_CTX_free(ctx: *mut HMAC_CTX);
}
} else {
extern "C" {
pub fn HMAC_CTX_init(ctx: *mut HMAC_CTX);
pub fn HMAC_CTX_cleanup(ctx: *mut HMAC_CTX);
}
}
} }
extern "C" { extern "C" {

View File

@ -87,7 +87,6 @@ pub type PasswordCallback = unsafe extern "C" fn(
user_data: *mut c_void, user_data: *mut c_void,
) -> c_int; ) -> c_int;
#[cfg(ossl110)]
pub fn init() { pub fn init() {
use std::ptr; use std::ptr;
use std::sync::Once; use std::sync::Once;
@ -101,74 +100,3 @@ pub fn init() {
OPENSSL_init_ssl(init_options, ptr::null_mut()); OPENSSL_init_ssl(init_options, ptr::null_mut());
}) })
} }
#[cfg(not(ossl110))]
pub fn init() {
use std::io::{self, Write};
use std::mem;
use std::process;
use std::sync::{Mutex, MutexGuard, Once};
static mut MUTEXES: *mut Vec<Mutex<()>> = 0 as *mut Vec<Mutex<()>>;
static mut GUARDS: *mut Vec<Option<MutexGuard<'static, ()>>> =
0 as *mut Vec<Option<MutexGuard<'static, ()>>>;
unsafe extern "C" fn locking_function(
mode: c_int,
n: c_int,
_file: *const c_char,
_line: c_int,
) {
let mutex = &(*MUTEXES)[n as usize];
if mode & ::CRYPTO_LOCK != 0 {
(*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
} else {
if let None = (*GUARDS)[n as usize].take() {
let _ = writeln!(
io::stderr(),
"BUG: rust-openssl lock {} already unlocked, aborting",
n
);
process::abort();
}
}
}
cfg_if! {
if #[cfg(unix)] {
fn set_id_callback() {
unsafe extern "C" fn thread_id() -> c_ulong {
::libc::pthread_self() as c_ulong
}
unsafe {
CRYPTO_set_id_callback(thread_id);
}
}
} else {
fn set_id_callback() {}
}
}
static INIT: Once = Once::new();
INIT.call_once(|| unsafe {
SSL_library_init();
SSL_load_error_strings();
OPENSSL_add_all_algorithms_noconf();
let num_locks = ::CRYPTO_num_locks();
let mut mutexes = Box::new(Vec::new());
for _ in 0..num_locks {
mutexes.push(Mutex::new(()));
}
MUTEXES = mem::transmute(mutexes);
let guards: Box<Vec<Option<MutexGuard<()>>>> =
Box::new((0..num_locks).map(|_| None).collect());
GUARDS = mem::transmute(guards);
CRYPTO_set_locking_callback(locking_function);
set_id_callback();
})
}

View File

@ -55,16 +55,7 @@ macro_rules! cfg_if {
macro_rules! stack { macro_rules! stack {
($t:ident) => { ($t:ident) => {
cfg_if! {
if #[cfg(ossl110)] {
pub enum $t {} pub enum $t {}
} else {
#[repr(C)]
pub struct $t {
pub stack: ::_STACK,
}
}
}
}; };
} }

View File

@ -13,115 +13,25 @@ pub enum ASN1_OBJECT {}
pub enum ASN1_OCTET_STRING {} pub enum ASN1_OCTET_STRING {}
pub enum bio_st {} // FIXME remove pub enum bio_st {} // FIXME remove
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { pub enum BIO {}
pub enum BIO {}
} else { pub enum BIGNUM {}
#[repr(C)]
pub struct BIO {
pub method: *mut BIO_METHOD,
pub callback: Option<
unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long) -> c_long,
>,
pub cb_arg: *mut c_char,
pub init: c_int,
pub shutdown: c_int,
pub flags: c_int,
pub retry_reason: c_int,
pub num: c_int,
pub ptr: *mut c_void,
pub next_bio: *mut BIO,
pub prev_bio: *mut BIO,
pub references: c_int,
pub num_read: c_ulong,
pub num_write: c_ulong,
pub ex_data: CRYPTO_EX_DATA,
}
}
}
cfg_if! {
if #[cfg(ossl110)] {
pub enum BIGNUM {}
} else {
#[repr(C)]
pub struct BIGNUM {
pub d: *mut BN_ULONG,
pub top: c_int,
pub dmax: c_int,
pub neg: c_int,
pub flags: c_int,
}
}
}
pub enum BN_BLINDING {} pub enum BN_BLINDING {}
pub enum BN_MONT_CTX {} pub enum BN_MONT_CTX {}
pub enum BN_CTX {} pub enum BN_CTX {}
pub enum BN_GENCB {} pub enum BN_GENCB {}
cfg_if! { pub enum EVP_CIPHER {}
if #[cfg(any(ossl110, libressl280))] {
pub enum EVP_CIPHER {}
} else {
#[repr(C)]
pub struct EVP_CIPHER {
pub nid: c_int,
pub block_size: c_int,
pub key_len: c_int,
pub iv_len: c_int,
pub flags: c_ulong,
pub init: Option<
unsafe extern "C" fn(*mut EVP_CIPHER_CTX, *const c_uchar, *const c_uchar, c_int) -> c_int,
>,
pub do_cipher: Option<
unsafe extern "C" fn(*mut EVP_CIPHER_CTX, *mut c_uchar, *const c_uchar, size_t) -> c_int,
>,
pub cleanup: Option<unsafe extern "C" fn(*mut EVP_CIPHER_CTX) -> c_int>,
pub ctx_size: c_int,
pub set_asn1_parameters:
Option<unsafe extern "C" fn(*mut EVP_CIPHER_CTX, *mut ASN1_TYPE) -> c_int>,
pub get_asn1_parameters:
Option<unsafe extern "C" fn(*mut EVP_CIPHER_CTX, *mut ASN1_TYPE) -> c_int>,
pub ctrl:
Option<unsafe extern "C" fn(*mut EVP_CIPHER_CTX, c_int, c_int, *mut c_void) -> c_int>,
pub app_data: *mut c_void,
}
}
}
pub enum EVP_CIPHER_CTX {} pub enum EVP_CIPHER_CTX {}
pub enum EVP_MD {} pub enum EVP_MD {}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { pub enum EVP_MD_CTX {}
pub enum EVP_MD_CTX {}
} else { pub enum EVP_PKEY {}
#[repr(C)]
pub struct EVP_MD_CTX {
digest: *mut EVP_MD,
engine: *mut ENGINE,
flags: c_ulong,
md_data: *mut c_void,
pctx: *mut EVP_PKEY_CTX,
update: *mut c_void,
}
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] {
pub enum EVP_PKEY {}
} else {
#[repr(C)]
pub struct EVP_PKEY {
pub type_: c_int,
pub save_type: c_int,
pub references: c_int,
pub ameth: *const EVP_PKEY_ASN1_METHOD,
pub engine: *mut ENGINE,
pub pkey: *mut c_void,
pub save_parameters: c_int,
pub attributes: *mut stack_st_X509_ATTRIBUTE,
}
}
}
pub enum PKCS8_PRIV_KEY_INFO {} pub enum PKCS8_PRIV_KEY_INFO {}
@ -129,202 +39,29 @@ pub enum EVP_PKEY_ASN1_METHOD {}
pub enum EVP_PKEY_CTX {} pub enum EVP_PKEY_CTX {}
cfg_if! { pub enum HMAC_CTX {}
if #[cfg(any(ossl110, libressl280))] {
pub enum HMAC_CTX {} pub enum DH {}
} else {
#[repr(C)]
pub struct HMAC_CTX {
md: *mut EVP_MD,
md_ctx: EVP_MD_CTX,
i_ctx: EVP_MD_CTX,
o_ctx: EVP_MD_CTX,
key_length: c_uint,
key: [c_uchar; 128],
}
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] {
pub enum DH {}
} else {
#[repr(C)]
pub struct DH {
pub pad: c_int,
pub version: c_int,
pub p: *mut ::BIGNUM,
pub g: *mut ::BIGNUM,
pub length: c_long,
pub pub_key: *mut ::BIGNUM,
pub priv_key: *mut ::BIGNUM,
pub flags: c_int,
pub method_mont_p: *mut ::BN_MONT_CTX,
pub q: *mut ::BIGNUM,
pub j: *mut ::BIGNUM,
pub seed: *mut c_uchar,
pub seedlen: c_int,
pub counter: *mut ::BIGNUM,
pub references: c_int,
pub ex_data: ::CRYPTO_EX_DATA,
pub meth: *const ::DH_METHOD,
pub engine: *mut ::ENGINE,
}
}
}
pub enum DH_METHOD {} pub enum DH_METHOD {}
cfg_if! { pub enum DSA {}
if #[cfg(any(ossl110, libressl280))] {
pub enum DSA {}
} else {
#[repr(C)]
pub struct DSA {
pub pad: c_int,
pub version: c_long,
pub write_params: c_int,
pub p: *mut BIGNUM,
pub q: *mut BIGNUM,
pub g: *mut BIGNUM,
pub pub_key: *mut BIGNUM,
pub priv_key: *mut BIGNUM,
pub kinv: *mut BIGNUM,
pub r: *mut BIGNUM,
pub flags: c_int,
pub method_mont_p: *mut BN_MONT_CTX,
pub references: c_int,
pub ex_data: CRYPTO_EX_DATA,
pub meth: *const DSA_METHOD,
pub engine: *mut ENGINE,
}
}
}
pub enum DSA_METHOD {} pub enum DSA_METHOD {}
cfg_if! { pub enum RSA {}
if #[cfg(any(ossl110, libressl280))] {
pub enum RSA {}
} else {
#[repr(C)]
pub struct RSA {
pub pad: c_int,
pub version: c_long,
pub meth: *const ::RSA_METHOD,
pub engine: *mut ::ENGINE,
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,
pub ex_data: ::CRYPTO_EX_DATA,
pub references: c_int,
pub flags: c_int,
pub _method_mod_n: *mut ::BN_MONT_CTX,
pub _method_mod_p: *mut ::BN_MONT_CTX,
pub _method_mod_q: *mut ::BN_MONT_CTX,
pub bignum_data: *mut c_char,
pub blinding: *mut ::BN_BLINDING,
pub mt_blinding: *mut ::BN_BLINDING,
}
}
}
pub enum RSA_METHOD {} pub enum RSA_METHOD {}
pub enum EC_KEY {} pub enum EC_KEY {}
cfg_if! { pub enum X509 {}
if #[cfg(any(ossl110, libressl280))] {
pub enum X509 {} pub enum X509_ALGOR {}
} else {
#[repr(C)]
pub struct X509 {
pub cert_info: *mut X509_CINF,
pub sig_alg: *mut X509_ALGOR,
pub signature: *mut ASN1_BIT_STRING,
pub valid: c_int,
pub references: c_int,
pub name: *mut c_char,
pub ex_data: CRYPTO_EX_DATA,
pub ex_pathlen: c_long,
pub ex_pcpathlen: c_long,
pub ex_flags: c_ulong,
pub ex_kusage: c_ulong,
pub ex_xkusage: c_ulong,
pub ex_nscert: c_ulong,
skid: *mut c_void,
akid: *mut c_void,
policy_cache: *mut c_void,
crldp: *mut c_void,
altname: *mut c_void,
nc: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_RFC3779"))]
rfc3779_addr: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_RFC3779"))]
rfc3779_asid: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_SHA"))]
sha1_hash: [c_uchar; 20],
aux: *mut c_void,
}
}
}
cfg_if! {
if #[cfg(ossl110)] {
pub enum X509_ALGOR {}
} else {
#[repr(C)]
pub struct X509_ALGOR {
pub algorithm: *mut ::ASN1_OBJECT,
parameter: *mut c_void,
}
}
}
pub enum X509_NAME {} pub enum X509_NAME {}
cfg_if! { pub enum X509_STORE {}
if #[cfg(any(ossl110, libressl270))] {
pub enum X509_STORE {}
} else {
#[repr(C)]
pub struct X509_STORE {
cache: c_int,
pub objs: *mut stack_st_X509_OBJECT,
get_cert_methods: *mut stack_st_X509_LOOKUP,
param: *mut X509_VERIFY_PARAM,
verify: Option<extern "C" fn(ctx: *mut X509_STORE_CTX) -> c_int>,
verify_cb: Option<extern "C" fn(ok: c_int, ctx: *mut X509_STORE_CTX) -> c_int>,
get_issuer: Option<
extern "C" fn(issuer: *mut *mut X509, ctx: *mut X509_STORE_CTX, x: *mut X509) -> c_int,
>,
check_issued:
Option<extern "C" fn(ctx: *mut X509_STORE_CTX, x: *mut X509, issuer: *mut X509) -> c_int>,
check_revocation: Option<extern "C" fn(ctx: *mut X509_STORE_CTX) -> c_int>,
get_crl: Option<
extern "C" fn(ctx: *mut X509_STORE_CTX, crl: *mut *mut X509_CRL, x: *mut X509) -> c_int,
>,
check_crl: Option<extern "C" fn(ctx: *mut X509_STORE_CTX, crl: *mut X509_CRL) -> c_int>,
cert_crl:
Option<extern "C" fn(ctx: *mut X509_STORE_CTX, crl: *mut X509_CRL, x: *mut X509) -> c_int>,
lookup_certs:
Option<extern "C" fn(ctx: *mut X509_STORE_CTX, nm: *const X509_NAME) -> *mut stack_st_X509>,
lookup_crls: Option<
extern "C" fn(ctx: *const X509_STORE_CTX, nm: *const X509_NAME) -> *mut stack_st_X509_CRL,
>,
cleanup: Option<extern "C" fn(ctx: *mut X509_STORE_CTX) -> c_int>,
ex_data: CRYPTO_EX_DATA,
references: c_int,
}
}
}
pub enum X509_STORE_CTX {} pub enum X509_STORE_CTX {}
pub enum X509_VERIFY_PARAM {} pub enum X509_VERIFY_PARAM {}
@ -342,356 +79,16 @@ pub struct X509V3_CTX {
// Maybe more here // Maybe more here
} }
pub enum CONF {} pub enum CONF {}
#[cfg(ossl110)]
pub enum OPENSSL_INIT_SETTINGS {} pub enum OPENSSL_INIT_SETTINGS {}
pub enum SSL {}
pub enum SSL_CTX {}
pub enum ENGINE {} pub enum ENGINE {}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] {
pub enum SSL {}
} else {
#[repr(C)]
pub struct SSL {
version: c_int,
type_: c_int,
method: *const ::SSL_METHOD,
rbio: *mut c_void,
wbio: *mut c_void,
bbio: *mut c_void,
rwstate: c_int,
in_handshake: c_int,
handshake_func: Option<unsafe extern "C" fn(*mut SSL) -> c_int>,
pub server: c_int,
new_session: c_int,
quiet_session: c_int,
shutdown: c_int,
state: c_int,
rstate: c_int,
init_buf: *mut c_void,
init_msg: *mut c_void,
init_num: c_int,
init_off: c_int,
packet: *mut c_uchar,
packet_length: c_uint,
s2: *mut c_void,
s3: *mut c_void,
d1: *mut c_void,
read_ahead: c_int,
msg_callback: Option<
unsafe extern "C" fn(c_int, c_int, c_int, *const c_void, size_t, *mut SSL, *mut c_void),
>,
msg_callback_arg: *mut c_void,
hit: c_int,
param: *mut c_void,
cipher_list: *mut stack_st_SSL_CIPHER,
cipher_list_by_id: *mut stack_st_SSL_CIPHER,
mac_flags: c_int,
enc_read_ctx: *mut ::EVP_CIPHER_CTX,
read_hash: *mut ::EVP_MD_CTX,
expand: *mut c_void,
enc_write_ctx: *mut ::EVP_CIPHER_CTX,
write_hash: *mut ::EVP_MD_CTX,
compress: *mut c_void,
cert: *mut c_void,
sid_ctx_length: c_uint,
sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize],
session: *mut ::SSL_SESSION,
verify_mode: c_int,
verify_callback: Option<unsafe extern "C" fn(c_int, *mut ::X509_STORE_CTX) -> c_int>,
info_callback: Option<unsafe extern "C" fn(*mut SSL, c_int, c_int)>,
error: c_int,
error_code: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_KRB5"))]
kssl_ctx: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_client_callback: Option<
unsafe extern "C" fn(*mut SSL, *const c_char, *mut c_char, c_uint, *mut c_uchar, c_uint)
-> c_uint,
>,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_server_callback:
Option<unsafe extern "C" fn(*mut SSL, *const c_char, *mut c_uchar, c_uint) -> c_uint>,
ctx: *mut ::SSL_CTX,
debug: c_int,
verify_result: c_long,
ex_data: ::CRYPTO_EX_DATA,
client_CA: *mut stack_st_X509_NAME,
references: c_int,
options: c_ulong,
mode: c_ulong,
max_cert_list: c_long,
first_packet: c_int,
client_version: c_int,
max_send_fragment: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_debug_cb:
Option<unsafe extern "C" fn(*mut SSL, c_int, c_int, *mut c_uchar, c_int, *mut c_void)>,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_debug_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_hostname: *mut c_char,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
servername_done: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_status_type: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_status_expected: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ocsp_ids: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ocsp_exts: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ocsp_resp: *mut c_uchar,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ocsp_resplen: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ticket_expected: c_int,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist: *mut c_uchar,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist: *mut c_uchar,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_opaque_prf_input: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_opaque_prf_input_len: size_t,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_session_ticket: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tls_session_ticket_ext_cb_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tls_session_secret_cb: ::tls_session_secret_cb_fn,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tls_session_secret_cb_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
initial_ctx: *mut ::SSL_CTX,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_proto_negotiated: *mut c_uchar,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_proto_negotiated_len: c_uchar,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
srtp_profiles: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
srtp_profile: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_heartbeat: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_hb_pending: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_hb_seq: c_uint,
renegotiate: c_int,
#[cfg(not(osslconf = "OPENSSL_NO_SRP"))]
srp_ctx: ::SRP_CTX,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_client_proto_list: *mut c_uchar,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_client_proto_list_len: c_uint,
}
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] {
pub enum SSL_CTX {}
} else {
#[repr(C)]
pub struct SSL_CTX {
method: *mut c_void,
cipher_list: *mut c_void,
cipher_list_by_id: *mut c_void,
cert_store: *mut c_void,
sessions: *mut c_void,
session_cache_size: c_ulong,
session_cache_head: *mut c_void,
session_cache_tail: *mut c_void,
session_cache_mode: c_int,
session_timeout: c_long,
new_session_cb: *mut c_void,
remove_session_cb: *mut c_void,
get_session_cb: *mut c_void,
stats: [c_int; 11],
pub references: c_int,
app_verify_callback: *mut c_void,
app_verify_arg: *mut c_void,
default_passwd_callback: *mut c_void,
default_passwd_callback_userdata: *mut c_void,
client_cert_cb: *mut c_void,
app_gen_cookie_cb: *mut c_void,
app_verify_cookie_cb: *mut c_void,
ex_dat: ::CRYPTO_EX_DATA,
rsa_md5: *mut c_void,
md5: *mut c_void,
sha1: *mut c_void,
extra_certs: *mut c_void,
comp_methods: *mut c_void,
info_callback: *mut c_void,
client_CA: *mut c_void,
options: c_ulong,
mode: c_ulong,
max_cert_list: c_long,
cert: *mut c_void,
read_ahead: c_int,
msg_callback: *mut c_void,
msg_callback_arg: *mut c_void,
verify_mode: c_int,
sid_ctx_length: c_uint,
sid_ctx: [c_uchar; 32],
default_verify_callback: *mut c_void,
generate_session_id: *mut c_void,
param: *mut c_void,
quiet_shutdown: c_int,
max_send_fragment: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_ENGINE"))]
client_cert_engine: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_servername_callback: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsect_servername_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_tick_key_name: [c_uchar; 16],
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_tick_hmac_key: [c_uchar; 16],
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_tick_aes_key: [c_uchar; 16],
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ticket_key_cb: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_status_cb: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_status_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_opaque_prf_input_callback: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_opaque_prf_input_callback_arg: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_identity_hint: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_client_callback: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_server_callback: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))]
freelist_max_len: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))]
wbuf_freelist: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))]
rbuf_freelist: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_SRP"))]
srp_ctx: SRP_CTX,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_protos_advertised_cb: *mut c_void,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_protos_advertised_cb_arg: *mut c_void,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_proto_select_cb: *mut c_void,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_NEXTPROTONEG")
))]
next_proto_select_cb_arg: *mut c_void,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
srtp_profiles: *mut c_void,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_select_cb: *mut c_void,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_select_cb_arg: *mut c_void,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_client_proto_list: *mut c_void,
#[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT")))]
alpn_client_proto_list_len: c_uint,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist: *mut c_uchar,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist: *mut c_uchar,
}
#[repr(C)]
#[cfg(not(osslconf = "OPENSSL_NO_SRP"))]
pub struct SRP_CTX {
SRP_cb_arg: *mut c_void,
TLS_ext_srp_username_callback: *mut c_void,
SRP_verify_param_callback: *mut c_void,
SRP_give_srp_client_pwd_callback: *mut c_void,
login: *mut c_void,
N: *mut c_void,
g: *mut c_void,
s: *mut c_void,
B: *mut c_void,
A: *mut c_void,
a: *mut c_void,
b: *mut c_void,
v: *mut c_void,
info: *mut c_void,
stringth: c_int,
srp_Mask: c_ulong,
}
}
}
pub enum COMP_METHOD {} pub enum COMP_METHOD {}
cfg_if! { pub enum CRYPTO_EX_DATA {}
if #[cfg(any(ossl110, libressl280))] {
pub enum CRYPTO_EX_DATA {}
} else {
#[repr(C)]
pub struct CRYPTO_EX_DATA {
pub sk: *mut stack_st_void,
pub dummy: c_int,
}
}
}
pub enum OCSP_RESPONSE {} pub enum OCSP_RESPONSE {}

View File

@ -19,32 +19,26 @@ extern "C" {
pub fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int; pub fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int;
pub fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int; pub fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn RSA_set0_key( pub fn RSA_set0_key(
r: *mut ::RSA, r: *mut ::RSA,
n: *mut ::BIGNUM, n: *mut ::BIGNUM,
e: *mut ::BIGNUM, e: *mut ::BIGNUM,
d: *mut ::BIGNUM, d: *mut ::BIGNUM,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn RSA_set0_factors(r: *mut ::RSA, p: *mut ::BIGNUM, q: *mut ::BIGNUM) -> c_int; pub fn RSA_set0_factors(r: *mut ::RSA, p: *mut ::BIGNUM, q: *mut ::BIGNUM) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn RSA_set0_crt_params( pub fn RSA_set0_crt_params(
r: *mut ::RSA, r: *mut ::RSA,
dmp1: *mut ::BIGNUM, dmp1: *mut ::BIGNUM,
dmq1: *mut ::BIGNUM, dmq1: *mut ::BIGNUM,
iqmp: *mut ::BIGNUM, iqmp: *mut ::BIGNUM,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn RSA_get0_key( pub fn RSA_get0_key(
r: *const ::RSA, r: *const ::RSA,
n: *mut *const ::BIGNUM, n: *mut *const ::BIGNUM,
e: *mut *const ::BIGNUM, e: *mut *const ::BIGNUM,
d: *mut *const ::BIGNUM, d: *mut *const ::BIGNUM,
); );
#[cfg(any(ossl110, libressl273))]
pub fn RSA_get0_factors(r: *const ::RSA, p: *mut *const ::BIGNUM, q: *mut *const ::BIGNUM); pub fn RSA_get0_factors(r: *const ::RSA, p: *mut *const ::BIGNUM, q: *mut *const ::BIGNUM);
#[cfg(any(ossl110, libressl273))]
pub fn RSA_get0_crt_params( pub fn RSA_get0_crt_params(
r: *const ::RSA, r: *const ::RSA,
dmp1: *mut *const ::BIGNUM, dmp1: *mut *const ::BIGNUM,
@ -52,14 +46,6 @@ extern "C" {
iqmp: *mut *const ::BIGNUM, iqmp: *mut *const ::BIGNUM,
); );
#[cfg(not(ossl110))]
pub fn RSA_generate_key(
modsz: c_int,
e: c_ulong,
cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>,
cbarg: *mut c_void,
) -> *mut RSA;
pub fn RSA_generate_key_ex( pub fn RSA_generate_key_ex(
rsa: *mut RSA, rsa: *mut RSA,
bits: c_int, bits: c_int,

View File

@ -3,19 +3,6 @@ use std::ptr;
use *; use *;
#[cfg(not(any(libressl, ossl110)))]
pub const SSL_MAX_KRB5_PRINCIPAL_LENGTH: c_int = 256;
#[cfg(not(ossl110))]
pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32;
#[cfg(not(ossl110))]
pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32;
#[cfg(not(any(libressl, ossl110)))]
pub const SSL_MAX_KEY_ARG_LENGTH: c_int = 8;
#[cfg(not(ossl110))]
pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48;
pub const SSL_SENT_SHUTDOWN: c_int = 1; pub const SSL_SENT_SHUTDOWN: c_int = 1;
pub const SSL_RECEIVED_SHUTDOWN: c_int = 2; pub const SSL_RECEIVED_SHUTDOWN: c_int = 2;
@ -24,76 +11,8 @@ pub const SSL_FILETYPE_ASN1: c_int = X509_FILETYPE_ASN1;
pub enum SSL_METHOD {} pub enum SSL_METHOD {}
pub enum SSL_CIPHER {} pub enum SSL_CIPHER {}
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { pub enum SSL_SESSION {}
pub enum SSL_SESSION {}
} else {
#[repr(C)]
pub struct SSL_SESSION {
ssl_version: c_int,
key_arg_length: c_uint,
key_arg: [c_uchar; SSL_MAX_KEY_ARG_LENGTH as usize],
pub master_key_length: c_int,
pub master_key: [c_uchar; 48],
session_id_length: c_uint,
session_id: [c_uchar; SSL_MAX_SSL_SESSION_ID_LENGTH as usize],
sid_ctx_length: c_uint,
sid_ctx: [c_uchar; SSL_MAX_SID_CTX_LENGTH as usize],
#[cfg(not(osslconf = "OPENSSL_NO_KRB5"))]
krb5_client_princ_len: c_uint,
#[cfg(not(osslconf = "OPENSSL_NO_KRB5"))]
krb5_client_princ: [c_uchar; SSL_MAX_KRB5_PRINCIPAL_LENGTH as usize],
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_identity_hint: *mut c_char,
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
psk_identity: *mut c_char,
not_resumable: c_int,
sess_cert: *mut c_void,
peer: *mut X509,
verify_result: c_long,
pub references: c_int,
timeout: c_long,
time: c_long,
compress_meth: c_uint,
cipher: *const c_void,
cipher_id: c_ulong,
ciphers: *mut c_void,
ex_data: ::CRYPTO_EX_DATA,
prev: *mut c_void,
next: *mut c_void,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_hostname: *mut c_char,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ecpointformatlist: *mut c_uchar,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist_length: size_t,
#[cfg(all(
not(osslconf = "OPENSSL_NO_TLSEXT"),
not(osslconf = "OPENSSL_NO_EC")
))]
tlsext_ellipticcurvelist: *mut c_uchar,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_tick: *mut c_uchar,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_ticklen: size_t,
#[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))]
tlsext_tick_lifetime_hint: c_long,
#[cfg(not(osslconf = "OPENSSL_NO_SRP"))]
srp_username: *mut c_char,
}
}
}
stack!(stack_st_SSL_CIPHER); stack!(stack_st_SSL_CIPHER);
@ -131,8 +50,7 @@ pub const SSL_OP_NO_DTLSv1_2: c_uint = 0x08000000;
pub const SSL_OP_NO_TLSv1_3: c_uint = 0x20000000; pub const SSL_OP_NO_TLSv1_3: c_uint = 0x20000000;
#[cfg(ossl110h)] pub const SSL_OP_NO_RENEGOTIATION: c_uint = 0x0;
pub const SSL_OP_NO_RENEGOTIATION: c_uint = 0x40000000;
pub const SSL_OP_ALL: c_uint = SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS | SSL_OP_LEGACY_SERVER_CONNECT; pub const SSL_OP_ALL: c_uint = SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS | SSL_OP_LEGACY_SERVER_CONNECT;
@ -190,26 +108,14 @@ extern "C" {
remove_session_cb: Option<unsafe extern "C" fn(*mut SSL_CTX, *mut SSL_SESSION)>, remove_session_cb: Option<unsafe extern "C" fn(*mut SSL_CTX, *mut SSL_SESSION)>,
); );
} }
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { extern "C" {
extern "C" {
pub fn SSL_CTX_sess_set_get_cb( pub fn SSL_CTX_sess_set_get_cb(
ctx: *mut ::SSL_CTX, ctx: *mut ::SSL_CTX,
get_session_cb: Option< get_session_cb: Option<
unsafe extern "C" fn(*mut ::SSL, *const c_uchar, c_int, *mut c_int) -> *mut SSL_SESSION, unsafe extern "C" fn(*mut ::SSL, *const c_uchar, c_int, *mut c_int) -> *mut SSL_SESSION,
>, >,
); );
}
} else {
extern "C" {
pub fn SSL_CTX_sess_set_get_cb(
ctx: *mut ::SSL_CTX,
get_session_cb: Option<
unsafe extern "C" fn(*mut ::SSL, *mut c_uchar, c_int, *mut c_int) -> *mut SSL_SESSION,
>,
);
}
}
} }
extern "C" { extern "C" {
@ -358,17 +264,11 @@ extern "C" {
pub fn SSL_get_current_cipher(ssl: *const SSL) -> *const SSL_CIPHER; pub fn SSL_get_current_cipher(ssl: *const SSL) -> *const SSL_CIPHER;
pub fn SSL_CIPHER_get_bits(cipher: *const SSL_CIPHER, alg_bits: *mut c_int) -> c_int; pub fn SSL_CIPHER_get_bits(cipher: *const SSL_CIPHER, alg_bits: *mut c_int) -> c_int;
} }
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { extern "C" {
extern "C" {
pub fn SSL_CIPHER_get_version(cipher: *const SSL_CIPHER) -> *const c_char; pub fn SSL_CIPHER_get_version(cipher: *const SSL_CIPHER) -> *const c_char;
}
} else {
extern "C" {
pub fn SSL_CIPHER_get_version(cipher: *const SSL_CIPHER) -> *mut c_char;
}
}
} }
extern "C" { extern "C" {
pub fn SSL_CIPHER_get_name(cipher: *const SSL_CIPHER) -> *const c_char; pub fn SSL_CIPHER_get_name(cipher: *const SSL_CIPHER) -> *const c_char;
pub fn SSL_CIPHER_standard_name(cipher: *const SSL_CIPHER) -> *const c_char; pub fn SSL_CIPHER_standard_name(cipher: *const SSL_CIPHER) -> *const c_char;
@ -402,18 +302,14 @@ extern "C" {
) -> c_int; ) -> c_int;
pub fn SSL_load_client_CA_file(file: *const c_char) -> *mut stack_st_X509_NAME; pub fn SSL_load_client_CA_file(file: *const c_char) -> *mut stack_st_X509_NAME;
#[cfg(not(ossl110))]
pub fn SSL_load_error_strings();
pub fn SSL_state_string(ssl: *const SSL) -> *const c_char; pub fn SSL_state_string(ssl: *const SSL) -> *const c_char;
pub fn SSL_state_string_long(ssl: *const SSL) -> *const c_char; pub fn SSL_state_string_long(ssl: *const SSL) -> *const c_char;
pub fn SSL_SESSION_get_time(s: *const SSL_SESSION) -> u64; pub fn SSL_SESSION_get_time(s: *const SSL_SESSION) -> u64;
pub fn SSL_SESSION_get_timeout(s: *const SSL_SESSION) -> u32; pub fn SSL_SESSION_get_timeout(s: *const SSL_SESSION) -> u32;
#[cfg(ossl110)]
pub fn SSL_SESSION_get_protocol_version(s: *const SSL_SESSION) -> u16; pub fn SSL_SESSION_get_protocol_version(s: *const SSL_SESSION) -> u16;
pub fn SSL_SESSION_get_id(s: *const SSL_SESSION, len: *mut c_uint) -> *const c_uchar; pub fn SSL_SESSION_get_id(s: *const SSL_SESSION, len: *mut c_uint) -> *const c_uchar;
#[cfg(any(ossl110, libressl273))]
pub fn SSL_SESSION_up_ref(ses: *mut SSL_SESSION) -> c_int; pub fn SSL_SESSION_up_ref(ses: *mut SSL_SESSION) -> c_int;
pub fn SSL_SESSION_free(s: *mut SSL_SESSION); pub fn SSL_SESSION_free(s: *mut SSL_SESSION);
pub fn i2d_SSL_SESSION(s: *mut SSL_SESSION, pp: *mut *mut c_uchar) -> c_int; pub fn i2d_SSL_SESSION(s: *mut SSL_SESSION, pp: *mut *mut c_uchar) -> c_int;
@ -461,9 +357,7 @@ extern "C" {
pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int; pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int;
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl291))] {
extern "C" {
pub fn TLS_method() -> *const SSL_METHOD; pub fn TLS_method() -> *const SSL_METHOD;
pub fn DTLS_method() -> *const SSL_METHOD; pub fn DTLS_method() -> *const SSL_METHOD;
@ -471,29 +365,6 @@ cfg_if! {
pub fn TLS_server_method() -> *const SSL_METHOD; pub fn TLS_server_method() -> *const SSL_METHOD;
pub fn TLS_client_method() -> *const SSL_METHOD; pub fn TLS_client_method() -> *const SSL_METHOD;
}
} else {
extern "C" {
#[cfg(not(osslconf = "OPENSSL_NO_SSL3_METHOD"))]
pub fn SSLv3_method() -> *const SSL_METHOD;
pub fn SSLv23_method() -> *const SSL_METHOD;
pub fn SSLv23_client_method() -> *const SSL_METHOD;
pub fn SSLv23_server_method() -> *const SSL_METHOD;
pub fn TLSv1_method() -> *const SSL_METHOD;
pub fn TLSv1_1_method() -> *const SSL_METHOD;
pub fn TLSv1_2_method() -> *const SSL_METHOD;
pub fn DTLSv1_method() -> *const SSL_METHOD;
pub fn DTLSv1_2_method() -> *const SSL_METHOD;
}
}
} }
extern "C" { extern "C" {
@ -520,9 +391,6 @@ extern "C" {
pub fn SSL_set_connect_state(s: *mut SSL); pub fn SSL_set_connect_state(s: *mut SSL);
pub fn SSL_set_accept_state(s: *mut SSL); pub fn SSL_set_accept_state(s: *mut SSL);
#[cfg(not(ossl110))]
pub fn SSL_library_init() -> c_int;
pub fn SSL_CIPHER_description( pub fn SSL_CIPHER_description(
cipher: *const SSL_CIPHER, cipher: *const SSL_CIPHER,
buf: *mut c_char, buf: *mut c_char,
@ -548,11 +416,8 @@ extern "C" {
pub fn SSL_set_SSL_CTX(ssl: *mut SSL, ctx: *mut SSL_CTX) -> *mut SSL_CTX; pub fn SSL_set_SSL_CTX(ssl: *mut SSL, ctx: *mut SSL_CTX) -> *mut SSL_CTX;
pub fn SSL_get_verify_result(ssl: *const SSL) -> c_long; pub fn SSL_get_verify_result(ssl: *const SSL) -> c_long;
#[cfg(ossl110)]
pub fn SSL_get_client_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t; pub fn SSL_get_client_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t;
#[cfg(ossl110)]
pub fn SSL_get_server_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t; pub fn SSL_get_server_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t;
#[cfg(any(ossl110, libressl273))]
pub fn SSL_SESSION_get_master_key( pub fn SSL_SESSION_get_master_key(
session: *const SSL_SESSION, session: *const SSL_SESSION,
out: *mut c_uchar, out: *mut c_uchar,
@ -599,29 +464,6 @@ extern "C" {
pub fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_int) -> c_int; pub fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_int) -> c_int;
} }
extern "C" {
// FIXME should take an option
#[cfg(not(ossl110))]
pub fn SSL_CTX_set_tmp_ecdh_callback(
ctx: *mut ::SSL_CTX,
ecdh: unsafe extern "C" fn(
ssl: *mut ::SSL,
is_export: c_int,
keylength: c_int,
) -> *mut ::EC_KEY,
);
// FIXME should take an option
#[cfg(not(ossl110))]
pub fn SSL_set_tmp_ecdh_callback(
ssl: *mut SSL,
ecdh: unsafe extern "C" fn(
ssl: *mut SSL,
is_export: c_int,
keylength: c_int,
) -> *mut EC_KEY,
);
}
cfg_if! { cfg_if! {
if #[cfg(osslconf = "OPENSSL_NO_COMP")] { if #[cfg(osslconf = "OPENSSL_NO_COMP")] {
} else { } else {
@ -639,9 +481,7 @@ cfg_if! {
} }
extern "C" { extern "C" {
#[cfg(ossl110)]
pub fn SSL_CIPHER_get_cipher_nid(c: *const SSL_CIPHER) -> c_int; pub fn SSL_CIPHER_get_cipher_nid(c: *const SSL_CIPHER) -> c_int;
#[cfg(ossl110)]
pub fn SSL_CIPHER_get_digest_nid(c: *const SSL_CIPHER) -> c_int; pub fn SSL_CIPHER_get_digest_nid(c: *const SSL_CIPHER) -> c_int;
} }
@ -653,10 +493,8 @@ extern "C" {
pub fn SSL_is_server(s: *const SSL) -> c_int; pub fn SSL_is_server(s: *const SSL) -> c_int;
} }
#[cfg(ossl110)]
pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000; pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000;
extern "C" { extern "C" {
#[cfg(ossl110)]
pub fn OPENSSL_init_ssl(opts: u64, settings: *const OPENSSL_INIT_SETTINGS) -> c_int; pub fn OPENSSL_init_ssl(opts: u64, settings: *const OPENSSL_INIT_SETTINGS) -> c_int;
} }

View File

@ -22,147 +22,25 @@ stack!(stack_st_X509_EXTENSION);
stack!(stack_st_X509_ATTRIBUTE); stack!(stack_st_X509_ATTRIBUTE);
cfg_if! { pub enum X509_REQ_INFO {}
if #[cfg(ossl110)] {
pub enum X509_REQ_INFO {}
} else {
#[repr(C)]
pub struct X509_REQ_INFO {
pub enc: ASN1_ENCODING,
pub version: *mut ::ASN1_INTEGER,
pub subject: *mut ::X509_NAME,
pubkey: *mut c_void,
pub attributes: *mut stack_st_X509_ATTRIBUTE,
}
}
}
cfg_if! { pub enum X509_CRL {}
if #[cfg(ossl110)] {
pub enum X509_CRL {}
} else {
#[repr(C)]
pub struct X509_CRL {
pub crl: *mut X509_CRL_INFO,
sig_alg: *mut X509_ALGOR,
signature: *mut c_void,
references: c_int,
flags: c_int,
akid: *mut c_void,
idp: *mut c_void,
idp_flags: c_int,
idp_reasons: c_int,
crl_number: *mut ASN1_INTEGER,
base_crl_number: *mut ASN1_INTEGER,
sha1_hash: [c_uchar; 20],
issuers: *mut c_void,
meth: *const c_void,
meth_data: *mut c_void,
}
}
}
stack!(stack_st_X509_CRL); stack!(stack_st_X509_CRL);
cfg_if! { pub enum X509_CRL_INFO {}
if #[cfg(ossl110)] {
pub enum X509_CRL_INFO {}
} else {
#[repr(C)]
pub struct X509_CRL_INFO {
version: *mut ASN1_INTEGER,
sig_alg: *mut X509_ALGOR,
pub issuer: *mut X509_NAME,
pub lastUpdate: *mut ASN1_TIME,
pub nextUpdate: *mut ASN1_TIME,
pub revoked: *mut stack_st_X509_REVOKED,
extensions: *mut stack_st_X509_EXTENSION,
enc: ASN1_ENCODING,
}
}
}
cfg_if! { pub enum X509_REVOKED {}
if #[cfg(ossl110)] {
pub enum X509_REVOKED {}
} else {
#[repr(C)]
pub struct X509_REVOKED {
pub serialNumber: *mut ASN1_INTEGER,
pub revocationDate: *mut ASN1_TIME,
pub extensions: *mut stack_st_X509_EXTENSION,
issuer: *mut stack_st_GENERAL_NAME,
reason: c_int,
sequence: c_int,
}
}
}
stack!(stack_st_X509_REVOKED); stack!(stack_st_X509_REVOKED);
cfg_if! { pub enum X509_REQ {}
if #[cfg(ossl110)] {
pub enum X509_REQ {}
} else {
#[repr(C)]
pub struct X509_REQ {
pub req_info: *mut X509_REQ_INFO,
sig_alg: *mut c_void,
signature: *mut c_void,
references: c_int,
}
}
}
cfg_if! { pub enum X509_CINF {}
if #[cfg(ossl110)] {
pub enum X509_CINF {}
} else {
#[repr(C)]
pub struct X509_CINF {
version: *mut c_void,
serialNumber: *mut c_void,
signature: *mut c_void,
issuer: *mut c_void,
pub validity: *mut X509_VAL,
subject: *mut c_void,
key: *mut c_void,
issuerUID: *mut c_void,
subjectUID: *mut c_void,
pub extensions: *mut stack_st_X509_EXTENSION,
enc: ASN1_ENCODING,
}
}
}
stack!(stack_st_X509); stack!(stack_st_X509);
cfg_if! { pub enum X509_OBJECT {}
if #[cfg(not(ossl110))] {
pub const X509_LU_FAIL: c_int = 0;
pub const X509_LU_X509: c_int = 1;
pub const X509_LU_CRL: c_int = 2;
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl270))] {
pub enum X509_OBJECT {}
} else {
#[repr(C)]
pub struct X509_OBJECT {
pub type_: c_int,
pub data: X509_OBJECT_data,
}
#[repr(C)]
pub union X509_OBJECT_data {
pub ptr: *mut c_char,
pub x509: *mut X509,
pub crl: *mut X509_CRL,
pub pkey: *mut EVP_PKEY,
}
}
}
stack!(stack_st_X509_OBJECT); stack!(stack_st_X509_OBJECT);
@ -229,7 +107,6 @@ extern "C" {
pub fn X509_REVOKED_new() -> *mut X509_REVOKED; pub fn X509_REVOKED_new() -> *mut X509_REVOKED;
pub fn X509_REVOKED_free(x: *mut X509_REVOKED); pub fn X509_REVOKED_free(x: *mut X509_REVOKED);
#[cfg(any(ossl110, libressl270))]
pub fn X509_REVOKED_dup(rev: *mut X509_REVOKED) -> *mut X509_REVOKED; pub fn X509_REVOKED_dup(rev: *mut X509_REVOKED) -> *mut X509_REVOKED;
pub fn d2i_X509_REVOKED( pub fn d2i_X509_REVOKED(
a: *mut *mut X509_REVOKED, a: *mut *mut X509_REVOKED,
@ -288,49 +165,27 @@ extern "C" {
pub fn X509_subject_name_hash(x: *mut ::X509) -> c_ulong; pub fn X509_subject_name_hash(x: *mut ::X509) -> c_ulong;
} }
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { extern "C" {
extern "C" {
pub fn X509_get_issuer_name(x: *const ::X509) -> *mut ::X509_NAME; pub fn X509_get_issuer_name(x: *const ::X509) -> *mut ::X509_NAME;
}
} else {
extern "C" {
pub fn X509_get_issuer_name(x: *mut ::X509) -> *mut ::X509_NAME;
}
}
} }
extern "C" { extern "C" {
pub fn X509_set_subject_name(x: *mut X509, name: *mut X509_NAME) -> c_int; pub fn X509_set_subject_name(x: *mut X509, name: *mut X509_NAME) -> c_int;
} }
cfg_if! {
if #[cfg(any(ossl110, libressl280))] { extern "C" {
extern "C" {
pub fn X509_get_subject_name(x: *const ::X509) -> *mut ::X509_NAME; pub fn X509_get_subject_name(x: *const ::X509) -> *mut ::X509_NAME;
}
} else {
extern "C" {
pub fn X509_get_subject_name(x: *mut ::X509) -> *mut ::X509_NAME;
}
}
} }
cfg_if! {
if #[cfg(ossl110)] { extern "C" {
extern "C" {
pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
}
} else {
extern "C" {
pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
}
}
} }
extern "C" { extern "C" {
#[cfg(ossl110)]
pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long; pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int; pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int;
#[cfg(ossl110)]
pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME; pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME;
pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut X509_NAME) -> c_int; pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut X509_NAME) -> c_int;
pub fn X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int; pub fn X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int;
@ -340,18 +195,12 @@ extern "C" {
-> c_int; -> c_int;
pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int; pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int;
pub fn X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int; pub fn X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int;
#[cfg(any(ossl110, libressl273))]
pub fn X509_getm_notBefore(x: *mut X509) -> *mut ASN1_TIME; pub fn X509_getm_notBefore(x: *mut X509) -> *mut ASN1_TIME;
#[cfg(any(ossl110, libressl273))]
pub fn X509_getm_notAfter(x: *mut X509) -> *mut ASN1_TIME; pub fn X509_getm_notAfter(x: *mut X509) -> *mut ASN1_TIME;
#[cfg(any(ossl110, libressl273))]
pub fn X509_up_ref(x: *mut X509) -> c_int; pub fn X509_up_ref(x: *mut X509) -> c_int;
#[cfg(any(ossl110, libressl270))]
pub fn X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER; pub fn X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER;
#[cfg(any(ossl110, libressl270))]
pub fn X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME; pub fn X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME;
#[cfg(any(ossl110, libressl270))]
pub fn X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION; pub fn X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION;
pub fn X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int; pub fn X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int;
@ -376,60 +225,35 @@ extern "C" {
serial: *mut ASN1_INTEGER, serial: *mut ASN1_INTEGER,
) -> c_int; ) -> c_int;
#[cfg(any(ossl110, libressl281))]
pub fn X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED; pub fn X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED;
#[cfg(any(ossl110, libressl281))]
pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME; pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
#[cfg(any(ossl110, libressl281))]
pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME; pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
#[cfg(any(ossl110, libressl281))]
pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME; pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME;
#[cfg(ossl110)]
pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION; pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION;
pub fn X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int; pub fn X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int;
pub fn X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: *mut X509_NAME) -> c_int; pub fn X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: *mut X509_NAME) -> c_int;
pub fn X509_CRL_sort(crl: *mut X509_CRL) -> c_int; pub fn X509_CRL_sort(crl: *mut X509_CRL) -> c_int;
#[cfg(any(ossl110, libressl270))]
pub fn X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int; pub fn X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int;
pub fn X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int; pub fn X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int;
} }
cfg_if! {
if #[cfg(any(ossl110, libressl270))] { extern "C" {
extern "C" {
pub fn X509_CRL_set1_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; pub fn X509_CRL_set1_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
pub fn X509_CRL_set1_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; pub fn X509_CRL_set1_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
}
} else {
// libressl270 kept them, ossl110 "#define"s them to the variants above
extern "C" {
pub fn X509_CRL_set_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
pub fn X509_CRL_set_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
}
}
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn X509_NAME_entry_count(n: *const X509_NAME) -> c_int; pub fn X509_NAME_entry_count(n: *const X509_NAME) -> c_int;
}
} else {
extern "C" {
pub fn X509_NAME_entry_count(n: *mut X509_NAME) -> c_int;
}
}
} }
extern "C" { extern "C" {
pub fn X509_NAME_get_index_by_NID(n: *const X509_NAME, nid: c_int, last_pos: c_int) -> c_int; pub fn X509_NAME_get_index_by_NID(n: *const X509_NAME, nid: c_int, last_pos: c_int) -> c_int;
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn X509_NAME_get_entry(n: *const X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY; pub fn X509_NAME_get_entry(n: *const X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY;
pub fn X509_NAME_add_entry_by_NID( pub fn X509_NAME_add_entry_by_NID(
x: *mut X509_NAME, x: *mut X509_NAME,
@ -442,24 +266,8 @@ cfg_if! {
) -> c_int; ) -> c_int;
pub fn X509_NAME_ENTRY_get_object(ne: *const X509_NAME_ENTRY) -> *mut ASN1_OBJECT; pub fn X509_NAME_ENTRY_get_object(ne: *const X509_NAME_ENTRY) -> *mut ASN1_OBJECT;
pub fn X509_NAME_ENTRY_get_data(ne: *const X509_NAME_ENTRY) -> *mut ASN1_STRING; pub fn X509_NAME_ENTRY_get_data(ne: *const X509_NAME_ENTRY) -> *mut ASN1_STRING;
}
} else {
extern "C" {
pub fn X509_NAME_get_entry(n: *mut X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY;
pub fn X509_NAME_add_entry_by_NID(
x: *mut X509_NAME,
field: c_int,
ty: c_int,
bytes: *mut c_uchar,
len: c_int,
loc: c_int,
set: c_int,
) -> c_int;
pub fn X509_NAME_ENTRY_get_object(ne: *mut X509_NAME_ENTRY) -> *mut ASN1_OBJECT;
pub fn X509_NAME_ENTRY_get_data(ne: *mut X509_NAME_ENTRY) -> *mut ASN1_STRING;
}
}
} }
extern "C" { extern "C" {
pub fn X509_NAME_add_entry_by_txt( pub fn X509_NAME_add_entry_by_txt(
x: *mut X509_NAME, x: *mut X509_NAME,
@ -616,7 +424,6 @@ extern "C" {
pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int; pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int;
} }
#[cfg(any(ossl110, libressl270))]
extern "C" { extern "C" {
pub fn X509_STORE_get0_objects(ctx: *mut X509_STORE) -> *mut stack_st_X509_OBJECT; pub fn X509_STORE_get0_objects(ctx: *mut X509_STORE) -> *mut stack_st_X509_OBJECT;
pub fn X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509; pub fn X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509;

View File

@ -98,16 +98,9 @@ extern "C" {
pub fn X509_STORE_CTX_get_error_depth(ctx: *mut X509_STORE_CTX) -> c_int; pub fn X509_STORE_CTX_get_error_depth(ctx: *mut X509_STORE_CTX) -> c_int;
pub fn X509_STORE_CTX_get_current_cert(ctx: *mut X509_STORE_CTX) -> *mut X509; pub fn X509_STORE_CTX_get_current_cert(ctx: *mut X509_STORE_CTX) -> *mut X509;
} }
cfg_if! {
if #[cfg(ossl110)] { extern "C" {
extern "C" {
pub fn X509_STORE_CTX_get0_chain(ctx: *mut X509_STORE_CTX) -> *mut stack_st_X509; pub fn X509_STORE_CTX_get0_chain(ctx: *mut X509_STORE_CTX) -> *mut stack_st_X509;
}
} else {
extern "C" {
pub fn X509_STORE_CTX_get_chain(ctx: *mut X509_STORE_CTX) -> *mut stack_st_X509;
}
}
} }
extern "C" { extern "C" {

View File

@ -43,9 +43,7 @@ pub const X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS: c_uint = 0x8;
pub const X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS: c_uint = 0x10; pub const X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS: c_uint = 0x10;
pub const X509_CHECK_FLAG_NEVER_CHECK_SUBJECT: c_uint = 0x20; pub const X509_CHECK_FLAG_NEVER_CHECK_SUBJECT: c_uint = 0x20;
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn X509V3_EXT_nconf_nid( pub fn X509V3_EXT_nconf_nid(
conf: *mut CONF, conf: *mut CONF,
ctx: *mut X509V3_CTX, ctx: *mut X509V3_CTX,
@ -58,23 +56,6 @@ cfg_if! {
name: *const c_char, name: *const c_char,
value: *const c_char, value: *const c_char,
) -> *mut X509_EXTENSION; ) -> *mut X509_EXTENSION;
}
} else {
extern "C" {
pub fn X509V3_EXT_nconf_nid(
conf: *mut CONF,
ctx: *mut X509V3_CTX,
ext_nid: c_int,
value: *mut c_char,
) -> *mut X509_EXTENSION;
pub fn X509V3_EXT_nconf(
conf: *mut CONF,
ctx: *mut X509V3_CTX,
name: *mut c_char,
value: *mut c_char,
) -> *mut X509_EXTENSION;
}
}
} }
extern "C" { extern "C" {
@ -95,28 +76,20 @@ extern "C" {
pub fn X509_get1_ocsp(x: *mut X509) -> *mut stack_st_OPENSSL_STRING; pub fn X509_get1_ocsp(x: *mut X509) -> *mut stack_st_OPENSSL_STRING;
} }
cfg_if! { extern "C" {
if #[cfg(any(ossl110, libressl280))] {
extern "C" {
pub fn X509V3_get_d2i( pub fn X509V3_get_d2i(
x: *const stack_st_X509_EXTENSION, x: *const stack_st_X509_EXTENSION,
nid: c_int, nid: c_int,
crit: *mut c_int, crit: *mut c_int,
idx: *mut c_int, idx: *mut c_int,
) -> *mut c_void; ) -> *mut c_void;
pub fn X509V3_extensions_print(out: *mut BIO, title: *const c_char, exts: *const stack_st_X509_EXTENSION, flag: c_ulong, indent: c_int) -> c_int; pub fn X509V3_extensions_print(
} out: *mut BIO,
} else { title: *const c_char,
extern "C" { exts: *const stack_st_X509_EXTENSION,
pub fn X509V3_get_d2i( flag: c_ulong,
x: *mut stack_st_X509_EXTENSION, indent: c_int,
nid: c_int, ) -> c_int;
crit: *mut c_int,
idx: *mut c_int,
) -> *mut c_void;
pub fn X509V3_extensions_print(out: *mut BIO, title: *mut c_char, exts: *mut stack_st_X509_EXTENSION, flag: c_ulong, indent: c_int) -> c_int;
}
}
} }
// X509V3_add1_i2d (and *_add1_ext_i2d) // X509V3_add1_i2d (and *_add1_ext_i2d)
@ -176,7 +149,6 @@ pub const XKU_SGC: u32 = 0x10;
pub const XKU_OCSP_SIGN: u32 = 0x20; pub const XKU_OCSP_SIGN: u32 = 0x20;
pub const XKU_TIMESTAMP: u32 = 0x40; pub const XKU_TIMESTAMP: u32 = 0x40;
pub const XKU_DVCS: u32 = 0x80; pub const XKU_DVCS: u32 = 0x80;
#[cfg(ossl110)]
pub const XKU_ANYEKU: u32 = 0x100; pub const XKU_ANYEKU: u32 = 0x100;
extern "C" { extern "C" {
@ -196,10 +168,7 @@ extern "C" {
indent: c_int, indent: c_int,
) -> c_int; ) -> c_int;
#[cfg(ossl110)]
pub fn X509_get_extension_flags(x: *mut X509) -> u32; pub fn X509_get_extension_flags(x: *mut X509) -> u32;
#[cfg(ossl110)]
pub fn X509_get_key_usage(x: *mut X509) -> u32; pub fn X509_get_key_usage(x: *mut X509) -> u32;
#[cfg(ossl110)]
pub fn X509_get_extended_key_usage(x: *mut X509) -> u32; pub fn X509_get_extended_key_usage(x: *mut X509) -> u32;
} }

View File

@ -1,9 +0,0 @@
fn main() {
let mut cfgs = vec![];
cfgs.push("ossl110");
for cfg in cfgs {
println!("cargo:rustc-cfg={}", cfg);
}
}

View File

@ -551,16 +551,7 @@ impl fmt::Debug for Asn1ObjectRef {
} }
} }
cfg_if! { use ffi::ASN1_STRING_get0_data;
if #[cfg(any(ossl110, libressl273))] {
use ffi::ASN1_STRING_get0_data;
} else {
#[allow(bad_style)]
unsafe fn ASN1_STRING_get0_data(s: *mut ffi::ASN1_STRING) -> *const ::libc::c_uchar {
ffi::ASN1_STRING_data(s)
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -80,24 +80,7 @@ impl Dh<Params> {
} }
} }
cfg_if! { use ffi::DH_set0_pqg;
if #[cfg(any(ossl110, libressl273))] {
use ffi::DH_set0_pqg;
} else {
#[allow(bad_style)]
unsafe fn DH_set0_pqg(
dh: *mut ffi::DH,
p: *mut ffi::BIGNUM,
q: *mut ffi::BIGNUM,
g: *mut ffi::BIGNUM,
) -> ::libc::c_int {
(*dh).p = p;
(*dh).q = q;
(*dh).g = g;
1
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -293,67 +293,7 @@ impl<T> fmt::Debug for Dsa<T> {
} }
} }
cfg_if! { use ffi::{DSA_get0_key, DSA_get0_pqg, DSA_set0_key, DSA_set0_pqg};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{DSA_get0_key, DSA_get0_pqg, DSA_set0_key, DSA_set0_pqg};
} else {
#[allow(bad_style)]
unsafe fn DSA_get0_pqg(
d: *mut ffi::DSA,
p: *mut *const ffi::BIGNUM,
q: *mut *const ffi::BIGNUM,
g: *mut *const ffi::BIGNUM)
{
if !p.is_null() {
*p = (*d).p;
}
if !q.is_null() {
*q = (*d).q;
}
if !g.is_null() {
*g = (*d).g;
}
}
#[allow(bad_style)]
unsafe fn DSA_get0_key(
d: *mut ffi::DSA,
pub_key: *mut *const ffi::BIGNUM,
priv_key: *mut *const ffi::BIGNUM)
{
if !pub_key.is_null() {
*pub_key = (*d).pub_key;
}
if !priv_key.is_null() {
*priv_key = (*d).priv_key;
}
}
#[allow(bad_style)]
unsafe fn DSA_set0_key(
d: *mut ffi::DSA,
pub_key: *mut ffi::BIGNUM,
priv_key: *mut ffi::BIGNUM) -> c_int
{
(*d).pub_key = pub_key;
(*d).priv_key = priv_key;
1
}
#[allow(bad_style)]
unsafe fn DSA_set0_pqg(
d: *mut ffi::DSA,
p: *mut ffi::BIGNUM,
q: *mut ffi::BIGNUM,
g: *mut ffi::BIGNUM) -> c_int
{
(*d).p = p;
(*d).q = q;
(*d).g = g;
1
}
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View File

@ -187,7 +187,6 @@ impl EcGroupRef {
/// OpenSSL documentation at [`EC_GROUP_order_bits`] /// OpenSSL documentation at [`EC_GROUP_order_bits`]
/// ///
/// [`EC_GROUP_order_bits`]: https://www.openssl.org/docs/man1.1.0/crypto/EC_GROUP_order_bits.html /// [`EC_GROUP_order_bits`]: https://www.openssl.org/docs/man1.1.0/crypto/EC_GROUP_order_bits.html
#[cfg(ossl110)]
pub fn order_bits(&self) -> u32 { pub fn order_bits(&self) -> u32 {
unsafe { ffi::EC_GROUP_order_bits(self.as_ptr()) as u32 } unsafe { ffi::EC_GROUP_order_bits(self.as_ptr()) as u32 }
} }

View File

@ -136,38 +136,4 @@ impl EcdsaSigRef {
} }
} }
cfg_if! { use ffi::{ECDSA_SIG_get0, ECDSA_SIG_set0};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{ECDSA_SIG_set0, ECDSA_SIG_get0};
} else {
#[allow(bad_style)]
unsafe fn ECDSA_SIG_set0(
sig: *mut ffi::ECDSA_SIG,
r: *mut ffi::BIGNUM,
s: *mut ffi::BIGNUM,
) -> c_int {
if r.is_null() || s.is_null() {
return 0;
}
ffi::BN_clear_free((*sig).r);
ffi::BN_clear_free((*sig).s);
(*sig).r = r;
(*sig).s = s;
1
}
#[allow(bad_style)]
unsafe fn ECDSA_SIG_get0(
sig: *const ffi::ECDSA_SIG,
pr: *mut *const ffi::BIGNUM,
ps: *mut *const ffi::BIGNUM)
{
if !pr.is_null() {
(*pr) = (*sig).r;
}
if !ps.is_null() {
(*ps) = (*sig).s;
}
}
}
}

View File

@ -8,14 +8,7 @@ use std::ptr;
use error::ErrorStack; use error::ErrorStack;
use nid::Nid; use nid::Nid;
use {cvt, cvt_p}; use {cvt, cvt_p};
use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new};
cfg_if! {
if #[cfg(ossl110)] {
use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new};
} else {
use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free};
}
}
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
pub struct MessageDigest(*const ffi::EVP_MD); pub struct MessageDigest(*const ffi::EVP_MD);

View File

@ -113,8 +113,6 @@
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]
extern crate cfg_if;
#[macro_use]
extern crate foreign_types; extern crate foreign_types;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;

View File

@ -112,7 +112,6 @@ pub fn pbkdf2_hmac(
/// Derives a key from a password and salt using the scrypt algorithm. /// Derives a key from a password and salt using the scrypt algorithm.
/// ///
/// Requires OpenSSL 1.1.0 or newer. /// Requires OpenSSL 1.1.0 or newer.
#[cfg(any(ossl110))]
pub fn scrypt( pub fn scrypt(
pass: &[u8], pass: &[u8],
salt: &[u8], salt: &[u8],
@ -280,7 +279,6 @@ mod tests {
} }
#[test] #[test]
#[cfg(any(ossl110))]
fn scrypt() { fn scrypt() {
use hex; use hex;

View File

@ -485,22 +485,7 @@ impl PKey<Public> {
} }
} }
cfg_if! { use ffi::EVP_PKEY_up_ref;
if #[cfg(any(ossl110, libressl270))] {
use ffi::EVP_PKEY_up_ref;
} else {
#[allow(bad_style)]
unsafe extern "C" fn EVP_PKEY_up_ref(pkey: *mut ffi::EVP_PKEY) {
ffi::CRYPTO_add_lock(
&mut (*pkey).references,
1,
ffi::CRYPTO_LOCK_EVP_PKEY,
"pkey.rs\0".as_ptr() as *const _,
line!() as c_int,
);
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -694,101 +694,10 @@ impl<T> fmt::Debug for Rsa<T> {
} }
} }
cfg_if! { use ffi::{
if #[cfg(any(ossl110, libressl273))] { RSA_get0_crt_params, RSA_get0_factors, RSA_get0_key, RSA_set0_crt_params, RSA_set0_factors,
use ffi::{ RSA_set0_key,
RSA_get0_key, RSA_get0_factors, RSA_get0_crt_params, RSA_set0_key, RSA_set0_factors, };
RSA_set0_crt_params,
};
} else {
#[allow(bad_style)]
unsafe fn RSA_get0_key(
r: *const ffi::RSA,
n: *mut *const ffi::BIGNUM,
e: *mut *const ffi::BIGNUM,
d: *mut *const ffi::BIGNUM,
) {
if !n.is_null() {
*n = (*r).n;
}
if !e.is_null() {
*e = (*r).e;
}
if !d.is_null() {
*d = (*r).d;
}
}
#[allow(bad_style)]
unsafe fn RSA_get0_factors(
r: *const ffi::RSA,
p: *mut *const ffi::BIGNUM,
q: *mut *const ffi::BIGNUM,
) {
if !p.is_null() {
*p = (*r).p;
}
if !q.is_null() {
*q = (*r).q;
}
}
#[allow(bad_style)]
unsafe fn RSA_get0_crt_params(
r: *const ffi::RSA,
dmp1: *mut *const ffi::BIGNUM,
dmq1: *mut *const ffi::BIGNUM,
iqmp: *mut *const ffi::BIGNUM,
) {
if !dmp1.is_null() {
*dmp1 = (*r).dmp1;
}
if !dmq1.is_null() {
*dmq1 = (*r).dmq1;
}
if !iqmp.is_null() {
*iqmp = (*r).iqmp;
}
}
#[allow(bad_style)]
unsafe fn RSA_set0_key(
r: *mut ffi::RSA,
n: *mut ffi::BIGNUM,
e: *mut ffi::BIGNUM,
d: *mut ffi::BIGNUM,
) -> c_int {
(*r).n = n;
(*r).e = e;
(*r).d = d;
1
}
#[allow(bad_style)]
unsafe fn RSA_set0_factors(
r: *mut ffi::RSA,
p: *mut ffi::BIGNUM,
q: *mut ffi::BIGNUM,
) -> c_int {
(*r).p = p;
(*r).q = q;
1
}
#[allow(bad_style)]
unsafe fn RSA_set0_crt_params(
r: *mut ffi::RSA,
dmp1: *mut ffi::BIGNUM,
dmq1: *mut ffi::BIGNUM,
iqmp: *mut ffi::BIGNUM,
) -> c_int {
(*r).dmp1 = dmp1;
(*r).dmq1 = dmq1;
(*r).iqmp = iqmp;
1
}
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View File

@ -47,13 +47,7 @@ use pkey::{HasPrivate, HasPublic, PKeyRef};
use rsa::Padding; use rsa::Padding;
use {cvt, cvt_p}; use {cvt, cvt_p};
cfg_if! { use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new};
if #[cfg(ossl110)] {
use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new};
} else {
use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free};
}
}
/// Salt lengths that must be used with `set_rsa_pss_saltlen`. /// Salt lengths that must be used with `set_rsa_pss_saltlen`.
pub struct RsaPssSaltlen(c_int); pub struct RsaPssSaltlen(c_int);

View File

@ -188,17 +188,15 @@ unsafe extern "C" fn destroy<S>(bio: *mut BIO) -> c_int {
1 1
} }
cfg_if! { use ffi::{BIO_get_data, BIO_set_data, BIO_set_flags, BIO_set_init};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{BIO_get_data, BIO_set_data, BIO_set_flags, BIO_set_init};
#[allow(bad_style)] #[allow(bad_style)]
unsafe fn BIO_set_num(_bio: *mut ffi::BIO, _num: c_int) {} unsafe fn BIO_set_num(_bio: *mut ffi::BIO, _num: c_int) {}
#[allow(bad_style)] #[allow(bad_style)]
struct BIO_METHOD(*mut ffi::BIO_METHOD); struct BIO_METHOD(*mut ffi::BIO_METHOD);
impl BIO_METHOD { impl BIO_METHOD {
fn new<S: Read + Write>() -> BIO_METHOD { fn new<S: Read + Write>() -> BIO_METHOD {
unsafe { unsafe {
let ptr = ffi::BIO_meth_new(ffi::BIO_TYPE_NONE, b"rust\0".as_ptr() as *const _); let ptr = ffi::BIO_meth_new(ffi::BIO_TYPE_NONE, b"rust\0".as_ptr() as *const _);
@ -217,73 +215,12 @@ cfg_if! {
fn get(&self) -> *mut ffi::BIO_METHOD { fn get(&self) -> *mut ffi::BIO_METHOD {
self.0 self.0
} }
} }
impl Drop for BIO_METHOD { impl Drop for BIO_METHOD {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
ffi::BIO_meth_free(self.0); ffi::BIO_meth_free(self.0);
} }
} }
}
} else {
#[allow(bad_style)]
struct BIO_METHOD(*mut ffi::BIO_METHOD);
impl BIO_METHOD {
fn new<S: Read + Write>() -> BIO_METHOD {
let ptr = Box::new(ffi::BIO_METHOD {
type_: ffi::BIO_TYPE_NONE,
name: b"rust\0".as_ptr() as *const _,
bwrite: Some(bwrite::<S>),
bread: Some(bread::<S>),
bputs: Some(bputs::<S>),
bgets: None,
ctrl: Some(ctrl::<S>),
create: Some(create),
destroy: Some(destroy::<S>),
callback_ctrl: None,
});
BIO_METHOD(Box::into_raw(ptr))
}
fn get(&self) -> *mut ffi::BIO_METHOD {
self.0
}
}
impl Drop for BIO_METHOD {
fn drop(&mut self) {
unsafe {
Box::<ffi::BIO_METHOD>::from_raw(self.0);
}
}
}
#[allow(bad_style)]
unsafe fn BIO_set_init(bio: *mut ffi::BIO, init: c_int) {
(*bio).init = init;
}
#[allow(bad_style)]
unsafe fn BIO_set_flags(bio: *mut ffi::BIO, flags: c_int) {
(*bio).flags = flags;
}
#[allow(bad_style)]
unsafe fn BIO_get_data(bio: *mut ffi::BIO) -> *mut c_void {
(*bio).ptr
}
#[allow(bad_style)]
unsafe fn BIO_set_data(bio: *mut ffi::BIO, data: *mut c_void) {
(*bio).ptr = data;
}
#[allow(bad_style)]
unsafe fn BIO_set_num(bio: *mut ffi::BIO, num: c_int) {
(*bio).num = num;
}
}
} }

View File

@ -258,13 +258,7 @@ pub unsafe extern "C" fn raw_remove_session<F>(
callback(ctx, session) callback(ctx, session)
} }
cfg_if! { type DataPtr = *const c_uchar;
if #[cfg(any(ossl110, libressl280))] {
type DataPtr = *const c_uchar;
} else {
type DataPtr = *mut c_uchar;
}
}
pub unsafe extern "C" fn raw_get_session<F>( pub unsafe extern "C" fn raw_get_session<F>(
ssl: *mut ffi::SSL, ssl: *mut ffi::SSL,

View File

@ -82,7 +82,6 @@ use dh::DhRef;
use ec::EcKeyRef; use ec::EcKeyRef;
use error::ErrorStack; use error::ErrorStack;
use ex_data::Index; use ex_data::Index;
#[cfg(ossl110)]
use nid::Nid; use nid::Nid;
use pkey::{HasPrivate, PKeyRef, Params, Private}; use pkey::{HasPrivate, PKeyRef, Params, Private};
use srtp::{SrtpProtectionProfile, SrtpProtectionProfileRef}; use srtp::{SrtpProtectionProfile, SrtpProtectionProfileRef};
@ -187,7 +186,6 @@ bitflags! {
/// Disallow all renegotiation in TLSv1.2 and earlier. /// Disallow all renegotiation in TLSv1.2 and earlier.
/// ///
/// Requires OpenSSL 1.1.0h or newer. /// Requires OpenSSL 1.1.0h or newer.
#[cfg(ossl110h)]
const NO_RENEGOTIATION = ffi::SSL_OP_NO_RENEGOTIATION; const NO_RENEGOTIATION = ffi::SSL_OP_NO_RENEGOTIATION;
} }
} }
@ -476,7 +474,6 @@ impl AlpnError {
/// Terminate the handshake with a fatal alert. /// Terminate the handshake with a fatal alert.
/// ///
/// Requires OpenSSL 1.1.0 or newer. /// Requires OpenSSL 1.1.0 or newer.
#[cfg(any(ossl110))]
pub const ALERT_FATAL: AlpnError = AlpnError(ffi::SSL_TLSEXT_ERR_ALERT_FATAL); pub const ALERT_FATAL: AlpnError = AlpnError(ffi::SSL_TLSEXT_ERR_ALERT_FATAL);
/// Do not select a protocol, but continue the handshake. /// Do not select a protocol, but continue the handshake.
@ -971,7 +968,6 @@ impl SslContextBuilder {
/// Requires OpenSSL 1.1.0 or LibreSSL 2.6.1 or newer. /// Requires OpenSSL 1.1.0 or LibreSSL 2.6.1 or newer.
/// ///
/// [`SSL_CTX_set_min_proto_version`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_min_proto_version.html /// [`SSL_CTX_set_min_proto_version`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_min_proto_version.html
#[cfg(any(ossl110, libressl261))]
pub fn set_min_proto_version(&mut self, version: Option<SslVersion>) -> Result<(), ErrorStack> { pub fn set_min_proto_version(&mut self, version: Option<SslVersion>) -> Result<(), ErrorStack> {
unsafe { unsafe {
cvt(ffi::SSL_CTX_set_min_proto_version( cvt(ffi::SSL_CTX_set_min_proto_version(
@ -992,7 +988,6 @@ impl SslContextBuilder {
/// Requires OpenSSL 1.1.0 or or LibreSSL 2.6.1 or newer. /// Requires OpenSSL 1.1.0 or or LibreSSL 2.6.1 or newer.
/// ///
/// [`SSL_CTX_set_max_proto_version`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_min_proto_version.html /// [`SSL_CTX_set_max_proto_version`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_min_proto_version.html
#[cfg(any(ossl110, libressl261))]
pub fn set_max_proto_version(&mut self, version: Option<SslVersion>) -> Result<(), ErrorStack> { pub fn set_max_proto_version(&mut self, version: Option<SslVersion>) -> Result<(), ErrorStack> {
unsafe { unsafe {
cvt(ffi::SSL_CTX_set_max_proto_version( cvt(ffi::SSL_CTX_set_max_proto_version(
@ -1729,7 +1724,6 @@ impl SslCipherRef {
/// This corresponds to [`SSL_CIPHER_get_cipher_nid`]. /// This corresponds to [`SSL_CIPHER_get_cipher_nid`].
/// ///
/// [`SSL_CIPHER_get_cipher_nid`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_cipher_nid.html /// [`SSL_CIPHER_get_cipher_nid`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_cipher_nid.html
#[cfg(any(ossl110))]
pub fn cipher_nid(&self) -> Option<Nid> { pub fn cipher_nid(&self) -> Option<Nid> {
let n = unsafe { ffi::SSL_CIPHER_get_cipher_nid(self.as_ptr()) }; let n = unsafe { ffi::SSL_CIPHER_get_cipher_nid(self.as_ptr()) };
if n == 0 { if n == 0 {
@ -1849,7 +1843,6 @@ impl SslSessionRef {
/// This corresponds to [`SSL_SESSION_get_protocol_version`]. /// This corresponds to [`SSL_SESSION_get_protocol_version`].
/// ///
/// [`SSL_SESSION_get_protocol_version`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_SESSION_get_protocol_version.html /// [`SSL_SESSION_get_protocol_version`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_SESSION_get_protocol_version.html
#[cfg(ossl110)]
pub fn protocol_version(&self) -> SslVersion { pub fn protocol_version(&self) -> SslVersion {
unsafe { unsafe {
let version = ffi::SSL_SESSION_get_protocol_version(self.as_ptr()); let version = ffi::SSL_SESSION_get_protocol_version(self.as_ptr());
@ -2453,7 +2446,6 @@ impl SslRef {
/// This corresponds to [`SSL_get_client_random`]. /// This corresponds to [`SSL_get_client_random`].
/// ///
/// [`SSL_get_client_random`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_client_random.html /// [`SSL_get_client_random`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_client_random.html
#[cfg(any(ossl110))]
pub fn client_random(&self, buf: &mut [u8]) -> usize { pub fn client_random(&self, buf: &mut [u8]) -> usize {
unsafe { unsafe {
ffi::SSL_get_client_random(self.as_ptr(), buf.as_mut_ptr() as *mut c_uchar, buf.len()) ffi::SSL_get_client_random(self.as_ptr(), buf.as_mut_ptr() as *mut c_uchar, buf.len())
@ -2470,7 +2462,6 @@ impl SslRef {
/// This corresponds to [`SSL_get_server_random`]. /// This corresponds to [`SSL_get_server_random`].
/// ///
/// [`SSL_get_server_random`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_client_random.html /// [`SSL_get_server_random`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_client_random.html
#[cfg(any(ossl110))]
pub fn server_random(&self, buf: &mut [u8]) -> usize { pub fn server_random(&self, buf: &mut [u8]) -> usize {
unsafe { unsafe {
ffi::SSL_get_server_random(self.as_ptr(), buf.as_mut_ptr() as *mut c_uchar, buf.len()) ffi::SSL_get_server_random(self.as_ptr(), buf.as_mut_ptr() as *mut c_uchar, buf.len())
@ -2670,7 +2661,6 @@ impl SslRef {
/// This corresponds to [`SSL_is_init_finished`]. /// This corresponds to [`SSL_is_init_finished`].
/// ///
/// [`SSL_is_init_finished`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_is_init_finished.html /// [`SSL_is_init_finished`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_is_init_finished.html
#[cfg(ossl110)]
pub fn is_init_finished(&self) -> bool { pub fn is_init_finished(&self) -> bool {
unsafe { ffi::SSL_is_init_finished(self.as_ptr()) != 0 } unsafe { ffi::SSL_is_init_finished(self.as_ptr()) != 0 }
} }
@ -3162,67 +3152,9 @@ bitflags! {
} }
} }
cfg_if! { use ffi::{SSL_CTX_up_ref, SSL_SESSION_get_master_key, SSL_SESSION_up_ref, SSL_is_server};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{SSL_CTX_up_ref, SSL_SESSION_get_master_key, SSL_SESSION_up_ref, SSL_is_server};
} else {
#[allow(bad_style)]
pub unsafe fn SSL_CTX_up_ref(ssl: *mut ffi::SSL_CTX) -> c_int {
ffi::CRYPTO_add_lock(
&mut (*ssl).references,
1,
ffi::CRYPTO_LOCK_SSL_CTX,
"mod.rs\0".as_ptr() as *const _,
line!() as c_int,
);
0
}
#[allow(bad_style)] use ffi::{DTLS_method, TLS_client_method, TLS_method, TLS_server_method};
pub unsafe fn SSL_SESSION_get_master_key(
session: *const ffi::SSL_SESSION,
out: *mut c_uchar,
mut outlen: usize,
) -> usize {
if outlen == 0 {
return (*session).master_key_length as usize;
}
if outlen > (*session).master_key_length as usize {
outlen = (*session).master_key_length as usize;
}
ptr::copy_nonoverlapping((*session).master_key.as_ptr(), out, outlen);
outlen
}
#[allow(bad_style)]
pub unsafe fn SSL_is_server(s: *mut ffi::SSL) -> c_int {
(*s).server
}
#[allow(bad_style)]
pub unsafe fn SSL_SESSION_up_ref(ses: *mut ffi::SSL_SESSION) -> c_int {
ffi::CRYPTO_add_lock(
&mut (*ses).references,
1,
ffi::CRYPTO_LOCK_SSL_CTX,
"mod.rs\0".as_ptr() as *const _,
line!() as c_int,
);
0
}
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl291))] {
use ffi::{TLS_method, DTLS_method, TLS_client_method, TLS_server_method};
} else {
use ffi::{
SSLv23_method as TLS_method, DTLSv1_method as DTLS_method, SSLv23_client_method as TLS_client_method,
SSLv23_server_method as TLS_server_method,
};
}
}
use std::sync::Once; use std::sync::Once;

View File

@ -443,7 +443,6 @@ fn test_alpn_server_advertise_multiple() {
} }
#[test] #[test]
#[cfg(any(ossl110))]
fn test_alpn_server_select_none_fatal() { fn test_alpn_server_select_none_fatal() {
let mut server = Server::builder(); let mut server = Server::builder();
// NOTE: in Boring all alpn errors are treated as SSL_TLSEXT_ERR_NOACK // NOTE: in Boring all alpn errors are treated as SSL_TLSEXT_ERR_NOACK
@ -946,7 +945,6 @@ fn keying_export() {
} }
#[test] #[test]
#[cfg(any(ossl110, libressl261))]
fn no_version_overlap() { fn no_version_overlap() {
let mut server = Server::builder(); let mut server = Server::builder();
server.ctx().set_min_proto_version(None).unwrap(); server.ctx().set_min_proto_version(None).unwrap();

View File

@ -80,12 +80,6 @@ impl fmt::Debug for OpensslStringRef {
} }
} }
#[cfg(not(ossl110))]
unsafe fn free(buf: *mut c_char) {
::ffi::CRYPTO_free(buf as *mut c_void);
}
#[cfg(ossl110)]
unsafe fn free(buf: *mut c_char) { unsafe fn free(buf: *mut c_char) {
::ffi::OPENSSL_free(buf as *mut c_void); ::ffi::OPENSSL_free(buf as *mut c_void);
} }

View File

@ -213,11 +213,6 @@ impl Cipher {
pub fn block_size(&self) -> usize { pub fn block_size(&self) -> usize {
unsafe { EVP_CIPHER_block_size(self.0) as usize } unsafe { EVP_CIPHER_block_size(self.0) as usize }
} }
#[cfg(not(ossl110))]
const fn is_ocb(self) -> bool {
false
}
} }
unsafe impl Sync for Cipher {} unsafe impl Sync for Cipher {}
@ -689,26 +684,7 @@ pub fn decrypt_aead(
Ok(out) Ok(out)
} }
cfg_if! { use ffi::{EVP_CIPHER_block_size, EVP_CIPHER_iv_length, EVP_CIPHER_key_length};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{EVP_CIPHER_block_size, EVP_CIPHER_iv_length, EVP_CIPHER_key_length};
} else {
#[allow(bad_style)]
pub unsafe fn EVP_CIPHER_iv_length(ptr: *const ffi::EVP_CIPHER) -> c_int {
(*ptr).iv_len
}
#[allow(bad_style)]
pub unsafe fn EVP_CIPHER_block_size(ptr: *const ffi::EVP_CIPHER) -> c_int {
(*ptr).block_size
}
#[allow(bad_style)]
pub unsafe fn EVP_CIPHER_key_length(ptr: *const ffi::EVP_CIPHER) -> c_int {
(*ptr).key_len
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -13,21 +13,10 @@
use std::ffi::CStr; use std::ffi::CStr;
cfg_if! { use ffi::{
if #[cfg(any(ossl110, libressl271))] { OpenSSL_version, OpenSSL_version_num, OPENSSL_BUILT_ON, OPENSSL_CFLAGS, OPENSSL_DIR,
use ffi::{ OPENSSL_PLATFORM, OPENSSL_VERSION,
OPENSSL_VERSION, OPENSSL_CFLAGS, OPENSSL_BUILT_ON, OPENSSL_PLATFORM, OPENSSL_DIR, };
OpenSSL_version_num, OpenSSL_version,
};
} else {
use ffi::{
SSLEAY_VERSION as OPENSSL_VERSION, SSLEAY_CFLAGS as OPENSSL_CFLAGS,
SSLEAY_BUILT_ON as OPENSSL_BUILT_ON, SSLEAY_PLATFORM as OPENSSL_PLATFORM,
SSLEAY_DIR as OPENSSL_DIR, SSLeay as OpenSSL_version_num,
SSLeay_version as OpenSSL_version,
};
}
}
/// OPENSSL_VERSION_NUMBER is a numeric release version identifier: /// OPENSSL_VERSION_NUMBER is a numeric release version identifier:
/// ///

View File

@ -33,9 +33,9 @@ use stack::{Stack, StackRef, Stackable};
use string::OpensslString; use string::OpensslString;
use {cvt, cvt_n, cvt_p}; use {cvt, cvt_n, cvt_p};
pub mod verify;
pub mod extension; pub mod extension;
pub mod store; pub mod store;
pub mod verify;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
@ -1417,101 +1417,14 @@ impl Stackable for X509Object {
type StackType = ffi::stack_st_X509_OBJECT; type StackType = ffi::stack_st_X509_OBJECT;
} }
cfg_if! { use ffi::{X509_get0_signature, X509_getm_notAfter, X509_getm_notBefore, X509_up_ref};
if #[cfg(any(ossl110, libressl273))] {
use ffi::{X509_getm_notAfter, X509_getm_notBefore, X509_up_ref, X509_get0_signature};
} else {
#[allow(bad_style)]
unsafe fn X509_getm_notAfter(x: *mut ffi::X509) -> *mut ffi::ASN1_TIME {
(*(*(*x).cert_info).validity).notAfter
}
#[allow(bad_style)] use ffi::{
unsafe fn X509_getm_notBefore(x: *mut ffi::X509) -> *mut ffi::ASN1_TIME { ASN1_STRING_get0_data, X509_ALGOR_get0, X509_REQ_get_subject_name, X509_REQ_get_version,
(*(*(*x).cert_info).validity).notBefore X509_STORE_CTX_get0_chain, X509_set1_notAfter, X509_set1_notBefore,
} };
#[allow(bad_style)] use ffi::X509_OBJECT_get0_X509;
unsafe fn X509_up_ref(x: *mut ffi::X509) {
ffi::CRYPTO_add_lock(
&mut (*x).references,
1,
ffi::CRYPTO_LOCK_X509,
"mod.rs\0".as_ptr() as *const _,
line!() as c_int,
);
}
#[allow(bad_style)]
unsafe fn X509_get0_signature(
psig: *mut *const ffi::ASN1_BIT_STRING,
palg: *mut *const ffi::X509_ALGOR,
x: *const ffi::X509,
) {
if !psig.is_null() {
*psig = (*x).signature;
}
if !palg.is_null() {
*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(
paobj: *mut *const ffi::ASN1_OBJECT,
pptype: *mut c_int,
pval: *mut *mut ::libc::c_void,
alg: *const ffi::X509_ALGOR,
) {
if !paobj.is_null() {
*paobj = (*alg).algorithm;
}
assert!(pptype.is_null());
assert!(pval.is_null());
}
}
}
cfg_if! {
if #[cfg(any(ossl110, libressl270))] {
use ffi::X509_OBJECT_get0_X509;
} else {
#[allow(bad_style)]
unsafe fn X509_OBJECT_get0_X509(x: *mut ffi::X509_OBJECT) -> *mut ffi::X509 {
if (*x).type_ == ffi::X509_LU_X509 {
(*x).data.x509
} else {
ptr::null_mut()
}
}
}
}
#[allow(bad_style)] #[allow(bad_style)]
unsafe fn X509_OBJECT_free(x: *mut ffi::X509_OBJECT) { unsafe fn X509_OBJECT_free(x: *mut ffi::X509_OBJECT) {

View File

@ -113,13 +113,4 @@ impl X509StoreRef {
} }
} }
cfg_if! { use ffi::X509_STORE_get0_objects;
if #[cfg(any(ossl110, libressl270))] {
use ffi::X509_STORE_get0_objects;
} else {
#[allow(bad_style)]
unsafe fn X509_STORE_get0_objects(x: *mut ffi::X509_STORE) -> *mut ffi::stack_st_X509_OBJECT {
(*x).objs
}
}
}

View File

@ -14,8 +14,6 @@ bitflags! {
const NO_PARTIAL_WILDCARDS = ffi::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS; const NO_PARTIAL_WILDCARDS = ffi::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS;
const MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS; const MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS;
const SINGLE_LABEL_SUBDOMAINS = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS; const SINGLE_LABEL_SUBDOMAINS = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS;
/// Requires OpenSSL 1.1.0 or newer.
#[cfg(any(ossl110))]
const NEVER_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT; const NEVER_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT;
#[deprecated(since = "0.10.6", note = "renamed to NO_WILDCARDS")] #[deprecated(since = "0.10.6", note = "renamed to NO_WILDCARDS")]

View File

@ -23,14 +23,6 @@ fn main() {
cfg.define("WIN32_LEAN_AND_MEAN", None); cfg.define("WIN32_LEAN_AND_MEAN", None);
} }
let mut cfgs = vec![];
cfgs.push("ossl110");
for c in cfgs {
cfg.cfg(c, None);
}
cfg.header("openssl/dh.h") cfg.header("openssl/dh.h")
.header("openssl/ossl_typ.h") .header("openssl/ossl_typ.h")
.header("openssl/stack.h") .header("openssl/stack.h")