1 use libc::*; 2 3 use *; 4 5 #[cfg(not(ossl110))] 6 pub const CRYPTO_LOCK_X509: c_int = 3; 7 #[cfg(not(ossl110))] 8 pub const CRYPTO_LOCK_EVP_PKEY: c_int = 10; 9 #[cfg(not(ossl110))] 10 pub const CRYPTO_LOCK_SSL_CTX: c_int = 12; 11 #[cfg(not(ossl110))] 12 pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14; 13 14 stack!(stack_st_void); 15 16 cfg_if! { 17 if #[cfg(ossl110)] { 18 pub const CRYPTO_EX_INDEX_SSL: c_int = 0; 19 pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 1; 20 } else if #[cfg(libressl)] { 21 pub const CRYPTO_EX_INDEX_SSL: c_int = 1; 22 pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 2; 23 } 24 } 25 cfg_if! { 26 if #[cfg(any(ossl110, libressl271))] { 27 extern "C" { 28 pub fn OpenSSL_version_num() -> c_ulong; 29 pub fn OpenSSL_version(key: c_int) -> *const c_char; 30 } 31 pub const OPENSSL_VERSION: c_int = 0; 32 pub const OPENSSL_CFLAGS: c_int = 1; 33 pub const OPENSSL_BUILT_ON: c_int = 2; 34 pub const OPENSSL_PLATFORM: c_int = 3; 35 pub const OPENSSL_DIR: c_int = 4; 36 } else { 37 extern "C" { 38 pub fn SSLeay() -> c_ulong; 39 pub fn SSLeay_version(key: c_int) -> *const c_char; 40 } 41 pub const SSLEAY_VERSION: c_int = 0; 42 pub const SSLEAY_CFLAGS: c_int = 2; 43 pub const SSLEAY_BUILT_ON: c_int = 3; 44 pub const SSLEAY_PLATFORM: c_int = 4; 45 pub const SSLEAY_DIR: c_int = 5; 46 } 47 } 48 49 // FIXME should be options 50 pub type CRYPTO_EX_new = unsafe extern "C" fn( 51 parent: *mut c_void, 52 ptr: *mut c_void, 53 ad: *const CRYPTO_EX_DATA, 54 idx: c_int, 55 argl: c_long, 56 argp: *const c_void, 57 ) -> c_int; 58 pub type CRYPTO_EX_dup = unsafe extern "C" fn( 59 to: *mut CRYPTO_EX_DATA, 60 from: *mut CRYPTO_EX_DATA, 61 from_d: *mut c_void, 62 idx: c_int, 63 argl: c_long, 64 argp: *mut c_void, 65 ) -> c_int; 66 pub type CRYPTO_EX_free = unsafe extern "C" fn( 67 parent: *mut c_void, 68 ptr: *mut c_void, 69 ad: *mut CRYPTO_EX_DATA, 70 idx: c_int, 71 argl: c_long, 72 argp: *mut c_void, 73 ); 74 extern "C" { 75 #[cfg(any(ossl110, libressl))] CRYPTO_get_ex_new_index( class_index: c_int, argl: c_long, argp: *mut c_void, new_func: Option<CRYPTO_EX_new>, dup_func: Option<CRYPTO_EX_dup>, free_func: Option<CRYPTO_EX_free>, ) -> c_int76 pub fn CRYPTO_get_ex_new_index( 77 class_index: c_int, 78 argl: c_long, 79 argp: *mut c_void, 80 new_func: Option<CRYPTO_EX_new>, 81 dup_func: Option<CRYPTO_EX_dup>, 82 free_func: Option<CRYPTO_EX_free>, 83 ) -> c_int; 84 } 85 86 pub const CRYPTO_LOCK: c_int = 1; 87 88 extern "C" { 89 #[cfg(not(ossl110))] CRYPTO_num_locks() -> c_int90 pub fn CRYPTO_num_locks() -> c_int; 91 #[cfg(not(ossl110))] CRYPTO_set_locking_callback( func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int), )92 pub fn CRYPTO_set_locking_callback( 93 func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int), 94 ); 95 96 #[cfg(not(ossl110))] CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong)97 pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong); 98 99 #[cfg(not(ossl110))] CRYPTO_add_lock( pointer: *mut c_int, amount: c_int, type_: c_int, file: *const c_char, line: c_int, ) -> c_int100 pub fn CRYPTO_add_lock( 101 pointer: *mut c_int, 102 amount: c_int, 103 type_: c_int, 104 file: *const c_char, 105 line: c_int, 106 ) -> c_int; 107 } 108 109 cfg_if! { 110 if #[cfg(ossl110)] { 111 extern "C" { 112 pub fn CRYPTO_malloc(num: size_t, file: *const c_char, line: c_int) -> *mut c_void; 113 pub fn CRYPTO_free(buf: *mut c_void, file: *const c_char, line: c_int); 114 } 115 } else { 116 extern "C" { 117 pub fn CRYPTO_malloc(num: c_int, file: *const c_char, line: c_int) -> *mut c_void; 118 pub fn CRYPTO_free(buf: *mut c_void); 119 } 120 } 121 } 122 123 extern "C" { 124 #[cfg(ossl101)] FIPS_mode() -> c_int125 pub fn FIPS_mode() -> c_int; 126 #[cfg(ossl101)] FIPS_mode_set(onoff: c_int) -> c_int127 pub fn FIPS_mode_set(onoff: c_int) -> c_int; 128 CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int129 pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; 130 } 131