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 dead_code
23)]
24mod generated {
25 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
26}
27
28pub use generated::{ssl_compliance_policy_t, ERR_add_error_data, SSL_set1_groups}; pub use generated::{BIO_new, OPENSSL_free, SSL_ERROR_NONE}; #[cfg(feature = "fips")]
32pub use generated::{FIPS_mode, SSL_CTX_set_compliance_policy}; #[cfg(feature = "rpk")]
34pub use generated::{SSL_CREDENTIAL_new_raw_public_key, SSL_CREDENTIAL_set1_spki}; pub use generated::*;
37
38#[cfg(target_pointer_width = "64")]
39pub type BN_ULONG = u64;
40#[cfg(target_pointer_width = "32")]
41pub type BN_ULONG = u32;
42
43#[must_use]
44pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong {
45 ((l as c_ulong & 0x0FF) << 24) | ((f as c_ulong & 0xFFF) << 12) | (r as c_ulong & 0xFFF)
46}
47
48#[must_use]
49pub const fn ERR_GET_LIB(l: c_uint) -> c_int {
50 ((l >> 24) & 0x0FF) as c_int
51}
52
53#[must_use]
54pub const fn ERR_GET_FUNC(l: c_uint) -> c_int {
55 ((l >> 12) & 0xFFF) as c_int
56}
57
58#[must_use]
59pub const fn ERR_GET_REASON(l: c_uint) -> c_int {
60 (l & 0xFFF) as c_int
61}
62
63pub fn init() {
64 unsafe {
65 CRYPTO_library_init();
66 }
67}