1use libc::*;
2use std::mem;
3use std::ptr;
4
5use super::*;
6
7pub const TLS1_VERSION: c_int = 0x301;
8pub const TLS1_1_VERSION: c_int = 0x302;
9pub const TLS1_2_VERSION: c_int = 0x303;
10#[cfg(any(ossl111, libressl340))]
11pub const TLS1_3_VERSION: c_int = 0x304;
12
13pub const TLS1_AD_DECODE_ERROR: c_int = 50;
14pub const TLS1_AD_UNRECOGNIZED_NAME: c_int = 112;
15
16pub const TLSEXT_NAMETYPE_host_name: c_int = 0;
17pub const TLSEXT_STATUSTYPE_ocsp: c_int = 1;
18
19pub unsafe fn SSL_set_tlsext_host_name(s: *mut SSL, name: *mut c_char) -> c_long {
20 SSL_ctrl(
21 s,
22 SSL_CTRL_SET_TLSEXT_HOSTNAME,
23 TLSEXT_NAMETYPE_host_name as c_long,
24 name as *mut c_void,
25 )
26}
27
28pub unsafe fn SSL_set_tlsext_status_type(s: *mut SSL, type_: c_int) -> c_long {
29 SSL_ctrl(
30 s,
31 SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,
32 type_ as c_long,
33 ptr::null_mut(),
34 )
35}
36
37pub unsafe fn SSL_get_tlsext_status_ocsp_resp(ssl: *mut SSL, resp: *mut *mut c_uchar) -> c_long {
38 SSL_ctrl(
39 ssl,
40 SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,
41 0,
42 resp as *mut c_void,
43 )
44}
45
46pub unsafe fn SSL_set_tlsext_status_ocsp_resp(
47 ssl: *mut SSL,
48 resp: *mut c_uchar,
49 len: c_long,
50) -> c_long {
51 SSL_ctrl(
52 ssl,
53 SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,
54 len,
55 resp as *mut c_void,
56 )
57}
58
59#[deprecated(note = "use SSL_CTX_set_tlsext_servername_callback__fixed_rust instead")]
60#[allow(deprecated)]
61pub unsafe fn SSL_CTX_set_tlsext_servername_callback(
62 ctx: *mut SSL_CTX,
63 cb: Option<extern "C" fn()>,
65) -> c_long {
66 SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, cb)
67}
68
69pub unsafe fn SSL_CTX_set_tlsext_servername_callback__fixed_rust(
70 ctx: *mut SSL_CTX,
71 cb: Option<unsafe extern "C" fn(*mut SSL, *mut c_int, *mut c_void) -> c_int>,
72) -> c_long {
73 SSL_CTX_callback_ctrl__fixed_rust(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, mem::transmute(cb))
74}
75
76pub const SSL_TLSEXT_ERR_OK: c_int = 0;
77pub const SSL_TLSEXT_ERR_ALERT_WARNING: c_int = 1;
78pub const SSL_TLSEXT_ERR_ALERT_FATAL: c_int = 2;
79pub const SSL_TLSEXT_ERR_NOACK: c_int = 3;
80
81pub unsafe fn SSL_CTX_set_tlsext_servername_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long {
82 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, arg)
83}
84
85pub unsafe fn SSL_CTX_set_tlsext_status_cb(
86 ctx: *mut SSL_CTX,
87 cb: Option<unsafe extern "C" fn(*mut SSL, *mut c_void) -> c_int>,
88) -> c_long {
89 SSL_CTX_callback_ctrl__fixed_rust(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, mem::transmute(cb))
90}
91
92pub unsafe fn SSL_CTX_set_tlsext_status_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long {
93 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg)
94}