1e5b75505Sopenharmony_ci/*
2e5b75505Sopenharmony_ci * SSL/TLS interface definition
3e5b75505Sopenharmony_ci * Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
4e5b75505Sopenharmony_ci *
5e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license.
6e5b75505Sopenharmony_ci * See README for more details.
7e5b75505Sopenharmony_ci */
8e5b75505Sopenharmony_ci
9e5b75505Sopenharmony_ci#ifndef TLS_H
10e5b75505Sopenharmony_ci#define TLS_H
11e5b75505Sopenharmony_ci
12e5b75505Sopenharmony_cistruct tls_connection;
13e5b75505Sopenharmony_ci
14e5b75505Sopenharmony_cistruct tls_random {
15e5b75505Sopenharmony_ci	const u8 *client_random;
16e5b75505Sopenharmony_ci	size_t client_random_len;
17e5b75505Sopenharmony_ci	const u8 *server_random;
18e5b75505Sopenharmony_ci	size_t server_random_len;
19e5b75505Sopenharmony_ci};
20e5b75505Sopenharmony_ci
21e5b75505Sopenharmony_cienum tls_event {
22e5b75505Sopenharmony_ci	TLS_CERT_CHAIN_SUCCESS,
23e5b75505Sopenharmony_ci	TLS_CERT_CHAIN_FAILURE,
24e5b75505Sopenharmony_ci	TLS_PEER_CERTIFICATE,
25e5b75505Sopenharmony_ci	TLS_ALERT
26e5b75505Sopenharmony_ci};
27e5b75505Sopenharmony_ci
28e5b75505Sopenharmony_ci/*
29e5b75505Sopenharmony_ci * Note: These are used as identifier with external programs and as such, the
30e5b75505Sopenharmony_ci * values must not be changed.
31e5b75505Sopenharmony_ci */
32e5b75505Sopenharmony_cienum tls_fail_reason {
33e5b75505Sopenharmony_ci	TLS_FAIL_UNSPECIFIED = 0,
34e5b75505Sopenharmony_ci	TLS_FAIL_UNTRUSTED = 1,
35e5b75505Sopenharmony_ci	TLS_FAIL_REVOKED = 2,
36e5b75505Sopenharmony_ci	TLS_FAIL_NOT_YET_VALID = 3,
37e5b75505Sopenharmony_ci	TLS_FAIL_EXPIRED = 4,
38e5b75505Sopenharmony_ci	TLS_FAIL_SUBJECT_MISMATCH = 5,
39e5b75505Sopenharmony_ci	TLS_FAIL_ALTSUBJECT_MISMATCH = 6,
40e5b75505Sopenharmony_ci	TLS_FAIL_BAD_CERTIFICATE = 7,
41e5b75505Sopenharmony_ci	TLS_FAIL_SERVER_CHAIN_PROBE = 8,
42e5b75505Sopenharmony_ci	TLS_FAIL_DOMAIN_SUFFIX_MISMATCH = 9,
43e5b75505Sopenharmony_ci	TLS_FAIL_DOMAIN_MISMATCH = 10,
44e5b75505Sopenharmony_ci	TLS_FAIL_INSUFFICIENT_KEY_LEN = 11,
45e5b75505Sopenharmony_ci	TLS_FAIL_DN_MISMATCH = 12,
46e5b75505Sopenharmony_ci};
47e5b75505Sopenharmony_ci
48e5b75505Sopenharmony_ci
49e5b75505Sopenharmony_ci#define TLS_MAX_ALT_SUBJECT 10
50e5b75505Sopenharmony_ci
51e5b75505Sopenharmony_cistruct tls_cert_data {
52e5b75505Sopenharmony_ci	int depth;
53e5b75505Sopenharmony_ci	const char *subject;
54e5b75505Sopenharmony_ci	const struct wpabuf *cert;
55e5b75505Sopenharmony_ci	const u8 *hash;
56e5b75505Sopenharmony_ci	size_t hash_len;
57e5b75505Sopenharmony_ci	const char *altsubject[TLS_MAX_ALT_SUBJECT];
58e5b75505Sopenharmony_ci	int num_altsubject;
59e5b75505Sopenharmony_ci	const char *serial_num;
60e5b75505Sopenharmony_ci	int tod;
61e5b75505Sopenharmony_ci};
62e5b75505Sopenharmony_ci
63e5b75505Sopenharmony_ciunion tls_event_data {
64e5b75505Sopenharmony_ci	struct {
65e5b75505Sopenharmony_ci		int depth;
66e5b75505Sopenharmony_ci		const char *subject;
67e5b75505Sopenharmony_ci		enum tls_fail_reason reason;
68e5b75505Sopenharmony_ci		const char *reason_txt;
69e5b75505Sopenharmony_ci		const struct wpabuf *cert;
70e5b75505Sopenharmony_ci	} cert_fail;
71e5b75505Sopenharmony_ci
72e5b75505Sopenharmony_ci	struct tls_cert_data peer_cert;
73e5b75505Sopenharmony_ci
74e5b75505Sopenharmony_ci	struct {
75e5b75505Sopenharmony_ci		int is_local;
76e5b75505Sopenharmony_ci		const char *type;
77e5b75505Sopenharmony_ci		const char *description;
78e5b75505Sopenharmony_ci	} alert;
79e5b75505Sopenharmony_ci};
80e5b75505Sopenharmony_ci
81e5b75505Sopenharmony_cistruct tls_config {
82e5b75505Sopenharmony_ci	const char *opensc_engine_path;
83e5b75505Sopenharmony_ci	const char *pkcs11_engine_path;
84e5b75505Sopenharmony_ci	const char *pkcs11_module_path;
85e5b75505Sopenharmony_ci	int fips_mode;
86e5b75505Sopenharmony_ci	int cert_in_cb;
87e5b75505Sopenharmony_ci	const char *openssl_ciphers;
88e5b75505Sopenharmony_ci	unsigned int tls_session_lifetime;
89e5b75505Sopenharmony_ci	unsigned int crl_reload_interval;
90e5b75505Sopenharmony_ci	unsigned int tls_flags;
91e5b75505Sopenharmony_ci
92e5b75505Sopenharmony_ci	void (*event_cb)(void *ctx, enum tls_event ev,
93e5b75505Sopenharmony_ci			 union tls_event_data *data);
94e5b75505Sopenharmony_ci	void *cb_ctx;
95e5b75505Sopenharmony_ci};
96e5b75505Sopenharmony_ci
97e5b75505Sopenharmony_ci#define TLS_CONN_ALLOW_SIGN_RSA_MD5 BIT(0)
98e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_TIME_CHECKS BIT(1)
99e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_SESSION_TICKET BIT(2)
100e5b75505Sopenharmony_ci#define TLS_CONN_REQUEST_OCSP BIT(3)
101e5b75505Sopenharmony_ci#define TLS_CONN_REQUIRE_OCSP BIT(4)
102e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_TLSv1_1 BIT(5)
103e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_TLSv1_2 BIT(6)
104e5b75505Sopenharmony_ci#define TLS_CONN_EAP_FAST BIT(7)
105e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_TLSv1_0 BIT(8)
106e5b75505Sopenharmony_ci#define TLS_CONN_EXT_CERT_CHECK BIT(9)
107e5b75505Sopenharmony_ci#define TLS_CONN_REQUIRE_OCSP_ALL BIT(10)
108e5b75505Sopenharmony_ci#define TLS_CONN_SUITEB BIT(11)
109e5b75505Sopenharmony_ci#define TLS_CONN_SUITEB_NO_ECDH BIT(12)
110e5b75505Sopenharmony_ci#define TLS_CONN_DISABLE_TLSv1_3 BIT(13)
111e5b75505Sopenharmony_ci#define TLS_CONN_ENABLE_TLSv1_0 BIT(14)
112e5b75505Sopenharmony_ci#define TLS_CONN_ENABLE_TLSv1_1 BIT(15)
113e5b75505Sopenharmony_ci#define TLS_CONN_ENABLE_TLSv1_2 BIT(16)
114e5b75505Sopenharmony_ci#define TLS_CONN_TEAP_ANON_DH BIT(17)
115e5b75505Sopenharmony_ci
116e5b75505Sopenharmony_ci/**
117e5b75505Sopenharmony_ci * struct tls_connection_params - Parameters for TLS connection
118e5b75505Sopenharmony_ci * @ca_cert: File or reference name for CA X.509 certificate in PEM or DER
119e5b75505Sopenharmony_ci * format
120e5b75505Sopenharmony_ci * @ca_cert_blob: ca_cert as inlined data or %NULL if not used
121e5b75505Sopenharmony_ci * @ca_cert_blob_len: ca_cert_blob length
122e5b75505Sopenharmony_ci * @ca_path: Path to CA certificates (OpenSSL specific)
123e5b75505Sopenharmony_ci * @subject_match: String to match in the subject of the peer certificate or
124e5b75505Sopenharmony_ci * %NULL to allow all subjects
125e5b75505Sopenharmony_ci * @altsubject_match: String to match in the alternative subject of the peer
126e5b75505Sopenharmony_ci * certificate or %NULL to allow all alternative subjects
127e5b75505Sopenharmony_ci * @suffix_match: Semicolon deliminated string of values to suffix match against
128e5b75505Sopenharmony_ci * the dNSName or CN of the peer certificate or %NULL to allow all domain names.
129e5b75505Sopenharmony_ci * This may allow subdomains and wildcard certificates. Each domain name label
130e5b75505Sopenharmony_ci * must have a full case-insensitive match.
131e5b75505Sopenharmony_ci * @domain_match: String to match in the dNSName or CN of the peer
132e5b75505Sopenharmony_ci * certificate or %NULL to allow all domain names. This requires a full,
133e5b75505Sopenharmony_ci * case-insensitive match.
134e5b75505Sopenharmony_ci *
135e5b75505Sopenharmony_ci * More than one match string can be provided by using semicolons to
136e5b75505Sopenharmony_ci * separate the strings (e.g., example.org;example.com). When multiple
137e5b75505Sopenharmony_ci * strings are specified, a match with any one of the values is
138e5b75505Sopenharmony_ci * considered a sufficient match for the certificate, i.e., the
139e5b75505Sopenharmony_ci * conditions are ORed together.
140e5b75505Sopenharmony_ci * @client_cert: File or reference name for client X.509 certificate in PEM or
141e5b75505Sopenharmony_ci * DER format
142e5b75505Sopenharmony_ci * @client_cert_blob: client_cert as inlined data or %NULL if not used
143e5b75505Sopenharmony_ci * @client_cert_blob_len: client_cert_blob length
144e5b75505Sopenharmony_ci * @private_key: File or reference name for client private key in PEM or DER
145e5b75505Sopenharmony_ci * format (traditional format (RSA PRIVATE KEY) or PKCS#8 (PRIVATE KEY)
146e5b75505Sopenharmony_ci * @private_key_blob: private_key as inlined data or %NULL if not used
147e5b75505Sopenharmony_ci * @private_key_blob_len: private_key_blob length
148e5b75505Sopenharmony_ci * @private_key_passwd: Passphrase for decrypted private key, %NULL if no
149e5b75505Sopenharmony_ci * passphrase is used.
150e5b75505Sopenharmony_ci * @dh_file: File name for DH/DSA data in PEM format, or %NULL if not used
151e5b75505Sopenharmony_ci * @dh_blob: dh_file as inlined data or %NULL if not used
152e5b75505Sopenharmony_ci * @dh_blob_len: dh_blob length
153e5b75505Sopenharmony_ci * @engine: 1 = use engine (e.g., a smartcard) for private key operations
154e5b75505Sopenharmony_ci * (this is OpenSSL specific for now)
155e5b75505Sopenharmony_ci * @engine_id: engine id string (this is OpenSSL specific for now)
156e5b75505Sopenharmony_ci * @ppin: pointer to the pin variable in the configuration
157e5b75505Sopenharmony_ci * (this is OpenSSL specific for now)
158e5b75505Sopenharmony_ci * @key_id: the private key's id when using engine (this is OpenSSL
159e5b75505Sopenharmony_ci * specific for now)
160e5b75505Sopenharmony_ci * @cert_id: the certificate's id when using engine
161e5b75505Sopenharmony_ci * @ca_cert_id: the CA certificate's id when using engine
162e5b75505Sopenharmony_ci * @openssl_ciphers: OpenSSL cipher configuration
163e5b75505Sopenharmony_ci * @openssl_ecdh_curves: OpenSSL ECDH curve configuration. %NULL for auto if
164e5b75505Sopenharmony_ci *	supported, empty string to disable, or a colon-separated curve list.
165e5b75505Sopenharmony_ci * @flags: Parameter options (TLS_CONN_*)
166e5b75505Sopenharmony_ci * @ocsp_stapling_response: DER encoded file with cached OCSP stapling response
167e5b75505Sopenharmony_ci *	or %NULL if OCSP is not enabled
168e5b75505Sopenharmony_ci * @ocsp_stapling_response_multi: DER encoded file with cached OCSP stapling
169e5b75505Sopenharmony_ci *	response list (OCSPResponseList for ocsp_multi in RFC 6961) or %NULL if
170e5b75505Sopenharmony_ci *	ocsp_multi is not enabled
171e5b75505Sopenharmony_ci * @check_cert_subject: Client certificate subject name matching string
172e5b75505Sopenharmony_ci *
173e5b75505Sopenharmony_ci * TLS connection parameters to be configured with tls_connection_set_params()
174e5b75505Sopenharmony_ci * and tls_global_set_params().
175e5b75505Sopenharmony_ci *
176e5b75505Sopenharmony_ci * Certificates and private key can be configured either as a reference name
177e5b75505Sopenharmony_ci * (file path or reference to certificate store) or by providing the same data
178e5b75505Sopenharmony_ci * as a pointer to the data in memory. Only one option will be used for each
179e5b75505Sopenharmony_ci * field.
180e5b75505Sopenharmony_ci */
181e5b75505Sopenharmony_cistruct tls_connection_params {
182e5b75505Sopenharmony_ci	const char *ca_cert;
183e5b75505Sopenharmony_ci	const u8 *ca_cert_blob;
184e5b75505Sopenharmony_ci	size_t ca_cert_blob_len;
185e5b75505Sopenharmony_ci	const char *ca_path;
186e5b75505Sopenharmony_ci	const char *subject_match;
187e5b75505Sopenharmony_ci	const char *altsubject_match;
188e5b75505Sopenharmony_ci	const char *suffix_match;
189e5b75505Sopenharmony_ci	const char *domain_match;
190e5b75505Sopenharmony_ci	const char *client_cert;
191e5b75505Sopenharmony_ci	const char *client_cert2;
192e5b75505Sopenharmony_ci	const u8 *client_cert_blob;
193e5b75505Sopenharmony_ci	size_t client_cert_blob_len;
194e5b75505Sopenharmony_ci	const char *private_key;
195e5b75505Sopenharmony_ci	const char *private_key2;
196e5b75505Sopenharmony_ci	const u8 *private_key_blob;
197e5b75505Sopenharmony_ci	size_t private_key_blob_len;
198e5b75505Sopenharmony_ci	const char *private_key_passwd;
199e5b75505Sopenharmony_ci	const char *private_key_passwd2;
200e5b75505Sopenharmony_ci	const char *dh_file;
201e5b75505Sopenharmony_ci	const u8 *dh_blob;
202e5b75505Sopenharmony_ci	size_t dh_blob_len;
203e5b75505Sopenharmony_ci
204e5b75505Sopenharmony_ci	/* OpenSSL specific variables */
205e5b75505Sopenharmony_ci	int engine;
206e5b75505Sopenharmony_ci	const char *engine_id;
207e5b75505Sopenharmony_ci	const char *pin;
208e5b75505Sopenharmony_ci	const char *key_id;
209e5b75505Sopenharmony_ci	const char *cert_id;
210e5b75505Sopenharmony_ci	const char *ca_cert_id;
211e5b75505Sopenharmony_ci	const char *openssl_ciphers;
212e5b75505Sopenharmony_ci	const char *openssl_ecdh_curves;
213e5b75505Sopenharmony_ci
214e5b75505Sopenharmony_ci	unsigned int flags;
215e5b75505Sopenharmony_ci	const char *ocsp_stapling_response;
216e5b75505Sopenharmony_ci	const char *ocsp_stapling_response_multi;
217e5b75505Sopenharmony_ci	const char *check_cert_subject;
218e5b75505Sopenharmony_ci};
219e5b75505Sopenharmony_ci
220e5b75505Sopenharmony_ci
221e5b75505Sopenharmony_ci/**
222e5b75505Sopenharmony_ci * tls_init - Initialize TLS library
223e5b75505Sopenharmony_ci * @conf: Configuration data for TLS library
224e5b75505Sopenharmony_ci * Returns: Context data to be used as tls_ctx in calls to other functions,
225e5b75505Sopenharmony_ci * or %NULL on failure.
226e5b75505Sopenharmony_ci *
227e5b75505Sopenharmony_ci * Called once during program startup and once for each RSN pre-authentication
228e5b75505Sopenharmony_ci * session. In other words, there can be two concurrent TLS contexts. If global
229e5b75505Sopenharmony_ci * library initialization is needed (i.e., one that is shared between both
230e5b75505Sopenharmony_ci * authentication types), the TLS library wrapper should maintain a reference
231e5b75505Sopenharmony_ci * counter and do global initialization only when moving from 0 to 1 reference.
232e5b75505Sopenharmony_ci */
233e5b75505Sopenharmony_civoid * tls_init(const struct tls_config *conf);
234e5b75505Sopenharmony_ci
235e5b75505Sopenharmony_ci/**
236e5b75505Sopenharmony_ci * tls_deinit - Deinitialize TLS library
237e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
238e5b75505Sopenharmony_ci *
239e5b75505Sopenharmony_ci * Called once during program shutdown and once for each RSN pre-authentication
240e5b75505Sopenharmony_ci * session. If global library deinitialization is needed (i.e., one that is
241e5b75505Sopenharmony_ci * shared between both authentication types), the TLS library wrapper should
242e5b75505Sopenharmony_ci * maintain a reference counter and do global deinitialization only when moving
243e5b75505Sopenharmony_ci * from 1 to 0 references.
244e5b75505Sopenharmony_ci */
245e5b75505Sopenharmony_civoid tls_deinit(void *tls_ctx);
246e5b75505Sopenharmony_ci
247e5b75505Sopenharmony_ci/**
248e5b75505Sopenharmony_ci * tls_get_errors - Process pending errors
249e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
250e5b75505Sopenharmony_ci * Returns: Number of found error, 0 if no errors detected.
251e5b75505Sopenharmony_ci *
252e5b75505Sopenharmony_ci * Process all pending TLS errors.
253e5b75505Sopenharmony_ci */
254e5b75505Sopenharmony_ciint tls_get_errors(void *tls_ctx);
255e5b75505Sopenharmony_ci
256e5b75505Sopenharmony_ci/**
257e5b75505Sopenharmony_ci * tls_connection_init - Initialize a new TLS connection
258e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
259e5b75505Sopenharmony_ci * Returns: Connection context data, conn for other function calls
260e5b75505Sopenharmony_ci */
261e5b75505Sopenharmony_cistruct tls_connection * tls_connection_init(void *tls_ctx);
262e5b75505Sopenharmony_ci
263e5b75505Sopenharmony_ci/**
264e5b75505Sopenharmony_ci * tls_connection_deinit - Free TLS connection data
265e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
266e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
267e5b75505Sopenharmony_ci *
268e5b75505Sopenharmony_ci * Release all resources allocated for TLS connection.
269e5b75505Sopenharmony_ci */
270e5b75505Sopenharmony_civoid tls_connection_deinit(void *tls_ctx, struct tls_connection *conn);
271e5b75505Sopenharmony_ci
272e5b75505Sopenharmony_ci/**
273e5b75505Sopenharmony_ci * tls_connection_established - Has the TLS connection been completed?
274e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
275e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
276e5b75505Sopenharmony_ci * Returns: 1 if TLS connection has been completed, 0 if not.
277e5b75505Sopenharmony_ci */
278e5b75505Sopenharmony_ciint tls_connection_established(void *tls_ctx, struct tls_connection *conn);
279e5b75505Sopenharmony_ci
280e5b75505Sopenharmony_ci/**
281e5b75505Sopenharmony_ci * tls_connection_peer_serial_num - Fetch peer certificate serial number
282e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
283e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
284e5b75505Sopenharmony_ci * Returns: Allocated string buffer containing the peer certificate serial
285e5b75505Sopenharmony_ci * number or %NULL on error.
286e5b75505Sopenharmony_ci *
287e5b75505Sopenharmony_ci * The caller is responsible for freeing the returned buffer with os_free().
288e5b75505Sopenharmony_ci */
289e5b75505Sopenharmony_cichar * tls_connection_peer_serial_num(void *tls_ctx,
290e5b75505Sopenharmony_ci				      struct tls_connection *conn);
291e5b75505Sopenharmony_ci
292e5b75505Sopenharmony_ci/**
293e5b75505Sopenharmony_ci * tls_connection_shutdown - Shutdown TLS connection
294e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
295e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
296e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
297e5b75505Sopenharmony_ci *
298e5b75505Sopenharmony_ci * Shutdown current TLS connection without releasing all resources. New
299e5b75505Sopenharmony_ci * connection can be started by using the same conn without having to call
300e5b75505Sopenharmony_ci * tls_connection_init() or setting certificates etc. again. The new
301e5b75505Sopenharmony_ci * connection should try to use session resumption.
302e5b75505Sopenharmony_ci */
303e5b75505Sopenharmony_ciint tls_connection_shutdown(void *tls_ctx, struct tls_connection *conn);
304e5b75505Sopenharmony_ci
305e5b75505Sopenharmony_cienum {
306e5b75505Sopenharmony_ci	TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN = -4,
307e5b75505Sopenharmony_ci	TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED = -3,
308e5b75505Sopenharmony_ci	TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED = -2
309e5b75505Sopenharmony_ci};
310e5b75505Sopenharmony_ci
311e5b75505Sopenharmony_ci/**
312e5b75505Sopenharmony_ci * tls_connection_set_params - Set TLS connection parameters
313e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
314e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
315e5b75505Sopenharmony_ci * @params: Connection parameters
316e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure,
317e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on error causing PKCS#11 engine
318e5b75505Sopenharmony_ci * failure, or
319e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
320e5b75505Sopenharmony_ci * PKCS#11 engine private key, or
321e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
322e5b75505Sopenharmony_ci * failure.
323e5b75505Sopenharmony_ci */
324e5b75505Sopenharmony_ciint __must_check
325e5b75505Sopenharmony_citls_connection_set_params(void *tls_ctx, struct tls_connection *conn,
326e5b75505Sopenharmony_ci			  const struct tls_connection_params *params);
327e5b75505Sopenharmony_ci
328e5b75505Sopenharmony_ci/**
329e5b75505Sopenharmony_ci * tls_global_set_params - Set TLS parameters for all TLS connection
330e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
331e5b75505Sopenharmony_ci * @params: Global TLS parameters
332e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure,
333e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on error causing PKCS#11 engine
334e5b75505Sopenharmony_ci * failure, or
335e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
336e5b75505Sopenharmony_ci * PKCS#11 engine private key, or
337e5b75505Sopenharmony_ci * TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
338e5b75505Sopenharmony_ci * failure.
339e5b75505Sopenharmony_ci */
340e5b75505Sopenharmony_ciint __must_check tls_global_set_params(
341e5b75505Sopenharmony_ci	void *tls_ctx, const struct tls_connection_params *params);
342e5b75505Sopenharmony_ci
343e5b75505Sopenharmony_ci/**
344e5b75505Sopenharmony_ci * tls_global_set_verify - Set global certificate verification options
345e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
346e5b75505Sopenharmony_ci * @check_crl: 0 = do not verify CRLs, 1 = verify CRL for the user certificate,
347e5b75505Sopenharmony_ci * 2 = verify CRL for all certificates
348e5b75505Sopenharmony_ci * @strict: 0 = allow CRL time errors, 1 = do not allow CRL time errors
349e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
350e5b75505Sopenharmony_ci */
351e5b75505Sopenharmony_ciint __must_check tls_global_set_verify(void *tls_ctx, int check_crl,
352e5b75505Sopenharmony_ci				       int strict);
353e5b75505Sopenharmony_ci
354e5b75505Sopenharmony_ci/**
355e5b75505Sopenharmony_ci * tls_connection_set_verify - Set certificate verification options
356e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
357e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
358e5b75505Sopenharmony_ci * @verify_peer: 1 = verify peer certificate
359e5b75505Sopenharmony_ci * @flags: Connection flags (TLS_CONN_*)
360e5b75505Sopenharmony_ci * @session_ctx: Session caching context or %NULL to use default
361e5b75505Sopenharmony_ci * @session_ctx_len: Length of @session_ctx in bytes.
362e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
363e5b75505Sopenharmony_ci */
364e5b75505Sopenharmony_ciint __must_check tls_connection_set_verify(void *tls_ctx,
365e5b75505Sopenharmony_ci					   struct tls_connection *conn,
366e5b75505Sopenharmony_ci					   int verify_peer,
367e5b75505Sopenharmony_ci					   unsigned int flags,
368e5b75505Sopenharmony_ci					   const u8 *session_ctx,
369e5b75505Sopenharmony_ci					   size_t session_ctx_len);
370e5b75505Sopenharmony_ci
371e5b75505Sopenharmony_ci/**
372e5b75505Sopenharmony_ci * tls_connection_get_random - Get random data from TLS connection
373e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
374e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
375e5b75505Sopenharmony_ci * @data: Structure of client/server random data (filled on success)
376e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
377e5b75505Sopenharmony_ci */
378e5b75505Sopenharmony_ciint __must_check tls_connection_get_random(void *tls_ctx,
379e5b75505Sopenharmony_ci					 struct tls_connection *conn,
380e5b75505Sopenharmony_ci					 struct tls_random *data);
381e5b75505Sopenharmony_ci
382e5b75505Sopenharmony_ci/**
383e5b75505Sopenharmony_ci * tls_connection_export_key - Derive keying material from a TLS connection
384e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
385e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
386e5b75505Sopenharmony_ci * @label: Label (e.g., description of the key) for PRF
387e5b75505Sopenharmony_ci * @context: Optional extra upper-layer context (max len 2^16)
388e5b75505Sopenharmony_ci * @context_len: The length of the context value
389e5b75505Sopenharmony_ci * @out: Buffer for output data from TLS-PRF
390e5b75505Sopenharmony_ci * @out_len: Length of the output buffer
391e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
392e5b75505Sopenharmony_ci *
393e5b75505Sopenharmony_ci * Exports keying material using the mechanism described in RFC 5705. If
394e5b75505Sopenharmony_ci * context is %NULL, context is not provided; otherwise, context is provided
395e5b75505Sopenharmony_ci * (including the case of empty context with context_len == 0).
396e5b75505Sopenharmony_ci */
397e5b75505Sopenharmony_ciint __must_check tls_connection_export_key(void *tls_ctx,
398e5b75505Sopenharmony_ci					   struct tls_connection *conn,
399e5b75505Sopenharmony_ci					   const char *label,
400e5b75505Sopenharmony_ci					   const u8 *context,
401e5b75505Sopenharmony_ci					   size_t context_len,
402e5b75505Sopenharmony_ci					   u8 *out, size_t out_len);
403e5b75505Sopenharmony_ci
404e5b75505Sopenharmony_ci/**
405e5b75505Sopenharmony_ci * tls_connection_get_eap_fast_key - Derive key material for EAP-FAST
406e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
407e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
408e5b75505Sopenharmony_ci * @out: Buffer for output data from TLS-PRF
409e5b75505Sopenharmony_ci * @out_len: Length of the output buffer
410e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
411e5b75505Sopenharmony_ci *
412e5b75505Sopenharmony_ci * Exports key material after the normal TLS key block for use with
413e5b75505Sopenharmony_ci * EAP-FAST. Most callers will want tls_connection_export_key(), but EAP-FAST
414e5b75505Sopenharmony_ci * uses a different legacy mechanism.
415e5b75505Sopenharmony_ci */
416e5b75505Sopenharmony_ciint __must_check tls_connection_get_eap_fast_key(void *tls_ctx,
417e5b75505Sopenharmony_ci						 struct tls_connection *conn,
418e5b75505Sopenharmony_ci						 u8 *out, size_t out_len);
419e5b75505Sopenharmony_ci
420e5b75505Sopenharmony_ci/**
421e5b75505Sopenharmony_ci * tls_connection_handshake - Process TLS handshake (client side)
422e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
423e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
424e5b75505Sopenharmony_ci * @in_data: Input data from TLS server
425e5b75505Sopenharmony_ci * @appl_data: Pointer to application data pointer, or %NULL if dropped
426e5b75505Sopenharmony_ci * Returns: Output data, %NULL on failure
427e5b75505Sopenharmony_ci *
428e5b75505Sopenharmony_ci * The caller is responsible for freeing the returned output data. If the final
429e5b75505Sopenharmony_ci * handshake message includes application data, this is decrypted and
430e5b75505Sopenharmony_ci * appl_data (if not %NULL) is set to point this data. The caller is
431e5b75505Sopenharmony_ci * responsible for freeing appl_data.
432e5b75505Sopenharmony_ci *
433e5b75505Sopenharmony_ci * This function is used during TLS handshake. The first call is done with
434e5b75505Sopenharmony_ci * in_data == %NULL and the library is expected to return ClientHello packet.
435e5b75505Sopenharmony_ci * This packet is then send to the server and a response from server is given
436e5b75505Sopenharmony_ci * to TLS library by calling this function again with in_data pointing to the
437e5b75505Sopenharmony_ci * TLS message from the server.
438e5b75505Sopenharmony_ci *
439e5b75505Sopenharmony_ci * If the TLS handshake fails, this function may return %NULL. However, if the
440e5b75505Sopenharmony_ci * TLS library has a TLS alert to send out, that should be returned as the
441e5b75505Sopenharmony_ci * output data. In this case, tls_connection_get_failed() must return failure
442e5b75505Sopenharmony_ci * (> 0).
443e5b75505Sopenharmony_ci *
444e5b75505Sopenharmony_ci * tls_connection_established() should return 1 once the TLS handshake has been
445e5b75505Sopenharmony_ci * completed successfully.
446e5b75505Sopenharmony_ci */
447e5b75505Sopenharmony_cistruct wpabuf * tls_connection_handshake(void *tls_ctx,
448e5b75505Sopenharmony_ci					 struct tls_connection *conn,
449e5b75505Sopenharmony_ci					 const struct wpabuf *in_data,
450e5b75505Sopenharmony_ci					 struct wpabuf **appl_data);
451e5b75505Sopenharmony_ci
452e5b75505Sopenharmony_cistruct wpabuf * tls_connection_handshake2(void *tls_ctx,
453e5b75505Sopenharmony_ci					  struct tls_connection *conn,
454e5b75505Sopenharmony_ci					  const struct wpabuf *in_data,
455e5b75505Sopenharmony_ci					  struct wpabuf **appl_data,
456e5b75505Sopenharmony_ci					  int *more_data_needed);
457e5b75505Sopenharmony_ci
458e5b75505Sopenharmony_ci/**
459e5b75505Sopenharmony_ci * tls_connection_server_handshake - Process TLS handshake (server side)
460e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
461e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
462e5b75505Sopenharmony_ci * @in_data: Input data from TLS peer
463e5b75505Sopenharmony_ci * @appl_data: Pointer to application data pointer, or %NULL if dropped
464e5b75505Sopenharmony_ci * Returns: Output data, %NULL on failure
465e5b75505Sopenharmony_ci *
466e5b75505Sopenharmony_ci * The caller is responsible for freeing the returned output data.
467e5b75505Sopenharmony_ci */
468e5b75505Sopenharmony_cistruct wpabuf * tls_connection_server_handshake(void *tls_ctx,
469e5b75505Sopenharmony_ci						struct tls_connection *conn,
470e5b75505Sopenharmony_ci						const struct wpabuf *in_data,
471e5b75505Sopenharmony_ci						struct wpabuf **appl_data);
472e5b75505Sopenharmony_ci
473e5b75505Sopenharmony_ci/**
474e5b75505Sopenharmony_ci * tls_connection_encrypt - Encrypt data into TLS tunnel
475e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
476e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
477e5b75505Sopenharmony_ci * @in_data: Plaintext data to be encrypted
478e5b75505Sopenharmony_ci * Returns: Encrypted TLS data or %NULL on failure
479e5b75505Sopenharmony_ci *
480e5b75505Sopenharmony_ci * This function is used after TLS handshake has been completed successfully to
481e5b75505Sopenharmony_ci * send data in the encrypted tunnel. The caller is responsible for freeing the
482e5b75505Sopenharmony_ci * returned output data.
483e5b75505Sopenharmony_ci */
484e5b75505Sopenharmony_cistruct wpabuf * tls_connection_encrypt(void *tls_ctx,
485e5b75505Sopenharmony_ci				       struct tls_connection *conn,
486e5b75505Sopenharmony_ci				       const struct wpabuf *in_data);
487e5b75505Sopenharmony_ci
488e5b75505Sopenharmony_ci/**
489e5b75505Sopenharmony_ci * tls_connection_decrypt - Decrypt data from TLS tunnel
490e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
491e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
492e5b75505Sopenharmony_ci * @in_data: Encrypted TLS data
493e5b75505Sopenharmony_ci * Returns: Decrypted TLS data or %NULL on failure
494e5b75505Sopenharmony_ci *
495e5b75505Sopenharmony_ci * This function is used after TLS handshake has been completed successfully to
496e5b75505Sopenharmony_ci * receive data from the encrypted tunnel. The caller is responsible for
497e5b75505Sopenharmony_ci * freeing the returned output data.
498e5b75505Sopenharmony_ci */
499e5b75505Sopenharmony_cistruct wpabuf * tls_connection_decrypt(void *tls_ctx,
500e5b75505Sopenharmony_ci				       struct tls_connection *conn,
501e5b75505Sopenharmony_ci				       const struct wpabuf *in_data);
502e5b75505Sopenharmony_ci
503e5b75505Sopenharmony_cistruct wpabuf * tls_connection_decrypt2(void *tls_ctx,
504e5b75505Sopenharmony_ci					struct tls_connection *conn,
505e5b75505Sopenharmony_ci					const struct wpabuf *in_data,
506e5b75505Sopenharmony_ci					int *more_data_needed);
507e5b75505Sopenharmony_ci
508e5b75505Sopenharmony_ci/**
509e5b75505Sopenharmony_ci * tls_connection_resumed - Was session resumption used
510e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
511e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
512e5b75505Sopenharmony_ci * Returns: 1 if current session used session resumption, 0 if not
513e5b75505Sopenharmony_ci */
514e5b75505Sopenharmony_ciint tls_connection_resumed(void *tls_ctx, struct tls_connection *conn);
515e5b75505Sopenharmony_ci
516e5b75505Sopenharmony_cienum {
517e5b75505Sopenharmony_ci	TLS_CIPHER_NONE,
518e5b75505Sopenharmony_ci	TLS_CIPHER_RC4_SHA /* 0x0005 */,
519e5b75505Sopenharmony_ci	TLS_CIPHER_AES128_SHA /* 0x002f */,
520e5b75505Sopenharmony_ci	TLS_CIPHER_RSA_DHE_AES128_SHA /* 0x0031 */,
521e5b75505Sopenharmony_ci	TLS_CIPHER_ANON_DH_AES128_SHA /* 0x0034 */,
522e5b75505Sopenharmony_ci	TLS_CIPHER_RSA_DHE_AES256_SHA /* 0x0039 */,
523e5b75505Sopenharmony_ci	TLS_CIPHER_AES256_SHA /* 0x0035 */,
524e5b75505Sopenharmony_ci};
525e5b75505Sopenharmony_ci
526e5b75505Sopenharmony_ci/**
527e5b75505Sopenharmony_ci * tls_connection_set_cipher_list - Configure acceptable cipher suites
528e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
529e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
530e5b75505Sopenharmony_ci * @ciphers: Zero (TLS_CIPHER_NONE) terminated list of allowed ciphers
531e5b75505Sopenharmony_ci * (TLS_CIPHER_*).
532e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
533e5b75505Sopenharmony_ci */
534e5b75505Sopenharmony_ciint __must_check tls_connection_set_cipher_list(void *tls_ctx,
535e5b75505Sopenharmony_ci						struct tls_connection *conn,
536e5b75505Sopenharmony_ci						u8 *ciphers);
537e5b75505Sopenharmony_ci
538e5b75505Sopenharmony_ci/**
539e5b75505Sopenharmony_ci * tls_get_version - Get the current TLS version number
540e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
541e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
542e5b75505Sopenharmony_ci * @buf: Buffer for returning the TLS version number
543e5b75505Sopenharmony_ci * @buflen: buf size
544e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
545e5b75505Sopenharmony_ci *
546e5b75505Sopenharmony_ci * Get the currently used TLS version number.
547e5b75505Sopenharmony_ci */
548e5b75505Sopenharmony_ciint __must_check tls_get_version(void *tls_ctx, struct tls_connection *conn,
549e5b75505Sopenharmony_ci				 char *buf, size_t buflen);
550e5b75505Sopenharmony_ci
551e5b75505Sopenharmony_ci/**
552e5b75505Sopenharmony_ci * tls_get_cipher - Get current cipher name
553e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
554e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
555e5b75505Sopenharmony_ci * @buf: Buffer for the cipher name
556e5b75505Sopenharmony_ci * @buflen: buf size
557e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
558e5b75505Sopenharmony_ci *
559e5b75505Sopenharmony_ci * Get the name of the currently used cipher.
560e5b75505Sopenharmony_ci */
561e5b75505Sopenharmony_ciint __must_check tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
562e5b75505Sopenharmony_ci				char *buf, size_t buflen);
563e5b75505Sopenharmony_ci
564e5b75505Sopenharmony_ci/**
565e5b75505Sopenharmony_ci * tls_connection_enable_workaround - Enable TLS workaround options
566e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
567e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
568e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
569e5b75505Sopenharmony_ci *
570e5b75505Sopenharmony_ci * This function is used to enable connection-specific workaround options for
571e5b75505Sopenharmony_ci * buffer SSL/TLS implementations.
572e5b75505Sopenharmony_ci */
573e5b75505Sopenharmony_ciint __must_check tls_connection_enable_workaround(void *tls_ctx,
574e5b75505Sopenharmony_ci						  struct tls_connection *conn);
575e5b75505Sopenharmony_ci
576e5b75505Sopenharmony_ci/**
577e5b75505Sopenharmony_ci * tls_connection_client_hello_ext - Set TLS extension for ClientHello
578e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
579e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
580e5b75505Sopenharmony_ci * @ext_type: Extension type
581e5b75505Sopenharmony_ci * @data: Extension payload (%NULL to remove extension)
582e5b75505Sopenharmony_ci * @data_len: Extension payload length
583e5b75505Sopenharmony_ci * Returns: 0 on success, -1 on failure
584e5b75505Sopenharmony_ci */
585e5b75505Sopenharmony_ciint __must_check tls_connection_client_hello_ext(void *tls_ctx,
586e5b75505Sopenharmony_ci						 struct tls_connection *conn,
587e5b75505Sopenharmony_ci						 int ext_type, const u8 *data,
588e5b75505Sopenharmony_ci						 size_t data_len);
589e5b75505Sopenharmony_ci
590e5b75505Sopenharmony_ci/**
591e5b75505Sopenharmony_ci * tls_connection_get_failed - Get connection failure status
592e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
593e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
594e5b75505Sopenharmony_ci *
595e5b75505Sopenharmony_ci * Returns >0 if connection has failed, 0 if not.
596e5b75505Sopenharmony_ci */
597e5b75505Sopenharmony_ciint tls_connection_get_failed(void *tls_ctx, struct tls_connection *conn);
598e5b75505Sopenharmony_ci
599e5b75505Sopenharmony_ci/**
600e5b75505Sopenharmony_ci * tls_connection_get_read_alerts - Get connection read alert status
601e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
602e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
603e5b75505Sopenharmony_ci * Returns: Number of times a fatal read (remote end reported error) has
604e5b75505Sopenharmony_ci * happened during this connection.
605e5b75505Sopenharmony_ci */
606e5b75505Sopenharmony_ciint tls_connection_get_read_alerts(void *tls_ctx, struct tls_connection *conn);
607e5b75505Sopenharmony_ci
608e5b75505Sopenharmony_ci/**
609e5b75505Sopenharmony_ci * tls_connection_get_write_alerts - Get connection write alert status
610e5b75505Sopenharmony_ci * @tls_ctx: TLS context data from tls_init()
611e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
612e5b75505Sopenharmony_ci * Returns: Number of times a fatal write (locally detected error) has happened
613e5b75505Sopenharmony_ci * during this connection.
614e5b75505Sopenharmony_ci */
615e5b75505Sopenharmony_ciint tls_connection_get_write_alerts(void *tls_ctx,
616e5b75505Sopenharmony_ci				    struct tls_connection *conn);
617e5b75505Sopenharmony_ci
618e5b75505Sopenharmony_citypedef int (*tls_session_ticket_cb)
619e5b75505Sopenharmony_ci(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
620e5b75505Sopenharmony_ci const u8 *server_random, u8 *master_secret);
621e5b75505Sopenharmony_ci
622e5b75505Sopenharmony_ciint __must_check  tls_connection_set_session_ticket_cb(
623e5b75505Sopenharmony_ci	void *tls_ctx, struct tls_connection *conn,
624e5b75505Sopenharmony_ci	tls_session_ticket_cb cb, void *ctx);
625e5b75505Sopenharmony_ci
626e5b75505Sopenharmony_civoid tls_connection_set_log_cb(struct tls_connection *conn,
627e5b75505Sopenharmony_ci			       void (*log_cb)(void *ctx, const char *msg),
628e5b75505Sopenharmony_ci			       void *ctx);
629e5b75505Sopenharmony_ci
630e5b75505Sopenharmony_ci#define TLS_BREAK_VERIFY_DATA BIT(0)
631e5b75505Sopenharmony_ci#define TLS_BREAK_SRV_KEY_X_HASH BIT(1)
632e5b75505Sopenharmony_ci#define TLS_BREAK_SRV_KEY_X_SIGNATURE BIT(2)
633e5b75505Sopenharmony_ci#define TLS_DHE_PRIME_511B BIT(3)
634e5b75505Sopenharmony_ci#define TLS_DHE_PRIME_767B BIT(4)
635e5b75505Sopenharmony_ci#define TLS_DHE_PRIME_15 BIT(5)
636e5b75505Sopenharmony_ci#define TLS_DHE_PRIME_58B BIT(6)
637e5b75505Sopenharmony_ci#define TLS_DHE_NON_PRIME BIT(7)
638e5b75505Sopenharmony_ci
639e5b75505Sopenharmony_civoid tls_connection_set_test_flags(struct tls_connection *conn, u32 flags);
640e5b75505Sopenharmony_ci
641e5b75505Sopenharmony_ciint tls_get_library_version(char *buf, size_t buf_len);
642e5b75505Sopenharmony_ci
643e5b75505Sopenharmony_civoid tls_connection_set_success_data(struct tls_connection *conn,
644e5b75505Sopenharmony_ci				     struct wpabuf *data);
645e5b75505Sopenharmony_ci
646e5b75505Sopenharmony_civoid tls_connection_set_success_data_resumed(struct tls_connection *conn);
647e5b75505Sopenharmony_ci
648e5b75505Sopenharmony_ciconst struct wpabuf *
649e5b75505Sopenharmony_citls_connection_get_success_data(struct tls_connection *conn);
650e5b75505Sopenharmony_ci
651e5b75505Sopenharmony_civoid tls_connection_remove_session(struct tls_connection *conn);
652e5b75505Sopenharmony_ci
653e5b75505Sopenharmony_ci/**
654e5b75505Sopenharmony_ci * tls_get_tls_unique - Fetch "tls-unique" for channel binding
655e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
656e5b75505Sopenharmony_ci * @buf: Buffer for returning the value
657e5b75505Sopenharmony_ci * @max_len: Maximum length of the buffer in bytes
658e5b75505Sopenharmony_ci * Returns: Number of bytes written to buf or -1 on error
659e5b75505Sopenharmony_ci *
660e5b75505Sopenharmony_ci * This function can be used to fetch "tls-unique" (RFC 5929, Section 3) which
661e5b75505Sopenharmony_ci * is the first TLS Finished message sent in the most recent TLS handshake of
662e5b75505Sopenharmony_ci * the TLS connection.
663e5b75505Sopenharmony_ci */
664e5b75505Sopenharmony_ciint tls_get_tls_unique(struct tls_connection *conn, u8 *buf, size_t max_len);
665e5b75505Sopenharmony_ci
666e5b75505Sopenharmony_ci/**
667e5b75505Sopenharmony_ci * tls_connection_get_cipher_suite - Get current TLS cipher suite
668e5b75505Sopenharmony_ci * @conn: Connection context data from tls_connection_init()
669e5b75505Sopenharmony_ci * Returns: TLS cipher suite of the current connection or 0 on error
670e5b75505Sopenharmony_ci */
671e5b75505Sopenharmony_ciu16 tls_connection_get_cipher_suite(struct tls_connection *conn);
672e5b75505Sopenharmony_ci
673e5b75505Sopenharmony_ci#endif /* TLS_H */
674