Skip to main content

variant_ssl_sys/
ssl.rs

1use std::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void};
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/* This extension is only allowed in DTLS */
28#[cfg(ossl111)]
29pub const SSL_EXT_DTLS_ONLY: c_uint = 0x0002;
30/* Some extensions may be allowed in DTLS but we don't implement them for it */
31#[cfg(ossl111)]
32pub const SSL_EXT_TLS_IMPLEMENTATION_ONLY: c_uint = 0x0004;
33/* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */
34#[cfg(ossl111)]
35pub const SSL_EXT_SSL3_ALLOWED: c_uint = 0x0008;
36/* Extension is only defined for TLS1.2 and below */
37#[cfg(ossl111)]
38pub const SSL_EXT_TLS1_2_AND_BELOW_ONLY: c_uint = 0x0010;
39/* Extension is only defined for TLS1.3 and above */
40#[cfg(ossl111)]
41pub const SSL_EXT_TLS1_3_ONLY: c_uint = 0x0020;
42/* Ignore this extension during parsing if we are resuming */
43#[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/* Really means TLS1.2 or below */
48#[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(libressl440)] {
190        pub const SSL_OP_ALL: ssl_op_type!() = 0x0;
191    } else if #[cfg(libressl)] {
192        pub const SSL_OP_ALL: ssl_op_type!() = 0x4;
193    } else {
194        pub const SSL_OP_ALL: ssl_op_type!() = 0x80000BFF;
195    }
196}
197
198pub const SSL_OP_MICROSOFT_SESS_ID_BUG: ssl_op_type!() = 0x0;
199pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: ssl_op_type!() = 0x0;
200pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: ssl_op_type!() = 0x0;
201pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: ssl_op_type!() = 0x0;
202pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: ssl_op_type!() = 0x0;
203pub const SSL_OP_TLS_D5_BUG: ssl_op_type!() = 0x0;
204pub const SSL_OP_TLS_BLOCK_PADDING_BUG: ssl_op_type!() = 0x0;
205pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x0;
206pub const SSL_OP_NO_SSLv2: ssl_op_type!() = 0x0;
207cfg_if! {
208    if #[cfg(libressl)] {
209        pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00100000;
210    } else {
211        pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00000000;
212    }
213}
214
215pub const SSL_MODE_ENABLE_PARTIAL_WRITE: c_long = 0x1;
216pub const SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER: c_long = 0x2;
217pub const SSL_MODE_AUTO_RETRY: c_long = 0x4;
218pub const SSL_MODE_NO_AUTO_CHAIN: c_long = 0x8;
219pub const SSL_MODE_RELEASE_BUFFERS: c_long = 0x10;
220#[cfg(ossl110)]
221pub const SSL_MODE_SEND_CLIENTHELLO_TIME: c_long = 0x20;
222#[cfg(ossl110)]
223pub const SSL_MODE_SEND_SERVERHELLO_TIME: c_long = 0x40;
224#[cfg(ossl110)]
225pub const SSL_MODE_SEND_FALLBACK_SCSV: c_long = 0x80;
226#[cfg(ossl110)]
227pub const SSL_MODE_ASYNC: c_long = 0x100;
228
229pub unsafe fn SSL_CTX_set_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long {
230    SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, op, ptr::null_mut())
231}
232pub unsafe fn SSL_CTX_clear_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long {
233    SSL_CTX_ctrl(ctx, SSL_CTRL_CLEAR_MODE, op, ptr::null_mut())
234}
235pub unsafe fn SSL_CTX_get_mode(ctx: *mut SSL_CTX) -> c_long {
236    SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, 0, ptr::null_mut())
237}
238
239pub unsafe fn SSL_set_mode(ssl: *mut SSL, op: c_long) -> c_long {
240    SSL_ctrl(ssl, SSL_CTRL_MODE, op, ptr::null_mut())
241}
242pub unsafe fn SSL_clear_mode(ssl: *mut SSL, op: c_long) -> c_long {
243    SSL_ctrl(ssl, SSL_CTRL_CLEAR_MODE, op, ptr::null_mut())
244}
245pub unsafe fn SSL_get_mode(ssl: *mut SSL) -> c_long {
246    SSL_ctrl(ssl, SSL_CTRL_MODE, 0, ptr::null_mut())
247}
248
249#[cfg(ossl111)]
250pub const SSL_COOKIE_LENGTH: c_int = 4096;
251
252cfg_if! {
253    if #[cfg(libressl)] {
254        pub unsafe fn SSL_CTX_get_options(ctx: *const SSL_CTX) -> c_ulong {
255            SSL_CTX_ctrl(ctx as *mut _, SSL_CTRL_OPTIONS, 0, ptr::null_mut()) as c_ulong
256        }
257
258        pub unsafe fn SSL_CTX_set_options(ctx: *const SSL_CTX, op: c_ulong) -> c_ulong {
259            SSL_CTX_ctrl(
260                ctx as *mut _,
261                SSL_CTRL_OPTIONS,
262                op as c_long,
263                ptr::null_mut(),
264            ) as c_ulong
265        }
266
267        pub unsafe fn SSL_CTX_clear_options(ctx: *const SSL_CTX, op: c_ulong) -> c_ulong {
268            SSL_CTX_ctrl(
269                ctx as *mut _,
270                SSL_CTRL_CLEAR_OPTIONS,
271                op as c_long,
272                ptr::null_mut(),
273            ) as c_ulong
274        }
275    }
276}
277
278pub unsafe fn SSL_set_mtu(ssl: *mut SSL, mtu: c_long) -> c_long {
279    SSL_ctrl(ssl, SSL_CTRL_SET_MTU, mtu, ptr::null_mut())
280}
281
282#[cfg(ossl110)]
283pub unsafe fn SSL_get_extms_support(ssl: *mut SSL) -> c_long {
284    SSL_ctrl(ssl, SSL_CTRL_GET_EXTMS_SUPPORT, 0, ptr::null_mut())
285}
286
287pub const SSL_SESS_CACHE_OFF: c_long = 0x0;
288pub const SSL_SESS_CACHE_CLIENT: c_long = 0x1;
289pub const SSL_SESS_CACHE_SERVER: c_long = 0x2;
290pub const SSL_SESS_CACHE_BOTH: c_long = SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_SERVER;
291pub const SSL_SESS_CACHE_NO_AUTO_CLEAR: c_long = 0x80;
292pub const SSL_SESS_CACHE_NO_INTERNAL_LOOKUP: c_long = 0x100;
293pub const SSL_SESS_CACHE_NO_INTERNAL_STORE: c_long = 0x200;
294pub const SSL_SESS_CACHE_NO_INTERNAL: c_long =
295    SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE;
296
297pub const OPENSSL_NPN_UNSUPPORTED: c_int = 0;
298pub const OPENSSL_NPN_NEGOTIATED: c_int = 1;
299pub const OPENSSL_NPN_NO_OVERLAP: c_int = 2;
300
301pub const SSL_AD_REASON_OFFSET: c_int = 1000;
302pub const SSL_AD_CLOSE_NOTIFY: c_int = 0;
303pub const SSL_AD_UNEXPECTED_MESSAGE: c_int = 10;
304pub const SSL_AD_BAD_RECORD_MAC: c_int = 20;
305pub const SSL_AD_DECRYPTION_FAILED: c_int = 21;
306pub const SSL_AD_RECORD_OVERFLOW: c_int = 22;
307pub const SSL_AD_DECOMPRESSION_FAILURE: c_int = 30;
308pub const SSL_AD_HANDSHAKE_FAILURE: c_int = 40;
309pub const SSL_AD_NO_CERTIFICATE: c_int = 41;
310pub const SSL_AD_BAD_CERTIFICATE: c_int = 42;
311pub const SSL_AD_UNSUPPORTED_CERTIFICATE: c_int = 43;
312pub const SSL_AD_CERTIFICATE_REVOKED: c_int = 44;
313pub const SSL_AD_CERTIFICATE_EXPIRED: c_int = 45;
314pub const SSL_AD_CERTIFICATE_UNKNOWN: c_int = 46;
315pub const SSL_AD_ILLEGAL_PARAMETER: c_int = SSL3_AD_ILLEGAL_PARAMETER;
316pub const SSL_AD_UNKNOWN_CA: c_int = 48;
317pub const SSL_AD_ACCESS_DENIED: c_int = 49;
318pub const SSL_AD_DECODE_ERROR: c_int = TLS1_AD_DECODE_ERROR;
319pub const SSL_AD_DECRYPT_ERROR: c_int = 51;
320pub const SSL_AD_EXPORT_RESTRICTION: c_int = 60;
321pub const SSL_AD_PROTOCOL_VERSION: c_int = 70;
322pub const SSL_AD_INSUFFICIENT_SECURITY: c_int = 71;
323pub const SSL_AD_INTERNAL_ERROR: c_int = 80;
324pub const SSL_AD_INAPPROPRIATE_FALLBACK: c_int = 86;
325pub const SSL_AD_USER_CANCELLED: c_int = 90;
326pub const SSL_AD_NO_RENEGOTIATION: c_int = 100;
327#[cfg(any(ossl111, libressl, boringssl, awslc))]
328pub const SSL_AD_MISSING_EXTENSION: c_int = 109;
329pub const SSL_AD_UNSUPPORTED_EXTENSION: c_int = 110;
330pub const SSL_AD_CERTIFICATE_UNOBTAINABLE: c_int = 111;
331pub const SSL_AD_UNRECOGNIZED_NAME: c_int = TLS1_AD_UNRECOGNIZED_NAME;
332pub const SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: c_int = 113;
333pub const SSL_AD_BAD_CERTIFICATE_HASH_VALUE: c_int = 114;
334pub const SSL_AD_UNKNOWN_PSK_IDENTITY: c_int = 115;
335#[cfg(any(ossl111, libressl, boringssl, awslc))]
336pub const SSL_AD_CERTIFICATE_REQUIRED: c_int = 116;
337pub const SSL_AD_NO_APPLICATION_PROTOCOL: c_int = 120;
338
339pub const SSL_ERROR_NONE: c_int = 0;
340pub const SSL_ERROR_SSL: c_int = 1;
341pub const SSL_ERROR_SYSCALL: c_int = 5;
342pub const SSL_ERROR_WANT_ACCEPT: c_int = 8;
343pub const SSL_ERROR_WANT_CONNECT: c_int = 7;
344#[cfg(ossl110)]
345pub const SSL_ERROR_WANT_ASYNC: c_int = 9;
346#[cfg(ossl110)]
347pub const SSL_ERROR_WANT_ASYNC_JOB: c_int = 10;
348pub const SSL_ERROR_WANT_READ: c_int = 2;
349pub const SSL_ERROR_WANT_WRITE: c_int = 3;
350pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4;
351pub const SSL_ERROR_ZERO_RETURN: c_int = 6;
352#[cfg(ossl111)]
353pub const SSL_ERROR_WANT_CLIENT_HELLO_CB: c_int = 11;
354pub const SSL_VERIFY_NONE: c_int = 0;
355pub const SSL_VERIFY_PEER: c_int = 1;
356pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2;
357pub const SSL_VERIFY_CLIENT_ONCE: c_int = 4;
358#[cfg(ossl111)]
359pub const SSL_VERIFY_POST_HANDSHAKE: c_int = 8;
360#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
361pub const SSL_CTRL_SET_TMP_DH: c_int = 3;
362#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
363pub const SSL_CTRL_SET_TMP_ECDH: c_int = 4;
364#[cfg(libressl)]
365pub const SSL_CTRL_GET_SESSION_REUSED: c_int = 8;
366pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14;
367pub const SSL_CTRL_SET_MTU: c_int = 17;
368#[cfg(libressl)]
369pub const SSL_CTRL_OPTIONS: c_int = 32;
370pub const SSL_CTRL_MODE: c_int = 33;
371pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41;
372pub const SSL_CTRL_SET_SESS_CACHE_SIZE: c_int = 42;
373pub const SSL_CTRL_GET_SESS_CACHE_SIZE: c_int = 43;
374pub const SSL_CTRL_SET_SESS_CACHE_MODE: c_int = 44;
375pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: c_int = 53;
376pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG: c_int = 54;
377pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55;
378pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB: c_int = 63;
379pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG: c_int = 64;
380pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE: c_int = 65;
381pub const SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 70;
382pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 71;
383pub const SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB: c_int = 72;
384#[cfg(libressl)]
385pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77;
386pub const SSL_CTRL_CLEAR_MODE: c_int = 78;
387pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS: c_int = 82;
388pub const SSL_CTRL_CHAIN_CERT: c_int = 89;
389#[cfg(any(ossl111, libressl))]
390pub const SSL_CTRL_SET_GROUPS_LIST: c_int = 92;
391#[cfg(libressl)]
392pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94;
393#[cfg(ossl110)]
394pub const SSL_CTRL_SET_SIGALGS_LIST: c_int = 98;
395#[cfg(ossl110)]
396pub const SSL_CTRL_SET_VERIFY_CERT_STORE: c_int = 106;
397#[cfg(ossl300)]
398pub const SSL_CTRL_GET_PEER_TMP_KEY: c_int = 109;
399#[cfg(ossl110)]
400pub const SSL_CTRL_SET_DH_AUTO: c_int = 118;
401#[cfg(ossl110)]
402pub const SSL_CTRL_GET_EXTMS_SUPPORT: c_int = 122;
403pub const SSL_CTRL_SET_MIN_PROTO_VERSION: c_int = 123;
404pub const SSL_CTRL_SET_MAX_PROTO_VERSION: c_int = 124;
405pub const SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE: c_int = 127;
406#[cfg(any(ossl110g, libressl))]
407pub const SSL_CTRL_GET_MIN_PROTO_VERSION: c_int = 130;
408#[cfg(any(ossl110g, libressl))]
409pub const SSL_CTRL_GET_MAX_PROTO_VERSION: c_int = 131;
410#[cfg(ossl300)]
411pub const SSL_CTRL_GET_TMP_KEY: c_int = 133;
412
413#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
414pub unsafe fn SSL_CTX_set_tmp_dh(ctx: *mut SSL_CTX, dh: *mut DH) -> c_long {
415    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void)
416}
417
418#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
419pub unsafe fn SSL_CTX_set_tmp_ecdh(ctx: *mut SSL_CTX, key: *mut EC_KEY) -> c_long {
420    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
421}
422
423#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
424pub unsafe fn SSL_set_tmp_dh(ssl: *mut SSL, dh: *mut DH) -> c_long {
425    SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void)
426}
427
428#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
429pub unsafe fn SSL_set_tmp_ecdh(ssl: *mut SSL, key: *mut EC_KEY) -> c_long {
430    SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
431}
432
433#[cfg(ossl110)]
434pub unsafe fn SSL_CTX_set_dh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_long {
435    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_DH_AUTO, onoff as c_long, ptr::null_mut())
436}
437
438#[cfg(ossl110)]
439pub unsafe fn SSL_set_dh_auto(ssl: *mut SSL, onoff: c_int) -> c_long {
440    SSL_ctrl(ssl, SSL_CTRL_SET_DH_AUTO, onoff as c_long, ptr::null_mut())
441}
442
443pub unsafe fn SSL_CTX_add_extra_chain_cert(ctx: *mut SSL_CTX, x509: *mut X509) -> c_long {
444    SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, x509 as *mut c_void)
445}
446
447pub unsafe fn SSL_CTX_get_extra_chain_certs(
448    ctx: *mut SSL_CTX,
449    chain: *mut *mut stack_st_X509,
450) -> c_long {
451    SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, chain as *mut c_void)
452}
453
454#[cfg(ossl110)]
455pub unsafe fn SSL_CTX_set0_verify_cert_store(ctx: *mut SSL_CTX, st: *mut X509_STORE) -> c_long {
456    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void)
457}
458
459#[cfg(ossl110)]
460pub unsafe fn SSL_set0_verify_cert_store(ssl: *mut SSL, st: *mut X509_STORE) -> c_long {
461    SSL_ctrl(ssl, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void)
462}
463
464cfg_if! {
465    if #[cfg(ossl111)] {
466        pub unsafe fn SSL_set1_groups_list(ctx: *mut SSL, s: *const c_char) -> c_long {
467            SSL_ctrl(
468                ctx,
469                SSL_CTRL_SET_GROUPS_LIST,
470                0,
471                s as *const c_void as *mut c_void,
472            )
473        }
474        pub unsafe fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
475            SSL_CTX_ctrl(
476                ctx,
477                SSL_CTRL_SET_GROUPS_LIST,
478                0,
479                s as *const c_void as *mut c_void,
480            )
481        }
482    } else if #[cfg(libressl)] {
483        extern "C" {
484            pub fn SSL_set1_groups_list(ctx: *mut SSL, list: *const c_char) -> c_int;
485            pub fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_int;
486        }
487    }
488}
489
490pub unsafe fn SSL_add0_chain_cert(ssl: *mut SSL, ptr: *mut X509) -> c_long {
491    SSL_ctrl(ssl, SSL_CTRL_CHAIN_CERT, 0, ptr as *mut c_void)
492}
493
494#[cfg(ossl110)]
495pub unsafe fn SSL_CTX_set1_sigalgs_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
496    SSL_CTX_ctrl(
497        ctx,
498        SSL_CTRL_SET_SIGALGS_LIST,
499        0,
500        s as *const c_void as *mut c_void,
501    )
502}
503
504#[cfg(libressl)]
505pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int {
506    SSL_CTX_ctrl(
507        ctx,
508        SSL_CTRL_SET_ECDH_AUTO,
509        onoff as c_long,
510        ptr::null_mut(),
511    ) as c_int
512}
513
514#[cfg(libressl)]
515pub unsafe fn SSL_set_ecdh_auto(ssl: *mut SSL, onoff: c_int) -> c_int {
516    SSL_ctrl(
517        ssl,
518        SSL_CTRL_SET_ECDH_AUTO,
519        onoff as c_long,
520        ptr::null_mut(),
521    ) as c_int
522}
523
524cfg_if! {
525    if #[cfg(ossl110)] {
526        pub unsafe fn SSL_CTX_set_min_proto_version(ctx: *mut SSL_CTX, version: c_int) -> c_int {
527            SSL_CTX_ctrl(
528                ctx,
529                SSL_CTRL_SET_MIN_PROTO_VERSION,
530                version as c_long,
531                ptr::null_mut(),
532            ) as c_int
533        }
534
535        pub unsafe fn SSL_CTX_set_max_proto_version(ctx: *mut SSL_CTX, version: c_int) -> c_int {
536            SSL_CTX_ctrl(
537                ctx,
538                SSL_CTRL_SET_MAX_PROTO_VERSION,
539                version as c_long,
540                ptr::null_mut(),
541            ) as c_int
542        }
543
544        pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
545            SSL_ctrl(
546                s,
547                SSL_CTRL_SET_MIN_PROTO_VERSION,
548                version as c_long,
549                ptr::null_mut(),
550            ) as c_int
551        }
552
553        pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
554            SSL_ctrl(
555                s,
556                SSL_CTRL_SET_MAX_PROTO_VERSION,
557                version as c_long,
558                ptr::null_mut(),
559            ) as c_int
560        }
561    }
562}
563
564cfg_if! {
565    if #[cfg(ossl110g)] {
566        pub unsafe fn SSL_CTX_get_min_proto_version(ctx: *mut SSL_CTX) -> c_int {
567            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
568        }
569
570        pub unsafe fn SSL_CTX_get_max_proto_version(ctx: *mut SSL_CTX) -> c_int {
571            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
572        }
573        pub unsafe fn SSL_get_min_proto_version(s: *mut SSL) -> c_int {
574            SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
575        }
576        pub unsafe fn SSL_get_max_proto_version(s: *mut SSL) -> c_int {
577            SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
578        }
579    }
580}
581cfg_if! {
582    if #[cfg(ossl300)] {
583        pub unsafe fn SSL_get_peer_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
584            SSL_ctrl(ssl, SSL_CTRL_GET_PEER_TMP_KEY, 0, key as *mut c_void)
585        }
586
587        pub unsafe fn SSL_get_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
588            SSL_ctrl(ssl, SSL_CTRL_GET_TMP_KEY, 0, key as *mut c_void)
589        }
590    }
591}
592
593#[cfg(ossl111)]
594pub const SSL_CLIENT_HELLO_SUCCESS: c_int = 1;
595#[cfg(ossl111)]
596pub const SSL_CLIENT_HELLO_ERROR: c_int = 0;
597#[cfg(ossl111)]
598pub const SSL_CLIENT_HELLO_RETRY: c_int = -1;
599
600#[cfg(any(ossl111, libressl))]
601pub const SSL_READ_EARLY_DATA_ERROR: c_int = 0;
602#[cfg(any(ossl111, libressl))]
603pub const SSL_READ_EARLY_DATA_SUCCESS: c_int = 1;
604#[cfg(any(ossl111, libressl))]
605pub const SSL_READ_EARLY_DATA_FINISH: c_int = 2;
606
607cfg_if! {
608    if #[cfg(ossl110)] {
609        pub unsafe fn SSL_get_ex_new_index(
610            l: c_long,
611            p: *mut c_void,
612            newf: CRYPTO_EX_new,
613            dupf: CRYPTO_EX_dup,
614            freef: CRYPTO_EX_free,
615        ) -> c_int {
616            CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)
617        }
618
619        pub unsafe fn SSL_CTX_get_ex_new_index(
620            l: c_long,
621            p: *mut c_void,
622            newf: CRYPTO_EX_new,
623            dupf: CRYPTO_EX_dup,
624            freef: CRYPTO_EX_free,
625        ) -> c_int {
626            CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef)
627        }
628    }
629}
630
631pub unsafe fn SSL_CTX_sess_set_cache_size(ctx: *mut SSL_CTX, t: c_long) -> c_long {
632    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, t, ptr::null_mut())
633}
634
635pub unsafe fn SSL_CTX_sess_get_cache_size(ctx: *mut SSL_CTX) -> c_long {
636    SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_SIZE, 0, ptr::null_mut())
637}
638
639pub unsafe fn SSL_CTX_set_session_cache_mode(ctx: *mut SSL_CTX, m: c_long) -> c_long {
640    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_MODE, m, ptr::null_mut())
641}
642
643pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long {
644    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut())
645}
646
647#[cfg(not(ossl110))]
648pub unsafe fn SSL_session_reused(ssl: *mut SSL) -> c_int {
649    SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int
650}
651
652#[cfg(ossl110)]
653pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000;
654#[cfg(ossl111b)]
655pub const OPENSSL_INIT_NO_ATEXIT: u64 = 0x00080000;
656
657#[cfg(ossl111)]
658pub const SSL_CT_VALIDATION_PERMISSIVE: c_int = 0;
659#[cfg(ossl111)]
660pub const SSL_CT_VALIDATION_STRICT: c_int = 1;
661
662cfg_if! {
663    if #[cfg(ossl330)] {
664        pub const SSL_VALUE_CLASS_GENERIC: c_uint = 0;
665        pub const SSL_VALUE_CLASS_FEATURE_REQUEST: c_uint = 1;
666        pub const SSL_VALUE_CLASS_FEATURE_PEER_REQUEST: c_uint = 2;
667        pub const SSL_VALUE_CLASS_FEATURE_NEGOTIATED: c_uint = 3;
668
669        pub const SSL_VALUE_NONE: c_uint = 0;
670        pub const SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL: c_uint = 1;
671        pub const SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL: c_uint = 2;
672        pub const SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL: c_uint = 3;
673        pub const SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL: c_uint = 4;
674        pub const SSL_VALUE_QUIC_IDLE_TIMEOUT: c_uint = 5;
675        pub const SSL_VALUE_EVENT_HANDLING_MODE: c_uint = 6;
676        pub const SSL_VALUE_STREAM_WRITE_BUF_SIZE: c_uint = 7;
677        pub const SSL_VALUE_STREAM_WRITE_BUF_USED: c_uint = 8;
678        pub const SSL_VALUE_STREAM_WRITE_BUF_AVAIL: c_uint = 9;
679
680        pub const SSL_VALUE_EVENT_HANDLING_MODE_INHERIT: c_uint = 0;
681        pub const SSL_VALUE_EVENT_HANDLING_MODE_IMPLICIT: c_uint = 1;
682        pub const SSL_VALUE_EVENT_HANDLING_MODE_EXPLICIT: c_uint = 2;
683
684        pub unsafe fn SSL_get_generic_value_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
685            SSL_get_value_uint(ssl, SSL_VALUE_CLASS_GENERIC, id, value)
686        }
687        pub unsafe fn SSL_set_generic_value_uint(ssl: *mut SSL, id: u32, value: u64) -> c_int {
688            SSL_set_value_uint(ssl, SSL_VALUE_CLASS_GENERIC, id, value)
689        }
690        pub unsafe fn SSL_get_feature_request_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
691            SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_REQUEST, id, value)
692        }
693        pub unsafe fn SSL_set_feature_request_uint(ssl: *mut SSL, id: u32, value: u64) -> c_int {
694            SSL_set_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_REQUEST, id, value)
695        }
696        pub unsafe fn SSL_get_feature_peer_request_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
697            SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_PEER_REQUEST, id, value)
698        }
699        pub unsafe fn SSL_get_feature_negotiated_uint(ssl: *mut SSL, id: u32, value: *mut u64) -> c_int {
700            SSL_get_value_uint(ssl, SSL_VALUE_CLASS_FEATURE_NEGOTIATED, id, value)
701        }
702        pub unsafe fn SSL_get_quic_stream_bidi_local_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
703            SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL, value)
704        }
705        pub unsafe fn SSL_get_quic_stream_bidi_remote_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
706            SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL, value)
707        }
708        pub unsafe fn SSL_get_quic_stream_uni_local_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
709            SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL, value)
710        }
711        pub unsafe fn SSL_get_quic_stream_uni_remote_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
712            SSL_get_generic_value_uint(ssl, SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL, value)
713        }
714        pub unsafe fn SSL_get_event_handling_mode(ssl: *mut SSL, value: *mut u64) -> c_int {
715            SSL_get_generic_value_uint(ssl, SSL_VALUE_EVENT_HANDLING_MODE, value)
716        }
717        pub unsafe fn SSL_set_event_handling_mode(ssl: *mut SSL, value: u64) -> c_int {
718            SSL_set_generic_value_uint(ssl, SSL_VALUE_EVENT_HANDLING_MODE, value)
719        }
720        pub unsafe fn SSL_get_stream_write_buf_size(ssl: *mut SSL, value: *mut u64) -> c_int {
721            SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_SIZE, value)
722        }
723        pub unsafe fn SSL_get_stream_write_buf_avail(ssl: *mut SSL, value: *mut u64) -> c_int {
724            SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_AVAIL, value)
725        }
726        pub unsafe fn SSL_get_stream_write_buf_used(ssl: *mut SSL, value: *mut u64) -> c_int {
727            SSL_get_generic_value_uint(ssl, SSL_VALUE_STREAM_WRITE_BUF_USED, value)
728        }
729    }
730}