diff options
| author | Steven Fackler <[email protected]> | 2018-09-08 21:13:15 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2018-09-12 19:21:18 -0700 |
| commit | 93a4e96255744363b80603e821e94b551621fbd8 (patch) | |
| tree | 1c1e77369f63d55738a5cbeea65d2d7c515d2971 /openssl-sys/src/crypto.rs | |
| parent | clean up example (diff) | |
| download | rust-openssl-93a4e96255744363b80603e821e94b551621fbd8.tar.xz rust-openssl-93a4e96255744363b80603e821e94b551621fbd8.zip | |
Refactor openssl-sys
The old layout tried to structure itself by version but it ended up with
a lot of duplication. Instead, follow the structure of the header files.
Diffstat (limited to 'openssl-sys/src/crypto.rs')
| -rw-r--r-- | openssl-sys/src/crypto.rs | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/openssl-sys/src/crypto.rs b/openssl-sys/src/crypto.rs new file mode 100644 index 00000000..48f4e062 --- /dev/null +++ b/openssl-sys/src/crypto.rs @@ -0,0 +1,122 @@ +use libc::*; + +use *; + +#[cfg(not(ossl110))] +pub const CRYPTO_LOCK_X509: c_int = 3; +#[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); + +cfg_if! { + if #[cfg(ossl110)] { + pub const CRYPTO_EX_INDEX_SSL: c_int = 0; + pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 1; + + extern "C" { + pub fn OpenSSL_version_num() -> c_ulong; + 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; + } +} + +// FIXME should be options +pub type CRYPTO_EX_new = unsafe extern "C" fn( + parent: *mut c_void, + ptr: *mut c_void, + ad: *const CRYPTO_EX_DATA, + idx: c_int, + argl: c_long, + argp: *const c_void, +) -> c_int; +pub type CRYPTO_EX_dup = unsafe extern "C" fn( + to: *mut CRYPTO_EX_DATA, + from: *mut CRYPTO_EX_DATA, + from_d: *mut c_void, + idx: c_int, + argl: c_long, + argp: *mut c_void, +) -> c_int; +pub type CRYPTO_EX_free = unsafe extern "C" fn( + parent: *mut c_void, + ptr: *mut c_void, + ad: *mut CRYPTO_EX_DATA, + idx: c_int, + argl: c_long, + argp: *mut c_void, +); +extern "C" { + #[cfg(ossl110)] + pub fn 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_int; +} + +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; +} + +cfg_if! { + if #[cfg(ossl110)] { + extern "C" { + pub fn CRYPTO_malloc(num: size_t, file: *const c_char, line: c_int) -> *mut c_void; + pub fn CRYPTO_free(buf: *mut c_void, file: *const c_char, line: c_int); + } + } else { + extern "C" { + pub fn CRYPTO_malloc(num: c_int, file: *const c_char, line: c_int) -> *mut c_void; + pub fn CRYPTO_free(buf: *mut c_void); + } + } +} + +extern "C" { + #[cfg(ossl101)] + pub fn FIPS_mode() -> c_int; + #[cfg(ossl101)] + pub fn FIPS_mode_set(onoff: c_int) -> c_int; + + pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; +} |