1#![allow(
2 clippy::missing_safety_doc,
3 dead_code,
4 non_camel_case_types,
5 non_snake_case,
6 non_upper_case_globals,
7 unused_imports
8)]
9#![doc(html_root_url = "https://docs.rs/openssl-sys/0.9")]
10#![recursion_limit = "128"] extern crate libc;
13pub use std::ffi::c_int;
14
15#[cfg(feature = "unstable_boringssl")]
16extern crate bssl_sys;
17
18#[cfg(boringssl)]
19mod boringssl {
20 #[cfg(feature = "unstable_boringssl")]
21 pub use bssl_sys::*;
22 #[cfg(not(feature = "unstable_boringssl"))]
23 include!(concat!(env!("OUT_DIR"), "/bindgen.rs"));
24
25 pub fn init() {}
27}
28#[cfg(boringssl)]
29pub use boringssl::*;
30
31#[cfg(feature = "aws-lc")]
32extern crate aws_lc_sys;
33
34#[cfg(awslc)]
35#[allow(unpredictable_function_pointer_comparisons)]
36mod aws_lc {
37 #[cfg(all(feature = "aws-lc", not(feature = "aws-lc-fips")))]
38 pub use aws_lc_sys::*;
39
40 #[cfg(feature = "aws-lc-fips")]
41 pub use aws_lc_fips_sys::*;
42
43 #[cfg(not(any(feature = "aws-lc", feature = "aws-lc-fips")))]
44 include!(concat!(env!("OUT_DIR"), "/bindgen.rs"));
45
46 use std::ffi::{c_char, c_int, c_long, c_uint, c_void};
47
48 pub fn init() {
49 unsafe { CRYPTO_library_init() }
50 }
51
52 #[allow(non_snake_case)]
54 pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
55 unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) }
56 }
57
58 #[cfg(awslc_pregenerated)]
66 #[allow(non_snake_case, clippy::cast_possible_wrap)]
67 pub fn ERR_GET_LIB(packed_error: c_uint) -> c_int {
68 ((packed_error >> 24) & 0xFF) as c_int
69 }
70
71 #[cfg(awslc_pregenerated)]
72 #[allow(non_snake_case, clippy::cast_possible_wrap)]
73 pub fn ERR_GET_REASON(packed_error: c_uint) -> c_int {
74 (packed_error & 0xFFF) as c_int
75 }
76
77 #[cfg(awslc_pregenerated)]
78 #[allow(non_snake_case)]
79 pub fn ERR_GET_FUNC(_packed_error: c_uint) -> c_int {
80 0
81 }
82}
83#[cfg(awslc)]
84pub use aws_lc::*;
85
86#[cfg(openssl)]
87#[path = "."]
88mod openssl {
89 use std::ffi::{c_char, c_int, c_void};
90
91 #[cfg(feature = "bindgen")]
92 include!(concat!(env!("OUT_DIR"), "/bindgen.rs"));
93
94 pub use self::aes::*;
95 pub use self::asn1::*;
96 pub use self::bio::*;
97 pub use self::bn::*;
98 pub use self::cms::*;
99 #[cfg(ossl300)]
100 pub use self::core_dispatch::*;
101 pub use self::crypto::*;
102 pub use self::dh::*;
103 pub use self::dsa::*;
104 pub use self::dtls1::*;
105 pub use self::ec::*;
106 pub use self::err::*;
107 pub use self::evp::*;
108 #[cfg(not(feature = "bindgen"))]
109 pub use self::handwritten::*;
110 pub use self::obj_mac::*;
111 pub use self::ocsp::*;
112 pub use self::pem::*;
113 pub use self::pkcs7::*;
114 pub use self::rsa::*;
115 pub use self::sha::*;
116 pub use self::srtp::*;
117 pub use self::ssl::*;
118 pub use self::ssl3::*;
119 pub use self::tls1::*;
120 pub use self::types::*;
121 pub use self::x509::*;
122 pub use self::x509_vfy::*;
123 pub use self::x509v3::*;
124
125 #[macro_use]
126 mod macros;
127
128 mod aes;
129 mod asn1;
130 mod bio;
131 mod bn;
132 mod cms;
133 #[cfg(ossl300)]
134 mod core_dispatch;
135 mod crypto;
136 mod dh;
137 mod dsa;
138 mod dtls1;
139 mod ec;
140 mod err;
141 mod evp;
142 #[cfg(not(feature = "bindgen"))]
143 mod handwritten;
144 mod obj_mac;
145 mod ocsp;
146 mod pem;
147 mod pkcs7;
148 mod rsa;
149 mod sha;
150 mod srtp;
151 mod ssl;
152 mod ssl3;
153 mod tls1;
154 mod types;
155 mod x509;
156 mod x509_vfy;
157 mod x509v3;
158
159 use std::sync::Once;
160 static INIT: Once = Once::new();
162
163 pub type PasswordCallback = unsafe extern "C" fn(
165 buf: *mut c_char,
166 size: c_int,
167 rwflag: c_int,
168 user_data: *mut c_void,
169 ) -> c_int;
170
171 #[cfg(ossl110)]
172 pub fn init() {
173 use std::ptr;
174
175 #[cfg(not(ossl111b))]
176 let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS;
177 #[cfg(ossl111b)]
178 let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_NO_ATEXIT;
179
180 INIT.call_once(|| unsafe {
181 OPENSSL_init_ssl(init_options, ptr::null_mut());
182 })
183 }
184
185 #[cfg(libressl)]
186 pub fn init() {}
187
188 pub unsafe fn assume_init() {
198 INIT.call_once(|| {});
199 }
200}
201#[cfg(openssl)]
202pub use openssl::*;