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 DTLS1_VERSION: c_int = 0xFEFF;
14#[cfg(any(ossl102, libressl332))]
15pub const DTLS1_2_VERSION: c_int = 0xFEFD;
16
17pub const TLS1_AD_DECODE_ERROR: c_int = 50;
18pub const TLS1_AD_UNRECOGNIZED_NAME: c_int = 112;
19
20pub const TLSEXT_NAMETYPE_host_name: c_int = 0;
21pub const TLSEXT_STATUSTYPE_ocsp: c_int = 1;
22
23pub unsafe fn SSL_set_tlsext_host_name(s: *mut SSL, name: *mut c_char) -> c_long {
24 SSL_ctrl(
25 ssl:s,
26 SSL_CTRL_SET_TLSEXT_HOSTNAME,
27 TLSEXT_NAMETYPE_host_name as c_long,
28 parg:name as *mut c_void,
29 )
30}
31
32pub unsafe fn SSL_set_tlsext_status_type(s: *mut SSL, type_: c_int) -> c_long {
33 SSL_ctrl(
34 ssl:s,
35 SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,
36 larg:type_ as c_long,
37 parg:ptr::null_mut(),
38 )
39}
40
41pub unsafe fn SSL_get_tlsext_status_ocsp_resp(ssl: *mut SSL, resp: *mut *mut c_uchar) -> c_long {
42 SSL_ctrl(
43 ssl,
44 SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,
45 larg:0,
46 parg:resp as *mut c_void,
47 )
48}
49
50pub unsafe fn SSL_set_tlsext_status_ocsp_resp(
51 ssl: *mut SSL,
52 resp: *mut c_uchar,
53 len: c_long,
54) -> c_long {
55 SSL_ctrl(
56 ssl,
57 SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,
58 larg:len,
59 parg:resp as *mut c_void,
60 )
61}
62
63#[deprecated(note = "use SSL_CTX_set_tlsext_servername_callback__fixed_rust instead")]
64#[allow(deprecated)]
65pub unsafe fn SSL_CTX_set_tlsext_servername_callback(
66 ctx: *mut SSL_CTX,
67 // FIXME should have the right signature
68 cb: Option<extern "C" fn()>,
69) -> c_long {
70 SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, fp:cb)
71}
72
73pub unsafe fn SSL_CTX_set_tlsext_servername_callback__fixed_rust(
74 ctx: *mut SSL_CTX,
75 cb: Option<unsafe extern "C" fn(*mut SSL, *mut c_int, *mut c_void) -> c_int>,
76) -> c_long {
77 SSL_CTX_callback_ctrl__fixed_rust(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, fp:mem::transmute(src:cb))
78}
79
80pub const SSL_TLSEXT_ERR_OK: c_int = 0;
81pub const SSL_TLSEXT_ERR_ALERT_WARNING: c_int = 1;
82pub const SSL_TLSEXT_ERR_ALERT_FATAL: c_int = 2;
83pub const SSL_TLSEXT_ERR_NOACK: c_int = 3;
84
85pub unsafe fn SSL_CTX_set_tlsext_servername_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long {
86 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, larg:0, parg:arg)
87}
88
89pub unsafe fn SSL_CTX_set_tlsext_status_cb(
90 ctx: *mut SSL_CTX,
91 cb: Option<unsafe extern "C" fn(*mut SSL, *mut c_void) -> c_int>,
92) -> c_long {
93 SSL_CTX_callback_ctrl__fixed_rust(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, fp:mem::transmute(src:cb))
94}
95
96pub unsafe fn SSL_CTX_set_tlsext_status_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long {
97 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, larg:0, parg:arg)
98}
99