| 1 |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 OR ISC |
| 3 |
|
| 4 |
#![cfg_attr(not(clippy), allow(unexpected_cfgs))] |
| 5 |
#![cfg_attr(not(clippy), allow(unknown_lints))] |
| 6 |
|
| 7 |
#[allow(unused_macros)] |
| 8 |
macro_rules! use_bindings { |
| 9 |
($bindings:ident) => { |
| 10 |
mod $bindings; |
| 11 |
pub use $bindings::*; |
| 12 |
}; |
| 13 |
} |
| 14 |
|
| 15 |
macro_rules! platform_binding { |
| 16 |
($platform:ident, $platform_crypto:ident) => { |
| 17 |
#[cfg(all($platform, not(feature = "ssl"), not(use_bindgen_pregenerated)))] |
| 18 |
use_bindings!($platform_crypto); |
| 19 |
}; |
| 20 |
} |
| 21 |
|
| 22 |
platform_binding!(universal_prefixed, universal_prefixed_crypto); |
| 23 |
platform_binding!(universal_no_u1_prefixed, universal_no_u1_prefixed_crypto); |
| 24 |
platform_binding!(universal_no_u1, universal_no_u1_crypto); |
| 25 |
platform_binding!(universal, universal_crypto); |
| 26 |
|
| 27 |
platform_binding!(aarch64_linux_android, aarch64_linux_android_crypto); |
| 28 |
platform_binding!(aarch64_apple_darwin, aarch64_apple_darwin_crypto); |
| 29 |
platform_binding!(aarch64_pc_windows_msvc, aarch64_pc_windows_msvc_crypto); |
| 30 |
platform_binding!(aarch64_unknown_linux_gnu, aarch64_unknown_linux_gnu_crypto); |
| 31 |
platform_binding!( |
| 32 |
aarch64_unknown_linux_musl, |
| 33 |
aarch64_unknown_linux_musl_crypto |
| 34 |
); |
| 35 |
platform_binding!(i686_pc_windows_msvc, i686_pc_windows_msvc_crypto); |
| 36 |
platform_binding!(i686_unknown_linux_gnu, i686_unknown_linux_gnu_crypto); |
| 37 |
platform_binding!( |
| 38 |
riscv64gc_unknown_linux_gnu, |
| 39 |
riscv64gc_unknown_linux_gnu_crypto |
| 40 |
); |
| 41 |
platform_binding!(x86_64_apple_darwin, x86_64_apple_darwin_crypto); |
| 42 |
platform_binding!(x86_64_pc_windows_gnu, x86_64_pc_windows_gnu_crypto); |
| 43 |
platform_binding!(x86_64_pc_windows_msvc, x86_64_pc_windows_msvc_crypto); |
| 44 |
platform_binding!(x86_64_unknown_linux_gnu, x86_64_unknown_linux_gnu_crypto); |
| 45 |
platform_binding!(x86_64_unknown_linux_musl, x86_64_unknown_linux_musl_crypto); |
| 46 |
|
| 47 |
#[cfg(use_bindgen_pregenerated)] |
| 48 |
#[allow( |
| 49 |
clippy::cast_lossless, |
| 50 |
clippy::cast_possible_truncation, |
| 51 |
clippy::cast_possible_wrap, |
| 52 |
clippy::default_trait_access, |
| 53 |
clippy::doc_markdown, |
| 54 |
clippy::missing_safety_doc, |
| 55 |
clippy::must_use_candidate, |
| 56 |
clippy::not_unsafe_ptr_arg_deref, |
| 57 |
clippy::ptr_as_ptr, |
| 58 |
clippy::ptr_offset_with_cast, |
| 59 |
clippy::pub_underscore_fields, |
| 60 |
clippy::semicolon_if_nothing_returned, |
| 61 |
clippy::too_many_lines, |
| 62 |
clippy::unreadable_literal, |
| 63 |
clippy::used_underscore_binding, |
| 64 |
clippy::useless_transmute, |
| 65 |
dead_code, |
| 66 |
improper_ctypes, |
| 67 |
non_camel_case_types, |
| 68 |
non_snake_case, |
| 69 |
non_upper_case_globals, |
| 70 |
unpredictable_function_pointer_comparisons, |
| 71 |
unused_imports |
| 72 |
)] |
| 73 |
mod generated { |
| 74 |
include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
| 75 |
} |
| 76 |
#[cfg(use_bindgen_pregenerated)] |
| 77 |
pub use generated::*; |
| 78 |
|
| 79 |
#[allow(non_snake_case, clippy::cast_possible_wrap)] |
| 80 |
#[must_use] |
| 81 |
pub fn ERR_GET_LIB(packed_error: u32) -> i32 { |
| 82 |
((packed_error >> 24) & 0xFF) as i32 |
| 83 |
} |
| 84 |
|
| 85 |
#[allow(non_snake_case, clippy::cast_possible_wrap)] |
| 86 |
#[must_use] |
| 87 |
pub fn ERR_GET_REASON(packed_error: u32) -> i32 { |
| 88 |
(packed_error & 0x0FFF) as i32 |
| 89 |
} |
| 90 |
|
| 91 |
#[allow(non_snake_case)] |
| 92 |
#[must_use] |
| 93 |
pub fn ERR_GET_FUNC(_packed_error: u32) -> i32 { |
| 94 |
0 |
| 95 |
} |
| 96 |
|
| 97 |
#[cfg(feature = "all-bindings")] |
| 98 |
use std::os::raw::{c_char, c_long, c_void}; |
| 99 |
|
| 100 |
#[cfg(feature = "all-bindings")] |
| 101 |
#[allow(non_snake_case, clippy::not_unsafe_ptr_arg_deref)] |
| 102 |
pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long { |
| 103 |
unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) } |
| 104 |
} |
| 105 |
|
| 106 |
pub fn init() { |
| 107 |
unsafe { CRYPTO_library_init() } |
| 108 |
} |