s2n_tls_sys/
api.rs

1/* automatically generated by rust-bindgen 0.65.1 */
2
3
4// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5// SPDX-License-Identifier: Apache-2.0
6
7
8#![allow(unused_imports, non_camel_case_types)]
9
10use libc::{iovec, FILE, off_t};
11// specify that aws-lc-rs is used, so that the rust compiler will link in the appropriate
12// libcrypto artifact.
13#[cfg(not(s2n_tls_external_build))]
14extern crate aws_lc_rs as _;
15
16
17extern "C" {
18    #[doc = " This function can be used instead of trying to resolve `s2n_errno` directly\n in runtimes where thread-local variables may not be easily accessible.\n\n @returns The address of the thread-local `s2n_errno` variable"]
19    pub fn s2n_errno_location() -> *mut ::libc::c_int;
20}
21pub mod s2n_error_type {
22    #[doc = " Used to help applications determine why an s2n-tls function failed.\n\n This enum is optimized for use in C switch statements. Each value in the enum represents\n an error \"category\".\n\n s2n-tls organizes errors into different \"types\" to allow applications to handle error\n values without catching all possibilities. Applications using non-blocking I/O should check\n the error type to determine if the I/O operation failed because it would block or for some other\n error. To retrieve the type for a given error use `s2n_error_get_type()`. Applications should\n perform any error handling logic using these high level types.\n\n See the [Error Handling](https://github.com/aws/s2n-tls/blob/main/docs/usage-guide/topics/ch03-error-handling.md) section for how the errors should be interpreted."]
23    pub type Type = ::libc::c_uint;
24    #[doc = " No error"]
25    pub const OK: Type = 0;
26    #[doc = " Underlying I/O operation failed, check system errno"]
27    pub const IO: Type = 1;
28    #[doc = " EOF"]
29    pub const CLOSED: Type = 2;
30    #[doc = " Underlying I/O operation would block"]
31    pub const BLOCKED: Type = 3;
32    #[doc = " Incoming Alert"]
33    pub const ALERT: Type = 4;
34    #[doc = " Failure in some part of the TLS protocol. Ex: CBC verification failure"]
35    pub const PROTO: Type = 5;
36    #[doc = " Error internal to s2n-tls. A precondition could have failed."]
37    pub const INTERNAL: Type = 6;
38    #[doc = " User input error. Ex: Providing an invalid cipher preference version"]
39    pub const USAGE: Type = 7;
40}
41extern "C" {
42    #[doc = " Gets the category of error from an error.\n\n s2n-tls organizes errors into different \"types\" to allow applications to do logic on error values without catching all possibilities.\n Applications using non-blocking I/O should check error type to determine if the I/O operation failed because\n it would block or for some other error.\n\n @param error The error from s2n. Usually this is `s2n_errno`.\n @returns An s2n_error_type"]
43    pub fn s2n_error_get_type(error: ::libc::c_int) -> ::libc::c_int;
44}
45#[doc = " An opaque configuration object, used by clients and servers for holding cryptographic certificates, keys and preferences."]
46#[repr(C)]
47#[derive(Debug, Copy, Clone)]
48pub struct s2n_config {
49    _unused: [u8; 0],
50}
51#[doc = " An opaque connection. Used to track each s2n connection."]
52#[repr(C)]
53#[derive(Debug, Copy, Clone)]
54pub struct s2n_connection {
55    _unused: [u8; 0],
56}
57extern "C" {
58    #[doc = " Prevents S2N from calling `OPENSSL_init_crypto`/`OPENSSL_cleanup`/`EVP_cleanup` on OpenSSL versions\n prior to 1.1.x. This allows applications or languages that also init OpenSSL to interoperate\n with S2N.\n\n @warning This function must be called BEFORE s2n_init() to have any effect. It will return an error\n if s2n is already initialized.\n\n @note If you disable this and are using a version of OpenSSL/libcrypto < 1.1.x, you will\n be responsible for library init and cleanup (specifically `OPENSSL_add_all_algorithms()`\n or `OPENSSL_init_crypto()`, and EVP_* APIs will not be usable unless the library is initialized.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
59    pub fn s2n_crypto_disable_init() -> ::libc::c_int;
60}
61extern "C" {
62    #[doc = " Prevents S2N from installing an atexit handler, which allows safe shutdown of S2N from within a\n re-entrant shared library\n\n @warning This function must be called BEFORE s2n_init() to have any effect. It will return an error\n if s2n is already initialized.\n\n @note This will cause `s2n_cleanup` to do complete cleanup of s2n-tls when called from the main\n thread (the thread `s2n_init` was called from).\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
63    pub fn s2n_disable_atexit() -> ::libc::c_int;
64}
65extern "C" {
66    #[doc = " Fetches the OpenSSL version s2n-tls was compiled with. This can be used by applications to validate at runtime\n that the versions of s2n-tls and Openssl that they have loaded are correct.\n\n @returns the version number of OpenSSL that s2n-tls was compiled with"]
67    pub fn s2n_get_openssl_version() -> ::libc::c_ulong;
68}
69extern "C" {
70    #[doc = " Initializes the s2n-tls library and should be called once in your application, before any other s2n-tls\n functions are called. Failure to call s2n_init() will result in errors from other s2n-tls functions.\n\n @warning This function is not thread safe and should only be called once.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
71    pub fn s2n_init() -> ::libc::c_int;
72}
73extern "C" {
74    #[doc = " Cleans up thread-local resources used by s2n-tls. Does not perform a full library cleanup. To fully\n clean up the library use s2n_cleanup_final().\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
75    pub fn s2n_cleanup() -> ::libc::c_int;
76}
77extern "C" {
78    pub fn s2n_cleanup_final() -> ::libc::c_int;
79}
80pub mod s2n_fips_mode {
81    pub type Type = ::libc::c_uint;
82    pub const FIPS_MODE_DISABLED: Type = 0;
83    pub const FIPS_MODE_ENABLED: Type = 1;
84}
85extern "C" {
86    #[doc = " Determines whether s2n-tls is operating in FIPS mode.\n\n s2n-tls enters FIPS mode on initialization when built with a version of AWS-LC that supports\n FIPS (https://github.com/aws/aws-lc/blob/main/crypto/fipsmodule/FIPS.md). FIPS mode controls\n some internal configuration related to FIPS support, like which random number generator is used.\n\n FIPS mode does not enforce the use of FIPS-approved cryptography. Applications attempting to use\n only FIPS-approved cryptography should also ensure that s2n-tls is configured to use a security\n policy that only supports FIPS-approved cryptography.\n\n @param fips_mode Set to the FIPS mode of s2n-tls.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
87    pub fn s2n_get_fips_mode(fips_mode: *mut s2n_fips_mode::Type) -> ::libc::c_int;
88}
89extern "C" {
90    #[doc = " Creates a new s2n_config object. This object can (and should) be associated with many connection\n objects.\n\n The returned config will be initialized with default system certificates in its trust store.\n\n The returned config should be freed with `s2n_config_free()` after it's no longer in use by any\n connection.\n\n @returns A new configuration object suitable for configuring connections and associating certs\n and keys."]
91    pub fn s2n_config_new() -> *mut s2n_config;
92}
93extern "C" {
94    #[doc = " Creates a new s2n_config object with minimal default options.\n\n This function has better performance than `s2n_config_new()` because it does not load default\n system certificates into the trust store by default. To add system certificates to this config,\n call `s2n_config_load_system_certs()`.\n\n The returned config should be freed with `s2n_config_free()` after it's no longer in use by any\n connection.\n\n @returns A new configuration object suitable for configuring connections and associating certs\n and keys."]
95    pub fn s2n_config_new_minimal() -> *mut s2n_config;
96}
97extern "C" {
98    #[doc = " Frees the memory associated with an `s2n_config` object.\n\n @param config The configuration object being freed\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
99    pub fn s2n_config_free(config: *mut s2n_config) -> ::libc::c_int;
100}
101extern "C" {
102    #[doc = " Frees the DH params associated with an `s2n_config` object.\n\n @param config The configuration object with DH params being freed\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
103    pub fn s2n_config_free_dhparams(config: *mut s2n_config) -> ::libc::c_int;
104}
105extern "C" {
106    #[doc = " Frees the certificate chain and key associated with an `s2n_config` object.\n\n @param config The configuration object with DH params being freed\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
107    pub fn s2n_config_free_cert_chain_and_key(config: *mut s2n_config) -> ::libc::c_int;
108}
109#[doc = " Callback function type used to get the system time.\n\n @param void* A pointer to arbitrary data for use within the callback\n @param uint64_t* A pointer that the callback will set to the time in nanoseconds\n The function should return 0 on success and -1 on failure."]
110pub type s2n_clock_time_nanoseconds = ::core::option::Option<
111    unsafe extern "C" fn(arg1: *mut ::libc::c_void, arg2: *mut u64) -> ::libc::c_int,
112>;
113#[doc = " Cache callback function that allows the caller to retrieve SSL session data\n from a cache.\n\n The callback function takes six arguments:\n a pointer to the s2n_connection object,\n a pointer to arbitrary data for use within the callback,\n a pointer to a key which can be used to retrieve the cached entry,\n a 64 bit unsigned integer specifying the size of this key,\n a pointer to a memory location where the value should be stored,\n and a pointer to a 64 bit unsigned integer specifying the size of this value.\n\n Initially *value_size will be set to the amount of space allocated for the value,\n the callback should set *value_size to the actual size of the data returned.\n If there is insufficient space, -1 should be returned.\n If the cache is not ready to provide data for the request,\n S2N_CALLBACK_BLOCKED should be returned.\n\n This will cause s2n_negotiate() to return S2N_BLOCKED_ON_APPLICATION_INPUT."]
114pub type s2n_cache_retrieve_callback = ::core::option::Option<
115    unsafe extern "C" fn(
116        conn: *mut s2n_connection,
117        arg1: *mut ::libc::c_void,
118        key: *const ::libc::c_void,
119        key_size: u64,
120        value: *mut ::libc::c_void,
121        value_size: *mut u64,
122    ) -> ::libc::c_int,
123>;
124#[doc = " Cache callback function that allows the caller to store SSL session data in a\n cache.\n\n The callback function takes seven arguments:\n a pointer to the s2n_connection object,\n a pointer to arbitrary data for use within the callback,\n a 64-bit unsigned integer specifying the number of seconds the session data may be stored for,\n a pointer to a key which can be used to retrieve the cached entry,\n a 64 bit unsigned integer specifying the size of this key,\n a pointer to a value which should be stored,\n and a 64 bit unsigned integer specified the size of this value."]
125pub type s2n_cache_store_callback = ::core::option::Option<
126    unsafe extern "C" fn(
127        conn: *mut s2n_connection,
128        arg1: *mut ::libc::c_void,
129        ttl_in_seconds: u64,
130        key: *const ::libc::c_void,
131        key_size: u64,
132        value: *const ::libc::c_void,
133        value_size: u64,
134    ) -> ::libc::c_int,
135>;
136#[doc = "  Cache callback function that allows the caller to set a callback function\n  that will be used to delete SSL session data from a cache.\n\n  The callback function takes four arguments:\n  a pointer to s2n_connection object,\n  a pointer to arbitrary data for use within the callback,\n  a pointer to a key which can be used to delete the cached entry,\n  and a 64 bit unsigned integer specifying the size of this key."]
137pub type s2n_cache_delete_callback = ::core::option::Option<
138    unsafe extern "C" fn(
139        conn: *mut s2n_connection,
140        arg1: *mut ::libc::c_void,
141        key: *const ::libc::c_void,
142        key_size: u64,
143    ) -> ::libc::c_int,
144>;
145extern "C" {
146    #[doc = " Allows the caller to set a callback function that will be used to get the\n system time. The time returned should be the number of nanoseconds since the\n Unix epoch (Midnight, January 1st, 1970).\n\n s2n-tls uses this clock for timestamps.\n\n @param config The configuration object being updated\n @param clock_fn The wall clock time callback function\n @param ctx An opaque pointer that the callback will be invoked with\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
147    pub fn s2n_config_set_wall_clock(
148        config: *mut s2n_config,
149        clock_fn: s2n_clock_time_nanoseconds,
150        ctx: *mut ::libc::c_void,
151    ) -> ::libc::c_int;
152}
153extern "C" {
154    #[doc = " Allows the caller to set a callback function that will be used to get\n monotonic time. The monotonic time is the time since an arbitrary, unspecified\n point. Unlike wall clock time, it MUST never move backwards.\n\n s2n-tls uses this clock for timers.\n\n @param config The configuration object being updated\n @param clock_fn The monotonic time callback function\n @param ctx An opaque pointer that the callback will be invoked with\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
155    pub fn s2n_config_set_monotonic_clock(
156        config: *mut s2n_config,
157        clock_fn: s2n_clock_time_nanoseconds,
158        ctx: *mut ::libc::c_void,
159    ) -> ::libc::c_int;
160}
161extern "C" {
162    #[doc = " Translates an s2n_error code to a human readable string explaining the error.\n\n @param error The error code to explain. Usually this is s2n_errno\n @param lang The language to explain the error code. Pass \"EN\" or NULL for English.\n @returns The error string"]
163    pub fn s2n_strerror(error: ::libc::c_int, lang: *const ::libc::c_char)
164        -> *const ::libc::c_char;
165}
166extern "C" {
167    #[doc = " Translates an s2n_error code to a human readable string containing internal debug\n information, including file name and line number. This function is useful when\n reporting issues to the s2n-tls development team.\n\n @param error The error code to explain. Usually this is s2n_errno\n @param lang The language to explain the error code. Pass \"EN\" or NULL for English.\n @returns The error string"]
168    pub fn s2n_strerror_debug(
169        error: ::libc::c_int,
170        lang: *const ::libc::c_char,
171    ) -> *const ::libc::c_char;
172}
173extern "C" {
174    #[doc = " Translates an s2n_error code to a human readable string.\n\n @param error The error code to explain. Usually this is s2n_errno\n @returns The error string"]
175    pub fn s2n_strerror_name(error: ::libc::c_int) -> *const ::libc::c_char;
176}
177extern "C" {
178    #[doc = " Translates an s2n_error code to a filename and line number.\n\n @param error The error code to explain. Usually this is s2n_errno.\n @returns The error string."]
179    pub fn s2n_strerror_source(error: ::libc::c_int) -> *const ::libc::c_char;
180}
181#[doc = " Opaque stack trace structure."]
182#[repr(C)]
183#[derive(Debug, Copy, Clone)]
184pub struct s2n_stacktrace {
185    _unused: [u8; 0],
186}
187extern "C" {
188    #[doc = " Checks if s2n stack trace captures are enabled.\n\n @returns True if stack traces are enabled. False if they are disabled."]
189    pub fn s2n_stack_traces_enabled() -> bool;
190}
191extern "C" {
192    #[doc = " Configures the s2n stack trace captures option.\n\n @param newval Boolean to determine if stack traces should be enabled. True to enable them. False to disable them.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
193    pub fn s2n_stack_traces_enabled_set(newval: bool) -> ::libc::c_int;
194}
195extern "C" {
196    #[doc = " Calculates the s2n stack trace.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
197    pub fn s2n_calculate_stacktrace() -> ::libc::c_int;
198}
199extern "C" {
200    #[doc = " Prints the s2n stack trace to a file. The file descriptor is expected to be\n open and ready for writing.\n\n @param fptr A pointer to the file s2n-tls should write the stack trace to.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
201    pub fn s2n_print_stacktrace(fptr: *mut FILE) -> ::libc::c_int;
202}
203extern "C" {
204    #[doc = " Clean up the memory used to contain the stack trace.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
205    pub fn s2n_free_stacktrace() -> ::libc::c_int;
206}
207extern "C" {
208    #[doc = " Export the s2n_stacktrace.\n\n @param trace A pointer to the s2n_stacktrace to fill.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
209    pub fn s2n_get_stacktrace(trace: *mut s2n_stacktrace) -> ::libc::c_int;
210}
211extern "C" {
212    #[doc = " Allows the caller to set a callback function that will be used to store SSL\n session data in a cache.\n\n @param config The configuration object being updated\n @param cache_store_callback The cache store callback function.\n @param data An opaque context pointer that the callback will be invoked with.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
213    pub fn s2n_config_set_cache_store_callback(
214        config: *mut s2n_config,
215        cache_store_callback: s2n_cache_store_callback,
216        data: *mut ::libc::c_void,
217    ) -> ::libc::c_int;
218}
219extern "C" {
220    #[doc = " Allows the caller to set a callback function that will be used to retrieve SSL\n session data from a cache.\n\n @param config The configuration object being updated\n @param cache_retrieve_callback The cache retrieve callback function.\n @param data An opaque context pointer that the callback will be invoked with.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
221    pub fn s2n_config_set_cache_retrieve_callback(
222        config: *mut s2n_config,
223        cache_retrieve_callback: s2n_cache_retrieve_callback,
224        data: *mut ::libc::c_void,
225    ) -> ::libc::c_int;
226}
227extern "C" {
228    #[doc = " Allows the caller to set a callback function that will be used to delete SSL\n session data from a cache.\n\n @param config The configuration object being updated\n @param cache_delete_callback The cache delete callback function.\n @param data An opaque context pointer that the callback will be invoked with.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
229    pub fn s2n_config_set_cache_delete_callback(
230        config: *mut s2n_config,
231        cache_delete_callback: s2n_cache_delete_callback,
232        data: *mut ::libc::c_void,
233    ) -> ::libc::c_int;
234}
235#[doc = " Called when `s2n_init` is executed."]
236pub type s2n_mem_init_callback = ::core::option::Option<unsafe extern "C" fn() -> ::libc::c_int>;
237#[doc = " Will be called when `s2n_cleanup` is executed."]
238pub type s2n_mem_cleanup_callback = ::core::option::Option<unsafe extern "C" fn() -> ::libc::c_int>;
239#[doc = " A function that can allocate at least `requested` bytes of memory.\n\n It stores the location of that memory in **\\*ptr** and the size of the allocated\n data in **\\*allocated**. The function may choose to allocate more memory\n than was requested. s2n-tls will consider all allocated memory available for\n use, and will attempt to free all allocated memory when able."]
240pub type s2n_mem_malloc_callback = ::core::option::Option<
241    unsafe extern "C" fn(
242        ptr: *mut *mut ::libc::c_void,
243        requested: u32,
244        allocated: *mut u32,
245    ) -> ::libc::c_int,
246>;
247#[doc = " Frees memory allocated by s2n_mem_malloc_callback."]
248pub type s2n_mem_free_callback = ::core::option::Option<
249    unsafe extern "C" fn(ptr: *mut ::libc::c_void, size: u32) -> ::libc::c_int,
250>;
251extern "C" {
252    #[doc = " Allows the caller to override s2n-tls's internal memory handling functions.\n\n @warning This function must be called before s2n_init().\n\n @param mem_init_callback The s2n_mem_init_callback\n @param mem_cleanup_callback The s2n_mem_cleanup_callback\n @param mem_malloc_callback The s2n_mem_malloc_callback\n @param mem_free_callback The s2n_mem_free_callback\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
253    pub fn s2n_mem_set_callbacks(
254        mem_init_callback: s2n_mem_init_callback,
255        mem_cleanup_callback: s2n_mem_cleanup_callback,
256        mem_malloc_callback: s2n_mem_malloc_callback,
257        mem_free_callback: s2n_mem_free_callback,
258    ) -> ::libc::c_int;
259}
260#[doc = " A callback function that will be called when s2n-tls is initialized."]
261pub type s2n_rand_init_callback = ::core::option::Option<unsafe extern "C" fn() -> ::libc::c_int>;
262#[doc = " A callback function that will be called when `s2n_cleanup` is executed."]
263pub type s2n_rand_cleanup_callback =
264    ::core::option::Option<unsafe extern "C" fn() -> ::libc::c_int>;
265#[doc = " A callback function that will be used to provide entropy to the s2n-tls\n random number generators."]
266pub type s2n_rand_seed_callback = ::core::option::Option<
267    unsafe extern "C" fn(data: *mut ::libc::c_void, size: u32) -> ::libc::c_int,
268>;
269#[doc = " A callback function that will be used to mix in entropy every time the RNG\n is invoked."]
270pub type s2n_rand_mix_callback = ::core::option::Option<
271    unsafe extern "C" fn(data: *mut ::libc::c_void, size: u32) -> ::libc::c_int,
272>;
273extern "C" {
274    #[doc = " Allows the caller to override s2n-tls's entropy functions.\n\n @warning This function must be called before s2n_init().\n\n @note The overriden random callbacks will not be used when s2n-tls is operating in FIPS mode.\n\n @param rand_init_callback The s2n_rand_init_callback\n @param rand_cleanup_callback The s2n_rand_cleanup_callback\n @param rand_seed_callback The s2n_rand_seed_callback\n @param rand_mix_callback The s2n_rand_mix_callback\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
275    pub fn s2n_rand_set_callbacks(
276        rand_init_callback: s2n_rand_init_callback,
277        rand_cleanup_callback: s2n_rand_cleanup_callback,
278        rand_seed_callback: s2n_rand_seed_callback,
279        rand_mix_callback: s2n_rand_mix_callback,
280    ) -> ::libc::c_int;
281}
282pub mod s2n_tls_extension_type {
283    #[doc = " TLS extensions supported by s2n-tls"]
284    pub type Type = ::libc::c_uint;
285    pub const SERVER_NAME: Type = 0;
286    pub const MAX_FRAG_LEN: Type = 1;
287    pub const OCSP_STAPLING: Type = 5;
288    pub const SUPPORTED_GROUPS: Type = 10;
289    pub const EC_POINT_FORMATS: Type = 11;
290    pub const SIGNATURE_ALGORITHMS: Type = 13;
291    pub const ALPN: Type = 16;
292    pub const CERTIFICATE_TRANSPARENCY: Type = 18;
293    pub const SUPPORTED_VERSIONS: Type = 43;
294    pub const RENEGOTIATION_INFO: Type = 65281;
295}
296pub mod s2n_max_frag_len {
297    #[doc = " MFL configurations from https://datatracker.ietf.org/doc/html/rfc6066#section-4."]
298    pub type Type = ::libc::c_uint;
299    pub const LEN_512: Type = 1;
300    pub const LEN_1024: Type = 2;
301    pub const LEN_2048: Type = 3;
302    pub const LEN_4096: Type = 4;
303}
304#[doc = " Opaque certificate type."]
305#[repr(C)]
306#[derive(Debug, Copy, Clone)]
307pub struct s2n_cert {
308    _unused: [u8; 0],
309}
310#[doc = " Opaque certificate chain and key type."]
311#[repr(C)]
312#[derive(Debug, Copy, Clone)]
313pub struct s2n_cert_chain_and_key {
314    _unused: [u8; 0],
315}
316#[doc = " Opaque key type."]
317#[repr(C)]
318#[derive(Debug, Copy, Clone)]
319pub struct s2n_pkey {
320    _unused: [u8; 0],
321}
322#[doc = " Opaque public key type."]
323pub type s2n_cert_public_key = s2n_pkey;
324#[doc = " Opaque private key type."]
325pub type s2n_cert_private_key = s2n_pkey;
326extern "C" {
327    #[doc = " Creates a new s2n_cert_chain_and_key object. This object can be associated\n with many config objects. It is used to represent a certificate and key pair.\n\n @returns A new object used to represent a certificate-chain/key pair"]
328    pub fn s2n_cert_chain_and_key_new() -> *mut s2n_cert_chain_and_key;
329}
330extern "C" {
331    #[doc = " Associates a certificate chain and private key with an `s2n_cert_chain_and_key` object.\n\n `cert_chain_pem` should be a PEM encoded certificate chain, with the first\n certificate in the chain being your leaf certificate. `private_key_pem`\n should be a PEM encoded private key corresponding to the leaf certificate.\n\n @note Prefer using s2n_cert_chain_and_key_load_pem_bytes.\n\n @param chain_and_key The certificate chain and private key handle\n @param chain_pem A byte array of a PEM encoded certificate chain.\n @param private_key_pem A byte array of a PEM encoded key.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
332    pub fn s2n_cert_chain_and_key_load_pem(
333        chain_and_key: *mut s2n_cert_chain_and_key,
334        chain_pem: *const ::libc::c_char,
335        private_key_pem: *const ::libc::c_char,
336    ) -> ::libc::c_int;
337}
338extern "C" {
339    #[doc = " Associates a certificate chain and private key with an `s2n_cert_chain_and_key` object.\n\n `cert_chain_pem` should be a PEM encoded certificate chain, with the first\n certificate in the chain being your leaf certificate. `private_key_pem`\n should be a PEM encoded private key corresponding to the leaf certificate.\n\n @param chain_and_key The certificate chain and private key handle\n @param chain_pem A byte array of a PEM encoded certificate chain.\n @param chain_pem_len Size of `chain_pem`\n @param private_key_pem A byte array of a PEM encoded key.\n @param private_key_pem_len Size of `private_key_pem`\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
340    pub fn s2n_cert_chain_and_key_load_pem_bytes(
341        chain_and_key: *mut s2n_cert_chain_and_key,
342        chain_pem: *mut u8,
343        chain_pem_len: u32,
344        private_key_pem: *mut u8,
345        private_key_pem_len: u32,
346    ) -> ::libc::c_int;
347}
348extern "C" {
349    #[doc = " Associates a public certificate chain with a `s2n_cert_chain_and_key` object. It does\n NOT set a private key, so the connection will need to be configured to\n [offload private key operations](https://github.com/aws/s2n-tls/blob/main/docs/usage-guide/topics/ch12-private-key-ops.md).\n\n @param chain_and_key The certificate chain and private key handle\n @param chain_pem A byte array of a PEM encoded certificate chain.\n @param chain_pem_len Size of `chain_pem`\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
350    pub fn s2n_cert_chain_and_key_load_public_pem_bytes(
351        chain_and_key: *mut s2n_cert_chain_and_key,
352        chain_pem: *mut u8,
353        chain_pem_len: u32,
354    ) -> ::libc::c_int;
355}
356extern "C" {
357    #[doc = " Frees the memory associated with an `s2n_cert_chain_and_key` object.\n\n @param cert_and_key The certificate chain and private key handle\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
358    pub fn s2n_cert_chain_and_key_free(cert_and_key: *mut s2n_cert_chain_and_key) -> ::libc::c_int;
359}
360extern "C" {
361    #[doc = " Adds a context to the `s2n_cert_chain_and_key` object.\n\n @param cert_and_key The certificate chain and private key handle\n @param ctx An opaque pointer to user supplied data.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
362    pub fn s2n_cert_chain_and_key_set_ctx(
363        cert_and_key: *mut s2n_cert_chain_and_key,
364        ctx: *mut ::libc::c_void,
365    ) -> ::libc::c_int;
366}
367extern "C" {
368    #[doc = " Get the user supplied context from the `s2n_cert_chain_and_key` object.\n\n @param cert_and_key The certificate chain and private key handle\n @returns The user supplied pointer from s2n_cert_chain_and_key_set_ctx()"]
369    pub fn s2n_cert_chain_and_key_get_ctx(
370        cert_and_key: *mut s2n_cert_chain_and_key,
371    ) -> *mut ::libc::c_void;
372}
373extern "C" {
374    #[doc = " Get the private key from the `s2n_cert_chain_and_key` object.\n\n @param cert_and_key The certificate chain and private key handle\n @returns A pointer to the `s2n_cert_private_key`"]
375    pub fn s2n_cert_chain_and_key_get_private_key(
376        cert_and_key: *mut s2n_cert_chain_and_key,
377    ) -> *mut s2n_cert_private_key;
378}
379extern "C" {
380    #[doc = " Set the raw OCSP stapling data for a certificate chain.\n\n @param chain_and_key The certificate chain handle\n @param data A pointer to the raw OCSP stapling data bytes. The data will be copied.\n @param length The length of the data bytes.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
381    pub fn s2n_cert_chain_and_key_set_ocsp_data(
382        chain_and_key: *mut s2n_cert_chain_and_key,
383        data: *const u8,
384        length: u32,
385    ) -> ::libc::c_int;
386}
387extern "C" {
388    #[doc = " Set the signed certificate timestamp (SCT) for a certificate chain.\n This is used for Certificate Transparency.\n\n @param chain_and_key The certificate chain handle\n @param data A pointer to the SCT data. The data will be copied.\n @param length The length of the data bytes.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
389    pub fn s2n_cert_chain_and_key_set_sct_list(
390        chain_and_key: *mut s2n_cert_chain_and_key,
391        data: *const u8,
392        length: u32,
393    ) -> ::libc::c_int;
394}
395#[doc = " A callback function that is invoked if s2n-tls cannot resolve a conflict between\n two certificates with the same domain name. This function is invoked while certificates\n are added to an `s2n_config`.\n\n Currently, the only builtin resolution for domain name conflicts is certificate type(RSA,\n ECDSA, etc). The callback should return a pointer to the `s2n_cert_chain_and_key` that\n should be used for dns name `name`.\n\n If NULL is returned, the first certificate will be used. Typically an application\n will use properties like trust and expiry to implement tiebreaking."]
396pub type s2n_cert_tiebreak_callback = ::core::option::Option<
397    unsafe extern "C" fn(
398        cert1: *mut s2n_cert_chain_and_key,
399        cert2: *mut s2n_cert_chain_and_key,
400        name: *mut u8,
401        name_len: u32,
402    ) -> *mut s2n_cert_chain_and_key,
403>;
404extern "C" {
405    #[doc = " Sets the `s2n_cert_tiebreak_callback` for resolving domain name conflicts.\n If no callback is set, the first certificate added for a domain name will always be preferred.\n\n @param config The configuration object being updated\n @param cert_tiebreak_cb The pointer to the certificate tiebreak function\n\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
406    pub fn s2n_config_set_cert_tiebreak_callback(
407        config: *mut s2n_config,
408        cert_tiebreak_cb: s2n_cert_tiebreak_callback,
409    ) -> ::libc::c_int;
410}
411extern "C" {
412    #[doc = " Associates a certificate chain and private key with an `s2n_config` object.\n Using this API, only one cert chain of each type (like ECDSA or RSA) may be associated with a config.\n `cert_chain_pem` should be a PEM encoded certificate chain, with the first certificate\n in the chain being your server's certificate. `private_key_pem` should be a\n PEM encoded private key corresponding to the server certificate.\n\n @deprecated Use s2n_config_add_cert_chain_and_key_to_store instead.\n\n @param config The configuration object being updated\n @param cert_chain_pem A byte array of a PEM encoded certificate chain.\n @param private_key_pem A byte array of a PEM encoded key.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
413    pub fn s2n_config_add_cert_chain_and_key(
414        config: *mut s2n_config,
415        cert_chain_pem: *const ::libc::c_char,
416        private_key_pem: *const ::libc::c_char,
417    ) -> ::libc::c_int;
418}
419extern "C" {
420    #[doc = " The preferred method of associating a certificate chain and private key pair with an `s2n_config` object.\n This method may be called multiple times to support multiple key types (RSA, RSA-PSS, ECDSA) and multiple\n domains. On the server side, the certificate selected will be based on the incoming SNI value and the\n client's capabilities (supported ciphers).\n\n In the case of no certificate matching the client's SNI extension or if no SNI extension was sent by\n the client, the certificate from the `first` call to `s2n_config_add_cert_chain_and_key_to_store()`\n will be selected. Use `s2n_config_set_cert_chain_and_key_defaults()` to set different defaults.\n\n @warning It is not recommended to free or modify the `cert_key_pair` as any subsequent changes will be\n reflected in the config.\n\n @param config The configuration object being updated\n @param cert_key_pair The certificate chain and private key handle\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
421    pub fn s2n_config_add_cert_chain_and_key_to_store(
422        config: *mut s2n_config,
423        cert_key_pair: *mut s2n_cert_chain_and_key,
424    ) -> ::libc::c_int;
425}
426extern "C" {
427    #[doc = " Explicitly sets certificate chain and private key pairs to be used as defaults for each auth\n method (key type). A \"default\" certificate is used when there is not an SNI match with any other\n configured certificate.\n\n Only one certificate can be set as the default per auth method (one RSA default, one ECDSA default,\n etc.). All previous default certificates will be cleared and re-set when this API is called.\n\n This API is called for a specific `s2n_config` object. s2n-tls will attempt to automatically choose\n default certificates for each auth method (key type) based on the order that `s2n_cert_chain_and_key`\n are added to the `s2n_config` using one of the APIs listed above.\n `s2n_config_set_cert_chain_and_key_defaults` can be called at any time; s2n-tls will clear defaults\n and no longer attempt to automatically choose any default certificates.\n\n @param config The configuration object being updated\n @param cert_key_pairs An array of certificate chain and private key handles\n @param num_cert_key_pairs The amount of handles in cert_key_pairs\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
428    pub fn s2n_config_set_cert_chain_and_key_defaults(
429        config: *mut s2n_config,
430        cert_key_pairs: *mut *mut s2n_cert_chain_and_key,
431        num_cert_key_pairs: u32,
432    ) -> ::libc::c_int;
433}
434extern "C" {
435    #[doc = " Adds to the trust store from a CA file or directory containing trusted certificates.\n\n When configs are created with `s2n_config_new()`, the trust store is initialized with default\n system certificates. To completely override these certificates, call\n `s2n_config_wipe_trust_store()` before calling this function.\n\n @note The trust store will be initialized with the common locations for the host\n operating system by default.\n\n @warning This API uses the PEM parsing implementation from the linked libcrypto. This\n implementation will typically make a best-effort attempt to parse all of the certificates in the\n provided file or directory. This permissive approach may silently ignore malformed certificates,\n leading to possible connection failures if a certificate was expected to exist in the trust\n store but was skipped while parsing. As such, this API should only be used on PEMs that are\n known to be well-formed and parsable with the linked libcrypto, such as the system trust store.\n For all other PEMs, `s2n_config_add_pem_to_trust_store()` should be used instead, which parses\n more strictly.\n\n @param config The configuration object being updated\n @param ca_pem_filename A string for the file path of the CA PEM file.\n @param ca_dir A string for the directory of the CA PEM files.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
436    pub fn s2n_config_set_verification_ca_location(
437        config: *mut s2n_config,
438        ca_pem_filename: *const ::libc::c_char,
439        ca_dir: *const ::libc::c_char,
440    ) -> ::libc::c_int;
441}
442extern "C" {
443    #[doc = " Adds a PEM to the trust store. This will allocate memory, and load `pem` into the trust store.\n\n When configs are created with `s2n_config_new()`, the trust store is initialized with default\n system certificates. To completely override these certificates, call\n `s2n_config_wipe_trust_store()` before calling this function.\n\n @note This API uses the s2n-tls PEM parsing implementation, which is more strict than typical\n libcrypto implementations such as OpenSSL. An error is returned if any unexpected data is\n encountered while parsing `pem`. This allows applications to be made aware of any malformed\n certificates rather than attempt to negotiate with a partial trust store. However, some PEMs may\n need to be loaded that are not under control of the application, such as system trust stores. In\n this case, `s2n_config_set_verification_ca_location()` may be used, which performs more widely\n compatible and permissive parsing from the linked libcrypto.\n\n @param config The configuration object being updated\n @param pem The string value of the PEM certificate.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
444    pub fn s2n_config_add_pem_to_trust_store(
445        config: *mut s2n_config,
446        pem: *const ::libc::c_char,
447    ) -> ::libc::c_int;
448}
449extern "C" {
450    #[doc = " Clears the trust store of all certificates.\n\n When configs are created with `s2n_config_new()`, the trust store is initialized with default\n system certificates. To completely override these certificates, call this function before\n functions like `s2n_config_set_verification_ca_location()` or\n `s2n_config_add_pem_to_trust_store()`.\n\n @param config The configuration object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
451    pub fn s2n_config_wipe_trust_store(config: *mut s2n_config) -> ::libc::c_int;
452}
453extern "C" {
454    #[doc = " Loads default system certificates into the trust store.\n\n `s2n_config_new_minimal()` doesn't load default system certificates into the config's trust\n store by default. If `config` was created with `s2n_config_new_minimal`, this function can be\n used to load system certificates into the trust store.\n\n @note This API will error if called on a config that has already loaded system certificates\n into its trust store, which includes all configs created with `s2n_config_new()`.\n\n @param config The configuration object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
455    pub fn s2n_config_load_system_certs(config: *mut s2n_config) -> ::libc::c_int;
456}
457pub mod s2n_verify_after_sign {
458    pub type Type = ::libc::c_uint;
459    pub const VERIFY_AFTER_SIGN_DISABLED: Type = 0;
460    pub const VERIFY_AFTER_SIGN_ENABLED: Type = 1;
461}
462extern "C" {
463    #[doc = " Toggle whether generated signatures are verified before being sent.\n\n Although signatures produced by the underlying libcrypto should always be valid,\n hardware faults, bugs in the signing implementation, or other uncommon factors\n can cause unexpected mistakes in the final signatures. Because these mistakes\n can leak information about the private key, applications with low trust in their\n hardware or libcrypto may want to verify signatures before sending them.\n\n However, this feature will significantly impact handshake latency.\n Additionally, most libcrypto implementations already check for common errors in signatures."]
464    pub fn s2n_config_set_verify_after_sign(
465        config: *mut s2n_config,
466        mode: s2n_verify_after_sign::Type,
467    ) -> ::libc::c_int;
468}
469extern "C" {
470    #[doc = " Set a custom send buffer size.\n\n This buffer is used to stage records for sending. By default,\n enough memory is allocated to hold a single record of the maximum\n size configured for the connection. With the default fragment size,\n that is about 8K bytes.\n\n Less memory can be allocated for the send buffer, but this will result in\n smaller, more fragmented records and increased overhead. While the absolute\n minimum size required is 1034 bytes, at least 2K bytes is recommended for\n reasonable record sizes.\n\n More memory can be allocated for the send buffer. This will result in s2n-tls\n buffering multiple records before sending them, reducing system write calls.\n At least 17K bytes is recommended for this use case, or at least 35K bytes\n if larger fragment sizes are used via `s2n_connection_prefer_throughput()`.\n\n @param config The configuration object being updated\n @param size The desired custom buffer size.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
471    pub fn s2n_config_set_send_buffer_size(config: *mut s2n_config, size: u32) -> ::libc::c_int;
472}
473extern "C" {
474    #[doc = " Enable or disable receiving of multiple TLS records in a single s2n_recv call\n\n By default, s2n-tls returns from s2n_recv() after reading a single TLS record.\n Enabling receiving of multiple records will instead cause s2n_recv() to attempt\n to read until the application-provided output buffer is full. This may be more\n efficient, especially if larger receive buffers are used.\n\n @note If this option is enabled with blocking IO, the call to s2n_recv() will\n not return until either the application-provided output buffer is full or the\n peer closes the connection. This may lead to unintentionally long waits if the\n peer does not send enough data.\n\n @param config The configuration object being updated\n @param enabled Set to `true` if multiple record receive is to be enabled; `false` to disable.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
475    pub fn s2n_config_set_recv_multi_record(
476        config: *mut s2n_config,
477        enabled: bool,
478    ) -> ::libc::c_int;
479}
480#[doc = " A callback function invoked (usually multiple times) during X.509 validation for each\n name encountered in the leaf certificate.\n\n Return 1 to trust that hostname or 0 to not trust the hostname.\n\n If this function returns 1, then the certificate is considered trusted and that portion\n of the X.509 validation will succeed.\n\n If no hostname results in a 1 being returned, the certificate will be untrusted and the\n validation will terminate immediately.\n\n Data is a opaque user context set in s2n_config_set_verify_host_callback() or s2n_connection_set_verify_host_callback()."]
481pub type s2n_verify_host_fn = ::core::option::Option<
482    unsafe extern "C" fn(
483        host_name: *const ::libc::c_char,
484        host_name_len: usize,
485        data: *mut ::libc::c_void,
486    ) -> u8,
487>;
488extern "C" {
489    #[doc = " Sets the callback to use for verifying that a hostname from an X.509 certificate is trusted.\n\n The default behavior is to require that the hostname match the server name set with s2n_set_server_name().\n This will likely lead to all client certificates being rejected, so the callback will need to be overriden when using\n  client authentication.\n\n This change will be inherited by s2n_connections using this config. If a separate callback for different connections\n using the same config is desired, see s2n_connection_set_verify_host_callback().\n\n @param config The configuration object being updated\n @param data A user supplied opaque context to pass back to the callback\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
490    pub fn s2n_config_set_verify_host_callback(
491        config: *mut s2n_config,
492        arg1: s2n_verify_host_fn,
493        data: *mut ::libc::c_void,
494    ) -> ::libc::c_int;
495}
496extern "C" {
497    #[doc = " Toggles whether or not to validate stapled OCSP responses.\n\n 1 means OCSP responses will be validated when they are encountered, while 0 means this step will\n be skipped.\n\n The default value is 1 if the underlying libCrypto implementation supports OCSP.\n\n @param config The configuration object being updated\n @param check_ocsp The desired OCSP response check configuration\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
498    pub fn s2n_config_set_check_stapled_ocsp_response(
499        config: *mut s2n_config,
500        check_ocsp: u8,
501    ) -> ::libc::c_int;
502}
503extern "C" {
504    #[doc = " Disables timestamp validation for received certificates.\n\n By default, s2n-tls checks the notBefore and notAfter fields on the certificates it receives\n during the handshake. If the current date is not within the range of these fields for any\n certificate in the chain of trust, `s2n_negotiate()` will error. This validation is in\n accordance with RFC 5280, section 6.1.3 a.2:\n https://datatracker.ietf.org/doc/html/rfc5280#section-6.1.3.\n\n This API will disable this timestamp validation, permitting negotiation with peers that send\n expired certificates, or certificates that are not yet considered valid.\n\n @warning Applications calling this API should seriously consider the security implications of\n disabling this validation. The validity period of a certificate corresponds to the range of time\n in which the CA is guaranteed to maintain information regarding the certificate's revocation\n status. As such, it may not be possible to obtain accurate revocation information for\n certificates with invalid timestamps. Applications disabling this validation MUST implement\n some external method for limiting certificate lifetime.\n\n @param config The associated connection config.\n @returns S2N_SUCCESS on success, S2N_FAILURE on failure."]
505    pub fn s2n_config_disable_x509_time_verification(config: *mut s2n_config) -> ::libc::c_int;
506}
507extern "C" {
508    #[doc = " Turns off all X.509 validation during the negotiation phase of the connection. This should only\n be used for testing or debugging purposes.\n\n @param config The configuration object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
509    pub fn s2n_config_disable_x509_verification(config: *mut s2n_config) -> ::libc::c_int;
510}
511extern "C" {
512    #[doc = " Sets the maximum allowed depth of a cert chain used for X509 validation. The default value is\n 7. If this limit is exceeded, validation will fail if s2n_config_disable_x509_verification()\n has not been called. 0 is an illegal value and will return an error.\n 1 means only a root certificate will be used.\n\n @param config The configuration object being updated\n @param max_depth The number of allowed certificates in the certificate chain\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
513    pub fn s2n_config_set_max_cert_chain_depth(
514        config: *mut s2n_config,
515        max_depth: u16,
516    ) -> ::libc::c_int;
517}
518extern "C" {
519    #[doc = " Associates a set of Diffie-Hellman parameters with an `s2n_config` object.\n @note `dhparams_pem` should be PEM encoded DH parameters.\n\n @param config The configuration object being updated\n @param dhparams_pem A string containing the PEM encoded DH parameters.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
520    pub fn s2n_config_add_dhparams(
521        config: *mut s2n_config,
522        dhparams_pem: *const ::libc::c_char,
523    ) -> ::libc::c_int;
524}
525extern "C" {
526    #[doc = " Sets the security policy that includes the cipher/kem/signature/ecc preferences and\n protocol version.\n\n See the [USAGE-GUIDE.md](https://github.com/aws/s2n-tls/blob/main/docs/usage-guide) for how to use security policies."]
527    pub fn s2n_config_set_cipher_preferences(
528        config: *mut s2n_config,
529        version: *const ::libc::c_char,
530    ) -> ::libc::c_int;
531}
532extern "C" {
533    #[doc = " Appends the provided application protocol to the preference list\n\n The data provided in `protocol` parameter will be copied into an internal buffer\n\n @param config The configuration object being updated\n @param protocol A pointer to a byte array value\n @param protocol_len The length of bytes that should be read from `protocol`. Note: this value cannot be 0, otherwise an error will be returned."]
534    pub fn s2n_config_append_protocol_preference(
535        config: *mut s2n_config,
536        protocol: *const u8,
537        protocol_len: u8,
538    ) -> ::libc::c_int;
539}
540extern "C" {
541    #[doc = " Sets the application protocol preferences on an `s2n_config` object.\n `protocols` is a list in order of preference, with most preferred protocol first, and of\n length `protocol_count`.\n\n When acting as an `S2N_CLIENT` the protocol list is included in the Client Hello message\n as the ALPN extension.\n\n As an `S2N_SERVER`, the list is used to negotiate a mutual application protocol with the\n client. After the negotiation for the connection has completed, the agreed upon protocol\n can be retrieved with s2n_get_application_protocol()\n\n @param config The configuration object being updated\n @param protocols The list of preferred protocols, in order of preference\n @param protocol_count The size of the protocols list\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
542    pub fn s2n_config_set_protocol_preferences(
543        config: *mut s2n_config,
544        protocols: *const *const ::libc::c_char,
545        protocol_count: ::libc::c_int,
546    ) -> ::libc::c_int;
547}
548pub mod s2n_status_request_type {
549    #[doc = " Enum used to define the type, if any, of certificate status request\n a connection should make during the handshake. The only supported status request type is\n OCSP, `S2N_STATUS_REQUEST_OCSP`."]
550    pub type Type = ::libc::c_uint;
551    pub const NONE: Type = 0;
552    pub const OCSP: Type = 1;
553}
554extern "C" {
555    #[doc = " Sets up a connection to request the certificate status of a peer during an SSL handshake. If set\n to S2N_STATUS_REQUEST_NONE, no status request is made.\n\n @note SHA-1 is the only supported hash algorithm for the `certID` field. This is different\n from the hash algorithm used for the OCSP signature. See\n [RFC 6960](https://datatracker.ietf.org/doc/html/rfc6960#section-4.1.1) for more information.\n While unlikely to be the case, if support for a different hash algorithm is required, the\n s2n-tls validation can be disabled with `s2n_config_set_check_stapled_ocsp_response()` and the\n response can be retrieved for manual validation with `s2n_connection_get_ocsp_response()`.\n\n @param config The configuration object being updated\n @param type The desired request status type\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
556    pub fn s2n_config_set_status_request_type(
557        config: *mut s2n_config,
558        type_: s2n_status_request_type::Type,
559    ) -> ::libc::c_int;
560}
561pub mod s2n_ct_support_level {
562    #[doc = " Enum to set Certificate Transparency Support level."]
563    pub type Type = ::libc::c_uint;
564    pub const NONE: Type = 0;
565    pub const REQUEST: Type = 1;
566}
567extern "C" {
568    #[doc = " Set the Certificate Transparency Support level.\n\n @param config The configuration object being updated\n @param level The desired Certificate Transparency Support configuration\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
569    pub fn s2n_config_set_ct_support_level(
570        config: *mut s2n_config,
571        level: s2n_ct_support_level::Type,
572    ) -> ::libc::c_int;
573}
574pub mod s2n_alert_behavior {
575    #[doc = " Sets whether or not a connection should terminate on receiving a WARNING alert from its peer.\n\n `alert_behavior` can take the following values:\n - `S2N_ALERT_FAIL_ON_WARNINGS` default behavior: s2n-tls will terminate the connection if its peer sends a WARNING alert.\n - `S2N_ALERT_IGNORE_WARNINGS` - with the exception of `close_notify` s2n-tls will ignore all WARNING alerts and keep communicating with its peer. This setting is ignored in TLS1.3\n\n @note TLS1.3 terminates a connection for all alerts except user_canceled.\n @warning S2N_ALERT_FAIL_ON_WARNINGS is the recommended behavior. Past TLS protocol vulnerabilities have involved downgrading alerts to warnings."]
576    pub type Type = ::libc::c_uint;
577    pub const FAIL_ON_WARNINGS: Type = 0;
578    pub const IGNORE_WARNINGS: Type = 1;
579}
580extern "C" {
581    #[doc = " Sets the config's alert behavior based on the `s2n_alert_behavior` enum.\n\n @param config The configuration object being updated\n @param alert_behavior The desired alert behavior.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
582    pub fn s2n_config_set_alert_behavior(
583        config: *mut s2n_config,
584        alert_behavior: s2n_alert_behavior::Type,
585    ) -> ::libc::c_int;
586}
587extern "C" {
588    #[doc = " Sets the extension data in the `s2n_config` object for the specified extension.\n This method will clear any existing data that is set. If the data and length\n parameters are set to NULL, no new data is set in the `s2n_config` object,\n effectively clearing existing data.\n\n @deprecated Use s2n_cert_chain_and_key_set_ocsp_data and s2n_cert_chain_and_key_set_sct_list instead.\n\n @param config The configuration object being updated\n @param type The extension type\n @param data Data for the extension\n @param length Length of the `data` buffer"]
589    pub fn s2n_config_set_extension_data(
590        config: *mut s2n_config,
591        type_: s2n_tls_extension_type::Type,
592        data: *const u8,
593        length: u32,
594    ) -> ::libc::c_int;
595}
596extern "C" {
597    #[doc = " Allows the caller to set a TLS Maximum Fragment Length extension that will be used\n to fragment outgoing messages. s2n-tls currently does not reject fragments larger\n than the configured maximum when in server mode. The TLS negotiated maximum fragment\n length overrides the preference set by the `s2n_connection_prefer_throughput` and\n `s2n_connection_prefer_low_latency`.\n\n @note Some TLS implementations do not respect their peer's max fragment length extension.\n\n @param config The configuration object being updated\n @param mfl_code The selected MFL size\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
598    pub fn s2n_config_send_max_fragment_length(
599        config: *mut s2n_config,
600        mfl_code: s2n_max_frag_len::Type,
601    ) -> ::libc::c_int;
602}
603extern "C" {
604    #[doc = " Allows the server to opt-in to accept client's TLS maximum fragment length extension\n requests. If this API is not called, and client requests the extension, server will ignore\n the request and continue TLS handshake with default maximum fragment length of 8k bytes\n\n @note Some TLS implementations do not respect their peer's max fragment length extension.\n\n @param config The configuration object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
605    pub fn s2n_config_accept_max_fragment_length(config: *mut s2n_config) -> ::libc::c_int;
606}
607extern "C" {
608    #[doc = " Sets the lifetime of the cached session state. The default value is 15 hours.\n\n @param config The configuration object being updated\n @param lifetime_in_secs The desired lifetime of the session state in seconds\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
609    pub fn s2n_config_set_session_state_lifetime(
610        config: *mut s2n_config,
611        lifetime_in_secs: u64,
612    ) -> ::libc::c_int;
613}
614extern "C" {
615    #[doc = " Enable or disable session resumption using session ticket.\n\n @param config The configuration object being updated\n @param enabled The configuration object being updated. Set to 1 to enable. Set to 0 to disable.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
616    pub fn s2n_config_set_session_tickets_onoff(
617        config: *mut s2n_config,
618        enabled: u8,
619    ) -> ::libc::c_int;
620}
621extern "C" {
622    #[doc = " Enable or disable session caching.\n\n @note Session caching will not be turned on unless all three session cache callbacks are set\n prior to calling this function.\n\n @param config The configuration object being updated\n @param enabled The configuration object being updated. Set to 1 to enable. Set to 0 to disable.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
623    pub fn s2n_config_set_session_cache_onoff(
624        config: *mut s2n_config,
625        enabled: u8,
626    ) -> ::libc::c_int;
627}
628extern "C" {
629    #[doc = " Sets how long a session ticket key will be in a state where it can be used for both encryption\n and decryption of tickets on the server side.\n\n @note The default value is 2 hours.\n @param config The configuration object being updated\n @param lifetime_in_secs The desired lifetime of decrypting and encrypting tickets in seconds\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
630    pub fn s2n_config_set_ticket_encrypt_decrypt_key_lifetime(
631        config: *mut s2n_config,
632        lifetime_in_secs: u64,
633    ) -> ::libc::c_int;
634}
635extern "C" {
636    #[doc = " Sets how long a session ticket key will be in a state where it can used just for decryption of\n already assigned tickets on the server side. Once decrypted, the session will resume and the\n server will issue a new session ticket encrypted using a key in encrypt-decrypt state.\n\n @note The default value is 13 hours.\n @param config The configuration object being updated\n @param lifetime_in_secs The desired lifetime of decrypting and encrypting tickets in seconds\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
637    pub fn s2n_config_set_ticket_decrypt_key_lifetime(
638        config: *mut s2n_config,
639        lifetime_in_secs: u64,
640    ) -> ::libc::c_int;
641}
642extern "C" {
643    #[doc = " Adds session ticket key on the server side. It would be ideal to add new keys after every\n (encrypt_decrypt_key_lifetime_in_nanos/2) nanos because this will allow for gradual and\n linear transition of a key from encrypt-decrypt state to decrypt-only state.\n\n @param config The configuration object being updated\n @param name Name of the session ticket key that should be randomly generated to avoid collisions\n @param name_len Length of session ticket key name\n @param key Key used to perform encryption/decryption of session ticket\n @param key_len Length of the session ticket key\n @param intro_time_in_seconds_from_epoch Time at which the session ticket key is introduced. If this is 0, then intro_time_in_seconds_from_epoch is set to now.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
644    pub fn s2n_config_add_ticket_crypto_key(
645        config: *mut s2n_config,
646        name: *const u8,
647        name_len: u32,
648        key: *mut u8,
649        key_len: u32,
650        intro_time_in_seconds_from_epoch: u64,
651    ) -> ::libc::c_int;
652}
653extern "C" {
654    #[doc = " Requires that session tickets are only used when forward secrecy is possible.\n\n Restricts session resumption to TLS1.3, as the tickets used in TLS1.2 resumption are\n not forward secret. Clients should not expect to receive new session tickets and servers\n will not send new session tickets when TLS1.2 is negotiated and ticket forward secrecy is required.\n\n @note The default behavior is that forward secrecy is not required.\n\n @param config The config object being updated\n @param enabled Indicates if forward secrecy is required or not on tickets\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
655    pub fn s2n_config_require_ticket_forward_secrecy(
656        config: *mut s2n_config,
657        enabled: bool,
658    ) -> ::libc::c_int;
659}
660extern "C" {
661    #[doc = " Sets user defined context on the `s2n_config` object.\n\n @param config The configuration object being updated\n @param ctx A pointer to the user defined ctx.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
662    pub fn s2n_config_set_ctx(config: *mut s2n_config, ctx: *mut ::libc::c_void) -> ::libc::c_int;
663}
664extern "C" {
665    #[doc = " Gets the user defined context from the `s2n_config` object.\n The context is set by calling s2n_config_set_ctx()\n\n @param config The configuration object being accessed\n @param ctx A pointer to the user defined ctx.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
666    pub fn s2n_config_get_ctx(
667        config: *mut s2n_config,
668        ctx: *mut *mut ::libc::c_void,
669    ) -> ::libc::c_int;
670}
671pub mod s2n_mode {
672    #[doc = " Used to declare connections as server or client type, respectively."]
673    pub type Type = ::libc::c_uint;
674    pub const SERVER: Type = 0;
675    pub const CLIENT: Type = 1;
676}
677extern "C" {
678    #[doc = " Creates a new connection object. Each s2n-tls SSL/TLS connection uses\n one of these objects. These connection objects can be operated on by up\n to two threads at a time, one sender and one receiver, but neither sending\n nor receiving are atomic, so if these objects are being called by multiple\n sender or receiver threads, you must perform your own locking to ensure\n that only one sender or receiver is active at a time.\n\n The `mode` parameters specifies if the caller is a server, or is a client.\n Connections objects are re-usable across many connections, and should be\n re-used (to avoid deallocating and allocating memory). You should wipe\n connections immediately after use.\n\n @param mode The desired connection type\n @returns A s2n_connection handle"]
679    pub fn s2n_connection_new(mode: s2n_mode::Type) -> *mut s2n_connection;
680}
681extern "C" {
682    #[doc = " Associates a configuration object with a connection.\n\n @param conn The connection object being associated\n @param config The configuration object being associated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
683    pub fn s2n_connection_set_config(
684        conn: *mut s2n_connection,
685        config: *mut s2n_config,
686    ) -> ::libc::c_int;
687}
688extern "C" {
689    #[doc = " Sets user defined context in `s2n_connection` object.\n\n @param conn The connection object being updated\n @param ctx A pointer to the user defined context\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
690    pub fn s2n_connection_set_ctx(
691        conn: *mut s2n_connection,
692        ctx: *mut ::libc::c_void,
693    ) -> ::libc::c_int;
694}
695extern "C" {
696    #[doc = " Gets user defined context from a `s2n_connection` object.\n\n @param conn The connection object that contains the desired context"]
697    pub fn s2n_connection_get_ctx(conn: *mut s2n_connection) -> *mut ::libc::c_void;
698}
699#[doc = " The callback function takes a s2n-tls connection as input, which receives the ClientHello\n and the context previously provided in `s2n_config_set_client_hello_cb`. The callback can\n access any ClientHello information from the connection and use the `s2n_connection_set_config`\n call to change the config of the connection."]
700pub type s2n_client_hello_fn = ::core::option::Option<
701    unsafe extern "C" fn(conn: *mut s2n_connection, ctx: *mut ::libc::c_void) -> ::libc::c_int,
702>;
703pub mod s2n_client_hello_cb_mode {
704    #[doc = " Client Hello callback modes\n - `S2N_CLIENT_HELLO_CB_BLOCKING` (default):\n   - In this mode s2n-tls expects the callback to complete its work and return the appropriate response code before the handshake continues. If any of the connection properties were changed based on the server_name extension the callback must either return a value greater than 0 or invoke `s2n_connection_server_name_extension_used`, otherwise the callback returns 0 to continue the handshake.\n - `S2N_CLIENT_HELLO_CB_NONBLOCKING`:\n   - In non-blocking mode, s2n-tls expects the callback to not complete its work. If the callback returns a response code of 0, s2n-tls will return `S2N_FAILURE` with `S2N_ERR_T_BLOCKED` error type and `s2n_blocked_status` set to `S2N_BLOCKED_ON_APPLICATION_INPUT`. The handshake is paused and further calls to `s2n_negotiate` will continue to return the same error until `s2n_client_hello_cb_done` is invoked for the `s2n_connection` to resume the handshake. If any of the connection properties were changed on the basis of the server_name extension then `s2n_connection_server_name_extension_used` must be invoked before marking the callback done."]
705    pub type Type = ::libc::c_uint;
706    pub const BLOCKING: Type = 0;
707    pub const NONBLOCKING: Type = 1;
708}
709extern "C" {
710    #[doc = " Allows the caller to set a callback function that will be called after ClientHello was parsed.\n\n @param config The configuration object being updated\n @param client_hello_callback The client hello callback function\n @param ctx A pointer to a user defined context that the Client Hello callback will be invoked with.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
711    pub fn s2n_config_set_client_hello_cb(
712        config: *mut s2n_config,
713        client_hello_callback: s2n_client_hello_fn,
714        ctx: *mut ::libc::c_void,
715    ) -> ::libc::c_int;
716}
717extern "C" {
718    #[doc = " Sets the callback execution mode.\n\n See s2n_client_hello_cb_mode for each mode's behavior.\n\n @param config The configuration object being updated\n @param cb_mode The desired callback mode\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
719    pub fn s2n_config_set_client_hello_cb_mode(
720        config: *mut s2n_config,
721        cb_mode: s2n_client_hello_cb_mode::Type,
722    ) -> ::libc::c_int;
723}
724extern "C" {
725    #[doc = " Marks the non-blocking callback as complete. Can be invoked from within the callback when\n operating in non-blocking mode to continue the handshake.\n\n @param conn The connection object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
726    pub fn s2n_client_hello_cb_done(conn: *mut s2n_connection) -> ::libc::c_int;
727}
728extern "C" {
729    #[doc = " Must be invoked if any of the connection properties were changed on the basis of the server_name\n extension. This must be invoked before marking the Client Hello callback done.\n\n @param conn The connection object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
730    pub fn s2n_connection_server_name_extension_used(conn: *mut s2n_connection) -> ::libc::c_int;
731}
732#[doc = " Opaque client hello handle"]
733#[repr(C)]
734#[derive(Debug, Copy, Clone)]
735pub struct s2n_client_hello {
736    _unused: [u8; 0],
737}
738extern "C" {
739    #[doc = " Get the Client Hello from a s2n_connection.\n\n Earliest point during the handshake when this structure is available for use is in the\n client_hello_callback (see s2n_config_set_client_hello_cb()).\n\n @param conn The connection object containing the client hello\n @returns A handle to the s2n_client_hello structure holding the client hello message sent by the client during the handshake. NULL is returned if a Client Hello has not yet been received and parsed."]
740    pub fn s2n_connection_get_client_hello(conn: *mut s2n_connection) -> *mut s2n_client_hello;
741}
742extern "C" {
743    #[doc = " Creates an s2n_client_hello from bytes representing a ClientHello message.\n\n The input bytes should include the message header (message type and length),\n but not the record header.\n\n Unlike s2n_connection_get_client_hello, the s2n_client_hello returned by this\n method is owned by the application and must be freed with s2n_client_hello_free.\n\n This method does not support SSLv2 ClientHellos.\n\n @param bytes The raw bytes representing the ClientHello.\n @param size The size of raw_message.\n @returns A new s2n_client_hello on success, or NULL on failure."]
744    pub fn s2n_client_hello_parse_message(bytes: *const u8, size: u32) -> *mut s2n_client_hello;
745}
746extern "C" {
747    #[doc = " Frees an s2n_client_hello structure.\n\n This method should be called to free s2n_client_hellos returned by\n s2n_client_hello_parse_message. It will error if passed an s2n_client_hello\n returned by s2n_connection_get_client_hello and owned by the connection.\n\n @param ch The structure to be freed.\n @returns S2N_SUCCESS on success, S2N_FAILURE on failure."]
748    pub fn s2n_client_hello_free(ch: *mut *mut s2n_client_hello) -> ::libc::c_int;
749}
750extern "C" {
751    #[doc = " Function to determine the size of the raw Client Hello buffer.\n\n Can be used to determine the necessary size of the `out` buffer for\n s2n_client_hello_get_raw_message()\n\n @param ch The Client Hello handle\n @returns The size of the ClientHello message received by the server"]
752    pub fn s2n_client_hello_get_raw_message_length(ch: *mut s2n_client_hello) -> isize;
753}
754extern "C" {
755    #[doc = " Copies `max_length` bytes of the ClientHello message into the `out` buffer.\n The ClientHello instrumented using this function will have the Random bytes\n zero-ed out.\n\n Note: SSLv2 ClientHello messages follow a different structure than more modern\n ClientHello messages. See [RFC5246](https://tools.ietf.org/html/rfc5246#appendix-E.2).\n In addition, due to how s2n-tls parses SSLv2 ClientHellos, the raw message is\n missing the first three bytes (the msg_type and version) and instead begins with\n the cipher_specs. To determine whether a ClientHello is an SSLv2 ClientHello,\n you will need to use s2n_connection_get_client_hello_version(). To get the\n protocol version advertised in the SSLv2 ClientHello (which may be higher\n than SSLv2), you will need to use s2n_connection_get_client_protocol_version().\n\n @param ch The Client Hello handle\n @param out The destination buffer for the raw Client Hello\n @param max_length The size of out in bytes\n @returns The number of copied bytes"]
756    pub fn s2n_client_hello_get_raw_message(
757        ch: *mut s2n_client_hello,
758        out: *mut u8,
759        max_length: u32,
760    ) -> isize;
761}
762extern "C" {
763    #[doc = " Function to determine the size of the Client Hello cipher suites.\n This can be used to allocate the `out` buffer for s2n_client_hello_get_cipher_suites().\n\n @param ch The Client Hello handle\n @returns the number of bytes the cipher_suites takes on the ClientHello message received by the server"]
764    pub fn s2n_client_hello_get_cipher_suites_length(ch: *mut s2n_client_hello) -> isize;
765}
766extern "C" {
767    #[doc = " Copies into the `out` buffer `max_length` bytes of the cipher_suites on the ClientHello.\n\n Note: SSLv2 ClientHello cipher suites follow a different structure than modern\n ClientHello messages. See [RFC5246](https://tools.ietf.org/html/rfc5246#appendix-E.2).\n To determine whether a ClientHello is an SSLv2 ClientHello,\n you will need to use s2n_connection_get_client_hello_version().\n\n @param ch The Client Hello handle\n @param out The destination buffer for the raw Client Hello cipher suites\n @param max_length The size of out in bytes\n @returns The number of copied bytes"]
768    pub fn s2n_client_hello_get_cipher_suites(
769        ch: *mut s2n_client_hello,
770        out: *mut u8,
771        max_length: u32,
772    ) -> isize;
773}
774extern "C" {
775    #[doc = " Function to determine the size of the Client Hello extensions.\n This can be used to allocate the `out` buffer for s2n_client_hello_get_extensions().\n\n @param ch The Client Hello handle\n @returns the number of bytes the extensions take in the ClientHello message received by the server"]
776    pub fn s2n_client_hello_get_extensions_length(ch: *mut s2n_client_hello) -> isize;
777}
778extern "C" {
779    #[doc = " Copies into the `out` buffer `max_length` bytes of the extensions in the ClientHello.\n\n @param ch The Client Hello handle\n @param out The destination buffer for the raw Client Hello extensions\n @param max_length The size of out in bytes\n @returns The number of copied bytes"]
780    pub fn s2n_client_hello_get_extensions(
781        ch: *mut s2n_client_hello,
782        out: *mut u8,
783        max_length: u32,
784    ) -> isize;
785}
786extern "C" {
787    #[doc = " Query the ClientHello message received by the server. Use this function to allocate the `out` buffer for\n other client hello extension functions.\n\n @param ch A pointer to the Client Hello\n @param extension_type Indicates the desired extension\n @returns The number of bytes the given extension type takes"]
788    pub fn s2n_client_hello_get_extension_length(
789        ch: *mut s2n_client_hello,
790        extension_type: s2n_tls_extension_type::Type,
791    ) -> isize;
792}
793extern "C" {
794    #[doc = " Copies into the `out` buffer `max_length` bytes of a given extension type on the ClientHello\n\n `ch` is a pointer to the `s2n_client_hello` of the `s2n_connection` which can be obtained using s2n_connection_get_client_hello().\n\n @param ch A pointer to the Client Hello\n @param extension_type Indicates the desired extension\n @param out A pointer to the buffer that s2n will write the client session id to. This buffer MUST be the size of `max_length`\n @param max_length The size of `out`.\n @returns The number of copied bytes"]
795    pub fn s2n_client_hello_get_extension_by_id(
796        ch: *mut s2n_client_hello,
797        extension_type: s2n_tls_extension_type::Type,
798        out: *mut u8,
799        max_length: u32,
800    ) -> isize;
801}
802extern "C" {
803    #[doc = " Used to check if a particular extension exists in the client hello.\n\n `ch` is a pointer to the `s2n_client_hello` of the `s2n_connection` which can be obtained using s2n_connection_get_client_hello().\n\n @param ch A pointer to the client hello object\n @param extension_iana The iana value of the extension\n @param exists A pointer that will be set to whether or not the extension exists"]
804    pub fn s2n_client_hello_has_extension(
805        ch: *mut s2n_client_hello,
806        extension_iana: u16,
807        exists: *mut bool,
808    ) -> ::libc::c_int;
809}
810extern "C" {
811    #[doc = " Get the the ClientHello session id length in bytes\n\n `ch` is a pointer to the `s2n_client_hello` of the `s2n_connection` which can be obtained using s2n_connection_get_client_hello().\n\n @param ch A pointer to the Client Hello\n @param out_length An out pointer. s2n will set it's value to the size of the session_id in bytes.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
812    pub fn s2n_client_hello_get_session_id_length(
813        ch: *mut s2n_client_hello,
814        out_length: *mut u32,
815    ) -> ::libc::c_int;
816}
817extern "C" {
818    #[doc = " Copies up to `max_length` bytes of the ClientHello session_id into the `out` buffer and stores the number of copied bytes in `out_length`.\n\n Retrieve the session id as sent by the client in the ClientHello message. The session id on the `s2n_connection` may change later\n when the server sends the ServerHello; see `s2n_connection_get_session_id` for how to get the final session id used for future session resumption.\n\n Use s2n_client_hello_get_session_id_length() to get the the ClientHello session id length in bytes. `ch` is a pointer to the `s2n_client_hello`\n of the `s2n_connection` which can be obtained using s2n_connection_get_client_hello().\n\n @param ch A pointer to the Client Hello\n @param out A pointer to the buffer that s2n will write the client session id to. This buffer MUST be the size of `max_length`\n @param out_length An out pointer. s2n will set it's value to the size of the session_id in bytes.\n @param max_length The size of `out`.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
819    pub fn s2n_client_hello_get_session_id(
820        ch: *mut s2n_client_hello,
821        out: *mut u8,
822        out_length: *mut u32,
823        max_length: u32,
824    ) -> ::libc::c_int;
825}
826extern "C" {
827    #[doc = " Get the length of the compression methods list sent in the Client Hello.\n\n @param ch A pointer to the Client Hello\n @param out_length An out pointer. Will be set to the length of the compression methods list in bytes.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
828    pub fn s2n_client_hello_get_compression_methods_length(
829        ch: *mut s2n_client_hello,
830        out_length: *mut u32,
831    ) -> ::libc::c_int;
832}
833extern "C" {
834    #[doc = " Retrieves the list of compression methods sent in the Client Hello.\n\n Use `s2n_client_hello_get_compression_methods_length()`\n to retrieve how much memory should be allocated for the buffer in advance.\n\n @note Compression methods were removed in TLS1.3 and therefore the only valid value in this list is the\n \"null\" compression method when TLS1.3 is negotiated.\n\n @note s2n-tls has never supported compression methods in any TLS version and therefore a\n compression method will never be negotiated or used.\n\n @param ch A pointer to the Client Hello\n @param list A pointer to some memory that s2n will write the compression methods to. This memory MUST be the size of `list_length`\n @param list_length The size of `list`.\n @param out_length An out pointer. s2n will set its value to the size of the compression methods list in bytes.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
835    pub fn s2n_client_hello_get_compression_methods(
836        ch: *mut s2n_client_hello,
837        list: *mut u8,
838        list_length: u32,
839        out_length: *mut u32,
840    ) -> ::libc::c_int;
841}
842extern "C" {
843    #[doc = " Access the Client Hello protocol version\n\n @note This field is a legacy field in TLS1.3 and is no longer used to negotiate the\n protocol version of the connection. It will be set to TLS1.2 even if TLS1.3 is negotiated.\n Therefore this method should only be used for logging or fingerprinting.\n\n @param ch A pointer to the client hello struct\n @param out The protocol version in the client hello."]
844    pub fn s2n_client_hello_get_legacy_protocol_version(
845        ch: *mut s2n_client_hello,
846        out: *mut u8,
847    ) -> ::libc::c_int;
848}
849extern "C" {
850    #[doc = " Retrieves the supported groups received from the client in the supported groups extension.\n\n IANA values for each of the received supported groups are written to the provided `groups`\n array, and `groups_count` is set to the number of received supported groups.\n\n `groups_count_max` should be set to the maximum capacity of the `groups` array. If\n `groups_count_max` is less than the number of received supported groups, this function will\n error. To determine how large `groups` should be in advance, use\n `s2n_client_hello_get_extension_length()` with the S2N_EXTENSION_SUPPORTED_GROUPS extension\n type, and divide the value by 2.\n\n If no supported groups extension was received from the peer, or the received supported groups\n extension is malformed, this function will error.\n\n @param ch A pointer to the ClientHello. Can be retrieved from a connection via\n `s2n_connection_get_client_hello()`.\n @param groups The array to populate with the received supported groups.\n @param groups_count_max The maximum number of supported groups that can fit in the `groups` array.\n @param groups_count Returns the number of received supported groups.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
851    pub fn s2n_client_hello_get_supported_groups(
852        ch: *mut s2n_client_hello,
853        groups: *mut u16,
854        groups_count_max: u16,
855        groups_count: *mut u16,
856    ) -> ::libc::c_int;
857}
858extern "C" {
859    #[doc = " Gets the length of the first server name in a Client Hello.\n\n @param ch A pointer to the ClientHello\n @param length A pointer which will be populated with the length of the server name"]
860    pub fn s2n_client_hello_get_server_name_length(
861        ch: *mut s2n_client_hello,
862        length: *mut u16,
863    ) -> ::libc::c_int;
864}
865extern "C" {
866    #[doc = " Gets the first server name in a Client Hello.\n\n Use `s2n_client_hello_get_server_name_length()` to get the amount of memory needed for the buffer.\n\n @param ch A pointer to the ClientHello\n @param server_name A pointer to the memory which will be populated with the server name\n @param length The maximum amount of data that can be written to `server_name`\n @param out_length A pointer which will be populated with the size of the server name"]
867    pub fn s2n_client_hello_get_server_name(
868        ch: *mut s2n_client_hello,
869        server_name: *mut u8,
870        length: u16,
871        out_length: *mut u16,
872    ) -> ::libc::c_int;
873}
874extern "C" {
875    #[doc = " Sets the file descriptor for a s2n connection.\n\n @warning If the read end of the pipe is closed unexpectedly, writing to the pipe will raise a SIGPIPE signal.\n **s2n-tls does NOT handle SIGPIPE.** A SIGPIPE signal will cause the process to terminate unless it is handled\n or ignored by the application.\n @note This file-descriptor should be active and connected\n @param conn A pointer to the s2n connection\n @param fd The new file descriptor\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
876    pub fn s2n_connection_set_fd(conn: *mut s2n_connection, fd: ::libc::c_int) -> ::libc::c_int;
877}
878extern "C" {
879    #[doc = " Sets the file descriptor for the read channel of an s2n connection.\n\n @warning If the read end of the pipe is closed unexpectedly, writing to the pipe will raise a SIGPIPE signal.\n **s2n-tls does NOT handle SIGPIPE.** A SIGPIPE signal will cause the process to terminate unless it is handled\n or ignored by the application.\n @note This file-descriptor should be active and connected\n @param conn A pointer to the s2n connection\n @param readfd The new read file descriptor\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
880    pub fn s2n_connection_set_read_fd(
881        conn: *mut s2n_connection,
882        readfd: ::libc::c_int,
883    ) -> ::libc::c_int;
884}
885extern "C" {
886    #[doc = " Sets the assigned file descriptor for the write channel of an s2n connection.\n\n @note This file-descriptor should be active and connected\n @param conn A pointer to the s2n connection\n @param writefd The new write file descriptor\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
887    pub fn s2n_connection_set_write_fd(
888        conn: *mut s2n_connection,
889        writefd: ::libc::c_int,
890    ) -> ::libc::c_int;
891}
892extern "C" {
893    #[doc = " Gets the assigned file descriptor for the read channel of an s2n connection.\n\n @param conn A pointer to the s2n connection\n @param readfd pointer to place the used file descriptor.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
894    pub fn s2n_connection_get_read_fd(
895        conn: *mut s2n_connection,
896        readfd: *mut ::libc::c_int,
897    ) -> ::libc::c_int;
898}
899extern "C" {
900    #[doc = " Gets the assigned file descriptor for the write channel of an s2n connection.\n\n @param conn A pointer to the s2n connection\n @param writefd pointer to place the used file descriptor.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
901    pub fn s2n_connection_get_write_fd(
902        conn: *mut s2n_connection,
903        writefd: *mut ::libc::c_int,
904    ) -> ::libc::c_int;
905}
906extern "C" {
907    #[doc = " Indicates to s2n that the connection is using corked IO.\n\n @warning This API should only be used when using managed send IO.\n\n @param conn The connection object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
908    pub fn s2n_connection_use_corked_io(conn: *mut s2n_connection) -> ::libc::c_int;
909}
910#[doc = " Function pointer for a user provided recv callback."]
911pub type s2n_recv_fn = ::core::option::Option<
912    unsafe extern "C" fn(io_context: *mut ::libc::c_void, buf: *mut u8, len: u32) -> ::libc::c_int,
913>;
914#[doc = " Function pointer for a user provided send callback."]
915pub type s2n_send_fn = ::core::option::Option<
916    unsafe extern "C" fn(
917        io_context: *mut ::libc::c_void,
918        buf: *const u8,
919        len: u32,
920    ) -> ::libc::c_int,
921>;
922extern "C" {
923    #[doc = " Set a context containing anything needed in the recv callback function (for example,\n a file descriptor), the buffer holding data to be sent or received, and the length of the buffer.\n\n @note The `io_context` passed to the callbacks may be set separately using `s2n_connection_set_recv_ctx` and `s2n_connection_set_send_ctx`.\n\n @param conn The connection object being updated\n @param ctx A user provided context that the callback will be invoked with\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
924    pub fn s2n_connection_set_recv_ctx(
925        conn: *mut s2n_connection,
926        ctx: *mut ::libc::c_void,
927    ) -> ::libc::c_int;
928}
929extern "C" {
930    #[doc = " Set a context containing anything needed in the send callback function (for example,\n a file descriptor), the buffer holding data to be sent or received, and the length of the buffer.\n\n @note The `io_context` passed to the callbacks may be set separately using `s2n_connection_set_recv_ctx` and `s2n_connection_set_send_ctx`.\n\n @param conn The connection object being updated\n @param ctx A user provided context that the callback will be invoked with\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
931    pub fn s2n_connection_set_send_ctx(
932        conn: *mut s2n_connection,
933        ctx: *mut ::libc::c_void,
934    ) -> ::libc::c_int;
935}
936extern "C" {
937    #[doc = " Configure a connection to use a recv callback to receive data.\n\n @note This callback may be blocking or nonblocking.\n @note The callback may receive less than the requested length. The function should return the number\n of bytes received, or set errno and return an error code < 0.\n\n @param conn The connection object being updated\n @param recv A recv callback function pointer\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
938    pub fn s2n_connection_set_recv_cb(
939        conn: *mut s2n_connection,
940        recv: s2n_recv_fn,
941    ) -> ::libc::c_int;
942}
943extern "C" {
944    #[doc = " Configure a connection to use a send callback to send data.\n\n @note This callback may be blocking or nonblocking.\n @note The callback may send less than the requested length. The function should return the\n number of bytes sent or set errno and return an error code < 0.\n\n @param conn The connection object being updated\n @param send A send callback function pointer\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
945    pub fn s2n_connection_set_send_cb(
946        conn: *mut s2n_connection,
947        send: s2n_send_fn,
948    ) -> ::libc::c_int;
949}
950extern "C" {
951    #[doc = " Change the behavior of s2n-tls when sending data to prefer high throughput.\n\n Connections preferring throughput will use\n large record sizes that minimize overhead.\n\n @param conn The connection object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
952    pub fn s2n_connection_prefer_throughput(conn: *mut s2n_connection) -> ::libc::c_int;
953}
954extern "C" {
955    #[doc = " Change the behavior of s2n-tls when sending data to prefer low latency.\n\n Connections preferring low latency will be encrypted\n using small record sizes that can be decrypted sooner by the recipient.\n\n @param conn The connection object being updated\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
956    pub fn s2n_connection_prefer_low_latency(conn: *mut s2n_connection) -> ::libc::c_int;
957}
958extern "C" {
959    #[doc = " Configure the connection to reduce potentially expensive calls to recv.\n\n If this setting is disabled, s2n-tls will call read twice for every TLS record,\n which can be expensive but ensures that s2n-tls will always attempt to read the\n exact number of bytes it requires. If this setting is enabled, s2n-tls will\n instead reduce the number of calls to read by attempting to read as much data\n as possible in each read call, storing the extra in the existing IO buffers.\n This may cause it to request more data than will ever actually be available.\n\n There is no additional memory cost of enabling this setting. It reuses the\n existing IO buffers.\n\n This setting is disabled by default. Depending on how your application detects\n data available for reading, buffering reads may break your event loop.\n In particular, note that:\n\n 1. File descriptor reads or calls to your custom s2n_recv_cb may request more\n    data than is available. Reads must return partial data when available rather\n    than blocking until all requested data is available.\n\n 2. s2n_negotiate may read and buffer application data records.\n    You must call s2n_recv at least once after negotiation to ensure that you\n    handle any buffered data.\n\n 3. s2n_recv may read and buffer more records than it parses and decrypts.\n    You must call s2n_recv until it reports S2N_ERR_T_BLOCKED, rather than just\n    until it reports S2N_SUCCESS.\n\n 4. s2n_peek reports available decrypted data. It does not report any data\n    buffered by this feature. However, s2n_peek_buffered does report data\n    buffered by this feature.\n\n 5. s2n_connection_release_buffers will not release the input buffer if it\n    contains buffered data.\n\n For example: if your event loop uses `poll`, you will receive a POLLIN event\n for your read file descriptor when new data is available. When you call s2n_recv\n to read that data, s2n-tls reads one or more TLS records from the file descriptor.\n If you stop calling s2n_recv before it reports S2N_ERR_T_BLOCKED, some of those\n records may remain in s2n-tls's read buffer. If you read part of a record,\n s2n_peek will report the remainder of that record as available. But if you don't\n read any of a record, it remains encrypted and is not reported by s2n_peek, but\n is still reported by s2n_peek_buffered. And because the data is buffered in s2n-tls\n instead of in the file descriptor, another call to `poll` will NOT report any\n more data available. Your application may hang waiting for more data.\n\n @warning This feature cannot be enabled for a connection that will enable kTLS for receiving.\n\n @warning This feature may work with blocking IO, if used carefully. Your blocking\n IO must support partial reads (so MSG_WAITALL cannot be used). You will either\n need to know exactly how much data your peer is sending, or will need to use\n `s2n_peek` and `s2n_peek_buffered` rather than relying on S2N_ERR_T_BLOCKED\n as noted in #3 above.\n\n @param conn The connection object being updated\n @param enabled Set to `true` to enable, `false` to disable.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
960    pub fn s2n_connection_set_recv_buffering(
961        conn: *mut s2n_connection,
962        enabled: bool,
963    ) -> ::libc::c_int;
964}
965extern "C" {
966    #[doc = " Reports how many bytes of unprocessed TLS records are buffered due to the optimization\n enabled by `s2n_connection_set_recv_buffering`.\n\n `s2n_peek_buffered` is not a replacement for `s2n_peek`.\n While `s2n_peek` reports application data that is ready for the application\n to read with no additional processing, `s2n_peek_buffered` reports raw TLS\n records that still need to be parsed and likely decrypted. Those records may\n contain application data, but they may also only contain TLS control messages.\n\n If an application needs to determine whether there is any data left to handle\n (for example, before calling `poll` to wait on the read file descriptor) then\n that application must check both `s2n_peek` and `s2n_peek_buffered`.\n\n @param conn A pointer to the s2n_connection object\n @returns The number of buffered encrypted bytes"]
967    pub fn s2n_peek_buffered(conn: *mut s2n_connection) -> u32;
968}
969extern "C" {
970    #[doc = " Configure the connection to free IO buffers when they are not currently in use.\n\n This configuration can be used to minimize connection memory footprint size, at the cost\n of more calls to alloc and free. Some of these costs can be mitigated by configuring s2n-tls\n to use an allocator that includes thread-local caches or lock-free allocation patterns.\n\n @param conn The connection object being update\n @param enabled Set to `true` if dynamic buffers are enabled; `false` if disabled\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
971    pub fn s2n_connection_set_dynamic_buffers(
972        conn: *mut s2n_connection,
973        enabled: bool,
974    ) -> ::libc::c_int;
975}
976extern "C" {
977    #[doc = " Changes the behavior of s2n-tls when sending data to initially prefer records\n small enough to fit in single ethernet frames.\n\n When dynamic record sizing is active, the connection sends records small enough\n to fit in a single standard 1500 byte ethernet frame. Otherwise, the connection\n chooses record sizes according to the configured maximum fragment length.\n\n Dynamic record sizing is active for the first resize_threshold bytes of a connection,\n and is reactivated whenever timeout_threshold seconds pass without sending data.\n\n @param conn The connection object being updated\n @param resize_threshold The number of bytes to send before changing the record size. Maximum 8MiB.\n @param timeout_threshold Reset record size back to a single segment after threshold seconds of inactivity\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
978    pub fn s2n_connection_set_dynamic_record_threshold(
979        conn: *mut s2n_connection,
980        resize_threshold: u32,
981        timeout_threshold: u16,
982    ) -> ::libc::c_int;
983}
984extern "C" {
985    #[doc = " Sets the callback to use for verifying that a hostname from an X.509 certificate is trusted.\n\n The default behavior is to require that the hostname match the server name set with s2n_set_server_name(). This will\n likely lead to all client certificates being rejected, so the callback will need to be overriden when using client authentication.\n\n If a single callback for different connections using the same config is desired, see s2n_config_set_verify_host_callback().\n\n @param conn A pointer to a s2n_connection object\n @param host_fn A pointer to a callback function that s2n will invoke in order to verify the hostname of an X.509 certificate\n @param data Opaque pointer to data that the verify host function will be invoked with\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
986    pub fn s2n_connection_set_verify_host_callback(
987        conn: *mut s2n_connection,
988        host_fn: s2n_verify_host_fn,
989        data: *mut ::libc::c_void,
990    ) -> ::libc::c_int;
991}
992pub mod s2n_blinding {
993    #[doc = " Used to opt-out of s2n-tls's built-in blinding. Blinding is a\n mitigation against timing side-channels which in some cases can leak information\n about encrypted data. By default s2n-tls will cause a thread to sleep between 10 and\n 30 seconds whenever tampering is detected.\n\n Setting the S2N_SELF_SERVICE_BLINDING option with s2n_connection_set_blinding()\n turns off this behavior. This is useful for applications that are handling many connections\n in a single thread. In that case, if s2n_recv() or s2n_negotiate() return an error,\n self-service applications should call s2n_connection_get_delay() and pause\n activity on the connection  for the specified number of nanoseconds before calling\n close() or shutdown()."]
994    pub type Type = ::libc::c_uint;
995    pub const BUILT_IN_BLINDING: Type = 0;
996    pub const SELF_SERVICE_BLINDING: Type = 1;
997}
998extern "C" {
999    #[doc = " Used to configure s2n-tls to either use built-in blinding (set blinding to S2N_BUILT_IN_BLINDING) or\n self-service blinding (set blinding to S2N_SELF_SERVICE_BLINDING).\n\n @param conn The connection object being updated\n @param blinding The desired blinding mode for the connection\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1000    pub fn s2n_connection_set_blinding(
1001        conn: *mut s2n_connection,
1002        blinding: s2n_blinding::Type,
1003    ) -> ::libc::c_int;
1004}
1005extern "C" {
1006    #[doc = " Query the connection object for the configured blinding delay.\n @param conn The connection object being updated\n @returns the number of nanoseconds an application using self-service blinding should pause before calling close() or shutdown()."]
1007    pub fn s2n_connection_get_delay(conn: *mut s2n_connection) -> u64;
1008}
1009extern "C" {
1010    #[doc = " Configures the maximum blinding delay enforced after errors.\n\n Blinding protects your application from timing side channel attacks like Lucky13. While s2n-tls\n implements other, more specific mitigations for known timing side channels, blinding is important\n as a defense against currently unknown or unreported timing attacks.\n\n Setting a maximum delay lower than the recommended default (30s) will make timing attacks against\n your application easier. The lower you set the delay, the fewer requests and less total time an\n attacker will require to execute an attack. If you must lower the delay for reasons such as client\n timeouts, then you should choose the highest value practically possible to limit your risk.\n\n If you lower the blinding delay, you should also consider implementing monitoring and filtering\n to detect and reject suspicious traffic that could be gathering timing information from a potential\n side channel. Timing attacks usually involve repeatedly triggering TLS errors.\n\n @warning Do NOT set a lower blinding delay unless you understand the risks and have other\n mitigations for timing side channels in place.\n\n @note This delay needs to be set lower than any timeouts, such as your TCP socket timeout.\n\n @param config The config object being updated.\n @param seconds The maximum number of seconds that s2n-tls will delay for in the event of a\n sensitive error.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
1011    pub fn s2n_config_set_max_blinding_delay(
1012        config: *mut s2n_config,
1013        seconds: u32,
1014    ) -> ::libc::c_int;
1015}
1016extern "C" {
1017    #[doc = " Sets the cipher preference override for the s2n_connection. Calling this function is not necessary\n unless you want to set the cipher preferences on the connection to something different than what is in the s2n_config.\n\n @param conn The connection object being updated\n @param version The human readable string representation of the security policy version.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1018    pub fn s2n_connection_set_cipher_preferences(
1019        conn: *mut s2n_connection,
1020        version: *const ::libc::c_char,
1021    ) -> ::libc::c_int;
1022}
1023pub mod s2n_peer_key_update {
1024    #[doc = " Used to indicate the type of key update that is being requested. For further\n information refer to `s2n_connection_request_key_update`."]
1025    pub type Type = ::libc::c_uint;
1026    pub const KEY_UPDATE_NOT_REQUESTED: Type = 0;
1027    pub const KEY_UPDATE_REQUESTED: Type = 1;
1028}
1029extern "C" {
1030    #[doc = " Signals the connection to do a key_update at the next possible opportunity. Note that the resulting key update message\n will not be sent until `s2n_send` is called.\n\n @param conn The connection object to trigger the key update on.\n @param peer_request Indicates if a key update should also be requested\n of the peer. When set to `S2N_KEY_UPDATE_NOT_REQUESTED`, then only the sending\n key of `conn` will be updated. If set to `S2N_KEY_UPDATE_REQUESTED`, then\n the sending key of conn will be updated AND the peer will be requested to\n update their sending key. Note that s2n-tls currently only supports\n `peer_request` being set to `S2N_KEY_UPDATE_NOT_REQUESTED` and will return\n  S2N_FAILURE if any other value is used.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1031    pub fn s2n_connection_request_key_update(
1032        conn: *mut s2n_connection,
1033        peer_request: s2n_peer_key_update::Type,
1034    ) -> ::libc::c_int;
1035}
1036extern "C" {
1037    #[doc = " Appends the provided application protocol to the preference list\n\n The data provided in `protocol` parameter will be copied into an internal buffer\n\n @param conn The connection object being updated\n @param protocol A pointer to a slice of bytes\n @param protocol_len The length of bytes that should be read from `protocol`. Note: this value cannot be 0, otherwise an error will be returned.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1038    pub fn s2n_connection_append_protocol_preference(
1039        conn: *mut s2n_connection,
1040        protocol: *const u8,
1041        protocol_len: u8,
1042    ) -> ::libc::c_int;
1043}
1044extern "C" {
1045    #[doc = " Sets the protocol preference override for the s2n_connection. Calling this function is not necessary unless you want\n to set the protocol preferences on the connection to something different than what is in the s2n_config.\n\n @param conn The connection object being updated\n @param protocols A pointer to an array of protocol strings\n @param protocol_count The number of protocols contained in protocols\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1046    pub fn s2n_connection_set_protocol_preferences(
1047        conn: *mut s2n_connection,
1048        protocols: *const *const ::libc::c_char,
1049        protocol_count: ::libc::c_int,
1050    ) -> ::libc::c_int;
1051}
1052extern "C" {
1053    #[doc = " Sets the server name for the connection.\n\n The provided server name will be sent by the client to the server in the\n server_name ClientHello extension. It may be desirable for clients\n to provide this information to facilitate secure connections to\n servers that host multiple 'virtual' servers at a single underlying\n network address.\n\n s2n-tls does not place any restrictions on the provided server name. However,\n other TLS implementations might. Specifically, the TLS specification for the\n server_name extension requires that it be an ASCII-encoded DNS name without a\n trailing dot, and explicitly forbids literal IPv4 or IPv6 addresses.\n\n @param conn The connection object being queried\n @param server_name A pointer to a string containing the desired server name\n @warning `server_name` must be a NULL terminated string.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1054    pub fn s2n_set_server_name(
1055        conn: *mut s2n_connection,
1056        server_name: *const ::libc::c_char,
1057    ) -> ::libc::c_int;
1058}
1059extern "C" {
1060    #[doc = " Query the connection for the selected server name.\n\n This can be used by a server to determine which server name the client is using. This function returns the first ServerName entry\n in the ServerNameList sent by the client. Subsequent entries are not returned.\n\n @param conn The connection object being queried\n @returns The server name associated with a connection, or NULL if none is found."]
1061    pub fn s2n_get_server_name(conn: *mut s2n_connection) -> *const ::libc::c_char;
1062}
1063extern "C" {
1064    #[doc = " Query the connection for the selected application protocol.\n\n @param conn The connection object being queried\n @returns The negotiated application protocol for a `s2n_connection`.  In the event of no protocol being negotiated, NULL is returned."]
1065    pub fn s2n_get_application_protocol(conn: *mut s2n_connection) -> *const ::libc::c_char;
1066}
1067extern "C" {
1068    #[doc = " Query the connection for a buffer containing the OCSP response.\n\n @param conn The connection object being queried\n @param length A pointer that is set to the certificate transparency response buffer's size\n @returns A pointer to the OCSP response sent by a server during the handshake.  If no status response is received, NULL is returned."]
1069    pub fn s2n_connection_get_ocsp_response(
1070        conn: *mut s2n_connection,
1071        length: *mut u32,
1072    ) -> *const u8;
1073}
1074extern "C" {
1075    #[doc = " Query the connection for a buffer containing the Certificate Transparency response.\n\n @param conn The connection object being queried\n @param length A pointer that is set to the certificate transparency response buffer's size\n @returns A pointer to the certificate transparency response buffer."]
1076    pub fn s2n_connection_get_sct_list(conn: *mut s2n_connection, length: *mut u32) -> *const u8;
1077}
1078pub mod s2n_blocked_status {
1079    #[doc = " Used in non-blocking mode to indicate in which direction s2n-tls became blocked on I/O before it\n returned control to the caller. This allows an application to avoid retrying s2n-tls operations\n until I/O is possible in that direction."]
1080    pub type Type = ::libc::c_uint;
1081    pub const NOT_BLOCKED: Type = 0;
1082    pub const BLOCKED_ON_READ: Type = 1;
1083    pub const BLOCKED_ON_WRITE: Type = 2;
1084    pub const BLOCKED_ON_APPLICATION_INPUT: Type = 3;
1085    pub const BLOCKED_ON_EARLY_DATA: Type = 4;
1086}
1087extern "C" {
1088    #[doc = " Performs the initial \"handshake\" phase of a TLS connection and must be called before any s2n_recv() or s2n_send() calls.\n\n @note When using client authentication with TLS1.3, s2n_negotiate() will report a successful\n handshake to clients before the server validates the client certificate. If the server then\n rejects the client certificate, the client may later receive an alert while calling s2n_recv,\n potentially after already having sent application data with s2n_send.\n\n See the following example for guidance on calling `s2n_negotiate()`:\n https://github.com/aws/s2n-tls/blob/main/docs/examples/s2n_negotiate.c\n\n @param conn A pointer to the s2n_connection object\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns S2N_SUCCESS if the handshake completed. S2N_FAILURE if the handshake encountered an error or is blocked."]
1089    pub fn s2n_negotiate(
1090        conn: *mut s2n_connection,
1091        blocked: *mut s2n_blocked_status::Type,
1092    ) -> ::libc::c_int;
1093}
1094extern "C" {
1095    #[doc = " Writes and encrypts `size` of `buf` data to the associated connection. s2n_send() will return the number of bytes\n written, and may indicate a partial write.\n\n @note Partial writes are possible not just for non-blocking I/O, but also for connections aborted while active.\n @note Unlike OpenSSL, repeated calls to s2n_send() should not duplicate the original parameters, but should\n update `buf` and `size` per the indication of size written.\n\n See the following example for guidance on calling `s2n_send()`:\n https://github.com/aws/s2n-tls/blob/main/docs/examples/s2n_send.c\n\n @param conn A pointer to the s2n_connection object\n @param buf A pointer to a buffer that s2n will write data from\n @param size The size of buf\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns The number of bytes written on success, which may indicate a partial write. S2N_FAILURE on failure."]
1096    pub fn s2n_send(
1097        conn: *mut s2n_connection,
1098        buf: *const ::libc::c_void,
1099        size: isize,
1100        blocked: *mut s2n_blocked_status::Type,
1101    ) -> isize;
1102}
1103extern "C" {
1104    #[doc = " Works in the same way as s2n_sendv_with_offset() but with the `offs` parameter implicitly assumed to be 0.\n Therefore in the partial write case, the caller would have to make sure that the `bufs` and `count` fields are modified in a way that takes\n the partial writes into account.\n\n @param conn A pointer to the s2n_connection object\n @param bufs A pointer to a vector of buffers that s2n will write data from.\n @param count The number of buffers in `bufs`\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns The number of bytes written on success, which may indicate a partial write. S2N_FAILURE on failure."]
1105    pub fn s2n_sendv(
1106        conn: *mut s2n_connection,
1107        bufs: *const iovec,
1108        count: isize,
1109        blocked: *mut s2n_blocked_status::Type,
1110    ) -> isize;
1111}
1112extern "C" {
1113    #[doc = " Works in the same way as s2n_send() except that it accepts vectorized buffers. Will return the number of bytes written, and may indicate a partial write. Partial writes are possible not just for non-blocking I/O, but also for connections aborted while active.\n\n @note Partial writes are possible not just for non-blocking I/O, but also for connections aborted while active.\n\n @note Unlike OpenSSL, repeated calls to s2n_sendv_with_offset() should not duplicate the original parameters, but should update `bufs` and `count` per the indication of size written.\n\n See the following example for guidance on calling `s2n_sendv_with_offset()`:\n https://github.com/aws/s2n-tls/blob/main/docs/examples/s2n_send.c\n\n @param conn A pointer to the s2n_connection object\n @param bufs A pointer to a vector of buffers that s2n will write data from.\n @param count The number of buffers in `bufs`\n @param offs The write cursor offset. This should be updated as data is written. See the example code.\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns The number of bytes written on success, which may indicate a partial write. S2N_FAILURE on failure."]
1114    pub fn s2n_sendv_with_offset(
1115        conn: *mut s2n_connection,
1116        bufs: *const iovec,
1117        count: isize,
1118        offs: isize,
1119        blocked: *mut s2n_blocked_status::Type,
1120    ) -> isize;
1121}
1122extern "C" {
1123    #[doc = " Decrypts and reads **size* to `buf` data from the associated\n connection.\n\n @note Unlike OpenSSL, repeated calls to `s2n_recv` should not duplicate the original parameters, but should update `buf` and `size` per the indication of size read.\n\n See the following example for guidance on calling `s2n_recv()`:\n https://github.com/aws/s2n-tls/blob/main/docs/examples/s2n_recv.c\n\n @param conn A pointer to the s2n_connection object\n @param buf A pointer to a buffer that s2n will place read data into.\n @param size Size of `buf`\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns The number of bytes read on success. 0 if the connection was shutdown by the peer. S2N_FAILURE on failure."]
1124    pub fn s2n_recv(
1125        conn: *mut s2n_connection,
1126        buf: *mut ::libc::c_void,
1127        size: isize,
1128        blocked: *mut s2n_blocked_status::Type,
1129    ) -> isize;
1130}
1131extern "C" {
1132    #[doc = " Allows users of s2n-tls to peek inside the data buffer of an s2n-tls connection to see if there more data to be read without actually reading it.\n\n This is useful when using select() on the underlying s2n-tls file descriptor with a message based application layer protocol. As a single call\n to s2n_recv may read all data off the underlying file descriptor, select() will be unable to tell you there if there is more application data\n ready for processing already loaded into the s2n-tls buffer.\n\n @note can then be used to determine if s2n_recv() needs to be called before more data comes in on the raw fd\n @param conn A pointer to the s2n_connection object\n @returns The number of bytes that can be read from the connection"]
1133    pub fn s2n_peek(conn: *mut s2n_connection) -> u32;
1134}
1135extern "C" {
1136    #[doc = " Wipes and releases buffers and memory allocated during the TLS handshake.\n\n @note This function should be called after the handshake is successfully negotiated and logging or recording of handshake data is complete.\n\n @param conn A pointer to the s2n_connection object\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1137    pub fn s2n_connection_free_handshake(conn: *mut s2n_connection) -> ::libc::c_int;
1138}
1139extern "C" {
1140    #[doc = " Wipes and free the `in` and `out` buffers associated with a connection.\n\n @note This function may be called when a connection is\n in keep-alive or idle state to reduce memory overhead of long lived connections.\n\n @param conn A pointer to the s2n_connection object\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1141    pub fn s2n_connection_release_buffers(conn: *mut s2n_connection) -> ::libc::c_int;
1142}
1143extern "C" {
1144    #[doc = " Wipes an existing connection and allows it to be reused. Erases all data associated with a connection including\n pending reads.\n\n @note This function should be called after all I/O is completed and s2n_shutdown has been called.\n @note Reusing the same connection handle(s) is more performant than repeatedly calling s2n_connection_new() and s2n_connection_free().\n\n @param conn A pointer to the s2n_connection object\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1145    pub fn s2n_connection_wipe(conn: *mut s2n_connection) -> ::libc::c_int;
1146}
1147extern "C" {
1148    #[doc = " Frees the memory associated with an s2n_connection\n handle. The handle is considered invalid after `s2n_connection_free` is used.\n s2n_connection_wipe() does not need to be called prior to this function. `s2n_connection_free` performs its own wipe\n of sensitive data.\n\n @param conn A pointer to the s2n_connection object\n @returns 0 on success. -1 on failure"]
1149    pub fn s2n_connection_free(conn: *mut s2n_connection) -> ::libc::c_int;
1150}
1151extern "C" {
1152    #[doc = " Attempts a closure at the TLS layer. Does not close the underlying transport. This call may block in either direction.\n\n Unlike other TLS implementations, `s2n_shutdown` attempts a graceful shutdown by default. It will not return with success unless a close_notify alert is successfully\n sent and received. As a result, `s2n_shutdown` may fail when interacting with a non-conformant TLS implementation.\n\n Once `s2n_shutdown` is complete:\n * The s2n_connection handle cannot be used for reading for writing.\n * The underlying transport can be closed. Most likely via `shutdown()` or `close()`.\n * The s2n_connection handle can be freed via s2n_connection_free() or reused via s2n_connection_wipe()\n\n @param conn A pointer to the s2n_connection object\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1153    pub fn s2n_shutdown(
1154        conn: *mut s2n_connection,
1155        blocked: *mut s2n_blocked_status::Type,
1156    ) -> ::libc::c_int;
1157}
1158extern "C" {
1159    #[doc = " Attempts to close the write side of the TLS connection.\n\n TLS1.3 supports closing the write side of a TLS connection while leaving the read\n side unaffected. This feature is usually referred to as \"half-close\". We send\n a close_notify alert, but do not wait for the peer to respond.\n\n Like `s2n_shutdown()`, this method does not affect the underlying transport.\n\n `s2n_shutdown_send()` may still be called for earlier TLS versions, but most\n TLS implementations will react by immediately discarding any pending writes and\n closing the connection.\n\n Once `s2n_shutdown_send()` is complete:\n * The s2n_connection handle CANNOT be used for writing.\n * The s2n_connection handle CAN be used for reading.\n * The write side of the underlying transport can be closed. Most likely via `shutdown()`.\n\n The application should still call `s2n_shutdown()` or wait for `s2n_recv()` to\n return 0 to indicate end-of-data before cleaning up the connection or closing\n the read side of the underlying transport.\n\n @param conn A pointer to the s2n_connection object\n @param blocked A pointer which will be set to the blocked status if an `S2N_ERR_T_BLOCKED` error is returned.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1160    pub fn s2n_shutdown_send(
1161        conn: *mut s2n_connection,
1162        blocked: *mut s2n_blocked_status::Type,
1163    ) -> ::libc::c_int;
1164}
1165pub mod s2n_cert_auth_type {
1166    #[doc = " Used to declare what type of client certificate authentication to use.\n\n A s2n_connection will enforce client certificate authentication (mTLS) differently based on\n the `s2n_cert_auth_type` and `s2n_mode` (client/server) of the connection, as described below.\n\n Server behavior:\n - None (default): Will not request client authentication.\n - Optional: Request the client's certificate and validate it. If no certificate is received then\n     no validation is performed.\n - Required: Request the client's certificate and validate it. Abort the handshake if a client\n     certificate is not received.\n\n Client behavior:\n - None: Abort the handshake if the server requests client authentication.\n - Optional (default): Sends the client certificate if the server requests client\n     authentication. No certificate is sent if the application hasn't provided a certificate.\n - Required: Send the client certificate. Abort the handshake if the server doesn't request\n     client authentication or if the application hasn't provided a certificate."]
1167    pub type Type = ::libc::c_uint;
1168    pub const NONE: Type = 0;
1169    pub const REQUIRED: Type = 1;
1170    pub const OPTIONAL: Type = 2;
1171}
1172extern "C" {
1173    #[doc = " Gets Client Certificate authentication method the s2n_config object is using.\n\n @param config A pointer to a s2n_config object\n @param client_auth_type A pointer to a client auth policy. This will be updated to the s2n_config value.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1174    pub fn s2n_config_get_client_auth_type(
1175        config: *mut s2n_config,
1176        client_auth_type: *mut s2n_cert_auth_type::Type,
1177    ) -> ::libc::c_int;
1178}
1179extern "C" {
1180    #[doc = " Sets whether or not a Client Certificate should be required to complete the TLS Connection.\n\n If this is set to `S2N_CERT_AUTH_OPTIONAL` the server will request a client certificate but allow the client to not provide one.\n Rejecting a client certificate when using `S2N_CERT_AUTH_OPTIONAL` will terminate the handshake.\n\n @param config A pointer to a s2n_config object\n @param client_auth_type The client auth policy for the connection\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1181    pub fn s2n_config_set_client_auth_type(
1182        config: *mut s2n_config,
1183        client_auth_type: s2n_cert_auth_type::Type,
1184    ) -> ::libc::c_int;
1185}
1186extern "C" {
1187    #[doc = " Gets Client Certificate authentication method the s2n_connection object is using.\n\n @param conn A pointer to the s2n_connection object\n @param client_auth_type A pointer to a client auth policy. This will be updated to the s2n_connection value.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1188    pub fn s2n_connection_get_client_auth_type(
1189        conn: *mut s2n_connection,
1190        client_auth_type: *mut s2n_cert_auth_type::Type,
1191    ) -> ::libc::c_int;
1192}
1193extern "C" {
1194    #[doc = " Sets whether or not a Client Certificate should be required to complete the TLS Connection.\n\n If this is set to `S2N_CERT_AUTH_OPTIONAL` the server will request a client certificate but allow the client to not provide one.\n Rejecting a client certificate when using `S2N_CERT_AUTH_OPTIONAL` will terminate the handshake.\n\n @param conn A pointer to the s2n_connection object\n @param client_auth_type The client auth policy for the connection\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1195    pub fn s2n_connection_set_client_auth_type(
1196        conn: *mut s2n_connection,
1197        client_auth_type: s2n_cert_auth_type::Type,
1198    ) -> ::libc::c_int;
1199}
1200extern "C" {
1201    #[doc = " Gets the raw certificate chain received from the client.\n\n The retrieved certificate chain has the format described by the TLS 1.2 RFC:\n https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.2. Each certificate is a DER-encoded ASN.1 X.509,\n prepended by a 3 byte network-endian length value. Note that this format is used regardless of the connection's\n protocol version.\n\n @warning The buffer pointed to by `cert_chain_out` shares its lifetime with the s2n_connection object.\n\n @param conn A pointer to the s2n_connection object\n @param cert_chain_out A pointer that's set to the client certificate chain.\n @param cert_chain_len A pointer that's set to the size of the `cert_chain_out` buffer.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1202    pub fn s2n_connection_get_client_cert_chain(
1203        conn: *mut s2n_connection,
1204        der_cert_chain_out: *mut *mut u8,
1205        cert_chain_len: *mut u32,
1206    ) -> ::libc::c_int;
1207}
1208extern "C" {
1209    #[doc = " Sets the initial number of session tickets to send after a >=TLS1.3 handshake. The default value is one ticket.\n\n @param config A pointer to the config object.\n @param num The number of session tickets that will be sent.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1210    pub fn s2n_config_set_initial_ticket_count(config: *mut s2n_config, num: u8) -> ::libc::c_int;
1211}
1212extern "C" {
1213    #[doc = " Increases the number of session tickets to send after a >=TLS1.3 handshake.\n\n @param conn A pointer to the connection object.\n @param num The number of additional session tickets to send.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1214    pub fn s2n_connection_add_new_tickets_to_send(
1215        conn: *mut s2n_connection,
1216        num: u8,
1217    ) -> ::libc::c_int;
1218}
1219extern "C" {
1220    #[doc = " Returns the number of session tickets issued by the server.\n\n In TLS1.3, this number can be up to the limit configured by s2n_config_set_initial_ticket_count\n and s2n_connection_add_new_tickets_to_send. In earlier versions of TLS, this number will be either 0 or 1.\n\n This method only works for server connections.\n\n @param conn A pointer to the connection object.\n @param num The number of additional session tickets sent.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1221    pub fn s2n_connection_get_tickets_sent(
1222        conn: *mut s2n_connection,
1223        num: *mut u16,
1224    ) -> ::libc::c_int;
1225}
1226extern "C" {
1227    #[doc = " Sets the keying material lifetime for >=TLS1.3 session tickets so that one session doesn't get re-used ad infinitum.\n The default value is one week.\n\n @param conn A pointer to the connection object.\n @param lifetime_in_secs Lifetime of keying material in seconds.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure"]
1228    pub fn s2n_connection_set_server_keying_material_lifetime(
1229        conn: *mut s2n_connection,
1230        lifetime_in_secs: u32,
1231    ) -> ::libc::c_int;
1232}
1233#[repr(C)]
1234#[derive(Debug, Copy, Clone)]
1235pub struct s2n_session_ticket {
1236    _unused: [u8; 0],
1237}
1238#[doc = " Callback function for receiving a session ticket.\n\n This function will be called each time a session ticket is received, which may be multiple times for TLS1.3.\n\n # Safety\n\n `ctx` is a void pointer and the caller is responsible for ensuring it is cast to the correct type.\n `ticket` is valid only within the scope of this callback.\n\n @param conn A pointer to the connection object.\n @param ctx Context for the session ticket callback function.\n @param ticket Pointer to the received session ticket object."]
1239pub type s2n_session_ticket_fn = ::core::option::Option<
1240    unsafe extern "C" fn(
1241        conn: *mut s2n_connection,
1242        ctx: *mut ::libc::c_void,
1243        ticket: *mut s2n_session_ticket,
1244    ) -> ::libc::c_int,
1245>;
1246extern "C" {
1247    #[doc = " Sets a session ticket callback to be called when a client receives a new session ticket.\n\n # Safety\n\n `callback` MUST cast `ctx` into the same type of pointer that was originally created.\n `ctx` MUST be valid for the lifetime of the config, or until a different context is set.\n\n @param config A pointer to the config object.\n @param callback The function that should be called when the callback is triggered.\n @param ctx The context to be passed when the callback is called."]
1248    pub fn s2n_config_set_session_ticket_cb(
1249        config: *mut s2n_config,
1250        callback: s2n_session_ticket_fn,
1251        ctx: *mut ::libc::c_void,
1252    ) -> ::libc::c_int;
1253}
1254extern "C" {
1255    #[doc = " Gets the length of the session ticket from a session ticket object.\n\n @param ticket Pointer to the session ticket object.\n @param data_len Pointer to be set to the length of the session ticket on success."]
1256    pub fn s2n_session_ticket_get_data_len(
1257        ticket: *mut s2n_session_ticket,
1258        data_len: *mut usize,
1259    ) -> ::libc::c_int;
1260}
1261extern "C" {
1262    #[doc = " Gets the session ticket data from a session ticket object.\n\n # Safety\n The entire session ticket will be copied into `data` on success. Therefore, `data` MUST have enough\n memory to store the session ticket data.\n\n @param ticket Pointer to the session ticket object.\n @param max_data_len Maximum length of data that can be written to the 'data' pointer.\n @param data Pointer to where the session ticket data will be stored."]
1263    pub fn s2n_session_ticket_get_data(
1264        ticket: *mut s2n_session_ticket,
1265        max_data_len: usize,
1266        data: *mut u8,
1267    ) -> ::libc::c_int;
1268}
1269extern "C" {
1270    #[doc = " Gets the lifetime in seconds of the session ticket from a session ticket object.\n\n @param ticket Pointer to the session ticket object.\n @param session_lifetime Pointer to a variable where the lifetime of the session ticket will be stored."]
1271    pub fn s2n_session_ticket_get_lifetime(
1272        ticket: *mut s2n_session_ticket,
1273        session_lifetime: *mut u32,
1274    ) -> ::libc::c_int;
1275}
1276extern "C" {
1277    #[doc = " De-serializes the session state and updates the connection accordingly.\n\n If this method fails, the connection should not be affected: calling s2n_negotiate\n with the connection should simply result in a full handshake.\n\n @param conn A pointer to the s2n_connection object\n @param session A pointer to a buffer of size `length`\n @param length The size of the `session` buffer\n\n @returns The number of copied bytes"]
1278    pub fn s2n_connection_set_session(
1279        conn: *mut s2n_connection,
1280        session: *const u8,
1281        length: usize,
1282    ) -> ::libc::c_int;
1283}
1284extern "C" {
1285    #[doc = " Serializes the session state from connection and copies into the `session` buffer and returns the number of copied bytes\n\n @note This function is not recommended for > TLS 1.2 because in TLS1.3\n servers can send multiple session tickets and this function will only\n return the most recently received ticket.\n\n @param conn A pointer to the s2n_connection object\n @param session A pointer to a buffer of size `max_length`\n @param max_length The size of the `session` buffer\n\n @returns The number of copied bytes"]
1286    pub fn s2n_connection_get_session(
1287        conn: *mut s2n_connection,
1288        session: *mut u8,
1289        max_length: usize,
1290    ) -> ::libc::c_int;
1291}
1292extern "C" {
1293    #[doc = " Retrieves a hint from the server indicating how long this ticket's lifetime is.\n\n @note This function is not recommended for > TLS 1.2 because in TLS1.3\n servers can send multiple session tickets and this function will only\n return the most recently received ticket lifetime hint.\n\n @param conn A pointer to the s2n_connection object\n\n @returns The session ticket lifetime hint in seconds from the server or -1 when session ticket was not used for resumption."]
1294    pub fn s2n_connection_get_session_ticket_lifetime_hint(
1295        conn: *mut s2n_connection,
1296    ) -> ::libc::c_int;
1297}
1298extern "C" {
1299    #[doc = " Use this to query the serialized session state size before copying it into a buffer.\n\n @param conn A pointer to the s2n_connection object\n\n @returns number of bytes needed to store serialized session state"]
1300    pub fn s2n_connection_get_session_length(conn: *mut s2n_connection) -> ::libc::c_int;
1301}
1302extern "C" {
1303    #[doc = " Gets the latest session id's length from the connection.\n\n Use this to query the session id size before copying it into a buffer.\n\n @param conn A pointer to the s2n_connection object\n\n @returns The latest session id length from the connection. Session id length will be 0 for TLS versions >= TLS1.3 as stateful session resumption has not yet been implemented in TLS1.3."]
1304    pub fn s2n_connection_get_session_id_length(conn: *mut s2n_connection) -> ::libc::c_int;
1305}
1306extern "C" {
1307    #[doc = " Gets the latest session id from the connection, copies it into the `session_id` buffer, and returns the number of copied bytes.\n\n The session id may change between s2n receiving the ClientHello and sending the ServerHello, but this function will always describe the latest session id.\n\n See s2n_client_hello_get_session_id() to get the session id as it was sent by the client in the ClientHello message.\n\n @param conn A pointer to the s2n_connection object\n @param session_id A pointer to a buffer of size `max_length`\n @param max_length The size of the `session_id` buffer\n\n @returns The number of copied bytes."]
1308    pub fn s2n_connection_get_session_id(
1309        conn: *mut s2n_connection,
1310        session_id: *mut u8,
1311        max_length: usize,
1312    ) -> ::libc::c_int;
1313}
1314extern "C" {
1315    #[doc = " Check if the connection was resumed from an earlier handshake.\n\n @param conn A pointer to the s2n_connection object\n\n @returns returns 1 if the handshake was abbreviated, otherwise returns 0"]
1316    pub fn s2n_connection_is_session_resumed(conn: *mut s2n_connection) -> ::libc::c_int;
1317}
1318extern "C" {
1319    #[doc = " Check if the connection is OCSP stapled.\n\n @param conn A pointer to the s2n_connection object\n\n @returns 1 if OCSP response was sent (if connection is in S2N_SERVER mode) or received (if connection is in S2N_CLIENT mode) during handshake, otherwise it returns 0."]
1320    pub fn s2n_connection_is_ocsp_stapled(conn: *mut s2n_connection) -> ::libc::c_int;
1321}
1322pub mod s2n_tls_signature_algorithm {
1323    #[doc = " TLS Signature Algorithms - RFC 5246 7.4.1.4.1\n https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16"]
1324    pub type Type = ::libc::c_uint;
1325    pub const ANONYMOUS: Type = 0;
1326    pub const RSA: Type = 1;
1327    pub const ECDSA: Type = 3;
1328    pub const MLDSA: Type = 9;
1329    pub const RSA_PSS_RSAE: Type = 224;
1330    pub const RSA_PSS_PSS: Type = 225;
1331}
1332pub mod s2n_tls_hash_algorithm {
1333    #[doc = " TLS Hash Algorithms - https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1\n https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-18"]
1334    pub type Type = ::libc::c_uint;
1335    pub const NONE: Type = 0;
1336    pub const MD5: Type = 1;
1337    pub const SHA1: Type = 2;
1338    pub const SHA224: Type = 3;
1339    pub const SHA256: Type = 4;
1340    pub const SHA384: Type = 5;
1341    pub const SHA512: Type = 6;
1342    pub const MD5_SHA1: Type = 224;
1343}
1344extern "C" {
1345    #[doc = " Get the connection's selected signature algorithm.\n\n @param conn A pointer to the s2n_connection object\n @param chosen_alg A pointer to a s2n_tls_signature_algorithm object. This is an output parameter.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE if bad parameters are received."]
1346    pub fn s2n_connection_get_selected_signature_algorithm(
1347        conn: *mut s2n_connection,
1348        chosen_alg: *mut s2n_tls_signature_algorithm::Type,
1349    ) -> ::libc::c_int;
1350}
1351extern "C" {
1352    #[doc = " Get the connection's selected digest algorithm.\n\n @param conn A pointer to the s2n_connection object\n @param chosen_alg A pointer to a s2n_tls_hash_algorithm object. This is an output parameter.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE if bad parameters are received."]
1353    pub fn s2n_connection_get_selected_digest_algorithm(
1354        conn: *mut s2n_connection,
1355        chosen_alg: *mut s2n_tls_hash_algorithm::Type,
1356    ) -> ::libc::c_int;
1357}
1358extern "C" {
1359    #[doc = " Get the client certificate's signature algorithm.\n\n @param conn A pointer to the s2n_connection object\n @param chosen_alg A pointer to a s2n_tls_signature_algorithm object. This is an output parameter.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE if bad parameters are received."]
1360    pub fn s2n_connection_get_selected_client_cert_signature_algorithm(
1361        conn: *mut s2n_connection,
1362        chosen_alg: *mut s2n_tls_signature_algorithm::Type,
1363    ) -> ::libc::c_int;
1364}
1365extern "C" {
1366    #[doc = " Get the client certificate's digest algorithm.\n\n @param conn A pointer to the s2n_connection object\n @param chosen_alg A pointer to a s2n_tls_hash_algorithm object. This is an output parameter.\n\n @returns S2N_SUCCESS on success. S2N_FAILURE if bad parameters are received."]
1367    pub fn s2n_connection_get_selected_client_cert_digest_algorithm(
1368        conn: *mut s2n_connection,
1369        chosen_alg: *mut s2n_tls_hash_algorithm::Type,
1370    ) -> ::libc::c_int;
1371}
1372extern "C" {
1373    #[doc = " Get the certificate used during the TLS handshake\n\n - If `conn` is a server connection, the certificate selected will depend on the\n   ServerName sent by the client and supported ciphers.\n - If `conn` is a client connection, the certificate sent in response to a CertificateRequest\n   message is returned. Currently s2n-tls supports loading only one certificate in client mode. Note that\n   not all TLS endpoints will request a certificate.\n\n @param conn A pointer to the s2n_connection object\n\n @returns NULL if the certificate selection phase of the handshake has not completed or if a certificate was not requested by the peer"]
1374    pub fn s2n_connection_get_selected_cert(
1375        conn: *mut s2n_connection,
1376    ) -> *mut s2n_cert_chain_and_key;
1377}
1378extern "C" {
1379    #[doc = " @param chain_and_key A pointer to the s2n_cert_chain_and_key object being read.\n @param cert_length This return value represents the length of the s2n certificate chain `chain_and_key`.\n @returns the length of the s2n certificate chain `chain_and_key`."]
1380    pub fn s2n_cert_chain_get_length(
1381        chain_and_key: *const s2n_cert_chain_and_key,
1382        cert_length: *mut u32,
1383    ) -> ::libc::c_int;
1384}
1385extern "C" {
1386    #[doc = " Returns the certificate `out_cert` present at the index `cert_idx` of the certificate chain `chain_and_key`.\n\n Note that the index of the leaf certificate is zero. If the certificate chain `chain_and_key` is NULL or the\n certificate index value is not in the acceptable range for the input certificate chain, an error is returned.\n\n # Safety\n\n There is no memory allocation required for `out_cert` buffer prior to calling the `s2n_cert_chain_get_cert` API.\n The `out_cert` will contain the pointer to the s2n_cert initialized within the input s2n_cert_chain_and_key `chain_and_key`.\n The pointer to the output s2n certificate `out_cert` is valid until `chain_and_key` is freed up.\n If a caller wishes to persist the `out_cert` beyond the lifetime of `chain_and_key`, the contents would need to be\n copied prior to freeing `chain_and_key`.\n\n @param chain_and_key A pointer to the s2n_cert_chain_and_key object being read.\n @param out_cert A pointer to the output s2n_cert `out_cert` present at the index `cert_idx` of the certificate chain `chain_and_key`.\n @param cert_idx The certificate index for the requested certificate within the s2n certificate chain."]
1387    pub fn s2n_cert_chain_get_cert(
1388        chain_and_key: *const s2n_cert_chain_and_key,
1389        out_cert: *mut *mut s2n_cert,
1390        cert_idx: u32,
1391    ) -> ::libc::c_int;
1392}
1393extern "C" {
1394    #[doc = " Returns the s2n certificate in DER format along with its length.\n\n The API gets the s2n certificate `cert` in DER format. The certificate is returned in the `out_cert_der` buffer.\n Here, `cert_len` represents the length of the certificate.\n\n A caller can use certificate parsing tools such as the ones provided by OpenSSL to parse the DER encoded certificate chain returned.\n\n # Safety\n\n The memory for the `out_cert_der` buffer is allocated and owned by s2n-tls.\n Since the size of the certificate can potentially be very large, a pointer to internal connection data is returned instead of\n copying the contents into a caller-provided buffer.\n\n The pointer to the output buffer `out_cert_der` is valid only while the connection exists.\n The `s2n_connection_free` API frees the memory associated with the out_cert_der buffer and after the `s2n_connection_wipe` API is\n called the memory pointed by out_cert_der is invalid.\n\n If a caller wishes to persist the `out_cert_der` beyond the lifetime of the connection, the contents would need to be\n copied prior to the connection termination.\n\n @param cert A pointer to the s2n_cert object being read.\n @param out_cert_der A pointer to the output buffer which will hold the s2n certificate `cert` in DER format.\n @param cert_length This return value represents the length of the certificate."]
1395    pub fn s2n_cert_get_der(
1396        cert: *const s2n_cert,
1397        out_cert_der: *mut *const u8,
1398        cert_length: *mut u32,
1399    ) -> ::libc::c_int;
1400}
1401extern "C" {
1402    #[doc = " Returns the validated peer certificate chain as a `s2n_cert_chain_and_key` opaque object.\n\n The `s2n_cert_chain_and_key` parameter must be allocated by the caller using the `s2n_cert_chain_and_key_new` API\n prior to this function call and must be empty. To free the memory associated with the `s2n_cert_chain_and_key` object use the\n `s2n_cert_chain_and_key_free` API.\n\n @param conn A pointer to the s2n_connection object being read.\n @param cert_chain The returned validated peer certificate chain `cert_chain` retrieved from the s2n connection."]
1403    pub fn s2n_connection_get_peer_cert_chain(
1404        conn: *const s2n_connection,
1405        cert_chain: *mut s2n_cert_chain_and_key,
1406    ) -> ::libc::c_int;
1407}
1408extern "C" {
1409    #[doc = " Returns the length of the DER encoded extension value of the ASN.1 X.509 certificate extension.\n\n @param cert A pointer to the s2n_cert object being read.\n @param oid A null-terminated cstring that contains the OID of the X.509 certificate extension to be read.\n @param ext_value_len This return value contains the length of DER encoded extension value of the ASN.1 X.509 certificate extension."]
1410    pub fn s2n_cert_get_x509_extension_value_length(
1411        cert: *mut s2n_cert,
1412        oid: *const u8,
1413        ext_value_len: *mut u32,
1414    ) -> ::libc::c_int;
1415}
1416extern "C" {
1417    #[doc = " Returns the DER encoding of an ASN.1 X.509 certificate extension value, it's length and a boolean critical.\n\n @param cert A pointer to the s2n_cert object being read.\n @param oid A null-terminated cstring that contains the OID of the X.509 certificate extension to be read.\n @param ext_value A pointer to the output buffer which will hold the DER encoding of an ASN.1 X.509 certificate extension value returned.\n @param ext_value_len  This value is both an input and output parameter and represents the length of the output buffer `ext_value`.\n When used as an input parameter, the caller must use this parameter to convey the maximum length of `ext_value`.\n When used as an output parameter, `ext_value_len` holds the actual length of the DER encoding of the ASN.1 X.509 certificate extension value returned.\n @param critical This return value contains the boolean value for `critical`."]
1418    pub fn s2n_cert_get_x509_extension_value(
1419        cert: *mut s2n_cert,
1420        oid: *const u8,
1421        ext_value: *mut u8,
1422        ext_value_len: *mut u32,
1423        critical: *mut bool,
1424    ) -> ::libc::c_int;
1425}
1426extern "C" {
1427    #[doc = " Returns the UTF8 String length of the ASN.1 X.509 certificate extension data.\n\n @param extension_data A pointer to the DER encoded ASN.1 X.509 certificate extension value being read.\n @param extension_len represents the length of the input buffer `extension_data`.\n @param utf8_str_len This return value contains the UTF8 String length of the ASN.1 X.509 certificate extension data."]
1428    pub fn s2n_cert_get_utf8_string_from_extension_data_length(
1429        extension_data: *const u8,
1430        extension_len: u32,
1431        utf8_str_len: *mut u32,
1432    ) -> ::libc::c_int;
1433}
1434extern "C" {
1435    #[doc = " Returns the UTF8 String representation of the DER encoded ASN.1 X.509 certificate extension data.\n\n @param extension_data A pointer to the DER encoded ASN.1 X.509 certificate extension value being read.\n @param extension_len represents the length of the input buffer `extension_data`.\n @param out_data A pointer to the output buffer which will hold the UTF8 String representation of the DER encoded ASN.1 X.509\n certificate extension data returned.\n @param out_len This value is both an input and output parameter and represents the length of the output buffer `out_data`.\n When used as an input parameter, the caller must use this parameter to convey the maximum length of `out_data`.\n When used as an output parameter, `out_len` holds the actual length of UTF8 String returned."]
1436    pub fn s2n_cert_get_utf8_string_from_extension_data(
1437        extension_data: *const u8,
1438        extension_len: u32,
1439        out_data: *mut u8,
1440        out_len: *mut u32,
1441    ) -> ::libc::c_int;
1442}
1443pub mod s2n_psk_hmac {
1444    #[doc = " Pre-shared key (PSK) Hash Algorithm - RFC 8446 Section-2.2"]
1445    pub type Type = ::libc::c_uint;
1446    pub const SHA256: Type = 0;
1447    pub const SHA384: Type = 1;
1448}
1449#[doc = " Opaque pre shared key handle"]
1450#[repr(C)]
1451#[derive(Debug, Copy, Clone)]
1452pub struct s2n_psk {
1453    _unused: [u8; 0],
1454}
1455extern "C" {
1456    #[doc = " Creates a new s2n external pre-shared key (PSK) object with `S2N_PSK_HMAC_SHA256` as the default\n PSK hash algorithm. An external PSK is a key established outside of TLS using a secure mutually agreed upon mechanism.\n\n Use `s2n_psk_free` to free the memory allocated to the s2n external PSK object created by this API.\n\n @returns struct s2n_psk* Returns a pointer to the newly created external PSK object."]
1457    pub fn s2n_external_psk_new() -> *mut s2n_psk;
1458}
1459extern "C" {
1460    #[doc = " Frees the memory associated with the external PSK object.\n\n @param psk Pointer to the PSK object to be freed."]
1461    pub fn s2n_psk_free(psk: *mut *mut s2n_psk) -> ::libc::c_int;
1462}
1463extern "C" {
1464    #[doc = " Sets the identity for a given external PSK object.\n The identity is a unique identifier for the pre-shared secret.\n It is a non-secret value represented by raw bytes.\n\n # Safety\n\n The identity is transmitted over the network unencrypted and is a non-secret value.\n Do not include confidential information in the identity.\n\n Note that the identity is copied into s2n-tls memory and the caller is responsible for\n freeing the memory associated with the identity input.\n\n @param psk A pointer to a PSK object to be updated with the identity.\n @param identity The identity in raw bytes format to be copied.\n @param identity_size The length of the PSK identity being set."]
1465    pub fn s2n_psk_set_identity(
1466        psk: *mut s2n_psk,
1467        identity: *const u8,
1468        identity_size: u16,
1469    ) -> ::libc::c_int;
1470}
1471extern "C" {
1472    #[doc = " Sets the out-of-band/externally provisioned secret for a given external PSK object.\n\n # Safety\n\n Note that the secret is copied into s2n-tls memory and the caller is responsible for\n freeing the memory associated with the `secret` input.\n\n Deriving a shared secret from a password or other low-entropy source\n is not secure and is subject to dictionary attacks.\n See https://tools.ietf.org/rfc/rfc8446#section-2.2 for more information.\n\n @param psk A pointer to a PSK object to be updated with the secret.\n @param secret The secret in raw bytes format to be copied.\n @param secret_size The length of the pre-shared secret being set."]
1473    pub fn s2n_psk_set_secret(
1474        psk: *mut s2n_psk,
1475        secret: *const u8,
1476        secret_size: u16,
1477    ) -> ::libc::c_int;
1478}
1479extern "C" {
1480    #[doc = " Sets the hash algorithm for a given external PSK object. The supported PSK hash\n algorithms are as listed in the enum `s2n_psk_hmac` above.\n\n @param psk A pointer to the external PSK object to be updated with the PSK hash algorithm.\n @param hmac The PSK hash algorithm being set."]
1481    pub fn s2n_psk_set_hmac(psk: *mut s2n_psk, hmac: s2n_psk_hmac::Type) -> ::libc::c_int;
1482}
1483extern "C" {
1484    #[doc = " Appends a PSK object to the list of PSKs supported by the s2n connection.\n If a PSK with a duplicate identity is found, an error is returned and the PSK is not added to the list.\n Note that a copy of `psk` is stored on the connection. The user is still responsible for freeing the\n memory associated with `psk`.\n\n @param conn A pointer to the s2n_connection object that contains the list of PSKs supported.\n @param psk A pointer to the `s2n_psk` object to be appended to the list of PSKs on the s2n connection."]
1485    pub fn s2n_connection_append_psk(conn: *mut s2n_connection, psk: *mut s2n_psk)
1486        -> ::libc::c_int;
1487}
1488pub mod s2n_psk_mode {
1489    #[doc = " The list of PSK modes supported by s2n-tls for TLS versions >= TLS1.3.\n Currently s2n-tls supports two modes - `S2N_PSK_MODE_RESUMPTION`, which represents the PSKs established\n using the previous connection via session resumption, and `S2N_PSK_MODE_EXTERNAL`, which represents PSKs\n established out-of-band/externally using a secure mutually agreed upon mechanism."]
1490    pub type Type = ::libc::c_uint;
1491    pub const RESUMPTION: Type = 0;
1492    pub const EXTERNAL: Type = 1;
1493}
1494extern "C" {
1495    #[doc = " Sets the PSK mode on the s2n config object.\n The supported PSK modes are listed in the enum `s2n_psk_mode` above.\n\n @param config A pointer to the s2n_config object being updated.\n @param mode The PSK mode to be set."]
1496    pub fn s2n_config_set_psk_mode(
1497        config: *mut s2n_config,
1498        mode: s2n_psk_mode::Type,
1499    ) -> ::libc::c_int;
1500}
1501extern "C" {
1502    #[doc = " Sets the PSK mode on the s2n connection object.\n The supported PSK modes are listed in the enum `s2n_psk_mode` above.\n This API overrides the PSK mode set on config for this connection.\n\n @param conn A pointer to the s2n_connection object being updated.\n @param mode The PSK mode to be set."]
1503    pub fn s2n_connection_set_psk_mode(
1504        conn: *mut s2n_connection,
1505        mode: s2n_psk_mode::Type,
1506    ) -> ::libc::c_int;
1507}
1508extern "C" {
1509    #[doc = " Gets the negotiated PSK identity length from the s2n connection object. The negotiated PSK\n refers to the chosen PSK by the server to be used for the connection.\n\n This API can be used to determine if the negotiated PSK exists. If negotiated PSK exists a\n call to this API returns a value greater than zero. If the negotiated PSK does not exist, the\n value `0` is returned.\n\n @param conn A pointer to the s2n_connection object that successfully negotiated a PSK connection.\n @param identity_length The length of the negotiated PSK identity."]
1510    pub fn s2n_connection_get_negotiated_psk_identity_length(
1511        conn: *mut s2n_connection,
1512        identity_length: *mut u16,
1513    ) -> ::libc::c_int;
1514}
1515extern "C" {
1516    #[doc = " Gets the negotiated PSK identity from the s2n connection object.\n If the negotiated PSK does not exist, the PSK identity will not be obtained and no error will be returned.\n Prior to this API call, use `s2n_connection_get_negotiated_psk_identity_length` to determine if a\n negotiated PSK exists or not.\n\n # Safety\n\n The negotiated PSK identity will be copied into the identity buffer on success.\n Therefore, the identity buffer must have enough memory to fit the identity length.\n\n @param conn A pointer to the s2n_connection object.\n @param identity The negotiated PSK identity obtained from the s2n_connection object.\n @param max_identity_length The maximum length for the PSK identity. If the negotiated psk_identity length is\n greater than this `max_identity_length` value an error will be returned."]
1517    pub fn s2n_connection_get_negotiated_psk_identity(
1518        conn: *mut s2n_connection,
1519        identity: *mut u8,
1520        max_identity_length: u16,
1521    ) -> ::libc::c_int;
1522}
1523#[repr(C)]
1524#[derive(Debug, Copy, Clone)]
1525pub struct s2n_offered_psk {
1526    _unused: [u8; 0],
1527}
1528extern "C" {
1529    #[doc = " Creates a new s2n offered PSK object.\n An offered PSK object represents a single PSK sent by the client.\n\n # Safety\n\n Use `s2n_offered_psk_free` to free the memory allocated to the s2n offered PSK object created by this API.\n\n @returns struct s2n_offered_psk* Returns a pointer to the newly created offered PSK object."]
1530    pub fn s2n_offered_psk_new() -> *mut s2n_offered_psk;
1531}
1532extern "C" {
1533    #[doc = " Frees the memory associated with the `s2n_offered_psk` object.\n\n @param psk A pointer to the `s2n_offered_psk` object to be freed."]
1534    pub fn s2n_offered_psk_free(psk: *mut *mut s2n_offered_psk) -> ::libc::c_int;
1535}
1536extern "C" {
1537    #[doc = " Gets the PSK identity and PSK identity length for a given offered PSK object.\n\n @param psk A pointer to the offered PSK object being read.\n @param identity The PSK identity being obtained.\n @param size The length of the PSK identity being obtained."]
1538    pub fn s2n_offered_psk_get_identity(
1539        psk: *mut s2n_offered_psk,
1540        identity: *mut *mut u8,
1541        size: *mut u16,
1542    ) -> ::libc::c_int;
1543}
1544#[repr(C)]
1545#[derive(Debug, Copy, Clone)]
1546pub struct s2n_offered_psk_list {
1547    _unused: [u8; 0],
1548}
1549extern "C" {
1550    #[doc = " Checks whether the offered PSK list has an offered psk object next in line in the list.\n An offered PSK list contains all the PSKs offered by the client for the server to select.\n\n # Safety\n\n This API returns a pointer to the s2n-tls internal memory with limited lifetime.\n After the completion of `s2n_psk_selection_callback` this pointer is invalid.\n\n @param psk_list A pointer to the offered PSK list being read.\n @returns bool A boolean value representing whether an offered psk object is present next in line in the offered PSK list."]
1551    pub fn s2n_offered_psk_list_has_next(psk_list: *mut s2n_offered_psk_list) -> bool;
1552}
1553extern "C" {
1554    #[doc = " Obtains the next offered PSK object from the list of offered PSKs. Use `s2n_offered_psk_list_has_next`\n prior to this API call to ensure we have not reached the end of the list.\n\n @param psk_list A pointer to the offered PSK list being read.\n @param psk A pointer to the next offered PSK object being obtained."]
1555    pub fn s2n_offered_psk_list_next(
1556        psk_list: *mut s2n_offered_psk_list,
1557        psk: *mut s2n_offered_psk,
1558    ) -> ::libc::c_int;
1559}
1560extern "C" {
1561    #[doc = " Returns the offered PSK list to its original read state.\n\n When `s2n_offered_psk_list_reread` is called, `s2n_offered_psk_list_next` will return the first PSK\n in the offered PSK list.\n\n @param psk_list A pointer to the offered PSK list being reread."]
1562    pub fn s2n_offered_psk_list_reread(psk_list: *mut s2n_offered_psk_list) -> ::libc::c_int;
1563}
1564extern "C" {
1565    #[doc = " Chooses a PSK from the offered PSK list to be used for the connection.\n This API matches the PSK identity received from the client against the server's known PSK identities\n list, in order to choose the PSK to be used for the connection. If the PSK identity sent from the client\n is NULL, no PSK is chosen for the connection. If the client offered PSK identity has no matching PSK identity\n with the server, an error will be returned. Use this API along with the `s2n_psk_selection_callback` callback\n to select a PSK identity.\n\n @param psk_list A pointer to the server's known PSK list used to compare for a matching PSK with the client.\n @param psk A pointer to the client's PSK object used to compare with the server's known PSK identities."]
1566    pub fn s2n_offered_psk_list_choose_psk(
1567        psk_list: *mut s2n_offered_psk_list,
1568        psk: *mut s2n_offered_psk,
1569    ) -> ::libc::c_int;
1570}
1571#[doc = " Callback function to select a PSK from a list of offered PSKs.\n Use this callback to implement custom PSK selection logic. The s2n-tls default PSK selection logic\n chooses the first matching PSK from the list of offered PSKs sent by the client.\n\n # Safety\n\n `context` is a void pointer and the caller is responsible for ensuring it is cast to the correct type.\n After the completion of this callback, the pointer to `psk_list` is invalid.\n\n @param conn A pointer to the s2n_connection object.\n @param context A pointer to a context for the caller to pass state to the callback, if needed.\n @param psk_list A pointer to the offered PSK list being read."]
1572pub type s2n_psk_selection_callback = ::core::option::Option<
1573    unsafe extern "C" fn(
1574        conn: *mut s2n_connection,
1575        context: *mut ::libc::c_void,
1576        psk_list: *mut s2n_offered_psk_list,
1577    ) -> ::libc::c_int,
1578>;
1579extern "C" {
1580    #[doc = " Sets the callback to select the matching PSK.\n If this callback is not set s2n-tls uses a default PSK selection logic that selects the first matching\n server PSK.\n\n @param config A pointer to the s2n_config object.\n @param cb The function that should be called when the callback is triggered.\n @param context A pointer to a context for the caller to pass state to the callback, if needed."]
1581    pub fn s2n_config_set_psk_selection_callback(
1582        config: *mut s2n_config,
1583        cb: s2n_psk_selection_callback,
1584        context: *mut ::libc::c_void,
1585    ) -> ::libc::c_int;
1586}
1587extern "C" {
1588    #[doc = " Get the number of bytes the connection has received.\n\n @param conn A pointer to the connection\n @returns return the number of bytes received by s2n-tls \"on the wire\""]
1589    pub fn s2n_connection_get_wire_bytes_in(conn: *mut s2n_connection) -> u64;
1590}
1591extern "C" {
1592    #[doc = " Get the number of bytes the connection has transmitted out.\n\n @param conn A pointer to the connection\n @returns return the number of bytes transmitted out by s2n-tls \"on the wire\""]
1593    pub fn s2n_connection_get_wire_bytes_out(conn: *mut s2n_connection) -> u64;
1594}
1595extern "C" {
1596    #[doc = " Access the protocol version supported by the client.\n\n @note The return value corresponds to the macros defined as S2N_SSLv2,\n S2N_SSLv3, S2N_TLS10, S2N_TLS11, S2N_TLS12, and S2N_TLS13.\n\n @param conn A pointer to the connection\n @returns returns the highest protocol version supported by the client"]
1597    pub fn s2n_connection_get_client_protocol_version(conn: *mut s2n_connection) -> ::libc::c_int;
1598}
1599extern "C" {
1600    #[doc = " Access the protocol version supported by the server.\n\n @note The return value corresponds to the macros defined as S2N_SSLv2,\n S2N_SSLv3, S2N_TLS10, S2N_TLS11, S2N_TLS12, and S2N_TLS13.\n\n @param conn A pointer to the connection\n @returns Returns the highest protocol version supported by the server"]
1601    pub fn s2n_connection_get_server_protocol_version(conn: *mut s2n_connection) -> ::libc::c_int;
1602}
1603extern "C" {
1604    #[doc = " Access the protocol version selected for the connection.\n\n @note The return value corresponds to the macros defined as S2N_SSLv2,\n S2N_SSLv3, S2N_TLS10, S2N_TLS11, S2N_TLS12, and S2N_TLS13.\n\n @param conn A pointer to the connection\n @returns The protocol version actually negotiated by the handshake"]
1605    pub fn s2n_connection_get_actual_protocol_version(conn: *mut s2n_connection) -> ::libc::c_int;
1606}
1607extern "C" {
1608    #[doc = " Access the client hello protocol version for the connection.\n\n @note The return value corresponds to the macros defined as S2N_SSLv2,\n S2N_SSLv3, S2N_TLS10, S2N_TLS11, S2N_TLS12, and S2N_TLS13.\n\n @param conn A pointer to the connection\n @returns The protocol version used to send the initial client hello message."]
1609    pub fn s2n_connection_get_client_hello_version(conn: *mut s2n_connection) -> ::libc::c_int;
1610}
1611extern "C" {
1612    #[doc = " Access the protocol version from the header of the first record that contained the ClientHello message.\n\n @note This field has been deprecated and should not be confused with the client hello\n version. It is often set very low, usually to TLS1.0 for compatibility reasons,\n and should never be set higher than TLS1.2. Therefore this method should only be used\n for logging or fingerprinting.\n\n @param conn A pointer to the client hello struct\n @param out The protocol version in the record header containing the Client Hello."]
1613    pub fn s2n_client_hello_get_legacy_record_version(
1614        ch: *mut s2n_client_hello,
1615        out: *mut u8,
1616    ) -> ::libc::c_int;
1617}
1618extern "C" {
1619    #[doc = " Check if Client Auth was used for a connection.\n\n @param conn A pointer to the connection\n @returns 1 if the handshake completed and Client Auth was negotiated during then\n handshake."]
1620    pub fn s2n_connection_client_cert_used(conn: *mut s2n_connection) -> ::libc::c_int;
1621}
1622extern "C" {
1623    #[doc = " A function that provides a human readable string of the cipher suite that was chosen\n for a connection.\n\n @warning The string \"TLS_NULL_WITH_NULL_NULL\" is returned before the TLS handshake has been performed.\n This does not mean that the ciphersuite \"TLS_NULL_WITH_NULL_NULL\" will be used by the connection,\n it is merely being used as a placeholder.\n\n @note This function is only accurate after the TLS handshake.\n\n @param conn A pointer to the connection\n @returns A string indicating the cipher suite negotiated by s2n in OpenSSL format."]
1624    pub fn s2n_connection_get_cipher(conn: *mut s2n_connection) -> *const ::libc::c_char;
1625}
1626pub mod s2n_cert_sni_match {
1627    #[doc = " A metric to determine whether or not the server found a certificate that matched\n the client's SNI extension.\n\n S2N_SNI_NONE: Client did not send the SNI extension.\n S2N_SNI_EXACT_MATCH: Server had a certificate that matched the client's SNI extension.\n S2N_SNI_WILDCARD_MATCH: Server had a certificate with a domain name containing a wildcard character\n that could be matched to the client's SNI extension.\n S2N_SNI_NO_MATCH: Server did not have a certificate that could be matched to the client's\n SNI extension."]
1628    pub type Type = ::libc::c_uint;
1629    pub const SNI_NONE: Type = 1;
1630    pub const SNI_EXACT_MATCH: Type = 2;
1631    pub const SNI_WILDCARD_MATCH: Type = 3;
1632    pub const SNI_NO_MATCH: Type = 4;
1633}
1634extern "C" {
1635    #[doc = " A function that provides insight into whether or not the server was able to send a certificate that\n partially or completely matched the client's SNI extension.\n\n @note This function can be used as a metric in a failed connection as long as the failure\n occurs after certificate selection.\n\n @param conn A pointer to the connection\n @param cert_match An enum indicating whether or not the server found a certificate\n that matched the client's SNI extension.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
1636    pub fn s2n_connection_get_certificate_match(
1637        conn: *mut s2n_connection,
1638        match_status: *mut s2n_cert_sni_match::Type,
1639    ) -> ::libc::c_int;
1640}
1641extern "C" {
1642    #[doc = " Provides access to the TLS master secret.\n\n This is a dangerous method and should not be used unless absolutely necessary.\n Mishandling the master secret can compromise both the current connection\n and any past or future connections that use the same master secret due to\n session resumption.\n\n This method is only supported for older TLS versions, and will report an S2N_ERR_INVALID_STATE\n usage error if called for a TLS1.3 connection. TLS1.3 includes a new key schedule\n that derives independent secrets from the master secret for specific purposes,\n such as separate traffic, session ticket, and exporter secrets. Using the master\n secret directly circumvents that security feature, reducing the security of\n the protocol.\n\n If you need cryptographic material tied to the current TLS session, consider\n `s2n_connection_tls_exporter` instead. Although s2n_connection_tls_exporter\n currently only supports TLS1.3, there is also an RFC that describes exporters\n for older TLS versions: https://datatracker.ietf.org/doc/html/rfc5705\n Using the master secret as-is or defining your own exporter is dangerous.\n\n @param conn A pointer to the connection.\n @param secret_bytes Memory to copy the master secret into. The secret\n is always 48 bytes long.\n @param max_size The size of the memory available at `secret_bytes`. Must be\n at least 48 bytes.\n @returns S2N_SUCCESS on success, S2N_FAILURE otherwise. `secret_bytes`\n will be set on success."]
1643    pub fn s2n_connection_get_master_secret(
1644        conn: *const s2n_connection,
1645        secret_bytes: *mut u8,
1646        max_size: usize,
1647    ) -> ::libc::c_int;
1648}
1649extern "C" {
1650    #[doc = " Provides access to the TLS-Exporter functionality.\n\n See https://datatracker.ietf.org/doc/html/rfc5705 and https://www.rfc-editor.org/rfc/rfc8446.\n\n @note This is currently only available with TLS 1.3 connections which have finished a handshake.\n\n @param conn A pointer to the connection\n @returns A POSIX error signal. If an error was returned, the value contained in `output` should be considered invalid."]
1651    pub fn s2n_connection_tls_exporter(
1652        conn: *mut s2n_connection,
1653        label: *const u8,
1654        label_length: u32,
1655        context: *const u8,
1656        context_length: u32,
1657        output: *mut u8,
1658        output_length: u32,
1659    ) -> ::libc::c_int;
1660}
1661extern "C" {
1662    #[doc = " Returns the IANA value for the connection's negotiated cipher suite.\n\n The value is returned in the form of `first,second`, in order to closely match\n the values defined in the [IANA Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#table-tls-parameters-4).\n For example if the connection's negotiated cipher suite is `TLS_AES_128_GCM_SHA256`,\n which is registered as `0x13,0x01`, then `first = 0x13` and `second = 0x01`.\n\n This method will only succeed after the cipher suite has been negotiated with the peer.\n\n @param conn A pointer to the connection being read\n @param first A pointer to a single byte, which will be updated with the first byte in the registered IANA value.\n @param second A pointer to a single byte, which will be updated with the second byte in the registered IANA value.\n @returns A POSIX error signal. If an error was returned, the values contained in `first` and `second` should be considered invalid."]
1663    pub fn s2n_connection_get_cipher_iana_value(
1664        conn: *mut s2n_connection,
1665        first: *mut u8,
1666        second: *mut u8,
1667    ) -> ::libc::c_int;
1668}
1669extern "C" {
1670    #[doc = " Function to check if the cipher used by current connection is supported by the current\n cipher preferences.\n @param conn A pointer to the s2n connection\n @param version A string representing the security policy to check against.\n @returns 1 if the connection satisfies the cipher suite. 0 if the connection does not satisfy the cipher suite. -1 if there is an error."]
1671    pub fn s2n_connection_is_valid_for_cipher_preferences(
1672        conn: *mut s2n_connection,
1673        version: *const ::libc::c_char,
1674    ) -> ::libc::c_int;
1675}
1676extern "C" {
1677    #[doc = " Function to get the human readable elliptic curve name for the connection.\n\n @deprecated Use `s2n_connection_get_key_exchange_group` instead\n\n @param conn A pointer to the s2n connection\n @returns A string indicating the elliptic curve used during ECDHE key exchange. The string \"NONE\" is returned if no curve was used."]
1678    pub fn s2n_connection_get_curve(conn: *mut s2n_connection) -> *const ::libc::c_char;
1679}
1680extern "C" {
1681    #[doc = " Function to get the human readable KEM name for the connection.\n\n @deprecated This function was previously used to retrieve the negotiated PQ group in TLS 1.2.\n PQ key exchange in TLS1.2 was experimental and is now deprecated. Use s2n_connection_get_kem_group_name()\n to retrieve the PQ TLS 1.3 Group name.\n\n @param conn A pointer to the s2n connection\n @returns A human readable string for the KEM group. If there is no KEM configured returns \"NONE\""]
1682    pub fn s2n_connection_get_kem_name(conn: *mut s2n_connection) -> *const ::libc::c_char;
1683}
1684extern "C" {
1685    #[doc = " Function to get the human readable KEM group name for the connection.\n\n @note PQ key exchange will not occur if the connection is < TLS1.3 or the configured security\n policy has no KEM groups on it. It also will not occur if the peer does not support PQ key exchange.\n In these instances this function will return \"NONE\".\n\n @param conn A pointer to the s2n connection\n @returns A human readable string for the KEM group. Returns \"NONE\" if no PQ key exchange occurred."]
1686    pub fn s2n_connection_get_kem_group_name(conn: *mut s2n_connection) -> *const ::libc::c_char;
1687}
1688extern "C" {
1689    #[doc = " Function to get the human readable key exchange group name for the connection, for example:\n `secp521r1` or `SecP256r1MLKEM768`. If an EC curve or KEM was not negotiated, S2N_FAILURE will be\n returned.\n\n @note This function replaces `s2n_connection_get_curve` and `s2n_connection_get_kem_group_name`, returning\n the named group regardless if a hybrid PQ group was negotiated or not.\n\n @param conn A pointer to the s2n connection\n @param group_name A pointer that will be set to point to a const char* containing the group name\n @returns S2N_SUCCESS on success, S2N_FAILURE otherwise. `group_name` will be set on success."]
1690    pub fn s2n_connection_get_key_exchange_group(
1691        conn: *mut s2n_connection,
1692        group_name: *mut *const ::libc::c_char,
1693    ) -> ::libc::c_int;
1694}
1695extern "C" {
1696    #[doc = " Function to get the alert that caused a connection to close. s2n-tls considers all\n TLS alerts fatal and shuts down a connection whenever one is received.\n\n @param conn A pointer to the s2n connection\n @returns The TLS alert code that caused a connection to be shut down"]
1697    pub fn s2n_connection_get_alert(conn: *mut s2n_connection) -> ::libc::c_int;
1698}
1699extern "C" {
1700    #[doc = " Function to return the last TLS handshake type that was processed. The returned format is a human readable string.\n\n @param conn A pointer to the s2n connection\n @returns A human-readable handshake type name, e.g. \"NEGOTIATED|FULL_HANDSHAKE|PERFECT_FORWARD_SECRECY\""]
1701    pub fn s2n_connection_get_handshake_type_name(
1702        conn: *mut s2n_connection,
1703    ) -> *const ::libc::c_char;
1704}
1705extern "C" {
1706    #[doc = " Function to return the last TLS message that was processed. The returned format is a human readable string.\n @param conn A pointer to the s2n connection\n @returns The last message name in the TLS state machine, e.g. \"SERVER_HELLO\", \"APPLICATION_DATA\"."]
1707    pub fn s2n_connection_get_last_message_name(conn: *mut s2n_connection)
1708        -> *const ::libc::c_char;
1709}
1710#[doc = " Opaque async private key operation handle"]
1711#[repr(C)]
1712#[derive(Debug, Copy, Clone)]
1713pub struct s2n_async_pkey_op {
1714    _unused: [u8; 0],
1715}
1716pub mod s2n_async_pkey_validation_mode {
1717    #[doc = " Sets whether or not a connection should enforce strict signature validation during the\n `s2n_async_pkey_op_apply` call.\n\n `mode` can take the following values:\n - `S2N_ASYNC_PKEY_VALIDATION_FAST` - default behavior: s2n-tls will perform only the minimum validation required for safe use of the asyn pkey operation.\n - `S2N_ASYNC_PKEY_VALIDATION_STRICT` - in addition to the previous checks, s2n-tls will also ensure that the signature created as a result of the async private key sign operation matches the public key on the connection."]
1718    pub type Type = ::libc::c_uint;
1719    pub const FAST: Type = 0;
1720    pub const STRICT: Type = 1;
1721}
1722pub mod s2n_async_pkey_op_type {
1723    #[doc = " The type of private key operation"]
1724    pub type Type = ::libc::c_uint;
1725    pub const DECRYPT: Type = 0;
1726    pub const SIGN: Type = 1;
1727}
1728#[doc = " Callback function for handling private key operations\n\n Invoked every time an operation requiring the private key is encountered\n during the handshake.\n\n # Safety\n * `op` is owned by the application and MUST be freed.\n\n @param conn Connection which triggered the callback\n @param op An opaque object representing the private key operation"]
1729pub type s2n_async_pkey_fn = ::core::option::Option<
1730    unsafe extern "C" fn(conn: *mut s2n_connection, op: *mut s2n_async_pkey_op) -> ::libc::c_int,
1731>;
1732extern "C" {
1733    #[doc = " Sets up the callback to invoke when private key operations occur.\n\n @param config Config to set the callback\n @param fn The function that should be called for each private key operation"]
1734    pub fn s2n_config_set_async_pkey_callback(
1735        config: *mut s2n_config,
1736        fn_: s2n_async_pkey_fn,
1737    ) -> ::libc::c_int;
1738}
1739extern "C" {
1740    #[doc = " Performs a private key operation using the given private key.\n\n # Safety\n * Can only be called once. Any subsequent calls will produce a `S2N_ERR_T_USAGE` error.\n * Safe to call from inside s2n_async_pkey_fn\n * Safe to call from a different thread, as long as no other thread is operating on `op`.\n\n @param op An opaque object representing the private key operation\n @param key The private key used for the operation. It can be extracted from\n `conn` through the `s2n_connection_get_selected_cert` and `s2n_cert_chain_and_key_get_private_key` calls"]
1741    pub fn s2n_async_pkey_op_perform(
1742        op: *mut s2n_async_pkey_op,
1743        key: *mut s2n_cert_private_key,
1744    ) -> ::libc::c_int;
1745}
1746extern "C" {
1747    #[doc = " Finalizes a private key operation and unblocks the connection.\n\n # Safety\n * `conn` must match the connection that originally triggered the callback.\n * Must be called after the operation is performed.\n * Can only be called once. Any subsequent calls will produce a `S2N_ERR_T_USAGE` error.\n * Safe to call from inside s2n_async_pkey_fn\n * Safe to call from a different thread, as long as no other thread is operating on `op`.\n\n @param op An opaque object representing the private key operation\n @param conn The connection associated with the operation that should be unblocked"]
1748    pub fn s2n_async_pkey_op_apply(
1749        op: *mut s2n_async_pkey_op,
1750        conn: *mut s2n_connection,
1751    ) -> ::libc::c_int;
1752}
1753extern "C" {
1754    #[doc = " Frees the opaque structure representing a private key operation.\n\n # Safety\n * MUST be called for every operation passed to s2n_async_pkey_fn\n * Safe to call before or after the connection that created the operation is freed\n\n @param op An opaque object representing the private key operation"]
1755    pub fn s2n_async_pkey_op_free(op: *mut s2n_async_pkey_op) -> ::libc::c_int;
1756}
1757extern "C" {
1758    #[doc = " Configures whether or not s2n-tls will perform potentially expensive validation of\n the results of a private key operation.\n\n @param config Config to set the validation mode for\n @param mode What level of validation to perform"]
1759    pub fn s2n_config_set_async_pkey_validation_mode(
1760        config: *mut s2n_config,
1761        mode: s2n_async_pkey_validation_mode::Type,
1762    ) -> ::libc::c_int;
1763}
1764extern "C" {
1765    #[doc = " Returns the type of the private key operation.\n\n @param op An opaque object representing the private key operation\n @param type A pointer to be set to the type"]
1766    pub fn s2n_async_pkey_op_get_op_type(
1767        op: *mut s2n_async_pkey_op,
1768        type_: *mut s2n_async_pkey_op_type::Type,
1769    ) -> ::libc::c_int;
1770}
1771extern "C" {
1772    #[doc = " Returns the size of the input to the private key operation.\n\n @param op An opaque object representing the private key operation\n @param data_len A pointer to be set to the size"]
1773    pub fn s2n_async_pkey_op_get_input_size(
1774        op: *mut s2n_async_pkey_op,
1775        data_len: *mut u32,
1776    ) -> ::libc::c_int;
1777}
1778extern "C" {
1779    #[doc = " Returns the input to the private key operation.\n\n When signing, the input is the digest to sign.\n When decrypting, the input is the data to decrypt.\n\n When signing with ML-DSA, the input is the \"external mu\" pre-hash value described in\n https://www.ietf.org/archive/id/draft-ietf-lamps-dilithium-certificates-09.html#appendix-D\n\n # Safety\n * `data` must be sufficiently large to contain the input.\n   `s2n_async_pkey_op_get_input_size` can be called to determine how much memory is required.\n * s2n-tls does not take ownership of `data`.\n   The application still owns the memory and must free it if necessary.\n\n @param op An opaque object representing the private key operation\n @param data A pointer to a buffer to copy the input into\n @param data_len The maximum size of the `data` buffer"]
1780    pub fn s2n_async_pkey_op_get_input(
1781        op: *mut s2n_async_pkey_op,
1782        data: *mut u8,
1783        data_len: u32,
1784    ) -> ::libc::c_int;
1785}
1786extern "C" {
1787    #[doc = " Sets the output of the private key operation.\n\n # Safety\n * s2n-tls does not take ownership of `data`.\n   The application still owns the memory and must free it if necessary.\n\n @param op An opaque object representing the private key operation\n @param data A pointer to a buffer containing the output\n @param data_len The size of the `data` buffer"]
1788    pub fn s2n_async_pkey_op_set_output(
1789        op: *mut s2n_async_pkey_op,
1790        data: *const u8,
1791        data_len: u32,
1792    ) -> ::libc::c_int;
1793}
1794#[doc = " Callback function for handling key log events\n\n THIS SHOULD BE USED FOR DEBUGGING PURPOSES ONLY!\n\n Each log line is formatted with the\n [NSS Key Log Format](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format)\n without a newline.\n\n # Safety\n\n * `ctx` MUST be cast into the same type of pointer that was originally created\n * `logline` bytes MUST be copied or discarded before this function returns\n\n @param ctx Context for the callback\n @param conn Connection for which the log line is being emitted\n @param logline Pointer to the log line data\n @param len Length of the log line data"]
1795pub type s2n_key_log_fn = ::core::option::Option<
1796    unsafe extern "C" fn(
1797        ctx: *mut ::libc::c_void,
1798        conn: *mut s2n_connection,
1799        logline: *mut u8,
1800        len: usize,
1801    ) -> ::libc::c_int,
1802>;
1803extern "C" {
1804    #[doc = " Sets a key logging callback on the provided config\n\n THIS SHOULD BE USED FOR DEBUGGING PURPOSES ONLY!\n\n Setting this function enables configurations to emit secrets in the\n [NSS Key Log Format](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format)\n\n # Safety\n\n * `callback` MUST cast `ctx` into the same type of pointer that was originally created\n * `ctx` MUST live for at least as long as it is set on the config\n\n @param config Config to set the callback\n @param callback The function that should be called for each secret log entry\n @param ctx The context to be passed when the callback is called"]
1805    pub fn s2n_config_set_key_log_cb(
1806        config: *mut s2n_config,
1807        callback: s2n_key_log_fn,
1808        ctx: *mut ::libc::c_void,
1809    ) -> ::libc::c_int;
1810}
1811extern "C" {
1812    #[doc = " s2n_config_enable_cert_req_dss_legacy_compat adds a dss cert type in the server certificate request when being called.\n It only sends the dss cert type in the cert request but does not succeed the handshake if a dss cert is received.\n Please DO NOT call this api unless you know you actually need legacy DSS certificate type compatibility\n @param config Config to enable legacy DSS certificates for"]
1813    pub fn s2n_config_enable_cert_req_dss_legacy_compat(config: *mut s2n_config) -> ::libc::c_int;
1814}
1815extern "C" {
1816    #[doc = " Sets the maximum bytes of early data the server will accept.\n\n The default maximum is 0. If the maximum is 0, the server rejects all early data requests.\n The config maximum can be overridden by the connection maximum or the maximum on an external pre-shared key.\n\n @param config A pointer to the config\n @param max_early_data_size The maximum early data that the server will accept\n @returns A POSIX error signal. If successful, the maximum early data size was updated."]
1817    pub fn s2n_config_set_server_max_early_data_size(
1818        config: *mut s2n_config,
1819        max_early_data_size: u32,
1820    ) -> ::libc::c_int;
1821}
1822extern "C" {
1823    #[doc = " Sets the maximum bytes of early data the server will accept.\n\n The default maximum is 0. If the maximum is 0, the server rejects all early data requests.\n The connection maximum can be overridden by the maximum on an external pre-shared key.\n\n @param conn A pointer to the connection\n @param max_early_data_size The maximum early data the server will accept\n @returns A POSIX error signal. If successful, the maximum early data size was updated."]
1824    pub fn s2n_connection_set_server_max_early_data_size(
1825        conn: *mut s2n_connection,
1826        max_early_data_size: u32,
1827    ) -> ::libc::c_int;
1828}
1829extern "C" {
1830    #[doc = " Sets the user context associated with early data on a server.\n\n This context is passed to the `s2n_early_data_cb` callback to help decide whether to accept or reject early data.\n\n Unlike most contexts, the early data context is a byte buffer instead of a void pointer.\n This is because we need to serialize the context into session tickets.\n\n This API is intended for use with session resumption, and will not affect pre-shared keys.\n\n @param conn A pointer to the connection\n @param context A pointer to the user context data. This data will be copied.\n @param context_size The size of the data to read from the `context` pointer.\n @returns A POSIX error signal. If successful, the context was updated."]
1831    pub fn s2n_connection_set_server_early_data_context(
1832        conn: *mut s2n_connection,
1833        context: *const u8,
1834        context_size: u16,
1835    ) -> ::libc::c_int;
1836}
1837extern "C" {
1838    #[doc = " Configures a particular pre-shared key to allow early data.\n\n `max_early_data_size` must be set to the maximum early data accepted by the server.\n\n In order to use early data, the cipher suite set on the pre-shared key must match the cipher suite\n ultimately negotiated by the TLS handshake. Additionally, the cipher suite must have the same\n hmac algorithm as the pre-shared key.\n\n @param psk A pointer to the pre-shared key, created with `s2n_external_psk_new`.\n @param max_early_data_size The maximum early data that can be sent or received using this key.\n @param cipher_suite_first_byte The first byte in the registered IANA value of the associated cipher suite.\n @param cipher_suite_second_byte The second byte in the registered IANA value of the associated cipher suite.\n @returns A POSIX error signal. If successful, `psk` was updated."]
1839    pub fn s2n_psk_configure_early_data(
1840        psk: *mut s2n_psk,
1841        max_early_data_size: u32,
1842        cipher_suite_first_byte: u8,
1843        cipher_suite_second_byte: u8,
1844    ) -> ::libc::c_int;
1845}
1846extern "C" {
1847    #[doc = " Sets the optional `application_protocol` associated with the given pre-shared key.\n\n In order to use early data, the `application_protocol` set on the pre-shared key must match\n the `application_protocol` ultimately negotiated by the TLS handshake.\n\n @param psk A pointer to the pre-shared key, created with `s2n_external_psk_new`.\n @param application_protocol A pointer to the associated application protocol data. This data will be copied.\n @param size The size of the data to read from the `application_protocol` pointer.\n @returns A POSIX error signal. If successful, the application protocol was set."]
1848    pub fn s2n_psk_set_application_protocol(
1849        psk: *mut s2n_psk,
1850        application_protocol: *const u8,
1851        size: u8,
1852    ) -> ::libc::c_int;
1853}
1854extern "C" {
1855    #[doc = " Sets the optional user early data context associated with the given pre-shared key.\n\n The early data context is passed to the `s2n_early_data_cb` callback to help decide whether\n to accept or reject early data.\n\n @param psk A pointer to the pre-shared key, created with `s2n_external_psk_new`.\n @param context A pointer to the associated user context data. This data will be copied.\n @param size The size of the data to read from the `context` pointer.\n @returns A POSIX error signal. If successful, the context was set."]
1856    pub fn s2n_psk_set_early_data_context(
1857        psk: *mut s2n_psk,
1858        context: *const u8,
1859        size: u16,
1860    ) -> ::libc::c_int;
1861}
1862pub mod s2n_early_data_status_t {
1863    #[doc = " The status of early data on a connection.\n\n S2N_EARLY_DATA_STATUS_OK: Early data is in progress.\n S2N_EARLY_DATA_STATUS_NOT_REQUESTED: The client did not request early data, so none was sent or received.\n S2N_EARLY_DATA_STATUS_REJECTED: The client requested early data, but the server rejected the request.\n                                 Early data may have been sent, but was not received.\n S2N_EARLY_DATA_STATUS_END: All early data was successfully sent and received."]
1864    pub type Type = ::libc::c_uint;
1865    pub const OK: Type = 0;
1866    pub const NOT_REQUESTED: Type = 1;
1867    pub const REJECTED: Type = 2;
1868    pub const END: Type = 3;
1869}
1870extern "C" {
1871    #[doc = " Reports the current state of early data for a connection.\n\n See `s2n_early_data_status_t` for all possible states.\n\n @param conn A pointer to the connection\n @param status A pointer which will be set to the current early data status\n @returns A POSIX error signal."]
1872    pub fn s2n_connection_get_early_data_status(
1873        conn: *mut s2n_connection,
1874        status: *mut s2n_early_data_status_t::Type,
1875    ) -> ::libc::c_int;
1876}
1877extern "C" {
1878    #[doc = " Reports the remaining size of the early data allowed by a connection.\n\n If early data was rejected or not requested, the remaining early data size is 0.\n Otherwise, the remaining early data size is the maximum early data allowed by the connection,\n minus the early data sent or received so far.\n\n @param conn A pointer to the connection\n @param allowed_early_data_size A pointer which will be set to the remaining early data currently allowed by `conn`\n @returns A POSIX error signal."]
1879    pub fn s2n_connection_get_remaining_early_data_size(
1880        conn: *mut s2n_connection,
1881        allowed_early_data_size: *mut u32,
1882    ) -> ::libc::c_int;
1883}
1884extern "C" {
1885    #[doc = " Reports the maximum size of the early data allowed by a connection.\n\n This is the maximum amount of early data that can ever be sent and received for a connection.\n It is not affected by the actual status of the early data, so can be non-zero even if early data\n is rejected or not requested.\n\n @param conn A pointer to the connection\n @param max_early_data_size A pointer which will be set to the maximum early data allowed by `conn`\n @returns A POSIX error signal."]
1886    pub fn s2n_connection_get_max_early_data_size(
1887        conn: *mut s2n_connection,
1888        max_early_data_size: *mut u32,
1889    ) -> ::libc::c_int;
1890}
1891extern "C" {
1892    #[doc = " Called by the client to begin negotiation and send early data.\n\n See https://github.com/aws/s2n-tls/blob/main/docs/usage-guide/topics/ch14-early-data.md\n for usage and examples. DO NOT USE unless you have considered the security issues and\n implemented mitigation for anti-replay attacks.\n\n @param conn A pointer to the connection\n @param data A pointer to the early data to be sent\n @param data_len The size of the early data to send\n @param data_sent A pointer which will be set to the size of the early data sent\n @param blocked A pointer which will be set to the blocked status, as in `s2n_negotiate`.\n @returns A POSIX error signal. The error should be handled as in `s2n_negotiate`."]
1893    pub fn s2n_send_early_data(
1894        conn: *mut s2n_connection,
1895        data: *const u8,
1896        data_len: isize,
1897        data_sent: *mut isize,
1898        blocked: *mut s2n_blocked_status::Type,
1899    ) -> ::libc::c_int;
1900}
1901extern "C" {
1902    #[doc = " Called by the server to begin negotiation and accept any early data the client sends.\n\n See https://github.com/aws/s2n-tls/blob/main/docs/usage-guide/topics/ch14-early-data.md\n for usage and examples. DO NOT USE unless you have considered the security issues and\n implemented mitigation for anti-replay attacks.\n\n @param conn A pointer to the connection\n @param data A pointer to a buffer to store the early data received\n @param max_data_len The size of the early data buffer\n @param data_received A pointer which will be set to the size of the early data received\n @param blocked A pointer which will be set to the blocked status, as in `s2n_negotiate`.\n @returns A POSIX error signal. The error should be handled as in `s2n_negotiate`."]
1903    pub fn s2n_recv_early_data(
1904        conn: *mut s2n_connection,
1905        data: *mut u8,
1906        max_data_len: isize,
1907        data_received: *mut isize,
1908        blocked: *mut s2n_blocked_status::Type,
1909    ) -> ::libc::c_int;
1910}
1911#[repr(C)]
1912#[derive(Debug, Copy, Clone)]
1913pub struct s2n_offered_early_data {
1914    _unused: [u8; 0],
1915}
1916#[doc = " A callback which can be implemented to accept or reject early data.\n\n This callback is triggered only after the server has determined early data is otherwise acceptable according\n to the TLS early data specification. Implementations therefore only need to cover application-specific checks,\n not the standard TLS early data validation.\n\n This callback can be synchronous or asynchronous. For asynchronous behavior, return success without\n calling `s2n_offered_early_data_reject` or `s2n_offered_early_data_accept`. `early_data` will\n still be a valid reference, and the connection will block until `s2n_offered_early_data_reject` or\n `s2n_offered_early_data_accept` is called.\n\n @param conn A pointer to the connection\n @param early_data A pointer which can be used to access information about the proposed early data\n                   and then accept or reject it.\n @returns A POSIX error signal. If unsuccessful, the connection will be closed with an error."]
1917pub type s2n_early_data_cb = ::core::option::Option<
1918    unsafe extern "C" fn(
1919        conn: *mut s2n_connection,
1920        early_data: *mut s2n_offered_early_data,
1921    ) -> ::libc::c_int,
1922>;
1923extern "C" {
1924    #[doc = " Set a callback to accept or reject early data.\n\n @param config A pointer to the connection config\n @param cb A pointer to the implementation of the callback.\n @returns A POSIX error signal. If successful, the callback was set."]
1925    pub fn s2n_config_set_early_data_cb(
1926        config: *mut s2n_config,
1927        cb: s2n_early_data_cb,
1928    ) -> ::libc::c_int;
1929}
1930extern "C" {
1931    #[doc = " Get the length of the early data context set by the user.\n\n @param early_data A pointer to the early data information\n @param context_len The length of the user context\n @returns A POSIX error signal."]
1932    pub fn s2n_offered_early_data_get_context_length(
1933        early_data: *mut s2n_offered_early_data,
1934        context_len: *mut u16,
1935    ) -> ::libc::c_int;
1936}
1937extern "C" {
1938    #[doc = " Get the early data context set by the user.\n\n @param early_data A pointer to the early data information\n @param context A byte buffer to copy the user context into\n @param max_len The size of `context`. Must be >= to the result of `s2n_offered_early_data_get_context_length`.\n @returns A POSIX error signal."]
1939    pub fn s2n_offered_early_data_get_context(
1940        early_data: *mut s2n_offered_early_data,
1941        context: *mut u8,
1942        max_len: u16,
1943    ) -> ::libc::c_int;
1944}
1945extern "C" {
1946    #[doc = " Reject early data offered by the client.\n\n @param early_data A pointer to the early data information\n @returns A POSIX error signal. If success, the client's early data will be rejected."]
1947    pub fn s2n_offered_early_data_reject(early_data: *mut s2n_offered_early_data) -> ::libc::c_int;
1948}
1949extern "C" {
1950    #[doc = " Accept early data offered by the client.\n\n @param early_data A pointer to the early data information\n @returns A POSIX error signal. If success, the client's early data will be accepted."]
1951    pub fn s2n_offered_early_data_accept(early_data: *mut s2n_offered_early_data) -> ::libc::c_int;
1952}
1953extern "C" {
1954    #[doc = " Retrieves the list of supported groups configured by the security policy associated with `config`.\n\n The retrieved list of groups will contain all of the supported groups for a security policy that are compatible\n with the build of s2n-tls. For instance, PQ kem groups that are not supported by the linked libcrypto will not\n be written. Otherwise, all of the supported groups configured for the security policy will be written. This API\n can be used with the s2n_client_hello_get_supported_groups() API as a means of comparing compatibility between\n a client and server.\n\n IANA values for each of the supported groups are written to the provided `groups` array, and `groups_count` is\n set to the number of written supported groups.\n\n `groups_count_max` should be set to the maximum capacity of the `groups` array. If `groups_count_max` is less\n than the number of supported groups configured by the security policy, this function will error.\n\n Note that this API retrieves only the groups from a security policy that are available to negotiate via the\n supported groups extension, and does not return TLS 1.2 PQ kem groups that are negotiated in the supported PQ\n kem parameters extension.\n\n @param config A pointer to the s2n_config object from which the supported groups will be retrieved.\n @param groups The array to populate with the supported groups.\n @param groups_count_max The maximum number of supported groups that can fit in the `groups` array.\n @param groups_count Set to the number of supported groups written to `groups`.\n @returns S2N_SUCCESS on success. S2N_FAILURE on failure."]
1955    pub fn s2n_config_get_supported_groups(
1956        config: *mut s2n_config,
1957        groups: *mut u16,
1958        groups_count_max: u16,
1959        groups_count: *mut u16,
1960    ) -> ::libc::c_int;
1961}
1962pub mod s2n_serialization_version {
1963    pub type Type = ::libc::c_uint;
1964    pub const SERIALIZED_CONN_NONE: Type = 0;
1965    pub const SERIALIZED_CONN_V1: Type = 1;
1966}
1967extern "C" {
1968    #[doc = " Set what version to use when serializing connections\n\n A version is required to serialize connections. Versioning ensures that all features negotiated\n during the handshake will be available wherever the connection is deserialized. Applications may\n need to update this version to pick up new features, since versioning may disable newer TLS\n features to ensure compatibility.\n\n @param config A pointer to the config object.\n @param version The requested version.\n @returns S2N_SUCCESS on success, S2N_FAILURE on error."]
1969    pub fn s2n_config_set_serialization_version(
1970        config: *mut s2n_config,
1971        version: s2n_serialization_version::Type,
1972    ) -> ::libc::c_int;
1973}
1974extern "C" {
1975    #[doc = " Retrieves the length of the serialized connection from `s2n_connection_serialize()`. Should be\n used to allocate enough memory for the serialized connection buffer.\n\n @note The size of the serialized connection changes based on parameters negotiated in the TLS\n handshake. Do not expect the size to always remain the same.\n\n @param conn A pointer to the connection object.\n @param length Output parameter where the length will be written.\n @returns S2N_SUCCESS on success, S2N_FAILURE on error."]
1976    pub fn s2n_connection_serialization_length(
1977        conn: *mut s2n_connection,
1978        length: *mut u32,
1979    ) -> ::libc::c_int;
1980}
1981extern "C" {
1982    #[doc = " Serializes the s2n_connection into the provided buffer.\n\n This API takes an established s2n-tls connection object and \"serializes\" it\n into a transferable object to be sent off-box or to another process. This transferable object can\n then be \"deserialized\" using the `s2n_connection_deserialize` method to instantiate an s2n-tls\n connection object that can talk to the original peer with the same encryption keys.\n\n @warning This feature is dangerous because it provides cryptographic material from a TLS session\n in plaintext. Users MUST both encrypt and MAC the contents of the outputted material to provide\n secrecy and integrity if this material is transported off-box. DO NOT store or send this material off-box\n without encryption.\n\n @note You MUST have used `s2n_config_set_serialization_version()` to set a version on the\n s2n_config object associated with this connection before this connection began its TLS handshake.\n @note Call `s2n_connection_serialization_length` to retrieve the amount of memory needed for the\n buffer parameter.\n @note This API will error if the handshake is not yet complete.\n\n @param conn A pointer to the connection object.\n @param buffer A pointer to the buffer where the serialized connection will be written.\n @param buffer_length Maximum amount of data that can be written to the buffer param.\n @returns S2N_SUCCESS on success, S2N_FAILURE on error."]
1983    pub fn s2n_connection_serialize(
1984        conn: *mut s2n_connection,
1985        buffer: *mut u8,
1986        buffer_length: u32,
1987    ) -> ::libc::c_int;
1988}
1989extern "C" {
1990    #[doc = " Deserializes the provided buffer into the `s2n_connection` parameter.\n\n @warning s2n-tls DOES NOT check the integrity of the provided buffer. s2n-tls may successfully\n deserialize a corrupted buffer which WILL cause a connection failure when attempting to resume\n sending/receiving encrypted data. To avoid this, it is recommended to MAC and encrypt the serialized\n connection before sending it off-box and deserializing it.\n\n @warning Only a minimal amount of information about the original TLS connection is serialized.\n Therefore, after deserialization, the connection will behave like a new `s2n_connection` from the\n `s2n_connection_new()` call, except that it can read/write encrypted data from a peer. Any desired\n config-level or connection-level configuration will need to be re-applied to the deserialized connection.\n For this same reason none of the connection getters will return useful information about the\n original connection after deserialization. Any information about the original connection needs to\n be retrieved before serialization.\n\n @param conn A pointer to the connection object. Should be a new s2n_connection object.\n @param buffer A pointer to the buffer where the serialized connection will be read from.\n @param buffer_length Maximum amount of data that can be read from the buffer parameter.\n @returns S2N_SUCCESS on success, S2N_FAILURE on error."]
1991    pub fn s2n_connection_deserialize(
1992        conn: *mut s2n_connection,
1993        buffer: *mut u8,
1994        buffer_length: u32,
1995    ) -> ::libc::c_int;
1996}
1997extern "C" {
1998    pub fn s2n_config_set_cert_authorities_from_trust_store(
1999        config: *mut s2n_config,
2000    ) -> ::libc::c_int;
2001}