1#![allow(
2 clippy::missing_safety_doc,
3 clippy::redundant_static_lifetimes,
4 clippy::too_many_arguments,
5 clippy::unreadable_literal,
6 clippy::upper_case_acronyms,
7 improper_ctypes,
8 non_camel_case_types,
9 non_snake_case,
10 non_upper_case_globals,
11 unused_imports
12)]
13
14use std::convert::TryInto;
15use std::ffi::c_void;
16use std::os::raw::{c_char, c_int, c_uint, c_ulong};
17
18#[allow(
19 clippy::useless_transmute,
20 clippy::derive_partial_eq_without_eq,
21 clippy::ptr_offset_with_cast,
22 unpredictable_function_pointer_comparisons, dead_code,
24)]
25mod generated {
26 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
27}
28
29pub use generated::{ssl_compliance_policy_t, ERR_add_error_data, SSL_set1_groups}; pub use generated::{BIO_new, OPENSSL_free, SSL_ERROR_NONE}; pub use generated::*;
36
37#[cfg(target_pointer_width = "64")]
38pub type BN_ULONG = u64;
39#[cfg(target_pointer_width = "32")]
40pub type BN_ULONG = u32;
41
42#[must_use]
43pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong {
44 ((l as c_ulong & 0x0FF) << 24) | ((f as c_ulong & 0xFFF) << 12) | (r as c_ulong & 0xFFF)
45}
46
47#[must_use]
48pub const fn ERR_GET_LIB(l: c_uint) -> c_int {
49 ((l >> 24) & 0x0FF) as c_int
50}
51
52#[must_use]
53pub const fn ERR_GET_FUNC(l: c_uint) -> c_int {
54 ((l >> 12) & 0xFFF) as c_int
55}
56
57#[must_use]
58pub const fn ERR_GET_REASON(l: c_uint) -> c_int {
59 (l & 0xFFF) as c_int
60}
61
62pub fn init() {
63 unsafe {
64 CRYPTO_library_init();
65 }
66}