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