1 use libc
::{c_int, c_void, c_char, c_uchar, c_ulong, c_long, c_uint, size_t}
;
2 use std
::sync
::{Once, ONCE_INIT}
;
8 pub enum CRYPTO_EX_DATA {}
11 pub enum EVP_CIPHER {}
12 pub enum EVP_MD_CTX {}
15 pub enum OPENSSL_STACK {}
20 pub enum SSL_SESSION {}
21 pub enum stack_st_ASN1_OBJECT {}
22 pub enum stack_st_GENERAL_NAME {}
23 pub enum stack_st_OPENSSL_STRING {}
24 pub enum stack_st_void {}
25 pub enum stack_st_X509 {}
26 pub enum stack_st_X509_NAME {}
27 pub enum stack_st_X509_ATTRIBUTE {}
28 pub enum stack_st_X509_EXTENSION {}
29 pub enum stack_st_SSL_CIPHER {}
30 pub enum OPENSSL_INIT_SETTINGS {}
32 pub enum X509_ALGOR {}
33 pub enum X509_VERIFY_PARAM {}
36 pub const SSL_OP_MICROSOFT_SESS_ID_BUG
: c_ulong
= 0x00000000;
37 pub const SSL_OP_NETSCAPE_CHALLENGE_BUG
: c_ulong
= 0x00000000;
38 pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
: c_ulong
= 0x00000000;
39 pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
: c_ulong
= 0x00000000;
40 pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG
: c_ulong
= 0x00000000;
41 pub const SSL_OP_TLS_D5_BUG
: c_ulong
= 0x00000000;
42 pub const SSL_OP_TLS_BLOCK_PADDING_BUG
: c_ulong
= 0x00000000;
43 pub const SSL_OP_SINGLE_ECDH_USE
: c_ulong
= 0x00000000;
44 pub const SSL_OP_SINGLE_DH_USE
: c_ulong
= 0x00000000;
45 pub const SSL_OP_NO_SSLv2
: c_ulong
= 0x00000000;
47 pub const OPENSSL_VERSION
: c_int
= 0;
48 pub const OPENSSL_CFLAGS
: c_int
= 1;
49 pub const OPENSSL_BUILT_ON
: c_int
= 2;
50 pub const OPENSSL_PLATFORM
: c_int
= 3;
51 pub const OPENSSL_DIR
: c_int
= 4;
53 pub const CRYPTO_EX_INDEX_SSL
: c_int
= 0;
54 pub const CRYPTO_EX_INDEX_SSL_CTX
: c_int
= 1;
56 pub const OPENSSL_INIT_LOAD_SSL_STRINGS
: u64 = 0x00200000;
58 pub const X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
: c_uint
= 0x20;
61 // explicitly initialize to work around https://github.com/openssl/openssl/issues/3505
62 static INIT
: Once
= ONCE_INIT
;
64 INIT
.call_once(|| unsafe {
65 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
, ptr
::null_mut());
70 pub fn BIO_new(type_
: *const BIO_METHOD
) -> *mut BIO
;
71 pub fn BIO_s_file() -> *const BIO_METHOD
;
72 pub fn BIO_s_mem() -> *const BIO_METHOD
;
74 pub fn BN_get_rfc2409_prime_768(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
75 pub fn BN_get_rfc2409_prime_1024(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
76 pub fn BN_get_rfc3526_prime_1536(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
77 pub fn BN_get_rfc3526_prime_2048(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
78 pub fn BN_get_rfc3526_prime_3072(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
79 pub fn BN_get_rfc3526_prime_4096(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
80 pub fn BN_get_rfc3526_prime_6144(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
81 pub fn BN_get_rfc3526_prime_8192(bn
: *mut BIGNUM
) -> *mut BIGNUM
;
83 pub fn CRYPTO_malloc(num
: size_t
, file
: *const c_char
, line
: c_int
) -> *mut c_void
;
84 pub fn CRYPTO_free(buf
: *mut c_void
, file
: *const c_char
, line
: c_int
);
86 pub fn EVP_chacha20() -> *const ::EVP_CIPHER
;
87 pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER
;
89 pub fn HMAC_CTX_new() -> *mut HMAC_CTX
;
90 pub fn HMAC_CTX_free(ctx
: *mut HMAC_CTX
);
92 pub fn OCSP_cert_to_id(
93 dgst
: *const ::EVP_MD
,
94 subject
: *const ::X509
,
95 issuer
: *const ::X509
,
96 ) -> *mut ::OCSP_CERTID
;
98 pub fn TLS_method() -> *const ::SSL_METHOD
;
99 pub fn DTLS_method() -> *const ::SSL_METHOD
;
100 pub fn SSL_CIPHER_get_version(cipher
: *const ::SSL_CIPHER
) -> *const c_char
;
101 pub fn X509_get_subject_name(x
: *const ::X509
) -> *mut ::X509_NAME
;
102 pub fn X509_set1_notAfter(x
: *mut ::X509
, tm
: *const ::ASN1_TIME
) -> c_int
;
103 pub fn X509_set1_notBefore(x
: *mut ::X509
, tm
: *const ::ASN1_TIME
) -> c_int
;
104 pub fn X509_get_ext_d2i(
110 pub fn X509_NAME_add_entry_by_NID(
114 bytes
: *const c_uchar
,
119 pub fn X509_get_signature_nid(x
: *const X509
) -> c_int
;
120 pub fn X509_ALGOR_get0(
121 paobj
: *mut *const ::ASN1_OBJECT
,
123 ppval
: *mut *const c_void
,
124 alg
: *const ::X509_ALGOR
,
126 pub fn X509_NAME_get_entry(n
: *const ::X509_NAME
, loc
: c_int
) -> *mut ::X509_NAME_ENTRY
;
127 pub fn X509_NAME_ENTRY_get_data(ne
: *const ::X509_NAME_ENTRY
) -> *mut ::ASN1_STRING
;
128 pub fn X509V3_EXT_nconf_nid(
130 ctx
: *mut ::X509V3_CTX
,
132 value
: *const c_char
,
133 ) -> *mut ::X509_EXTENSION
;
134 pub fn X509V3_EXT_nconf(
136 ctx
: *mut ::X509V3_CTX
,
138 value
: *const c_char
,
139 ) -> *mut ::X509_EXTENSION
;
140 pub fn ASN1_STRING_to_UTF8(out
: *mut *mut c_uchar
, s
: *const ::ASN1_STRING
) -> c_int
;
141 pub fn BN_is_negative(b
: *const ::BIGNUM
) -> c_int
;
142 pub fn EVP_CIPHER_key_length(cipher
: *const EVP_CIPHER
) -> c_int
;
143 pub fn EVP_CIPHER_block_size(cipher
: *const EVP_CIPHER
) -> c_int
;
144 pub fn EVP_CIPHER_iv_length(cipher
: *const EVP_CIPHER
) -> c_int
;
145 pub fn EVP_PBE_scrypt(
148 salt
: *const c_uchar
,
159 p
: *mut *const ::BIGNUM
,
160 q
: *mut *const ::BIGNUM
,
161 q
: *mut *const ::BIGNUM
,
165 pub_key
: *mut *const ::BIGNUM
,
166 priv_key
: *mut *const ::BIGNUM
,
170 n
: *mut *const ::BIGNUM
,
171 e
: *mut *const ::BIGNUM
,
172 d
: *mut *const ::BIGNUM
,
174 pub fn RSA_get0_factors(r
: *const ::RSA
, p
: *mut *const ::BIGNUM
, q
: *mut *const ::BIGNUM
);
181 pub fn RSA_set0_factors(r
: *mut ::RSA
, p
: *mut ::BIGNUM
, q
: *mut ::BIGNUM
) -> c_int
;
182 pub fn RSA_set0_crt_params(
188 pub fn ASN1_STRING_get0_data(x
: *const ::ASN1_STRING
) -> *const c_uchar
;
189 pub fn OPENSSL_sk_num(stack
: *const ::OPENSSL_STACK
) -> c_int
;
190 pub fn OPENSSL_sk_value(stack
: *const ::OPENSSL_STACK
, idx
: c_int
) -> *mut c_void
;
191 pub fn SSL_CTX_get_options(ctx
: *const ::SSL_CTX
) -> c_ulong
;
192 pub fn SSL_CTX_set_options(ctx
: *mut ::SSL_CTX
, op
: c_ulong
) -> c_ulong
;
193 pub fn SSL_CTX_clear_options(ctx
: *mut ::SSL_CTX
, op
: c_ulong
) -> c_ulong
;
194 pub fn X509_getm_notAfter(x
: *const ::X509
) -> *mut ::ASN1_TIME
;
195 pub fn X509_getm_notBefore(x
: *const ::X509
) -> *mut ::ASN1_TIME
;
196 pub fn X509_get0_signature(
197 psig
: *mut *const ::ASN1_BIT_STRING
,
198 palg
: *mut *const ::X509_ALGOR
,
207 pub fn BIO_set_init(a
: *mut ::BIO
, init
: c_int
);
208 pub fn BIO_set_data(a
: *mut ::BIO
, data
: *mut c_void
);
209 pub fn BIO_get_data(a
: *mut ::BIO
) -> *mut c_void
;
210 pub fn BIO_meth_new(type_
: c_int
, name
: *const c_char
) -> *mut ::BIO_METHOD
;
211 pub fn BIO_meth_free(biom
: *mut ::BIO_METHOD
);
212 pub fn BIO_meth_set_write(
213 biom
: *mut ::BIO_METHOD
,
214 write
: unsafe extern "C" fn(*mut ::BIO
, *const c_char
, c_int
) -> c_int
,
216 pub fn BIO_meth_set_read(
217 biom
: *mut ::BIO_METHOD
,
218 read
: unsafe extern "C" fn(*mut ::BIO
, *mut c_char
, c_int
) -> c_int
,
220 pub fn BIO_meth_set_puts(
221 biom
: *mut ::BIO_METHOD
,
222 read
: unsafe extern "C" fn(*mut ::BIO
, *const c_char
) -> c_int
,
224 pub fn BIO_meth_set_ctrl(
225 biom
: *mut ::BIO_METHOD
,
226 read
: unsafe extern "C" fn(*mut ::BIO
, c_int
, c_long
, *mut c_void
) -> c_long
,
228 pub fn BIO_meth_set_create(
229 biom
: *mut ::BIO_METHOD
,
230 create
: unsafe extern "C" fn(*mut ::BIO
) -> c_int
,
232 pub fn BIO_meth_set_destroy(
233 biom
: *mut ::BIO_METHOD
,
234 destroy
: unsafe extern "C" fn(*mut ::BIO
) -> c_int
,
236 pub fn CRYPTO_get_ex_new_index(
240 new_func
: Option
<::CRYPTO_EX_new
>,
241 dup_func
: Option
<::CRYPTO_EX_dup
>,
242 free_func
: Option
<::CRYPTO_EX_free
>,
244 pub fn X509_up_ref(x
: *mut X509
) -> c_int
;
245 pub fn SSL_CTX_up_ref(x
: *mut SSL_CTX
) -> c_int
;
246 pub fn SSL_session_reused(ssl
: *mut SSL
) -> c_int
;
247 pub fn SSL_SESSION_get_master_key(
248 session
: *const SSL_SESSION
,
252 pub fn SSL_SESSION_up_ref(ses
: *mut SSL_SESSION
) -> c_int
;
253 pub fn X509_get0_extensions(req
: *const ::X509
) -> *const stack_st_X509_EXTENSION
;
254 pub fn X509_STORE_CTX_get0_chain(ctx
: *mut ::X509_STORE_CTX
) -> *mut stack_st_X509
;
255 pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX
;
256 pub fn EVP_MD_CTX_free(ctx
: *mut EVP_MD_CTX
);
257 pub fn EVP_PKEY_bits(key
: *const EVP_PKEY
) -> c_int
;
259 pub fn OpenSSL_version_num() -> c_ulong
;
260 pub fn OpenSSL_version(key
: c_int
) -> *const c_char
;
261 pub fn OPENSSL_init_ssl(opts
: u64, settings
: *const OPENSSL_INIT_SETTINGS
) -> c_int
;
262 pub fn OPENSSL_sk_new_null() -> *mut ::OPENSSL_STACK
;
263 pub fn OPENSSL_sk_free(st
: *mut ::OPENSSL_STACK
);
264 pub fn OPENSSL_sk_pop_free(
265 st
: *mut ::OPENSSL_STACK
,
266 free
: Option
<unsafe extern "C" fn(*mut c_void
)>,
268 pub fn OPENSSL_sk_push(st
: *mut ::OPENSSL_STACK
, data
: *const c_void
) -> c_int
;
269 pub fn OPENSSL_sk_pop(st
: *mut ::OPENSSL_STACK
) -> *mut c_void
;
271 pub fn PKCS12_create(
273 friendly_name
: *const c_char
,
276 ca
: *mut stack_st_X509
,
283 pub fn X509_REQ_get_version(req
: *const X509_REQ
) -> c_long
;
284 pub fn X509_REQ_get_subject_name(req
: *const X509_REQ
) -> *mut ::X509_NAME
;