2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright 2005 Nokia. All rights reserved.
5 * Licensed under the OpenSSL license (the "License"). You may not use
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
13 #include <openssl/comp.h>
14 #include <openssl/evp.h>
15 #include <openssl/kdf.h>
16 #include <openssl/rand.h>
18 /* seed1 through seed5 are concatenated */
19 static int tls1_PRF(SSL *s,
20 const void *seed1, size_t seed1_len,
21 const void *seed2, size_t seed2_len,
22 const void *seed3, size_t seed3_len,
23 const void *seed4, size_t seed4_len,
24 const void *seed5, size_t seed5_len,
25 const unsigned char *sec, size_t slen,
26 unsigned char *out, size_t olen, int fatal)
28 const EVP_MD *md = ssl_prf_md(s);
29 EVP_PKEY_CTX *pctx = NULL;
33 /* Should never happen */
35 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_PRF,
36 ERR_R_INTERNAL_ERROR);
38 SSLerr(SSL_F_TLS1_PRF, ERR_R_INTERNAL_ERROR);
41 pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
42 if (pctx == NULL || EVP_PKEY_derive_init(pctx) <= 0
43 || EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) <= 0
44 || EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, (int)slen) <= 0
45 || EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed1, (int)seed1_len) <= 0
46 || EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed2, (int)seed2_len) <= 0
47 || EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed3, (int)seed3_len) <= 0
48 || EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed4, (int)seed4_len) <= 0
49 || EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed5, (int)seed5_len) <= 0
50 || EVP_PKEY_derive(pctx, out, &olen) <= 0) {
52 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_PRF,
53 ERR_R_INTERNAL_ERROR);
55 SSLerr(SSL_F_TLS1_PRF, ERR_R_INTERNAL_ERROR);
62 EVP_PKEY_CTX_free(pctx);
66 static int tls1_generate_key_block(SSL *s, unsigned char *km, size_t num)
70 /* Calls SSLfatal() as required */
72 TLS_MD_KEY_EXPANSION_CONST,
73 TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3->server_random,
74 SSL3_RANDOM_SIZE, s->s3->client_random, SSL3_RANDOM_SIZE,
75 NULL, 0, NULL, 0, s->session->master_key,
76 s->session->master_key_length, km, num, 1);
81 int tls1_change_cipher_state(SSL *s, int which)
83 unsigned char *p, *mac_secret;
84 unsigned char tmp1[EVP_MAX_KEY_LENGTH];
85 unsigned char tmp2[EVP_MAX_KEY_LENGTH];
86 unsigned char iv1[EVP_MAX_IV_LENGTH * 2];
87 unsigned char iv2[EVP_MAX_IV_LENGTH * 2];
88 unsigned char *ms, *key, *iv;
91 #ifndef OPENSSL_NO_COMP
96 size_t *mac_secret_size;
99 size_t n, i, j, k, cl;
102 c = s->s3->tmp.new_sym_enc;
103 m = s->s3->tmp.new_hash;
104 mac_type = s->s3->tmp.new_mac_pkey_type;
105 #ifndef OPENSSL_NO_COMP
106 comp = s->s3->tmp.new_compression;
109 if (which & SSL3_CC_READ) {
111 s->s3->flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
113 s->s3->flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
115 if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
116 s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM;
118 s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM;
120 if (s->enc_read_ctx != NULL) {
122 } else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL) {
123 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
124 ERR_R_MALLOC_FAILURE);
128 * make sure it's initialised in case we exit later with an error
130 EVP_CIPHER_CTX_reset(s->enc_read_ctx);
132 dd = s->enc_read_ctx;
133 mac_ctx = ssl_replace_hash(&s->read_hash, NULL);
136 #ifndef OPENSSL_NO_COMP
137 COMP_CTX_free(s->expand);
140 s->expand = COMP_CTX_new(comp->method);
141 if (s->expand == NULL) {
142 SSLfatal(s, SSL_AD_INTERNAL_ERROR,
143 SSL_F_TLS1_CHANGE_CIPHER_STATE,
144 SSL_R_COMPRESSION_LIBRARY_ERROR);
150 * this is done by dtls1_reset_seq_numbers for DTLS
153 RECORD_LAYER_reset_read_sequence(&s->rlayer);
154 mac_secret = &(s->s3->read_mac_secret[0]);
155 mac_secret_size = &(s->s3->read_mac_secret_size);
158 s->s3->flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
160 s->s3->flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
162 if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
163 s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
165 s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
166 if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s)) {
168 } else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL) {
169 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
170 ERR_R_MALLOC_FAILURE);
173 dd = s->enc_write_ctx;
174 if (SSL_IS_DTLS(s)) {
175 mac_ctx = EVP_MD_CTX_new();
176 if (mac_ctx == NULL) {
177 SSLfatal(s, SSL_AD_INTERNAL_ERROR,
178 SSL_F_TLS1_CHANGE_CIPHER_STATE,
179 ERR_R_MALLOC_FAILURE);
182 s->write_hash = mac_ctx;
184 mac_ctx = ssl_replace_hash(&s->write_hash, NULL);
185 if (mac_ctx == NULL) {
186 SSLfatal(s, SSL_AD_INTERNAL_ERROR,
187 SSL_F_TLS1_CHANGE_CIPHER_STATE,
188 ERR_R_MALLOC_FAILURE);
192 #ifndef OPENSSL_NO_COMP
193 COMP_CTX_free(s->compress);
196 s->compress = COMP_CTX_new(comp->method);
197 if (s->compress == NULL) {
198 SSLfatal(s, SSL_AD_INTERNAL_ERROR,
199 SSL_F_TLS1_CHANGE_CIPHER_STATE,
200 SSL_R_COMPRESSION_LIBRARY_ERROR);
206 * this is done by dtls1_reset_seq_numbers for DTLS
209 RECORD_LAYER_reset_write_sequence(&s->rlayer);
210 mac_secret = &(s->s3->write_mac_secret[0]);
211 mac_secret_size = &(s->s3->write_mac_secret_size);
215 EVP_CIPHER_CTX_reset(dd);
217 p = s->s3->tmp.key_block;
218 i = *mac_secret_size = s->s3->tmp.new_mac_secret_size;
220 /* TODO(size_t): convert me */
221 cl = EVP_CIPHER_key_length(c);
223 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */
224 /* If GCM/CCM mode only part of IV comes from PRF */
225 if (EVP_CIPHER_mode(c) == EVP_CIPH_GCM_MODE)
226 k = EVP_GCM_TLS_FIXED_IV_LEN;
227 else if (EVP_CIPHER_mode(c) == EVP_CIPH_CCM_MODE)
228 k = EVP_CCM_TLS_FIXED_IV_LEN;
230 k = EVP_CIPHER_iv_length(c);
231 if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
232 (which == SSL3_CHANGE_CIPHER_SERVER_READ)) {
249 if (n > s->s3->tmp.key_block_length) {
250 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
251 ERR_R_INTERNAL_ERROR);
255 memcpy(mac_secret, ms, i);
257 if (!(EVP_CIPHER_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER)) {
258 /* TODO(size_t): Convert this function */
259 mac_key = EVP_PKEY_new_mac_key(mac_type, NULL,
260 mac_secret, (int)*mac_secret_size);
262 || EVP_DigestSignInit(mac_ctx, NULL, m, NULL, mac_key) <= 0) {
263 EVP_PKEY_free(mac_key);
264 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
265 ERR_R_INTERNAL_ERROR);
268 EVP_PKEY_free(mac_key);
271 printf("which = %04X\nmac key=", which);
274 for (z = 0; z < i; z++)
275 printf("%02X%c", ms[z], ((z + 1) % 16) ? ' ' : '\n');
279 if (EVP_CIPHER_mode(c) == EVP_CIPH_GCM_MODE) {
280 if (!EVP_CipherInit_ex(dd, c, NULL, key, NULL, (which & SSL3_CC_WRITE))
281 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_GCM_SET_IV_FIXED, (int)k,
283 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
284 ERR_R_INTERNAL_ERROR);
287 } else if (EVP_CIPHER_mode(c) == EVP_CIPH_CCM_MODE) {
290 new_cipher->algorithm_enc & (SSL_AES128CCM8 | SSL_AES256CCM8))
291 taglen = EVP_CCM8_TLS_TAG_LEN;
293 taglen = EVP_CCM_TLS_TAG_LEN;
294 if (!EVP_CipherInit_ex(dd, c, NULL, NULL, NULL, (which & SSL3_CC_WRITE))
295 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_IVLEN, 12, NULL)
296 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_TAG, taglen, NULL)
297 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_CCM_SET_IV_FIXED, (int)k, iv)
298 || !EVP_CipherInit_ex(dd, NULL, NULL, key, NULL, -1)) {
299 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
300 ERR_R_INTERNAL_ERROR);
304 if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE))) {
305 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
306 ERR_R_INTERNAL_ERROR);
310 /* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */
311 if ((EVP_CIPHER_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER) && *mac_secret_size
312 && !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_MAC_KEY,
313 (int)*mac_secret_size, mac_secret)) {
314 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
315 ERR_R_INTERNAL_ERROR);
320 printf("which = %04X\nkey=", which);
323 for (z = 0; z < EVP_CIPHER_key_length(c); z++)
324 printf("%02X%c", key[z], ((z + 1) % 16) ? ' ' : '\n');
329 for (z = 0; z < k; z++)
330 printf("%02X%c", iv[z], ((z + 1) % 16) ? ' ' : '\n');
335 OPENSSL_cleanse(tmp1, sizeof(tmp1));
336 OPENSSL_cleanse(tmp2, sizeof(tmp1));
337 OPENSSL_cleanse(iv1, sizeof(iv1));
338 OPENSSL_cleanse(iv2, sizeof(iv2));
341 OPENSSL_cleanse(tmp1, sizeof(tmp1));
342 OPENSSL_cleanse(tmp2, sizeof(tmp1));
343 OPENSSL_cleanse(iv1, sizeof(iv1));
344 OPENSSL_cleanse(iv2, sizeof(iv2));
348 int tls1_setup_key_block(SSL *s)
354 int mac_type = NID_undef;
355 size_t num, mac_secret_size = 0;
358 if (s->s3->tmp.key_block_length != 0)
361 if (!ssl_cipher_get_evp(s->session, &c, &hash, &mac_type, &mac_secret_size,
362 &comp, s->ext.use_etm)) {
363 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_SETUP_KEY_BLOCK,
364 SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
368 s->s3->tmp.new_sym_enc = c;
369 s->s3->tmp.new_hash = hash;
370 s->s3->tmp.new_mac_pkey_type = mac_type;
371 s->s3->tmp.new_mac_secret_size = mac_secret_size;
372 num = EVP_CIPHER_key_length(c) + mac_secret_size + EVP_CIPHER_iv_length(c);
375 ssl3_cleanup_key_block(s);
377 if ((p = OPENSSL_malloc(num)) == NULL) {
378 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_SETUP_KEY_BLOCK,
379 ERR_R_MALLOC_FAILURE);
383 s->s3->tmp.key_block_length = num;
384 s->s3->tmp.key_block = p;
387 printf("client random\n");
390 for (z = 0; z < SSL3_RANDOM_SIZE; z++)
391 printf("%02X%c", s->s3->client_random[z],
392 ((z + 1) % 16) ? ' ' : '\n');
394 printf("server random\n");
397 for (z = 0; z < SSL3_RANDOM_SIZE; z++)
398 printf("%02X%c", s->s3->server_random[z],
399 ((z + 1) % 16) ? ' ' : '\n');
401 printf("master key\n");
404 for (z = 0; z < s->session->master_key_length; z++)
405 printf("%02X%c", s->session->master_key[z],
406 ((z + 1) % 16) ? ' ' : '\n');
409 if (!tls1_generate_key_block(s, p, num)) {
410 /* SSLfatal() already called */
414 printf("\nkey block\n");
417 for (z = 0; z < num; z++)
418 printf("%02X%c", p[z], ((z + 1) % 16) ? ' ' : '\n');
422 if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)
423 && s->method->version <= TLS1_VERSION) {
425 * enable vulnerability countermeasure for CBC ciphers with known-IV
426 * problem (http://www.openssl.org/~bodo/tls-cbc.txt)
428 s->s3->need_empty_fragments = 1;
430 if (s->session->cipher != NULL) {
431 if (s->session->cipher->algorithm_enc == SSL_eNULL)
432 s->s3->need_empty_fragments = 0;
434 #ifndef OPENSSL_NO_RC4
435 if (s->session->cipher->algorithm_enc == SSL_RC4)
436 s->s3->need_empty_fragments = 0;
446 size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen,
450 unsigned char hash[EVP_MAX_MD_SIZE];
452 if (!ssl3_digest_cached_records(s, 0)) {
453 /* SSLfatal() already called */
457 if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
458 /* SSLfatal() already called */
462 if (!tls1_PRF(s, str, slen, hash, hashlen, NULL, 0, NULL, 0, NULL, 0,
463 s->session->master_key, s->session->master_key_length,
464 out, TLS1_FINISH_MAC_LENGTH, 1)) {
465 /* SSLfatal() already called */
468 OPENSSL_cleanse(hash, hashlen);
469 return TLS1_FINISH_MAC_LENGTH;
472 int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
473 size_t len, size_t *secret_size)
475 if (s->session->flags & SSL_SESS_FLAG_EXTMS) {
476 unsigned char hash[EVP_MAX_MD_SIZE * 2];
479 * Digest cached records keeping record buffer (if present): this wont
480 * affect client auth because we're freezing the buffer at the same
481 * point (after client key exchange and before certificate verify)
483 if (!ssl3_digest_cached_records(s, 1)
484 || !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
485 /* SSLfatal() already called */
489 fprintf(stderr, "Handshake hashes:\n");
490 BIO_dump_fp(stderr, (char *)hash, hashlen);
493 TLS_MD_EXTENDED_MASTER_SECRET_CONST,
494 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE,
498 NULL, 0, p, len, out,
499 SSL3_MASTER_SECRET_SIZE, 1)) {
500 /* SSLfatal() already called */
503 OPENSSL_cleanse(hash, hashlen);
506 TLS_MD_MASTER_SECRET_CONST,
507 TLS_MD_MASTER_SECRET_CONST_SIZE,
508 s->s3->client_random, SSL3_RANDOM_SIZE,
510 s->s3->server_random, SSL3_RANDOM_SIZE,
511 NULL, 0, p, len, out,
512 SSL3_MASTER_SECRET_SIZE, 1)) {
513 /* SSLfatal() already called */
518 fprintf(stderr, "Premaster Secret:\n");
519 BIO_dump_fp(stderr, (char *)p, len);
520 fprintf(stderr, "Client Random:\n");
521 BIO_dump_fp(stderr, (char *)s->s3->client_random, SSL3_RANDOM_SIZE);
522 fprintf(stderr, "Server Random:\n");
523 BIO_dump_fp(stderr, (char *)s->s3->server_random, SSL3_RANDOM_SIZE);
524 fprintf(stderr, "Master Secret:\n");
525 BIO_dump_fp(stderr, (char *)s->session->master_key,
526 SSL3_MASTER_SECRET_SIZE);
529 *secret_size = SSL3_MASTER_SECRET_SIZE;
533 int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
534 const char *label, size_t llen,
535 const unsigned char *context,
536 size_t contextlen, int use_context)
538 unsigned char *val = NULL;
539 size_t vallen = 0, currentvalpos;
543 * construct PRF arguments we construct the PRF argument ourself rather
544 * than passing separate values into the TLS PRF to ensure that the
545 * concatenation of values does not create a prohibited label.
547 vallen = llen + SSL3_RANDOM_SIZE * 2;
549 vallen += 2 + contextlen;
552 val = OPENSSL_malloc(vallen);
556 memcpy(val + currentvalpos, (unsigned char *)label, llen);
557 currentvalpos += llen;
558 memcpy(val + currentvalpos, s->s3->client_random, SSL3_RANDOM_SIZE);
559 currentvalpos += SSL3_RANDOM_SIZE;
560 memcpy(val + currentvalpos, s->s3->server_random, SSL3_RANDOM_SIZE);
561 currentvalpos += SSL3_RANDOM_SIZE;
564 val[currentvalpos] = (contextlen >> 8) & 0xff;
566 val[currentvalpos] = contextlen & 0xff;
568 if ((contextlen > 0) || (context != NULL)) {
569 memcpy(val + currentvalpos, context, contextlen);
574 * disallow prohibited labels note that SSL3_RANDOM_SIZE > max(prohibited
575 * label len) = 15, so size of val > max(prohibited label len) = 15 and
576 * the comparisons won't have buffer overflow
578 if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST,
579 TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0)
581 if (memcmp(val, TLS_MD_SERVER_FINISH_CONST,
582 TLS_MD_SERVER_FINISH_CONST_SIZE) == 0)
584 if (memcmp(val, TLS_MD_MASTER_SECRET_CONST,
585 TLS_MD_MASTER_SECRET_CONST_SIZE) == 0)
587 if (memcmp(val, TLS_MD_EXTENDED_MASTER_SECRET_CONST,
588 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE) == 0)
590 if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST,
591 TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0)
600 s->session->master_key, s->session->master_key_length,
605 SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL);
609 SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, ERR_R_MALLOC_FAILURE);
612 OPENSSL_clear_free(val, vallen);
616 int tls1_alert_code(int code)
619 case SSL_AD_CLOSE_NOTIFY:
620 return SSL3_AD_CLOSE_NOTIFY;
621 case SSL_AD_UNEXPECTED_MESSAGE:
622 return SSL3_AD_UNEXPECTED_MESSAGE;
623 case SSL_AD_BAD_RECORD_MAC:
624 return SSL3_AD_BAD_RECORD_MAC;
625 case SSL_AD_DECRYPTION_FAILED:
626 return TLS1_AD_DECRYPTION_FAILED;
627 case SSL_AD_RECORD_OVERFLOW:
628 return TLS1_AD_RECORD_OVERFLOW;
629 case SSL_AD_DECOMPRESSION_FAILURE:
630 return SSL3_AD_DECOMPRESSION_FAILURE;
631 case SSL_AD_HANDSHAKE_FAILURE:
632 return SSL3_AD_HANDSHAKE_FAILURE;
633 case SSL_AD_NO_CERTIFICATE:
635 case SSL_AD_BAD_CERTIFICATE:
636 return SSL3_AD_BAD_CERTIFICATE;
637 case SSL_AD_UNSUPPORTED_CERTIFICATE:
638 return SSL3_AD_UNSUPPORTED_CERTIFICATE;
639 case SSL_AD_CERTIFICATE_REVOKED:
640 return SSL3_AD_CERTIFICATE_REVOKED;
641 case SSL_AD_CERTIFICATE_EXPIRED:
642 return SSL3_AD_CERTIFICATE_EXPIRED;
643 case SSL_AD_CERTIFICATE_UNKNOWN:
644 return SSL3_AD_CERTIFICATE_UNKNOWN;
645 case SSL_AD_ILLEGAL_PARAMETER:
646 return SSL3_AD_ILLEGAL_PARAMETER;
647 case SSL_AD_UNKNOWN_CA:
648 return TLS1_AD_UNKNOWN_CA;
649 case SSL_AD_ACCESS_DENIED:
650 return TLS1_AD_ACCESS_DENIED;
651 case SSL_AD_DECODE_ERROR:
652 return TLS1_AD_DECODE_ERROR;
653 case SSL_AD_DECRYPT_ERROR:
654 return TLS1_AD_DECRYPT_ERROR;
655 case SSL_AD_EXPORT_RESTRICTION:
656 return TLS1_AD_EXPORT_RESTRICTION;
657 case SSL_AD_PROTOCOL_VERSION:
658 return TLS1_AD_PROTOCOL_VERSION;
659 case SSL_AD_INSUFFICIENT_SECURITY:
660 return TLS1_AD_INSUFFICIENT_SECURITY;
661 case SSL_AD_INTERNAL_ERROR:
662 return TLS1_AD_INTERNAL_ERROR;
663 case SSL_AD_USER_CANCELLED:
664 return TLS1_AD_USER_CANCELLED;
665 case SSL_AD_NO_RENEGOTIATION:
666 return TLS1_AD_NO_RENEGOTIATION;
667 case SSL_AD_UNSUPPORTED_EXTENSION:
668 return TLS1_AD_UNSUPPORTED_EXTENSION;
669 case SSL_AD_CERTIFICATE_UNOBTAINABLE:
670 return TLS1_AD_CERTIFICATE_UNOBTAINABLE;
671 case SSL_AD_UNRECOGNIZED_NAME:
672 return TLS1_AD_UNRECOGNIZED_NAME;
673 case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
674 return TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
675 case SSL_AD_BAD_CERTIFICATE_HASH_VALUE:
676 return TLS1_AD_BAD_CERTIFICATE_HASH_VALUE;
677 case SSL_AD_UNKNOWN_PSK_IDENTITY:
678 return TLS1_AD_UNKNOWN_PSK_IDENTITY;
679 case SSL_AD_INAPPROPRIATE_FALLBACK:
680 return TLS1_AD_INAPPROPRIATE_FALLBACK;
681 case SSL_AD_NO_APPLICATION_PROTOCOL:
682 return TLS1_AD_NO_APPLICATION_PROTOCOL;
683 case SSL_AD_CERTIFICATE_REQUIRED:
684 return SSL_AD_HANDSHAKE_FAILURE;