2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* ====================================================================
11 * Copyright 2005 Nokia. All rights reserved.
13 * The portions of the attached software ("Contribution") is developed by
14 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
17 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
18 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
19 * support (see RFC 4279) to OpenSSL.
21 * No patent licenses or other rights except those expressly stated in
22 * the OpenSSL open source license shall be deemed granted or received
23 * expressly, by implication, estoppel, or otherwise.
25 * No assurances are provided by Nokia that the Contribution does not
26 * infringe the patent or other intellectual property rights of any third
27 * party or that the license provides you with all the necessary rights
28 * to make use of the Contribution.
30 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
31 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
32 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
33 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
39 #include <openssl/comp.h>
40 #include <openssl/evp.h>
41 #include <openssl/kdf.h>
42 #include <openssl/rand.h>
44 /* seed1 through seed5 are concatenated */
45 static int tls1_PRF(SSL *s,
46 const void *seed1, size_t seed1_len,
47 const void *seed2, size_t seed2_len,
48 const void *seed3, size_t seed3_len,
49 const void *seed4, size_t seed4_len,
50 const void *seed5, size_t seed5_len,
51 const unsigned char *sec, size_t slen,
52 unsigned char *out, size_t olen)
54 const EVP_MD *md = ssl_prf_md(s);
55 EVP_PKEY_CTX *pctx = NULL;
60 /* Should never happen */
61 SSLerr(SSL_F_TLS1_PRF, ERR_R_INTERNAL_ERROR);
64 pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
65 if (pctx == NULL || EVP_PKEY_derive_init(pctx) <= 0
66 || EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) <= 0
67 || EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, slen) <= 0)
70 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed1, seed1_len) <= 0)
72 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed2, seed2_len) <= 0)
74 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed3, seed3_len) <= 0)
76 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed4, seed4_len) <= 0)
78 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed5, seed5_len) <= 0)
81 if (EVP_PKEY_derive(pctx, out, &olen) <= 0)
86 EVP_PKEY_CTX_free(pctx);
90 static int tls1_generate_key_block(SSL *s, unsigned char *km, size_t num)
94 TLS_MD_KEY_EXPANSION_CONST,
95 TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3->server_random,
96 SSL3_RANDOM_SIZE, s->s3->client_random, SSL3_RANDOM_SIZE,
97 NULL, 0, NULL, 0, s->session->master_key,
98 s->session->master_key_length, km, num);
103 int tls1_change_cipher_state(SSL *s, int which)
105 unsigned char *p, *mac_secret;
106 unsigned char tmp1[EVP_MAX_KEY_LENGTH];
107 unsigned char tmp2[EVP_MAX_KEY_LENGTH];
108 unsigned char iv1[EVP_MAX_IV_LENGTH * 2];
109 unsigned char iv2[EVP_MAX_IV_LENGTH * 2];
110 unsigned char *ms, *key, *iv;
113 #ifndef OPENSSL_NO_COMP
114 const SSL_COMP *comp;
118 size_t *mac_secret_size;
121 size_t n, i, j, k, cl;
124 c = s->s3->tmp.new_sym_enc;
125 m = s->s3->tmp.new_hash;
126 mac_type = s->s3->tmp.new_mac_pkey_type;
127 #ifndef OPENSSL_NO_COMP
128 comp = s->s3->tmp.new_compression;
131 if (which & SSL3_CC_READ) {
132 if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
133 s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM;
135 s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM;
137 if (s->enc_read_ctx != NULL)
139 else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL)
143 * make sure it's initialised in case we exit later with an error
145 EVP_CIPHER_CTX_reset(s->enc_read_ctx);
146 dd = s->enc_read_ctx;
147 mac_ctx = ssl_replace_hash(&s->read_hash, NULL);
150 #ifndef OPENSSL_NO_COMP
151 COMP_CTX_free(s->expand);
154 s->expand = COMP_CTX_new(comp->method);
155 if (s->expand == NULL) {
156 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,
157 SSL_R_COMPRESSION_LIBRARY_ERROR);
163 * this is done by dtls1_reset_seq_numbers for DTLS
166 RECORD_LAYER_reset_read_sequence(&s->rlayer);
167 mac_secret = &(s->s3->read_mac_secret[0]);
168 mac_secret_size = &(s->s3->read_mac_secret_size);
170 if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
171 s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
173 s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
174 if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s))
176 else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL)
178 dd = s->enc_write_ctx;
179 if (SSL_IS_DTLS(s)) {
180 mac_ctx = EVP_MD_CTX_new();
183 s->write_hash = mac_ctx;
185 mac_ctx = ssl_replace_hash(&s->write_hash, NULL);
189 #ifndef OPENSSL_NO_COMP
190 COMP_CTX_free(s->compress);
193 s->compress = COMP_CTX_new(comp->method);
194 if (s->compress == NULL) {
195 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,
196 SSL_R_COMPRESSION_LIBRARY_ERROR);
202 * this is done by dtls1_reset_seq_numbers for DTLS
205 RECORD_LAYER_reset_write_sequence(&s->rlayer);
206 mac_secret = &(s->s3->write_mac_secret[0]);
207 mac_secret_size = &(s->s3->write_mac_secret_size);
211 EVP_CIPHER_CTX_reset(dd);
213 p = s->s3->tmp.key_block;
214 i = *mac_secret_size = s->s3->tmp.new_mac_secret_size;
216 /* TODO(size_t): convert me */
217 cl = EVP_CIPHER_key_length(c);
219 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */
220 /* If GCM/CCM mode only part of IV comes from PRF */
221 if (EVP_CIPHER_mode(c) == EVP_CIPH_GCM_MODE)
222 k = EVP_GCM_TLS_FIXED_IV_LEN;
223 else if (EVP_CIPHER_mode(c) == EVP_CIPH_CCM_MODE)
224 k = EVP_CCM_TLS_FIXED_IV_LEN;
226 k = EVP_CIPHER_iv_length(c);
227 if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
228 (which == SSL3_CHANGE_CIPHER_SERVER_READ)) {
245 if (n > s->s3->tmp.key_block_length) {
246 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
250 memcpy(mac_secret, ms, i);
252 if (!(EVP_CIPHER_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER)) {
253 mac_key = EVP_PKEY_new_mac_key(mac_type, NULL,
254 mac_secret, *mac_secret_size);
256 || EVP_DigestSignInit(mac_ctx, NULL, m, NULL, mac_key) <= 0) {
257 EVP_PKEY_free(mac_key);
258 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
261 EVP_PKEY_free(mac_key);
264 printf("which = %04X\nmac key=", which);
267 for (z = 0; z < i; z++)
268 printf("%02X%c", ms[z], ((z + 1) % 16) ? ' ' : '\n');
272 if (EVP_CIPHER_mode(c) == EVP_CIPH_GCM_MODE) {
273 if (!EVP_CipherInit_ex(dd, c, NULL, key, NULL, (which & SSL3_CC_WRITE))
274 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_GCM_SET_IV_FIXED, k, iv)) {
275 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
278 } else if (EVP_CIPHER_mode(c) == EVP_CIPH_CCM_MODE) {
281 new_cipher->algorithm_enc & (SSL_AES128CCM8 | SSL_AES256CCM8))
285 if (!EVP_CipherInit_ex(dd, c, NULL, NULL, NULL, (which & SSL3_CC_WRITE))
286 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_IVLEN, 12, NULL)
287 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_TAG, taglen, NULL)
288 || !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_CCM_SET_IV_FIXED, k, iv)
289 || !EVP_CipherInit_ex(dd, NULL, NULL, key, NULL, -1)) {
290 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
294 if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE))) {
295 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
299 /* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */
300 if ((EVP_CIPHER_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER) && *mac_secret_size
301 && !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_MAC_KEY,
302 *mac_secret_size, mac_secret)) {
303 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
306 #ifdef OPENSSL_SSL_TRACE_CRYPTO
307 if (s->msg_callback) {
308 int wh = which & SSL3_CC_WRITE ? TLS1_RT_CRYPTO_WRITE : 0;
309 if (*mac_secret_size)
310 s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_MAC,
311 mac_secret, *mac_secret_size,
312 s, s->msg_callback_arg);
314 s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_KEY,
315 key, c->key_len, s, s->msg_callback_arg);
317 if (EVP_CIPHER_mode(c) == EVP_CIPH_GCM_MODE)
318 wh |= TLS1_RT_CRYPTO_FIXED_IV;
320 wh |= TLS1_RT_CRYPTO_IV;
321 s->msg_callback(2, s->version, wh, iv, k, s, s->msg_callback_arg);
327 printf("which = %04X\nkey=", which);
330 for (z = 0; z < EVP_CIPHER_key_length(c); z++)
331 printf("%02X%c", key[z], ((z + 1) % 16) ? ' ' : '\n');
336 for (z = 0; z < k; z++)
337 printf("%02X%c", iv[z], ((z + 1) % 16) ? ' ' : '\n');
342 OPENSSL_cleanse(tmp1, sizeof(tmp1));
343 OPENSSL_cleanse(tmp2, sizeof(tmp1));
344 OPENSSL_cleanse(iv1, sizeof(iv1));
345 OPENSSL_cleanse(iv2, sizeof(iv2));
348 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
350 OPENSSL_cleanse(tmp1, sizeof(tmp1));
351 OPENSSL_cleanse(tmp2, sizeof(tmp1));
352 OPENSSL_cleanse(iv1, sizeof(iv1));
353 OPENSSL_cleanse(iv2, sizeof(iv2));
357 int tls1_setup_key_block(SSL *s)
363 int mac_type = NID_undef;
364 size_t num, mac_secret_size = 0;
367 if (s->s3->tmp.key_block_length != 0)
370 if (!ssl_cipher_get_evp
371 (s->session, &c, &hash, &mac_type, &mac_secret_size, &comp,
373 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
377 s->s3->tmp.new_sym_enc = c;
378 s->s3->tmp.new_hash = hash;
379 s->s3->tmp.new_mac_pkey_type = mac_type;
380 s->s3->tmp.new_mac_secret_size = mac_secret_size;
381 num = EVP_CIPHER_key_length(c) + mac_secret_size + EVP_CIPHER_iv_length(c);
384 ssl3_cleanup_key_block(s);
386 if ((p = OPENSSL_malloc(num)) == NULL) {
387 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
391 s->s3->tmp.key_block_length = num;
392 s->s3->tmp.key_block = p;
395 printf("client random\n");
398 for (z = 0; z < SSL3_RANDOM_SIZE; z++)
399 printf("%02X%c", s->s3->client_random[z],
400 ((z + 1) % 16) ? ' ' : '\n');
402 printf("server random\n");
405 for (z = 0; z < SSL3_RANDOM_SIZE; z++)
406 printf("%02X%c", s->s3->server_random[z],
407 ((z + 1) % 16) ? ' ' : '\n');
409 printf("master key\n");
412 for (z = 0; z < s->session->master_key_length; z++)
413 printf("%02X%c", s->session->master_key[z],
414 ((z + 1) % 16) ? ' ' : '\n');
417 if (!tls1_generate_key_block(s, p, num))
420 printf("\nkey block\n");
423 for (z = 0; z < num; z++)
424 printf("%02X%c", p[z], ((z + 1) % 16) ? ' ' : '\n');
428 if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)
429 && s->method->version <= TLS1_VERSION) {
431 * enable vulnerability countermeasure for CBC ciphers with known-IV
432 * problem (http://www.openssl.org/~bodo/tls-cbc.txt)
434 s->s3->need_empty_fragments = 1;
436 if (s->session->cipher != NULL) {
437 if (s->session->cipher->algorithm_enc == SSL_eNULL)
438 s->s3->need_empty_fragments = 0;
440 #ifndef OPENSSL_NO_RC4
441 if (s->session->cipher->algorithm_enc == SSL_RC4)
442 s->s3->need_empty_fragments = 0;
452 size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen,
456 unsigned char hash[EVP_MAX_MD_SIZE];
458 if (!ssl3_digest_cached_records(s, 0))
461 if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen))
464 if (!tls1_PRF(s, str, slen, hash, hashlen, NULL, 0, NULL, 0, NULL, 0,
465 s->session->master_key, s->session->master_key_length,
466 out, TLS1_FINISH_MAC_LENGTH))
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))
485 if(!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen))
488 fprintf(stderr, "Handshake hashes:\n");
489 BIO_dump_fp(stderr, (char *)hash, hashlen);
492 TLS_MD_EXTENDED_MASTER_SECRET_CONST,
493 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE,
497 NULL, 0, p, len, s->session->master_key,
498 SSL3_MASTER_SECRET_SIZE);
499 OPENSSL_cleanse(hash, hashlen);
502 TLS_MD_MASTER_SECRET_CONST,
503 TLS_MD_MASTER_SECRET_CONST_SIZE,
504 s->s3->client_random, SSL3_RANDOM_SIZE,
506 s->s3->server_random, SSL3_RANDOM_SIZE,
507 NULL, 0, p, len, s->session->master_key,
508 SSL3_MASTER_SECRET_SIZE);
511 fprintf(stderr, "Premaster Secret:\n");
512 BIO_dump_fp(stderr, (char *)p, len);
513 fprintf(stderr, "Client Random:\n");
514 BIO_dump_fp(stderr, (char *)s->s3->client_random, SSL3_RANDOM_SIZE);
515 fprintf(stderr, "Server Random:\n");
516 BIO_dump_fp(stderr, (char *)s->s3->server_random, SSL3_RANDOM_SIZE);
517 fprintf(stderr, "Master Secret:\n");
518 BIO_dump_fp(stderr, (char *)s->session->master_key,
519 SSL3_MASTER_SECRET_SIZE);
522 #ifdef OPENSSL_SSL_TRACE_CRYPTO
523 if (s->msg_callback) {
524 s->msg_callback(2, s->version, TLS1_RT_CRYPTO_PREMASTER,
525 p, len, s, s->msg_callback_arg);
526 s->msg_callback(2, s->version, TLS1_RT_CRYPTO_CLIENT_RANDOM,
527 s->s3->client_random, SSL3_RANDOM_SIZE,
528 s, s->msg_callback_arg);
529 s->msg_callback(2, s->version, TLS1_RT_CRYPTO_SERVER_RANDOM,
530 s->s3->server_random, SSL3_RANDOM_SIZE,
531 s, s->msg_callback_arg);
532 s->msg_callback(2, s->version, TLS1_RT_CRYPTO_MASTER,
533 s->session->master_key,
534 SSL3_MASTER_SECRET_SIZE, s, s->msg_callback_arg);
538 *secret_size = SSL3_MASTER_SECRET_SIZE;
542 int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
543 const char *label, size_t llen,
544 const unsigned char *context,
545 size_t contextlen, int use_context)
547 unsigned char *val = NULL;
548 size_t vallen = 0, currentvalpos;
552 * construct PRF arguments we construct the PRF argument ourself rather
553 * than passing separate values into the TLS PRF to ensure that the
554 * concatenation of values does not create a prohibited label.
556 vallen = llen + SSL3_RANDOM_SIZE * 2;
558 vallen += 2 + contextlen;
561 val = OPENSSL_malloc(vallen);
565 memcpy(val + currentvalpos, (unsigned char *)label, llen);
566 currentvalpos += llen;
567 memcpy(val + currentvalpos, s->s3->client_random, SSL3_RANDOM_SIZE);
568 currentvalpos += SSL3_RANDOM_SIZE;
569 memcpy(val + currentvalpos, s->s3->server_random, SSL3_RANDOM_SIZE);
570 currentvalpos += SSL3_RANDOM_SIZE;
573 val[currentvalpos] = (contextlen >> 8) & 0xff;
575 val[currentvalpos] = contextlen & 0xff;
577 if ((contextlen > 0) || (context != NULL)) {
578 memcpy(val + currentvalpos, context, contextlen);
583 * disallow prohibited labels note that SSL3_RANDOM_SIZE > max(prohibited
584 * label len) = 15, so size of val > max(prohibited label len) = 15 and
585 * the comparisons won't have buffer overflow
587 if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST,
588 TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0)
590 if (memcmp(val, TLS_MD_SERVER_FINISH_CONST,
591 TLS_MD_SERVER_FINISH_CONST_SIZE) == 0)
593 if (memcmp(val, TLS_MD_MASTER_SECRET_CONST,
594 TLS_MD_MASTER_SECRET_CONST_SIZE) == 0)
596 if (memcmp(val, TLS_MD_EXTENDED_MASTER_SECRET_CONST,
597 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE) == 0)
599 if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST,
600 TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0)
609 s->session->master_key, s->session->master_key_length,
614 SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL);
618 SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, ERR_R_MALLOC_FAILURE);
621 OPENSSL_clear_free(val, vallen);
625 int tls1_alert_code(int code)
628 case SSL_AD_CLOSE_NOTIFY:
629 return (SSL3_AD_CLOSE_NOTIFY);
630 case SSL_AD_UNEXPECTED_MESSAGE:
631 return (SSL3_AD_UNEXPECTED_MESSAGE);
632 case SSL_AD_BAD_RECORD_MAC:
633 return (SSL3_AD_BAD_RECORD_MAC);
634 case SSL_AD_DECRYPTION_FAILED:
635 return (TLS1_AD_DECRYPTION_FAILED);
636 case SSL_AD_RECORD_OVERFLOW:
637 return (TLS1_AD_RECORD_OVERFLOW);
638 case SSL_AD_DECOMPRESSION_FAILURE:
639 return (SSL3_AD_DECOMPRESSION_FAILURE);
640 case SSL_AD_HANDSHAKE_FAILURE:
641 return (SSL3_AD_HANDSHAKE_FAILURE);
642 case SSL_AD_NO_CERTIFICATE:
644 case SSL_AD_BAD_CERTIFICATE:
645 return (SSL3_AD_BAD_CERTIFICATE);
646 case SSL_AD_UNSUPPORTED_CERTIFICATE:
647 return (SSL3_AD_UNSUPPORTED_CERTIFICATE);
648 case SSL_AD_CERTIFICATE_REVOKED:
649 return (SSL3_AD_CERTIFICATE_REVOKED);
650 case SSL_AD_CERTIFICATE_EXPIRED:
651 return (SSL3_AD_CERTIFICATE_EXPIRED);
652 case SSL_AD_CERTIFICATE_UNKNOWN:
653 return (SSL3_AD_CERTIFICATE_UNKNOWN);
654 case SSL_AD_ILLEGAL_PARAMETER:
655 return (SSL3_AD_ILLEGAL_PARAMETER);
656 case SSL_AD_UNKNOWN_CA:
657 return (TLS1_AD_UNKNOWN_CA);
658 case SSL_AD_ACCESS_DENIED:
659 return (TLS1_AD_ACCESS_DENIED);
660 case SSL_AD_DECODE_ERROR:
661 return (TLS1_AD_DECODE_ERROR);
662 case SSL_AD_DECRYPT_ERROR:
663 return (TLS1_AD_DECRYPT_ERROR);
664 case SSL_AD_EXPORT_RESTRICTION:
665 return (TLS1_AD_EXPORT_RESTRICTION);
666 case SSL_AD_PROTOCOL_VERSION:
667 return (TLS1_AD_PROTOCOL_VERSION);
668 case SSL_AD_INSUFFICIENT_SECURITY:
669 return (TLS1_AD_INSUFFICIENT_SECURITY);
670 case SSL_AD_INTERNAL_ERROR:
671 return (TLS1_AD_INTERNAL_ERROR);
672 case SSL_AD_USER_CANCELLED:
673 return (TLS1_AD_USER_CANCELLED);
674 case SSL_AD_NO_RENEGOTIATION:
675 return (TLS1_AD_NO_RENEGOTIATION);
676 case SSL_AD_UNSUPPORTED_EXTENSION:
677 return (TLS1_AD_UNSUPPORTED_EXTENSION);
678 case SSL_AD_CERTIFICATE_UNOBTAINABLE:
679 return (TLS1_AD_CERTIFICATE_UNOBTAINABLE);
680 case SSL_AD_UNRECOGNIZED_NAME:
681 return (TLS1_AD_UNRECOGNIZED_NAME);
682 case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
683 return (TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE);
684 case SSL_AD_BAD_CERTIFICATE_HASH_VALUE:
685 return (TLS1_AD_BAD_CERTIFICATE_HASH_VALUE);
686 case SSL_AD_UNKNOWN_PSK_IDENTITY:
687 return (TLS1_AD_UNKNOWN_PSK_IDENTITY);
688 case SSL_AD_INAPPROPRIATE_FALLBACK:
689 return (TLS1_AD_INAPPROPRIATE_FALLBACK);
690 case SSL_AD_NO_APPLICATION_PROTOCOL:
691 return (TLS1_AD_NO_APPLICATION_PROTOCOL);