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