| 1 |
use super::*; |
| 2 |
use std::ffi::{c_char, c_int, c_long, c_ulong, c_void}; |
| 3 |
|
| 4 |
extern "C" { |
| 5 |
#[deprecated(note = "use CRYPTO_set_locking_callback__fixed_rust instead")] |
| 6 |
#[cfg(not(ossl110))] |
| 7 |
pub fn CRYPTO_set_locking_callback( |
| 8 |
func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int), |
| 9 |
); |
| 10 |
|
| 11 |
#[deprecated(note = "use CRYPTO_set_id_callback__fixed_rust instead")] |
| 12 |
#[cfg(not(ossl110))] |
| 13 |
pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong); |
| 14 |
} |
| 15 |
|
| 16 |
cfg_if! { |
| 17 |
if #[cfg(ossl110)] { |
| 18 |
type CRYPTO_EX_new_ret = (); |
| 19 |
type CRYPTO_EX_dup_from = *const CRYPTO_EX_DATA; |
| 20 |
} else { |
| 21 |
type CRYPTO_EX_new_ret = c_int; |
| 22 |
type CRYPTO_EX_dup_from = *mut CRYPTO_EX_DATA; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
cfg_if! { |
| 27 |
if #[cfg(ossl300)] { |
| 28 |
type CRYPTO_EX_dup_from_d = *mut *mut c_void; |
| 29 |
} else { |
| 30 |
type CRYPTO_EX_dup_from_d = *mut c_void; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
// FIXME should be options |
| 35 |
pub type CRYPTO_EX_new = unsafe extern "C" fn( |
| 36 |
parent: *mut c_void, |
| 37 |
ptr: *mut c_void, |
| 38 |
ad: *mut CRYPTO_EX_DATA, |
| 39 |
idx: c_int, |
| 40 |
argl: c_long, |
| 41 |
argp: *mut c_void, |
| 42 |
) -> CRYPTO_EX_new_ret; |
| 43 |
pub type CRYPTO_EX_dup = unsafe extern "C" fn( |
| 44 |
to: *mut CRYPTO_EX_DATA, |
| 45 |
from: CRYPTO_EX_dup_from, |
| 46 |
from_d: CRYPTO_EX_dup_from_d, |
| 47 |
idx: c_int, |
| 48 |
argl: c_long, |
| 49 |
argp: *mut c_void, |
| 50 |
) -> c_int; |
| 51 |
pub type CRYPTO_EX_free = unsafe extern "C" fn( |
| 52 |
parent: *mut c_void, |
| 53 |
ptr: *mut c_void, |
| 54 |
ad: *mut CRYPTO_EX_DATA, |
| 55 |
idx: c_int, |
| 56 |
argl: c_long, |
| 57 |
argp: *mut c_void, |
| 58 |
); |
| 59 |
|
| 60 |
#[cfg(any(ossl110, libressl390))] |
| 61 |
#[inline] |
| 62 |
#[track_caller] |
| 63 |
pub unsafe fn OPENSSL_malloc(num: usize) -> *mut c_void { |
| 64 |
CRYPTO_malloc( |
| 65 |
num, |
| 66 |
concat!(file!(), "\0").as_ptr() as *const _, |
| 67 |
line!() as _, |
| 68 |
) |
| 69 |
} |
| 70 |
|
| 71 |
#[cfg(not(any(ossl110, libressl390)))] |
| 72 |
#[inline] |
| 73 |
#[track_caller] |
| 74 |
pub unsafe fn OPENSSL_malloc(num: c_int) -> *mut c_void { |
| 75 |
CRYPTO_malloc( |
| 76 |
num, |
| 77 |
concat!(file!(), "\0").as_ptr() as *const _, |
| 78 |
line!() as _, |
| 79 |
) |
| 80 |
} |
| 81 |
|
| 82 |
#[cfg(any(ossl110, libressl390))] |
| 83 |
#[inline] |
| 84 |
#[track_caller] |
| 85 |
pub unsafe fn OPENSSL_free(addr: *mut c_void) { |
| 86 |
CRYPTO_free( |
| 87 |
addr, |
| 88 |
concat!(file!(), "\0").as_ptr() as *const _, |
| 89 |
line!() as _, |
| 90 |
) |
| 91 |
} |
| 92 |
|
| 93 |
#[cfg(not(any(ossl110, libressl390)))] |
| 94 |
#[inline] |
| 95 |
pub unsafe fn OPENSSL_free(addr: *mut c_void) { |
| 96 |
CRYPTO_free(addr) |
| 97 |
} |
| 98 |
|
| 99 |
#[cfg(not(ossl110))] |
| 100 |
pub const CRYPTO_LOCK_X509: c_int = 3; |
| 101 |
#[cfg(not(ossl110))] |
| 102 |
pub const CRYPTO_LOCK_EVP_PKEY: c_int = 10; |
| 103 |
#[cfg(not(ossl110))] |
| 104 |
pub const CRYPTO_LOCK_SSL_CTX: c_int = 12; |
| 105 |
#[cfg(not(ossl110))] |
| 106 |
pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14; |
| 107 |
|
| 108 |
cfg_if! { |
| 109 |
if #[cfg(any(ossl110, libressl381))] { |
| 110 |
pub const CRYPTO_EX_INDEX_SSL: c_int = 0; |
| 111 |
pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 1; |
| 112 |
} else if #[cfg(libressl)] { |
| 113 |
pub const CRYPTO_EX_INDEX_SSL: c_int = 1; |
| 114 |
pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 2; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
pub const OPENSSL_VERSION: c_int = 0; |
| 119 |
pub const OPENSSL_CFLAGS: c_int = 1; |
| 120 |
pub const OPENSSL_BUILT_ON: c_int = 2; |
| 121 |
pub const OPENSSL_PLATFORM: c_int = 3; |
| 122 |
pub const OPENSSL_DIR: c_int = 4; |
| 123 |
|
| 124 |
#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))] |
| 125 |
pub const CRYPTO_LOCK: c_int = 1; |