1use libc::*;
2use std::ptr;
3
4use super::*;
5
6#[cfg(not(ossl110))]
7pub const SSL_MAX_KRB5_PRINCIPAL_LENGTH: c_int = 256;
8
9#[cfg(not(ossl110))]
10pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32;
11#[cfg(not(ossl110))]
12pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32;
13
14#[cfg(not(ossl110))]
15pub const SSL_MAX_KEY_ARG_LENGTH: c_int = 8;
16#[cfg(not(ossl110))]
17pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48;
18
19pub const SSL_SENT_SHUTDOWN: c_int = 1;
20pub const SSL_RECEIVED_SHUTDOWN: c_int = 2;
21
22pub const SSL_FILETYPE_PEM: c_int = X509_FILETYPE_PEM;
23pub const SSL_FILETYPE_ASN1: c_int = X509_FILETYPE_ASN1;
24
25#[cfg(ossl111)]
26pub const SSL_EXT_TLS_ONLY: c_uint = 0x0001;
27#[cfg(ossl111)]
29pub const SSL_EXT_DTLS_ONLY: c_uint = 0x0002;
30#[cfg(ossl111)]
32pub const SSL_EXT_TLS_IMPLEMENTATION_ONLY: c_uint = 0x0004;
33#[cfg(ossl111)]
35pub const SSL_EXT_SSL3_ALLOWED: c_uint = 0x0008;
36#[cfg(ossl111)]
38pub const SSL_EXT_TLS1_2_AND_BELOW_ONLY: c_uint = 0x0010;
39#[cfg(ossl111)]
41pub const SSL_EXT_TLS1_3_ONLY: c_uint = 0x0020;
42#[cfg(ossl111)]
44pub const SSL_EXT_IGNORE_ON_RESUMPTION: c_uint = 0x0040;
45#[cfg(ossl111)]
46pub const SSL_EXT_CLIENT_HELLO: c_uint = 0x0080;
47#[cfg(ossl111)]
49pub const SSL_EXT_TLS1_2_SERVER_HELLO: c_uint = 0x0100;
50#[cfg(ossl111)]
51pub const SSL_EXT_TLS1_3_SERVER_HELLO: c_uint = 0x0200;
52#[cfg(ossl111)]
53pub const SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS: c_uint = 0x0400;
54#[cfg(ossl111)]
55pub const SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST: c_uint = 0x0800;
56#[cfg(ossl111)]
57pub const SSL_EXT_TLS1_3_CERTIFICATE: c_uint = 0x1000;
58#[cfg(ossl111)]
59pub const SSL_EXT_TLS1_3_NEW_SESSION_TICKET: c_uint = 0x2000;
60#[cfg(ossl111)]
61pub const SSL_EXT_TLS1_3_CERTIFICATE_REQUEST: c_uint = 0x4000;
62
63cfg_if! {
64 if #[cfg(ossl300)] {
65 macro_rules! ssl_op_type {
66 () => {u64};
67 }
68 } else {
69 macro_rules! ssl_op_type {
70 () => {c_ulong};
71 }
72 }
73}
74
75pub const SSL_OP_LEGACY_SERVER_CONNECT: ssl_op_type!() = 0x00000004;
76cfg_if! {
77 if #[cfg(libressl)] {
78 pub const SSL_OP_TLSEXT_PADDING: ssl_op_type!() = 0x0;
79 } else {
80 pub const SSL_OP_TLSEXT_PADDING: ssl_op_type!() = 0x10;
81 }
82}
83#[cfg(ossl110)]
84pub const SSL_OP_SAFARI_ECDHE_ECDSA_BUG: ssl_op_type!() = 0x00000040;
85#[cfg(ossl300)]
86pub const SSL_OP_IGNORE_UNEXPECTED_EOF: ssl_op_type!() = 0x00000080;
87
88#[cfg(not(libressl430))]
89pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: ssl_op_type!() = 0x00000800;
90#[cfg(libressl430)]
91pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: ssl_op_type!() = 0x00000000;
92
93pub const SSL_OP_NO_QUERY_MTU: ssl_op_type!() = 0x00001000;
94pub const SSL_OP_COOKIE_EXCHANGE: ssl_op_type!() = 0x00002000;
95pub const SSL_OP_NO_TICKET: ssl_op_type!() = 0x00004000;
96cfg_if! {
97 if #[cfg(ossl110)] {
98 pub const SSL_OP_CISCO_ANYCONNECT: ssl_op_type!() = 0x00008000;
99 } else {
100 pub const SSL_OP_CISCO_ANYCONNECT: ssl_op_type!() = 0x0;
101 }
102}
103
104pub const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: ssl_op_type!() = 0x00010000;
105cfg_if! {
106 if #[cfg(ossl110)] {
107 pub const SSL_OP_NO_COMPRESSION: ssl_op_type!() = 0x00020000;
108 pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: ssl_op_type!() = 0x00040000;
109 } else {
110 pub const SSL_OP_NO_COMPRESSION: ssl_op_type!() = 0x0;
111 pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: ssl_op_type!() = 0x0;
112 }
113}
114
115#[cfg(ossl111)]
116pub const SSL_OP_ENABLE_MIDDLEBOX_COMPAT: ssl_op_type!() = 0x00100000;
117#[cfg(ossl111)]
118pub const SSL_OP_PRIORITIZE_CHACHA: ssl_op_type!() = 0x00200000;
119
120pub const SSL_OP_CIPHER_SERVER_PREFERENCE: ssl_op_type!() = 0x00400000;
121cfg_if! {
122 if #[cfg(libressl)] {
123 pub const SSL_OP_TLS_ROLLBACK_BUG: ssl_op_type!() = 0;
124 } else {
125 pub const SSL_OP_TLS_ROLLBACK_BUG: ssl_op_type!() = 0x00800000;
126 }
127}
128
129cfg_if! {
130 if #[cfg(ossl110)] {
131 pub const SSL_OP_NO_SSLv3: ssl_op_type!() = 0x02000000;
132 } else {
133 pub const SSL_OP_NO_SSLv3: ssl_op_type!() = 0x0;
134 }
135}
136pub const SSL_OP_NO_TLSv1_1: ssl_op_type!() = 0x10000000;
137pub const SSL_OP_NO_TLSv1_2: ssl_op_type!() = 0x08000000;
138
139pub const SSL_OP_NO_TLSv1: ssl_op_type!() = 0x04000000;
140cfg_if! {
141 if #[cfg(libressl)] {
142 pub const SSL_OP_NO_DTLSv1: ssl_op_type!() = 0x40000000;
143 pub const SSL_OP_NO_DTLSv1_2: ssl_op_type!() = 0x80000000;
144 } else {
145 pub const SSL_OP_NO_DTLSv1: ssl_op_type!() = 0x04000000;
146 pub const SSL_OP_NO_DTLSv1_2: ssl_op_type!() = 0x08000000;
147 }
148}
149#[cfg(any(ossl111, libressl))]
150pub const SSL_OP_NO_TLSv1_3: ssl_op_type!() = 0x20000000;
151
152#[cfg(ossl110h)]
153pub const SSL_OP_NO_RENEGOTIATION: ssl_op_type!() = 0x40000000;
154
155cfg_if! {
156 if #[cfg(ossl111)] {
157 pub const SSL_OP_NO_SSL_MASK: ssl_op_type!() = SSL_OP_NO_SSLv2
158 | SSL_OP_NO_SSLv3
159 | SSL_OP_NO_TLSv1
160 | SSL_OP_NO_TLSv1_1
161 | SSL_OP_NO_TLSv1_2
162 | SSL_OP_NO_TLSv1_3;
163 } else if #[cfg(ossl110)] {
164 pub const SSL_OP_NO_SSL_MASK: ssl_op_type!() =
165 SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2;
166 }
167}
168
169cfg_if! {
170 if #[cfg(libressl)] {
171 pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: ssl_op_type!() = 0x0;
172 } else {
173 pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: ssl_op_type!() = 0x80000000;
174 }
175}
176
177cfg_if! {
178 if #[cfg(ossl300)] {
179 pub const SSL_OP_ALL: ssl_op_type!() = SSL_OP_CRYPTOPRO_TLSEXT_BUG
180 | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
181 | SSL_OP_TLSEXT_PADDING
182 | SSL_OP_SAFARI_ECDHE_ECDSA_BUG;
183 } else if #[cfg(ossl110f)] {
184 pub const SSL_OP_ALL: ssl_op_type!() = SSL_OP_CRYPTOPRO_TLSEXT_BUG
185 | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
186 | SSL_OP_LEGACY_SERVER_CONNECT
187 | SSL_OP_TLSEXT_PADDING
188 | SSL_OP_SAFARI_ECDHE_ECDSA_BUG;
189 } else if #[cfg(libressl)] {
190 pub const SSL_OP_ALL: ssl_op_type!() = 0x4;
191 } else {
192 pub const SSL_OP_ALL: ssl_op_type!() = 0x80000BFF;
193 }
194}
195
196pub const SSL_OP_MICROSOFT_SESS_ID_BUG: ssl_op_type!() = 0x0;
197pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: ssl_op_type!() = 0x0;
198pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: ssl_op_type!() = 0x0;
199pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: ssl_op_type!() = 0x0;
200pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: ssl_op_type!() = 0x0;
201pub const SSL_OP_TLS_D5_BUG: ssl_op_type!() = 0x0;
202pub const SSL_OP_TLS_BLOCK_PADDING_BUG: ssl_op_type!() = 0x0;
203pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x0;
204pub const SSL_OP_NO_SSLv2: ssl_op_type!() = 0x0;
205cfg_if! {
206 if #[cfg(libressl)] {
207 pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00100000;
208 } else {
209 pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00000000;
210 }
211}
212
213pub const SSL_MODE_ENABLE_PARTIAL_WRITE: c_long = 0x1;
214pub const SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER: c_long = 0x2;
215pub const SSL_MODE_AUTO_RETRY: c_long = 0x4;
216pub const SSL_MODE_NO_AUTO_CHAIN: c_long = 0x8;
217pub const SSL_MODE_RELEASE_BUFFERS: c_long = 0x10;
218#[cfg(ossl110)]
219pub const SSL_MODE_SEND_CLIENTHELLO_TIME: c_long = 0x20;
220#[cfg(ossl110)]
221pub const SSL_MODE_SEND_SERVERHELLO_TIME: c_long = 0x40;
222#[cfg(ossl110)]
223pub const SSL_MODE_SEND_FALLBACK_SCSV: c_long = 0x80;
224
225pub unsafe fn SSL_CTX_set_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long {
226 SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, op, ptr::null_mut())
227}
228
229#[cfg(ossl111)]
230pub const SSL_COOKIE_LENGTH: c_int = 4096;
231
232cfg_if! {
233 if #[cfg(libressl)] {
234 pub unsafe fn SSL_CTX_get_options(ctx: *const SSL_CTX) -> c_ulong {
235 SSL_CTX_ctrl(ctx as *mut _, SSL_CTRL_OPTIONS, 0, ptr::null_mut()) as c_ulong
236 }
237
238 pub unsafe fn SSL_CTX_set_options(ctx: *const SSL_CTX, op: c_ulong) -> c_ulong {
239 SSL_CTX_ctrl(
240 ctx as *mut _,
241 SSL_CTRL_OPTIONS,
242 op as c_long,
243 ptr::null_mut(),
244 ) as c_ulong
245 }
246
247 pub unsafe fn SSL_CTX_clear_options(ctx: *const SSL_CTX, op: c_ulong) -> c_ulong {
248 SSL_CTX_ctrl(
249 ctx as *mut _,
250 SSL_CTRL_CLEAR_OPTIONS,
251 op as c_long,
252 ptr::null_mut(),
253 ) as c_ulong
254 }
255 }
256}
257
258pub unsafe fn SSL_set_mtu(ssl: *mut SSL, mtu: c_long) -> c_long {
259 SSL_ctrl(ssl, SSL_CTRL_SET_MTU, mtu, ptr::null_mut())
260}
261
262#[cfg(ossl110)]
263pub unsafe fn SSL_get_extms_support(ssl: *mut SSL) -> c_long {
264 SSL_ctrl(ssl, SSL_CTRL_GET_EXTMS_SUPPORT, 0, ptr::null_mut())
265}
266
267pub const SSL_SESS_CACHE_OFF: c_long = 0x0;
268pub const SSL_SESS_CACHE_CLIENT: c_long = 0x1;
269pub const SSL_SESS_CACHE_SERVER: c_long = 0x2;
270pub const SSL_SESS_CACHE_BOTH: c_long = SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_SERVER;
271pub const SSL_SESS_CACHE_NO_AUTO_CLEAR: c_long = 0x80;
272pub const SSL_SESS_CACHE_NO_INTERNAL_LOOKUP: c_long = 0x100;
273pub const SSL_SESS_CACHE_NO_INTERNAL_STORE: c_long = 0x200;
274pub const SSL_SESS_CACHE_NO_INTERNAL: c_long =
275 SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE;
276
277pub const OPENSSL_NPN_UNSUPPORTED: c_int = 0;
278pub const OPENSSL_NPN_NEGOTIATED: c_int = 1;
279pub const OPENSSL_NPN_NO_OVERLAP: c_int = 2;
280
281pub const SSL_AD_ILLEGAL_PARAMETER: c_int = SSL3_AD_ILLEGAL_PARAMETER;
282pub const SSL_AD_DECODE_ERROR: c_int = TLS1_AD_DECODE_ERROR;
283pub const SSL_AD_UNRECOGNIZED_NAME: c_int = TLS1_AD_UNRECOGNIZED_NAME;
284pub const SSL_ERROR_NONE: c_int = 0;
285pub const SSL_ERROR_SSL: c_int = 1;
286pub const SSL_ERROR_SYSCALL: c_int = 5;
287pub const SSL_ERROR_WANT_ACCEPT: c_int = 8;
288pub const SSL_ERROR_WANT_CONNECT: c_int = 7;
289pub const SSL_ERROR_WANT_READ: c_int = 2;
290pub const SSL_ERROR_WANT_WRITE: c_int = 3;
291pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4;
292pub const SSL_ERROR_ZERO_RETURN: c_int = 6;
293#[cfg(ossl111)]
294pub const SSL_ERROR_WANT_CLIENT_HELLO_CB: c_int = 11;
295pub const SSL_VERIFY_NONE: c_int = 0;
296pub const SSL_VERIFY_PEER: c_int = 1;
297pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2;
298#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
299pub const SSL_CTRL_SET_TMP_DH: c_int = 3;
300#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
301pub const SSL_CTRL_SET_TMP_ECDH: c_int = 4;
302#[cfg(libressl)]
303pub const SSL_CTRL_GET_SESSION_REUSED: c_int = 8;
304pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14;
305pub const SSL_CTRL_SET_MTU: c_int = 17;
306#[cfg(libressl)]
307pub const SSL_CTRL_OPTIONS: c_int = 32;
308pub const SSL_CTRL_MODE: c_int = 33;
309pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41;
310pub const SSL_CTRL_SET_SESS_CACHE_SIZE: c_int = 42;
311pub const SSL_CTRL_GET_SESS_CACHE_SIZE: c_int = 43;
312pub const SSL_CTRL_SET_SESS_CACHE_MODE: c_int = 44;
313pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: c_int = 53;
314pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG: c_int = 54;
315pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55;
316pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB: c_int = 63;
317pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG: c_int = 64;
318pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE: c_int = 65;
319pub const SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 70;
320pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 71;
321#[cfg(libressl)]
322pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77;
323pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS: c_int = 82;
324#[cfg(ossl110)]
325pub const SSL_CTRL_CHAIN_CERT: c_int = 89;
326#[cfg(any(ossl111, libressl))]
327pub const SSL_CTRL_SET_GROUPS_LIST: c_int = 92;
328#[cfg(libressl)]
329pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94;
330#[cfg(ossl110)]
331pub const SSL_CTRL_SET_SIGALGS_LIST: c_int = 98;
332#[cfg(ossl110)]
333pub const SSL_CTRL_SET_VERIFY_CERT_STORE: c_int = 106;
334#[cfg(ossl300)]
335pub const SSL_CTRL_GET_PEER_TMP_KEY: c_int = 109;
336#[cfg(ossl110)]
337pub const SSL_CTRL_SET_DH_AUTO: c_int = 118;
338#[cfg(ossl110)]
339pub const SSL_CTRL_GET_EXTMS_SUPPORT: c_int = 122;
340pub const SSL_CTRL_SET_MIN_PROTO_VERSION: c_int = 123;
341pub const SSL_CTRL_SET_MAX_PROTO_VERSION: c_int = 124;
342#[cfg(any(ossl110g, libressl))]
343pub const SSL_CTRL_GET_MIN_PROTO_VERSION: c_int = 130;
344#[cfg(any(ossl110g, libressl))]
345pub const SSL_CTRL_GET_MAX_PROTO_VERSION: c_int = 131;
346#[cfg(ossl300)]
347pub const SSL_CTRL_GET_TMP_KEY: c_int = 133;
348
349#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
350pub unsafe fn SSL_CTX_set_tmp_dh(ctx: *mut SSL_CTX, dh: *mut DH) -> c_long {
351 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void)
352}
353
354#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
355pub unsafe fn SSL_CTX_set_tmp_ecdh(ctx: *mut SSL_CTX, key: *mut EC_KEY) -> c_long {
356 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
357}
358
359#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
360pub unsafe fn SSL_set_tmp_dh(ssl: *mut SSL, dh: *mut DH) -> c_long {
361 SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void)
362}
363
364#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
365pub unsafe fn SSL_set_tmp_ecdh(ssl: *mut SSL, key: *mut EC_KEY) -> c_long {
366 SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
367}
368
369#[cfg(ossl110)]
370pub unsafe fn SSL_CTX_set_dh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_long {
371 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_DH_AUTO, onoff as c_long, ptr::null_mut())
372}
373
374#[cfg(ossl110)]
375pub unsafe fn SSL_set_dh_auto(ssl: *mut SSL, onoff: c_int) -> c_long {
376 SSL_ctrl(ssl, SSL_CTRL_SET_DH_AUTO, onoff as c_long, ptr::null_mut())
377}
378
379pub unsafe fn SSL_CTX_add_extra_chain_cert(ctx: *mut SSL_CTX, x509: *mut X509) -> c_long {
380 SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, x509 as *mut c_void)
381}
382
383pub unsafe fn SSL_CTX_get_extra_chain_certs(
384 ctx: *mut SSL_CTX,
385 chain: *mut *mut stack_st_X509,
386) -> c_long {
387 SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, chain as *mut c_void)
388}
389
390#[cfg(ossl110)]
391pub unsafe fn SSL_CTX_set0_verify_cert_store(ctx: *mut SSL_CTX, st: *mut X509_STORE) -> c_long {
392 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void)
393}
394
395#[cfg(ossl110)]
396pub unsafe fn SSL_set0_verify_cert_store(ssl: *mut SSL, st: *mut X509_STORE) -> c_long {
397 SSL_ctrl(ssl, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void)
398}
399
400cfg_if! {
401 if #[cfg(ossl111)] {
402 pub unsafe fn SSL_set1_groups_list(ctx: *mut SSL, s: *const c_char) -> c_long {
403 SSL_ctrl(
404 ctx,
405 SSL_CTRL_SET_GROUPS_LIST,
406 0,
407 s as *const c_void as *mut c_void,
408 )
409 }
410 pub unsafe fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
411 SSL_CTX_ctrl(
412 ctx,
413 SSL_CTRL_SET_GROUPS_LIST,
414 0,
415 s as *const c_void as *mut c_void,
416 )
417 }
418 } else if #[cfg(libressl)] {
419 extern "C" {
420 pub fn SSL_set1_groups_list(ctx: *mut SSL, list: *const c_char) -> c_int;
421 pub fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_int;
422 }
423 }
424}
425
426#[cfg(ossl110)]
427pub unsafe fn SSL_add0_chain_cert(ssl: *mut SSL, ptr: *mut X509) -> c_long {
428 SSL_ctrl(ssl, SSL_CTRL_CHAIN_CERT, 0, ptr as *mut c_void)
429}
430
431#[cfg(ossl110)]
432pub unsafe fn SSL_CTX_set1_sigalgs_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
433 SSL_CTX_ctrl(
434 ctx,
435 SSL_CTRL_SET_SIGALGS_LIST,
436 0,
437 s as *const c_void as *mut c_void,
438 )
439}
440
441#[cfg(libressl)]
442pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int {
443 SSL_CTX_ctrl(
444 ctx,
445 SSL_CTRL_SET_ECDH_AUTO,
446 onoff as c_long,
447 ptr::null_mut(),
448 ) as c_int
449}
450
451#[cfg(libressl)]
452pub unsafe fn SSL_set_ecdh_auto(ssl: *mut SSL, onoff: c_int) -> c_int {
453 SSL_ctrl(
454 ssl,
455 SSL_CTRL_SET_ECDH_AUTO,
456 onoff as c_long,
457 ptr::null_mut(),
458 ) as c_int
459}
460
461cfg_if! {
462 if #[cfg(ossl110)] {
463 pub unsafe fn SSL_CTX_set_min_proto_version(ctx: *mut SSL_CTX, version: c_int) -> c_int {
464 SSL_CTX_ctrl(
465 ctx,
466 SSL_CTRL_SET_MIN_PROTO_VERSION,
467 version as c_long,
468 ptr::null_mut(),
469 ) as c_int
470 }
471
472 pub unsafe fn SSL_CTX_set_max_proto_version(ctx: *mut SSL_CTX, version: c_int) -> c_int {
473 SSL_CTX_ctrl(
474 ctx,
475 SSL_CTRL_SET_MAX_PROTO_VERSION,
476 version as c_long,
477 ptr::null_mut(),
478 ) as c_int
479 }
480
481 pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
482 SSL_ctrl(
483 s,
484 SSL_CTRL_SET_MIN_PROTO_VERSION,
485 version as c_long,
486 ptr::null_mut(),
487 ) as c_int
488 }
489
490 pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
491 SSL_ctrl(
492 s,
493 SSL_CTRL_SET_MAX_PROTO_VERSION,
494 version as c_long,
495 ptr::null_mut(),
496 ) as c_int
497 }
498 }
499}
500
501cfg_if! {
502 if #[cfg(ossl110g)] {
503 pub unsafe fn SSL_CTX_get_min_proto_version(ctx: *mut SSL_CTX) -> c_int {
504 SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
505 }
506
507 pub unsafe fn SSL_CTX_get_max_proto_version(ctx: *mut SSL_CTX) -> c_int {
508 SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
509 }
510 pub unsafe fn SSL_get_min_proto_version(s: *mut SSL) -> c_int {
511 SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
512 }
513 pub unsafe fn SSL_get_max_proto_version(s: *mut SSL) -> c_int {
514 SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
515 }
516 }
517}
518cfg_if! {
519 if #[cfg(ossl300)] {
520 pub unsafe fn SSL_get_peer_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
521 SSL_ctrl(ssl, SSL_CTRL_GET_PEER_TMP_KEY, 0, key as *mut c_void)
522 }
523
524 pub unsafe fn SSL_get_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
525 SSL_ctrl(ssl, SSL_CTRL_GET_TMP_KEY, 0, key as *mut c_void)
526 }
527 }
528}
529
530#[cfg(ossl111)]
531pub const SSL_CLIENT_HELLO_SUCCESS: c_int = 1;
532#[cfg(ossl111)]
533pub const SSL_CLIENT_HELLO_ERROR: c_int = 0;
534#[cfg(ossl111)]
535pub const SSL_CLIENT_HELLO_RETRY: c_int = -1;
536
537#[cfg(any(ossl111, libressl))]
538pub const SSL_READ_EARLY_DATA_ERROR: c_int = 0;
539#[cfg(any(ossl111, libressl))]
540pub const SSL_READ_EARLY_DATA_SUCCESS: c_int = 1;
541#[cfg(any(ossl111, libressl))]
542pub const SSL_READ_EARLY_DATA_FINISH: c_int = 2;
543
544cfg_if! {
545 if #[cfg(ossl110)] {
546 pub unsafe fn SSL_get_ex_new_index(
547 l: c_long,
548 p: *mut c_void,
549 newf: Option<CRYPTO_EX_new>,
550 dupf: Option<CRYPTO_EX_dup>,
551 freef: Option<CRYPTO_EX_free>,
552 ) -> c_int {
553 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)
554 }
555
556 pub unsafe fn SSL_CTX_get_ex_new_index(
557 l: c_long,
558 p: *mut c_void,
559 newf: Option<CRYPTO_EX_new>,
560 dupf: Option<CRYPTO_EX_dup>,
561 freef: Option<CRYPTO_EX_free>,
562 ) -> c_int {
563 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef)
564 }
565 }
566}
567
568pub unsafe fn SSL_CTX_sess_set_cache_size(ctx: *mut SSL_CTX, t: c_long) -> c_long {
569 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, t, ptr::null_mut())
570}
571
572pub unsafe fn SSL_CTX_sess_get_cache_size(ctx: *mut SSL_CTX) -> c_long {
573 SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_SIZE, 0, ptr::null_mut())
574}
575
576pub unsafe fn SSL_CTX_set_session_cache_mode(ctx: *mut SSL_CTX, m: c_long) -> c_long {
577 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_MODE, m, ptr::null_mut())
578}
579
580pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long {
581 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut())
582}
583
584#[allow(clashing_extern_declarations)]
585extern "C" {
586 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
587 #[deprecated(note = "use SSL_CTX_set_tmp_dh_callback__fixed_rust instead")]
588 pub fn SSL_CTX_set_tmp_dh_callback(
589 ctx: *mut SSL_CTX,
590 dh: unsafe extern "C" fn(ssl: *mut SSL, is_export: c_int, keylength: c_int) -> *mut DH,
591 );
592 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
593 #[deprecated(note = "use SSL_set_tmp_dh_callback__fixed_rust instead")]
594 pub fn SSL_set_tmp_dh_callback(
595 ctx: *mut SSL,
596 dh: unsafe extern "C" fn(ssl: *mut SSL, is_export: c_int, keylength: c_int) -> *mut DH,
597 );
598 #[deprecated(note = "use SSL_CTX_set_tmp_ecdh_callback__fixed_rust instead")]
599 #[cfg(not(ossl110))]
600 pub fn SSL_CTX_set_tmp_ecdh_callback(
601 ctx: *mut SSL_CTX,
602 ecdh: unsafe extern "C" fn(
603 ssl: *mut SSL,
604 is_export: c_int,
605 keylength: c_int,
606 ) -> *mut EC_KEY,
607 );
608 #[deprecated(note = "use SSL_set_tmp_ecdh_callback__fixed_rust instead")]
609 #[cfg(not(ossl110))]
610 pub fn SSL_set_tmp_ecdh_callback(
611 ssl: *mut SSL,
612 ecdh: unsafe extern "C" fn(
613 ssl: *mut SSL,
614 is_export: c_int,
615 keylength: c_int,
616 ) -> *mut EC_KEY,
617 );
618
619 #[deprecated(note = "use SSL_CTX_callback_ctrl__fixed_rust instead")]
620 pub fn SSL_CTX_callback_ctrl(
621 ctx: *mut SSL_CTX,
622 cmd: c_int,
623 fp: Option<extern "C" fn()>,
624 ) -> c_long;
625
626 #[deprecated(note = "use SSL_CTX_set_alpn_select_cb__fixed_rust instead")]
627 pub fn SSL_CTX_set_alpn_select_cb(
628 ssl: *mut SSL_CTX,
629 cb: extern "C" fn(
630 ssl: *mut SSL,
631 out: *mut *const c_uchar,
632 outlen: *mut c_uchar,
633 inbuf: *const c_uchar,
634 inlen: c_uint,
635 arg: *mut c_void,
636 ) -> c_int,
637 arg: *mut c_void,
638 );
639}
640
641#[cfg(not(ossl110))]
642pub unsafe fn SSL_session_reused(ssl: *mut SSL) -> c_int {
643 SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int
644}
645
646#[cfg(ossl110)]
647pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000;
648#[cfg(ossl111b)]
649pub const OPENSSL_INIT_NO_ATEXIT: u64 = 0x00080000;
650
651cfg_if! {
652 if #[cfg(ossl330)] {
653 pub const SSL_VALUE_CLASS_GENERIC: c_uint = 0;
654 pub const SSL_VALUE_CLASS_FEATURE_REQUEST: c_uint = 1;
655 pub const SSL_VALUE_CLASS_FEATURE_PEER_REQUEST: c_uint = 2;
656 pub const SSL_VALUE_CLASS_FEATURE_NEGOTIATED: c_uint = 3;
657
658 pub const SSL_VALUE_NONE: c_uint = 0;
659 pub const SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL: c_uint = 1;
660 pub const SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL: c_uint = 2;
661 pub const SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL: c_uint = 3;
662 pub const SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL: c_uint = 4;
663 pub const SSL_VALUE_QUIC_IDLE_TIMEOUT: c_uint = 5;
664 pub const SSL_VALUE_EVENT_HANDLING_MODE: c_uint = 6;
665 pub const SSL_VALUE_STREAM_WRITE_BUF_SIZE: c_uint = 7;
666 pub const SSL_VALUE_STREAM_WRITE_BUF_USED: c_uint = 8;
667 pub const SSL_VALUE_STREAM_WRITE_BUF_AVAIL: c_uint = 9;
668
669 pub const SSL_VALUE_EVENT_HANDLING_MODE_INHERIT: c_uint = 0;
670 pub const SSL_VALUE_EVENT_HANDLING_MODE_IMPLICIT: c_uint = 1;
671 pub const SSL_VALUE_EVENT_HANDLING_MODE_EXPLICIT: c_uint = 2;
672
673 pub unsafe fn SSL_get_generic_value_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
674 SSL_get_value_uint(ssl, SSL_VALUE_CLASS_GENERIC, id, value)
675 }
676 pub unsafe fn SSL_set_generic_value_uint(ssl: *mut SSL, id: u32, value: u64) -> c_int {
677 SSL_set_value_uint(ssl, SSL_VALUE_CLASS_GENERIC, id, value)
678 }
679 pub unsafe fn SSL_get_feature_request_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
680 SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_REQUEST, id, value)
681 }
682 pub unsafe fn SSL_set_feature_request_uint(ssl: *mut SSL, id: u32, value: u64) -> c_int {
683 SSL_set_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_REQUEST, id, value)
684 }
685 pub unsafe fn SSL_get_feature_peer_request_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
686 SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_PEER_REQUEST, id, value)
687 }
688 pub unsafe fn SSL_get_feature_negotiated_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
689 SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_NEGOTIATED, id, value)
690 }
691 pub unsafe fn SSL_get_quic_stream_bidi_local_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
692 SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL, value)
693 }
694 pub unsafe fn SSL_get_quic_stream_bidi_remote_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
695 SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL, value)
696 }
697 pub unsafe fn SSL_get_quic_stream_uni_local_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
698 SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL, value)
699 }
700 pub unsafe fn SSL_get_quic_stream_uni_remote_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
701 SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL, value)
702 }
703 pub unsafe fn SSL_get_event_handling_mode(ssl: *mut SSL, value: *mut u64) -> c_int {
704 SSL_get_generic_value_uint(ssl, SSL_VALUE_EVENT_HANDLING_MODE, value)
705 }
706 pub unsafe fn SSL_set_event_handling_mode(ssl: *mut SSL, value: u64) -> c_int {
707 SSL_set_generic_value_uint(ssl, SSL_VALUE_EVENT_HANDLING_MODE, value)
708 }
709 pub unsafe fn SSL_get_stream_write_buf_size(ssl: *mut SSL, value: *mut u64) -> c_int {
710 SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_SIZE, value)
711 }
712 pub unsafe fn SSL_get_stream_write_buf_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
713 SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_AVAIL, value)
714 }
715 pub unsafe fn SSL_get_stream_write_buf_used(ssl: *mut SSL, value: *mut u64) -> c_int {
716 SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_USED, value)
717 }
718 }
719}