1 /* 2 * TLS v1.0 (RFC 2246) and v1.1 (RFC 4346) client 3 * Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation. 8 * 9 * Alternatively, this software may be distributed under the terms of BSD 10 * license. 11 * 12 * See README and COPYING for more details. 13 */ 14 15 #include "includes.h" 16 17 #include "common.h" 18 #include "crypto/sha1.h" 19 #include "crypto/tls.h" 20 #include "tlsv1_common.h" 21 #include "tlsv1_record.h" 22 #include "tlsv1_client.h" 23 #include "tlsv1_client_i.h" 24 25 /* TODO: 26 * Support for a message fragmented across several records (RFC 2246, 6.2.1) 27 */ 28 29 30 void tls_alert(struct tlsv1_client *conn, u8 level, u8 description) 31 { 32 conn->alert_level = level; 33 conn->alert_description = description; 34 } 35 36 37 void tlsv1_client_free_dh(struct tlsv1_client *conn) 38 { 39 os_free(conn->dh_p); 40 os_free(conn->dh_g); 41 os_free(conn->dh_ys); 42 conn->dh_p = conn->dh_g = conn->dh_ys = NULL; 43 } 44 45 46 int tls_derive_pre_master_secret(u8 *pre_master_secret) 47 { 48 WPA_PUT_BE16(pre_master_secret, TLS_VERSION); 49 if (os_get_random(pre_master_secret + 2, 50 TLS_PRE_MASTER_SECRET_LEN - 2)) 51 return -1; 52 return 0; 53 } 54 55 56 int tls_derive_keys(struct tlsv1_client *conn, 57 const u8 *pre_master_secret, size_t pre_master_secret_len) 58 { 59 u8 seed[2 * TLS_RANDOM_LEN]; 60 u8 key_block[TLS_MAX_KEY_BLOCK_LEN]; 61 u8 *pos; 62 size_t key_block_len; 63 64 if (pre_master_secret) { 65 wpa_hexdump_key(MSG_MSGDUMP, "TLSv1: pre_master_secret", 66 pre_master_secret, pre_master_secret_len); 67 os_memcpy(seed, conn->client_random, TLS_RANDOM_LEN); 68 os_memcpy(seed + TLS_RANDOM_LEN, conn->server_random, 69 TLS_RANDOM_LEN); 70 if (tls_prf(pre_master_secret, pre_master_secret_len, 71 "master secret", seed, 2 * TLS_RANDOM_LEN, 72 conn->master_secret, TLS_MASTER_SECRET_LEN)) { 73 wpa_printf(MSG_DEBUG, "TLSv1: Failed to derive " 74 "master_secret"); 75 return -1; 76 } 77 wpa_hexdump_key(MSG_MSGDUMP, "TLSv1: master_secret", 78 conn->master_secret, TLS_MASTER_SECRET_LEN); 79 } 80 81 os_memcpy(seed, conn->server_random, TLS_RANDOM_LEN); 82 os_memcpy(seed + TLS_RANDOM_LEN, conn->client_random, TLS_RANDOM_LEN); 83 key_block_len = 2 * (conn->rl.hash_size + conn->rl.key_material_len); 84 if (conn->rl.tls_version == TLS_VERSION_1) 85 key_block_len += 2 * conn->rl.iv_size; 86 if (tls_prf(conn->master_secret, TLS_MASTER_SECRET_LEN, 87 "key expansion", seed, 2 * TLS_RANDOM_LEN, 88 key_block, key_block_len)) { 89 wpa_printf(MSG_DEBUG, "TLSv1: Failed to derive key_block"); 90 return -1; 91 } 92 wpa_hexdump_key(MSG_MSGDUMP, "TLSv1: key_block", 93 key_block, key_block_len); 94 95 pos = key_block; 96 97 /* client_write_MAC_secret */ 98 os_memcpy(conn->rl.write_mac_secret, pos, conn->rl.hash_size); 99 pos += conn->rl.hash_size; 100 /* server_write_MAC_secret */ 101 os_memcpy(conn->rl.read_mac_secret, pos, conn->rl.hash_size); 102 pos += conn->rl.hash_size; 103 104 /* client_write_key */ 105 os_memcpy(conn->rl.write_key, pos, conn->rl.key_material_len); 106 pos += conn->rl.key_material_len; 107 /* server_write_key */ 108 os_memcpy(conn->rl.read_key, pos, conn->rl.key_material_len); 109 pos += conn->rl.key_material_len; 110 111 if (conn->rl.tls_version == TLS_VERSION_1) { 112 /* client_write_IV */ 113 os_memcpy(conn->rl.write_iv, pos, conn->rl.iv_size); 114 pos += conn->rl.iv_size; 115 /* server_write_IV */ 116 os_memcpy(conn->rl.read_iv, pos, conn->rl.iv_size); 117 pos += conn->rl.iv_size; 118 } else { 119 /* 120 * Use IV field to set the mask value for TLS v1.1. A fixed 121 * mask of zero is used per the RFC 4346, 6.2.3.2 CBC Block 122 * Cipher option 2a. 123 */ 124 os_memset(conn->rl.write_iv, 0, conn->rl.iv_size); 125 } 126 127 return 0; 128 } 129 130 131 /** 132 * tlsv1_client_handshake - Process TLS handshake 133 * @conn: TLSv1 client connection data from tlsv1_client_init() 134 * @in_data: Input data from TLS peer 135 * @in_len: Input data length 136 * @out_len: Length of the output buffer. 137 * @appl_data: Pointer to application data pointer, or %NULL if dropped 138 * @appl_data_len: Pointer to variable that is set to appl_data length 139 * Returns: Pointer to output data, %NULL on failure 140 */ 141 u8 * tlsv1_client_handshake(struct tlsv1_client *conn, 142 const u8 *in_data, size_t in_len, 143 size_t *out_len, u8 **appl_data, 144 size_t *appl_data_len) 145 { 146 const u8 *pos, *end; 147 u8 *msg = NULL, *in_msg, *in_pos, *in_end, alert, ct; 148 size_t in_msg_len; 149 int no_appl_data; 150 151 if (conn->state == CLIENT_HELLO) { 152 if (in_len) 153 return NULL; 154 return tls_send_client_hello(conn, out_len); 155 } 156 157 if (in_data == NULL || in_len == 0) 158 return NULL; 159 160 pos = in_data; 161 end = in_data + in_len; 162 in_msg = os_malloc(in_len); 163 if (in_msg == NULL) 164 return NULL; 165 166 /* Each received packet may include multiple records */ 167 while (pos < end) { 168 in_msg_len = in_len; 169 if (tlsv1_record_receive(&conn->rl, pos, end - pos, 170 in_msg, &in_msg_len, &alert)) { 171 wpa_printf(MSG_DEBUG, "TLSv1: Processing received " 172 "record failed"); 173 tls_alert(conn, TLS_ALERT_LEVEL_FATAL, alert); 174 goto failed; 175 } 176 ct = pos[0]; 177 178 in_pos = in_msg; 179 in_end = in_msg + in_msg_len; 180 181 /* Each received record may include multiple messages of the 182 * same ContentType. */ 183 while (in_pos < in_end) { 184 in_msg_len = in_end - in_pos; 185 if (tlsv1_client_process_handshake(conn, ct, in_pos, 186 &in_msg_len, 187 appl_data, 188 appl_data_len) < 0) 189 goto failed; 190 in_pos += in_msg_len; 191 } 192 193 pos += TLS_RECORD_HEADER_LEN + WPA_GET_BE16(pos + 3); 194 } 195 196 os_free(in_msg); 197 in_msg = NULL; 198 199 no_appl_data = appl_data == NULL || *appl_data == NULL; 200 msg = tlsv1_client_handshake_write(conn, out_len, no_appl_data); 201 202 failed: 203 os_free(in_msg); 204 if (conn->alert_level) { 205 conn->state = FAILED; 206 os_free(msg); 207 msg = tlsv1_client_send_alert(conn, conn->alert_level, 208 conn->alert_description, 209 out_len); 210 } else if (msg == NULL) { 211 msg = os_zalloc(1); 212 *out_len = 0; 213 } 214 215 return msg; 216 } 217 218 219 /** 220 * tlsv1_client_encrypt - Encrypt data into TLS tunnel 221 * @conn: TLSv1 client connection data from tlsv1_client_init() 222 * @in_data: Pointer to plaintext data to be encrypted 223 * @in_len: Input buffer length 224 * @out_data: Pointer to output buffer (encrypted TLS data) 225 * @out_len: Maximum out_data length 226 * Returns: Number of bytes written to out_data, -1 on failure 227 * 228 * This function is used after TLS handshake has been completed successfully to 229 * send data in the encrypted tunnel. 230 */ 231 int tlsv1_client_encrypt(struct tlsv1_client *conn, 232 const u8 *in_data, size_t in_len, 233 u8 *out_data, size_t out_len) 234 { 235 size_t rlen; 236 237 wpa_hexdump_key(MSG_MSGDUMP, "TLSv1: Plaintext AppData", 238 in_data, in_len); 239 240 if (tlsv1_record_send(&conn->rl, TLS_CONTENT_TYPE_APPLICATION_DATA, 241 out_data, out_len, in_data, in_len, &rlen) < 0) { 242 wpa_printf(MSG_DEBUG, "TLSv1: Failed to create a record"); 243 tls_alert(conn, TLS_ALERT_LEVEL_FATAL, 244 TLS_ALERT_INTERNAL_ERROR); 245 return -1; 246 } 247 248 return rlen; 249 } 250 251 252 /** 253 * tlsv1_client_decrypt - Decrypt data from TLS tunnel 254 * @conn: TLSv1 client connection data from tlsv1_client_init() 255 * @in_data: Pointer to input buffer (encrypted TLS data) 256 * @in_len: Input buffer length 257 * @out_data: Pointer to output buffer (decrypted data from TLS tunnel) 258 * @out_len: Maximum out_data length 259 * Returns: Number of bytes written to out_data, -1 on failure 260 * 261 * This function is used after TLS handshake has been completed successfully to 262 * receive data from the encrypted tunnel. 263 */ 264 int tlsv1_client_decrypt(struct tlsv1_client *conn, 265 const u8 *in_data, size_t in_len, 266 u8 *out_data, size_t out_len) 267 { 268 const u8 *in_end, *pos; 269 int res; 270 u8 alert, *out_end, *out_pos; 271 size_t olen; 272 273 pos = in_data; 274 in_end = in_data + in_len; 275 out_pos = out_data; 276 out_end = out_data + out_len; 277 278 while (pos < in_end) { 279 if (pos[0] != TLS_CONTENT_TYPE_APPLICATION_DATA) { 280 wpa_printf(MSG_DEBUG, "TLSv1: Unexpected content type " 281 "0x%x", pos[0]); 282 tls_alert(conn, TLS_ALERT_LEVEL_FATAL, 283 TLS_ALERT_UNEXPECTED_MESSAGE); 284 return -1; 285 } 286 287 olen = out_end - out_pos; 288 res = tlsv1_record_receive(&conn->rl, pos, in_end - pos, 289 out_pos, &olen, &alert); 290 if (res < 0) { 291 wpa_printf(MSG_DEBUG, "TLSv1: Record layer processing " 292 "failed"); 293 tls_alert(conn, TLS_ALERT_LEVEL_FATAL, alert); 294 return -1; 295 } 296 out_pos += olen; 297 if (out_pos > out_end) { 298 wpa_printf(MSG_DEBUG, "TLSv1: Buffer not large enough " 299 "for processing the received record"); 300 tls_alert(conn, TLS_ALERT_LEVEL_FATAL, 301 TLS_ALERT_INTERNAL_ERROR); 302 return -1; 303 } 304 305 pos += TLS_RECORD_HEADER_LEN + WPA_GET_BE16(pos + 3); 306 } 307 308 return out_pos - out_data; 309 } 310 311 312 /** 313 * tlsv1_client_global_init - Initialize TLSv1 client 314 * Returns: 0 on success, -1 on failure 315 * 316 * This function must be called before using any other TLSv1 client functions. 317 */ 318 int tlsv1_client_global_init(void) 319 { 320 return crypto_global_init(); 321 } 322 323 324 /** 325 * tlsv1_client_global_deinit - Deinitialize TLSv1 client 326 * 327 * This function can be used to deinitialize the TLSv1 client that was 328 * initialized by calling tlsv1_client_global_init(). No TLSv1 client functions 329 * can be called after this before calling tlsv1_client_global_init() again. 330 */ 331 void tlsv1_client_global_deinit(void) 332 { 333 crypto_global_deinit(); 334 } 335 336 337 /** 338 * tlsv1_client_init - Initialize TLSv1 client connection 339 * Returns: Pointer to TLSv1 client connection data or %NULL on failure 340 */ 341 struct tlsv1_client * tlsv1_client_init(void) 342 { 343 struct tlsv1_client *conn; 344 size_t count; 345 u16 *suites; 346 347 conn = os_zalloc(sizeof(*conn)); 348 if (conn == NULL) 349 return NULL; 350 351 conn->state = CLIENT_HELLO; 352 353 if (tls_verify_hash_init(&conn->verify) < 0) { 354 wpa_printf(MSG_DEBUG, "TLSv1: Failed to initialize verify " 355 "hash"); 356 os_free(conn); 357 return NULL; 358 } 359 360 count = 0; 361 suites = conn->cipher_suites; 362 #ifndef CONFIG_CRYPTO_INTERNAL 363 suites[count++] = TLS_RSA_WITH_AES_256_CBC_SHA; 364 #endif /* CONFIG_CRYPTO_INTERNAL */ 365 suites[count++] = TLS_RSA_WITH_AES_128_CBC_SHA; 366 suites[count++] = TLS_RSA_WITH_3DES_EDE_CBC_SHA; 367 suites[count++] = TLS_RSA_WITH_RC4_128_SHA; 368 suites[count++] = TLS_RSA_WITH_RC4_128_MD5; 369 conn->num_cipher_suites = count; 370 371 conn->rl.tls_version = TLS_VERSION; 372 373 return conn; 374 } 375 376 377 /** 378 * tlsv1_client_deinit - Deinitialize TLSv1 client connection 379 * @conn: TLSv1 client connection data from tlsv1_client_init() 380 */ 381 void tlsv1_client_deinit(struct tlsv1_client *conn) 382 { 383 crypto_public_key_free(conn->server_rsa_key); 384 tlsv1_record_set_cipher_suite(&conn->rl, TLS_NULL_WITH_NULL_NULL); 385 tlsv1_record_change_write_cipher(&conn->rl); 386 tlsv1_record_change_read_cipher(&conn->rl); 387 tls_verify_hash_free(&conn->verify); 388 os_free(conn->client_hello_ext); 389 tlsv1_client_free_dh(conn); 390 tlsv1_cred_free(conn->cred); 391 os_free(conn); 392 } 393 394 395 /** 396 * tlsv1_client_established - Check whether connection has been established 397 * @conn: TLSv1 client connection data from tlsv1_client_init() 398 * Returns: 1 if connection is established, 0 if not 399 */ 400 int tlsv1_client_established(struct tlsv1_client *conn) 401 { 402 return conn->state == ESTABLISHED; 403 } 404 405 406 /** 407 * tlsv1_client_prf - Use TLS-PRF to derive keying material 408 * @conn: TLSv1 client connection data from tlsv1_client_init() 409 * @label: Label (e.g., description of the key) for PRF 410 * @server_random_first: seed is 0 = client_random|server_random, 411 * 1 = server_random|client_random 412 * @out: Buffer for output data from TLS-PRF 413 * @out_len: Length of the output buffer 414 * Returns: 0 on success, -1 on failure 415 */ 416 int tlsv1_client_prf(struct tlsv1_client *conn, const char *label, 417 int server_random_first, u8 *out, size_t out_len) 418 { 419 u8 seed[2 * TLS_RANDOM_LEN]; 420 421 if (conn->state != ESTABLISHED) 422 return -1; 423 424 if (server_random_first) { 425 os_memcpy(seed, conn->server_random, TLS_RANDOM_LEN); 426 os_memcpy(seed + TLS_RANDOM_LEN, conn->client_random, 427 TLS_RANDOM_LEN); 428 } else { 429 os_memcpy(seed, conn->client_random, TLS_RANDOM_LEN); 430 os_memcpy(seed + TLS_RANDOM_LEN, conn->server_random, 431 TLS_RANDOM_LEN); 432 } 433 434 return tls_prf(conn->master_secret, TLS_MASTER_SECRET_LEN, 435 label, seed, 2 * TLS_RANDOM_LEN, out, out_len); 436 } 437 438 439 /** 440 * tlsv1_client_get_cipher - Get current cipher name 441 * @conn: TLSv1 client connection data from tlsv1_client_init() 442 * @buf: Buffer for the cipher name 443 * @buflen: buf size 444 * Returns: 0 on success, -1 on failure 445 * 446 * Get the name of the currently used cipher. 447 */ 448 int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf, 449 size_t buflen) 450 { 451 char *cipher; 452 453 switch (conn->rl.cipher_suite) { 454 case TLS_RSA_WITH_RC4_128_MD5: 455 cipher = "RC4-MD5"; 456 break; 457 case TLS_RSA_WITH_RC4_128_SHA: 458 cipher = "RC4-SHA"; 459 break; 460 case TLS_RSA_WITH_DES_CBC_SHA: 461 cipher = "DES-CBC-SHA"; 462 break; 463 case TLS_RSA_WITH_3DES_EDE_CBC_SHA: 464 cipher = "DES-CBC3-SHA"; 465 break; 466 case TLS_DH_anon_WITH_AES_128_CBC_SHA: 467 cipher = "ADH-AES-128-SHA"; 468 break; 469 case TLS_RSA_WITH_AES_256_CBC_SHA: 470 cipher = "AES-256-SHA"; 471 break; 472 case TLS_RSA_WITH_AES_128_CBC_SHA: 473 cipher = "AES-128-SHA"; 474 break; 475 default: 476 return -1; 477 } 478 479 if (os_strlcpy(buf, cipher, buflen) >= buflen) 480 return -1; 481 return 0; 482 } 483 484 485 /** 486 * tlsv1_client_shutdown - Shutdown TLS connection 487 * @conn: TLSv1 client connection data from tlsv1_client_init() 488 * Returns: 0 on success, -1 on failure 489 */ 490 int tlsv1_client_shutdown(struct tlsv1_client *conn) 491 { 492 conn->state = CLIENT_HELLO; 493 494 if (tls_verify_hash_init(&conn->verify) < 0) { 495 wpa_printf(MSG_DEBUG, "TLSv1: Failed to re-initialize verify " 496 "hash"); 497 return -1; 498 } 499 500 tlsv1_record_set_cipher_suite(&conn->rl, TLS_NULL_WITH_NULL_NULL); 501 tlsv1_record_change_write_cipher(&conn->rl); 502 tlsv1_record_change_read_cipher(&conn->rl); 503 504 conn->certificate_requested = 0; 505 crypto_public_key_free(conn->server_rsa_key); 506 conn->server_rsa_key = NULL; 507 conn->session_resumed = 0; 508 509 return 0; 510 } 511 512 513 /** 514 * tlsv1_client_resumed - Was session resumption used 515 * @conn: TLSv1 client connection data from tlsv1_client_init() 516 * Returns: 1 if current session used session resumption, 0 if not 517 */ 518 int tlsv1_client_resumed(struct tlsv1_client *conn) 519 { 520 return !!conn->session_resumed; 521 } 522 523 524 /** 525 * tlsv1_client_hello_ext - Set TLS extension for ClientHello 526 * @conn: TLSv1 client connection data from tlsv1_client_init() 527 * @ext_type: Extension type 528 * @data: Extension payload (%NULL to remove extension) 529 * @data_len: Extension payload length 530 * Returns: 0 on success, -1 on failure 531 */ 532 int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type, 533 const u8 *data, size_t data_len) 534 { 535 u8 *pos; 536 537 conn->session_ticket_included = 0; 538 os_free(conn->client_hello_ext); 539 conn->client_hello_ext = NULL; 540 conn->client_hello_ext_len = 0; 541 542 if (data == NULL || data_len == 0) 543 return 0; 544 545 pos = conn->client_hello_ext = os_malloc(6 + data_len); 546 if (pos == NULL) 547 return -1; 548 549 WPA_PUT_BE16(pos, 4 + data_len); 550 pos += 2; 551 WPA_PUT_BE16(pos, ext_type); 552 pos += 2; 553 WPA_PUT_BE16(pos, data_len); 554 pos += 2; 555 os_memcpy(pos, data, data_len); 556 conn->client_hello_ext_len = 6 + data_len; 557 558 if (ext_type == TLS_EXT_PAC_OPAQUE) { 559 conn->session_ticket_included = 1; 560 wpa_printf(MSG_DEBUG, "TLSv1: Using session ticket"); 561 } 562 563 return 0; 564 } 565 566 567 /** 568 * tlsv1_client_get_keys - Get master key and random data from TLS connection 569 * @conn: TLSv1 client connection data from tlsv1_client_init() 570 * @keys: Structure of key/random data (filled on success) 571 * Returns: 0 on success, -1 on failure 572 */ 573 int tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys) 574 { 575 os_memset(keys, 0, sizeof(*keys)); 576 if (conn->state == CLIENT_HELLO) 577 return -1; 578 579 keys->client_random = conn->client_random; 580 keys->client_random_len = TLS_RANDOM_LEN; 581 582 if (conn->state != SERVER_HELLO) { 583 keys->server_random = conn->server_random; 584 keys->server_random_len = TLS_RANDOM_LEN; 585 keys->master_key = conn->master_secret; 586 keys->master_key_len = TLS_MASTER_SECRET_LEN; 587 } 588 589 return 0; 590 } 591 592 593 /** 594 * tlsv1_client_get_keyblock_size - Get TLS key_block size 595 * @conn: TLSv1 client connection data from tlsv1_client_init() 596 * Returns: Size of the key_block for the negotiated cipher suite or -1 on 597 * failure 598 */ 599 int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn) 600 { 601 if (conn->state == CLIENT_HELLO || conn->state == SERVER_HELLO) 602 return -1; 603 604 return 2 * (conn->rl.hash_size + conn->rl.key_material_len + 605 conn->rl.iv_size); 606 } 607 608 609 /** 610 * tlsv1_client_set_cipher_list - Configure acceptable cipher suites 611 * @conn: TLSv1 client connection data from tlsv1_client_init() 612 * @ciphers: Zero (TLS_CIPHER_NONE) terminated list of allowed ciphers 613 * (TLS_CIPHER_*). 614 * Returns: 0 on success, -1 on failure 615 */ 616 int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers) 617 { 618 size_t count; 619 u16 *suites; 620 621 /* TODO: implement proper configuration of cipher suites */ 622 if (ciphers[0] == TLS_CIPHER_ANON_DH_AES128_SHA) { 623 count = 0; 624 suites = conn->cipher_suites; 625 #ifndef CONFIG_CRYPTO_INTERNAL 626 suites[count++] = TLS_DH_anon_WITH_AES_256_CBC_SHA; 627 #endif /* CONFIG_CRYPTO_INTERNAL */ 628 suites[count++] = TLS_DH_anon_WITH_AES_128_CBC_SHA; 629 suites[count++] = TLS_DH_anon_WITH_3DES_EDE_CBC_SHA; 630 suites[count++] = TLS_DH_anon_WITH_RC4_128_MD5; 631 suites[count++] = TLS_DH_anon_WITH_DES_CBC_SHA; 632 633 /* 634 * Cisco AP (at least 350 and 1200 series) local authentication 635 * server does not know how to search cipher suites from the 636 * list and seem to require that the last entry in the list is 637 * the one that it wants to use. However, TLS specification 638 * requires the list to be in the client preference order. As a 639 * workaround, add anon-DH AES-128-SHA1 again at the end of the 640 * list to allow the Cisco code to find it. 641 */ 642 suites[count++] = TLS_DH_anon_WITH_AES_128_CBC_SHA; 643 conn->num_cipher_suites = count; 644 } 645 646 return 0; 647 } 648 649 650 /** 651 * tlsv1_client_set_cred - Set client credentials 652 * @conn: TLSv1 client connection data from tlsv1_client_init() 653 * @cred: Credentials from tlsv1_cred_alloc() 654 * Returns: 0 on success, -1 on failure 655 * 656 * On success, the client takes ownership of the credentials block and caller 657 * must not free it. On failure, caller is responsible for freeing the 658 * credential block. 659 */ 660 int tlsv1_client_set_cred(struct tlsv1_client *conn, 661 struct tlsv1_credentials *cred) 662 { 663 tlsv1_cred_free(conn->cred); 664 conn->cred = cred; 665 return 0; 666 } 667 668 669 void tlsv1_client_set_time_checks(struct tlsv1_client *conn, int enabled) 670 { 671 conn->disable_time_checks = !enabled; 672 } 673 674 675 void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn, 676 tlsv1_client_session_ticket_cb cb, 677 void *ctx) 678 { 679 wpa_printf(MSG_DEBUG, "TLSv1: SessionTicket callback set %p (ctx %p)", 680 cb, ctx); 681 conn->session_ticket_cb = cb; 682 conn->session_ticket_cb_ctx = ctx; 683 } 684