Skip to main content

variant_ssl_sys/handwritten/
crypto.rs

1use super::super::*;
2use libc::size_t;
3use std::ffi::{c_char, c_int, c_long, c_ulong, c_void};
4
5stack!(stack_st_void);
6
7extern "C" {
8    pub fn OpenSSL_version_num() -> c_ulong;
9    pub fn OpenSSL_version(key: c_int) -> *const c_char;
10}
11
12extern "C" {
13    pub fn CRYPTO_get_ex_new_index(
14        class_index: c_int,
15        argl: c_long,
16        argp: *mut c_void,
17        new_func: CRYPTO_EX_new,
18        dup_func: CRYPTO_EX_dup,
19        free_func: CRYPTO_EX_free,
20    ) -> c_int;
21
22    #[cfg(not(ossl110))]
23    pub fn CRYPTO_num_locks() -> c_int;
24}
25
26#[allow(clashing_extern_declarations)]
27extern "C" {
28    #[cfg(not(ossl110))]
29    pub fn CRYPTO_set_locking_callback(
30        func: Option<unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int)>,
31    );
32
33    #[cfg(not(ossl110))]
34    pub fn CRYPTO_set_id_callback(func: Option<unsafe extern "C" fn() -> c_ulong>);
35}
36
37extern "C" {
38    #[cfg(not(ossl110))]
39    pub fn CRYPTO_add_lock(
40        pointer: *mut c_int,
41        amount: c_int,
42        type_: c_int,
43        file: *const c_char,
44        line: c_int,
45    ) -> c_int;
46}
47
48cfg_if! {
49    if #[cfg(any(ossl110, libressl390))] {
50        extern "C" {
51            pub fn CRYPTO_malloc(num: size_t, file: *const c_char, line: c_int) -> *mut c_void;
52            pub fn CRYPTO_free(buf: *mut c_void, file: *const c_char, line: c_int);
53        }
54    } else {
55        extern "C" {
56            pub fn CRYPTO_malloc(num: c_int, file: *const c_char, line: c_int) -> *mut c_void;
57            pub fn CRYPTO_free(buf: *mut c_void);
58        }
59    }
60}
61
62extern "C" {
63    #[cfg(all(ossl110, not(ossl300)))]
64    pub fn FIPS_mode() -> c_int;
65    #[cfg(all(ossl110, not(ossl300)))]
66    pub fn FIPS_mode_set(onoff: c_int) -> c_int;
67
68    pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int;
69
70    #[cfg(ossl300)]
71    pub fn OSSL_LIB_CTX_new() -> *mut OSSL_LIB_CTX;
72    #[cfg(ossl300)]
73    pub fn OSSL_LIB_CTX_free(libcts: *mut OSSL_LIB_CTX);
74}