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