1 /*
2 * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright 2005 Nokia. All rights reserved.
4 *
5 * Licensed under the Apache License 2.0 (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
9 */
10
11 #include <stdio.h>
12 #include "ssl_local.h"
13 #include "record/record_local.h"
14 #include "internal/ktls.h"
15 #include "internal/cryptlib.h"
16 #include <openssl/comp.h>
17 #include <openssl/evp.h>
18 #include <openssl/kdf.h>
19 #include <openssl/rand.h>
20 #include <openssl/obj_mac.h>
21 #include <openssl/core_names.h>
22 #include <openssl/trace.h>
23
24 /* seed1 through seed5 are concatenated */
tls1_PRF(SSL_CONNECTION * s,const void * seed1,size_t seed1_len,const void * seed2,size_t seed2_len,const void * seed3,size_t seed3_len,const void * seed4,size_t seed4_len,const void * seed5,size_t seed5_len,const unsigned char * sec,size_t slen,unsigned char * out,size_t olen,int fatal)25 static int tls1_PRF(SSL_CONNECTION *s,
26 const void *seed1, size_t seed1_len,
27 const void *seed2, size_t seed2_len,
28 const void *seed3, size_t seed3_len,
29 const void *seed4, size_t seed4_len,
30 const void *seed5, size_t seed5_len,
31 const unsigned char *sec, size_t slen,
32 unsigned char *out, size_t olen, int fatal)
33 {
34 const EVP_MD *md = ssl_prf_md(s);
35 EVP_KDF *kdf;
36 EVP_KDF_CTX *kctx = NULL;
37 OSSL_PARAM params[8], *p = params;
38 const char *mdname;
39
40 if (md == NULL) {
41 /* Should never happen */
42 if (fatal)
43 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
44 else
45 ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
46 return 0;
47 }
48 kdf = EVP_KDF_fetch(SSL_CONNECTION_GET_CTX(s)->libctx,
49 OSSL_KDF_NAME_TLS1_PRF,
50 SSL_CONNECTION_GET_CTX(s)->propq);
51 if (kdf == NULL)
52 goto err;
53 kctx = EVP_KDF_CTX_new(kdf);
54 EVP_KDF_free(kdf);
55 if (kctx == NULL)
56 goto err;
57 mdname = EVP_MD_get0_name(md);
58 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
59 (char *)mdname, 0);
60 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
61 (unsigned char *)sec,
62 (size_t)slen);
63 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
64 (void *)seed1, (size_t)seed1_len);
65 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
66 (void *)seed2, (size_t)seed2_len);
67 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
68 (void *)seed3, (size_t)seed3_len);
69 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
70 (void *)seed4, (size_t)seed4_len);
71 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
72 (void *)seed5, (size_t)seed5_len);
73 *p = OSSL_PARAM_construct_end();
74 if (EVP_KDF_derive(kctx, out, olen, params)) {
75 EVP_KDF_CTX_free(kctx);
76 return 1;
77 }
78
79 err:
80 if (fatal)
81 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
82 else
83 ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
84 EVP_KDF_CTX_free(kctx);
85 return 0;
86 }
87
tls1_generate_key_block(SSL_CONNECTION * s,unsigned char * km,size_t num)88 static int tls1_generate_key_block(SSL_CONNECTION *s, unsigned char *km,
89 size_t num)
90 {
91 int ret;
92
93 /* Calls SSLfatal() as required */
94 ret = tls1_PRF(s,
95 TLS_MD_KEY_EXPANSION_CONST,
96 TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3.server_random,
97 SSL3_RANDOM_SIZE, s->s3.client_random, SSL3_RANDOM_SIZE,
98 NULL, 0, NULL, 0, s->session->master_key,
99 s->session->master_key_length, km, num, 1);
100
101 return ret;
102 }
103
tls_iv_length_within_key_block(const EVP_CIPHER * c)104 static int tls_iv_length_within_key_block(const EVP_CIPHER *c)
105 {
106 /* If GCM/CCM mode only part of IV comes from PRF */
107 if (EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE)
108 return EVP_GCM_TLS_FIXED_IV_LEN;
109 else if (EVP_CIPHER_get_mode(c) == EVP_CIPH_CCM_MODE)
110 return EVP_CCM_TLS_FIXED_IV_LEN;
111 else
112 return EVP_CIPHER_get_iv_length(c);
113 }
114
tls1_change_cipher_state(SSL_CONNECTION * s,int which)115 int tls1_change_cipher_state(SSL_CONNECTION *s, int which)
116 {
117 unsigned char *p, *mac_secret;
118 unsigned char *key, *iv;
119 const EVP_CIPHER *c;
120 const SSL_COMP *comp = NULL;
121 const EVP_MD *m;
122 int mac_type;
123 size_t mac_secret_size;
124 size_t n, i, j, k, cl;
125 int iivlen;
126 /*
127 * Taglen is only relevant for CCM ciphersuites. Other ciphersuites
128 * ignore this value so we can default it to 0.
129 */
130 size_t taglen = 0;
131 int direction;
132
133 c = s->s3.tmp.new_sym_enc;
134 m = s->s3.tmp.new_hash;
135 mac_type = s->s3.tmp.new_mac_pkey_type;
136 #ifndef OPENSSL_NO_COMP
137 comp = s->s3.tmp.new_compression;
138 #endif
139
140 p = s->s3.tmp.key_block;
141 i = mac_secret_size = s->s3.tmp.new_mac_secret_size;
142
143 cl = EVP_CIPHER_get_key_length(c);
144 j = cl;
145 iivlen = tls_iv_length_within_key_block(c);
146 if (iivlen < 0) {
147 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
148 goto err;
149 }
150 k = iivlen;
151 if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
152 (which == SSL3_CHANGE_CIPHER_SERVER_READ)) {
153 mac_secret = &(p[0]);
154 n = i + i;
155 key = &(p[n]);
156 n += j + j;
157 iv = &(p[n]);
158 n += k + k;
159 } else {
160 n = i;
161 mac_secret = &(p[n]);
162 n += i + j;
163 key = &(p[n]);
164 n += j + k;
165 iv = &(p[n]);
166 n += k;
167 }
168
169 if (n > s->s3.tmp.key_block_length) {
170 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
171 goto err;
172 }
173
174 switch (EVP_CIPHER_get_mode(c)) {
175 case EVP_CIPH_GCM_MODE:
176 taglen = EVP_GCM_TLS_TAG_LEN;
177 break;
178 case EVP_CIPH_CCM_MODE:
179 if ((s->s3.tmp.new_cipher->algorithm_enc
180 & (SSL_AES128CCM8 | SSL_AES256CCM8)) != 0)
181 taglen = EVP_CCM8_TLS_TAG_LEN;
182 else
183 taglen = EVP_CCM_TLS_TAG_LEN;
184 break;
185 default:
186 if (EVP_CIPHER_is_a(c, "CHACHA20-POLY1305")) {
187 taglen = EVP_CHACHAPOLY_TLS_TAG_LEN;
188 } else {
189 /* MAC secret size corresponds to the MAC output size */
190 taglen = s->s3.tmp.new_mac_secret_size;
191 }
192 break;
193 }
194
195 if (which & SSL3_CC_READ) {
196 if (s->ext.use_etm)
197 s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
198 else
199 s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
200
201 if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
202 s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM;
203 else
204 s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM;
205
206 if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE)
207 s->mac_flags |= SSL_MAC_FLAG_READ_MAC_TLSTREE;
208 else
209 s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_TLSTREE;
210
211 direction = OSSL_RECORD_DIRECTION_READ;
212 } else {
213 if (s->ext.use_etm)
214 s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
215 else
216 s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
217
218 if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
219 s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
220 else
221 s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
222
223 if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE)
224 s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_TLSTREE;
225 else
226 s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_TLSTREE;
227
228 direction = OSSL_RECORD_DIRECTION_WRITE;
229 }
230
231 if (SSL_CONNECTION_IS_DTLS(s))
232 dtls1_increment_epoch(s, which);
233
234 if (!ssl_set_new_record_layer(s, s->version, direction,
235 OSSL_RECORD_PROTECTION_LEVEL_APPLICATION,
236 NULL, 0, key, cl, iv, (size_t)k, mac_secret,
237 mac_secret_size, c, taglen, mac_type,
238 m, comp, NULL)) {
239 /* SSLfatal already called */
240 goto err;
241 }
242
243 OSSL_TRACE_BEGIN(TLS) {
244 BIO_printf(trc_out, "which = %04X, key:\n", which);
245 BIO_dump_indent(trc_out, key, EVP_CIPHER_get_key_length(c), 4);
246 BIO_printf(trc_out, "iv:\n");
247 BIO_dump_indent(trc_out, iv, k, 4);
248 } OSSL_TRACE_END(TLS);
249
250 return 1;
251 err:
252 return 0;
253 }
254
tls1_setup_key_block(SSL_CONNECTION * s)255 int tls1_setup_key_block(SSL_CONNECTION *s)
256 {
257 unsigned char *p;
258 const EVP_CIPHER *c;
259 const EVP_MD *hash;
260 SSL_COMP *comp;
261 int mac_type = NID_undef;
262 size_t num, mac_secret_size = 0;
263 int ret = 0;
264 int ivlen;
265
266 if (s->s3.tmp.key_block_length != 0)
267 return 1;
268
269 if (!ssl_cipher_get_evp(SSL_CONNECTION_GET_CTX(s), s->session, &c, &hash,
270 &mac_type, &mac_secret_size, &comp,
271 s->ext.use_etm)) {
272 /* Error is already recorded */
273 SSLfatal_alert(s, SSL_AD_INTERNAL_ERROR);
274 return 0;
275 }
276
277 ssl_evp_cipher_free(s->s3.tmp.new_sym_enc);
278 s->s3.tmp.new_sym_enc = c;
279 ssl_evp_md_free(s->s3.tmp.new_hash);
280 s->s3.tmp.new_hash = hash;
281 s->s3.tmp.new_mac_pkey_type = mac_type;
282 s->s3.tmp.new_mac_secret_size = mac_secret_size;
283 ivlen = tls_iv_length_within_key_block(c);
284 if (ivlen < 0) {
285 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
286 return 0;
287 }
288 num = mac_secret_size + EVP_CIPHER_get_key_length(c) + ivlen;
289 num *= 2;
290
291 ssl3_cleanup_key_block(s);
292
293 if ((p = OPENSSL_malloc(num)) == NULL) {
294 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_CRYPTO_LIB);
295 goto err;
296 }
297
298 s->s3.tmp.key_block_length = num;
299 s->s3.tmp.key_block = p;
300
301 OSSL_TRACE_BEGIN(TLS) {
302 BIO_printf(trc_out, "key block length: %zu\n", num);
303 BIO_printf(trc_out, "client random\n");
304 BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4);
305 BIO_printf(trc_out, "server random\n");
306 BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4);
307 BIO_printf(trc_out, "master key\n");
308 BIO_dump_indent(trc_out,
309 s->session->master_key,
310 s->session->master_key_length, 4);
311 } OSSL_TRACE_END(TLS);
312
313 if (!tls1_generate_key_block(s, p, num)) {
314 /* SSLfatal() already called */
315 goto err;
316 }
317
318 OSSL_TRACE_BEGIN(TLS) {
319 BIO_printf(trc_out, "key block\n");
320 BIO_dump_indent(trc_out, p, num, 4);
321 } OSSL_TRACE_END(TLS);
322
323 ret = 1;
324 err:
325 return ret;
326 }
327
tls1_final_finish_mac(SSL_CONNECTION * s,const char * str,size_t slen,unsigned char * out)328 size_t tls1_final_finish_mac(SSL_CONNECTION *s, const char *str,
329 size_t slen, unsigned char *out)
330 {
331 size_t hashlen;
332 unsigned char hash[EVP_MAX_MD_SIZE];
333 size_t finished_size = TLS1_FINISH_MAC_LENGTH;
334
335 if (s->s3.tmp.new_cipher->algorithm_mkey & SSL_kGOST18)
336 finished_size = 32;
337
338 if (!ssl3_digest_cached_records(s, 0)) {
339 /* SSLfatal() already called */
340 return 0;
341 }
342
343 if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
344 /* SSLfatal() already called */
345 return 0;
346 }
347
348 if (!tls1_PRF(s, str, slen, hash, hashlen, NULL, 0, NULL, 0, NULL, 0,
349 s->session->master_key, s->session->master_key_length,
350 out, finished_size, 1)) {
351 /* SSLfatal() already called */
352 return 0;
353 }
354 OPENSSL_cleanse(hash, hashlen);
355 return finished_size;
356 }
357
tls1_generate_master_secret(SSL_CONNECTION * s,unsigned char * out,unsigned char * p,size_t len,size_t * secret_size)358 int tls1_generate_master_secret(SSL_CONNECTION *s, unsigned char *out,
359 unsigned char *p, size_t len,
360 size_t *secret_size)
361 {
362 if (s->session->flags & SSL_SESS_FLAG_EXTMS) {
363 unsigned char hash[EVP_MAX_MD_SIZE * 2];
364 size_t hashlen;
365 /*
366 * Digest cached records keeping record buffer (if present): this won't
367 * affect client auth because we're freezing the buffer at the same
368 * point (after client key exchange and before certificate verify)
369 */
370 if (!ssl3_digest_cached_records(s, 1)
371 || !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
372 /* SSLfatal() already called */
373 return 0;
374 }
375 OSSL_TRACE_BEGIN(TLS) {
376 BIO_printf(trc_out, "Handshake hashes:\n");
377 BIO_dump(trc_out, (char *)hash, hashlen);
378 } OSSL_TRACE_END(TLS);
379 if (!tls1_PRF(s,
380 TLS_MD_EXTENDED_MASTER_SECRET_CONST,
381 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE,
382 hash, hashlen,
383 NULL, 0,
384 NULL, 0,
385 NULL, 0, p, len, out,
386 SSL3_MASTER_SECRET_SIZE, 1)) {
387 /* SSLfatal() already called */
388 return 0;
389 }
390 OPENSSL_cleanse(hash, hashlen);
391 } else {
392 if (!tls1_PRF(s,
393 TLS_MD_MASTER_SECRET_CONST,
394 TLS_MD_MASTER_SECRET_CONST_SIZE,
395 s->s3.client_random, SSL3_RANDOM_SIZE,
396 NULL, 0,
397 s->s3.server_random, SSL3_RANDOM_SIZE,
398 NULL, 0, p, len, out,
399 SSL3_MASTER_SECRET_SIZE, 1)) {
400 /* SSLfatal() already called */
401 return 0;
402 }
403 }
404
405 OSSL_TRACE_BEGIN(TLS) {
406 BIO_printf(trc_out, "Premaster Secret:\n");
407 BIO_dump_indent(trc_out, p, len, 4);
408 BIO_printf(trc_out, "Client Random:\n");
409 BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4);
410 BIO_printf(trc_out, "Server Random:\n");
411 BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4);
412 BIO_printf(trc_out, "Master Secret:\n");
413 BIO_dump_indent(trc_out,
414 s->session->master_key,
415 SSL3_MASTER_SECRET_SIZE, 4);
416 } OSSL_TRACE_END(TLS);
417
418 *secret_size = SSL3_MASTER_SECRET_SIZE;
419 return 1;
420 }
421
tls1_export_keying_material(SSL_CONNECTION * s,unsigned char * out,size_t olen,const char * label,size_t llen,const unsigned char * context,size_t contextlen,int use_context)422 int tls1_export_keying_material(SSL_CONNECTION *s, unsigned char *out,
423 size_t olen, const char *label, size_t llen,
424 const unsigned char *context,
425 size_t contextlen, int use_context)
426 {
427 unsigned char *val = NULL;
428 size_t vallen = 0, currentvalpos;
429 int rv = 0;
430
431 /*
432 * RFC 5705 embeds context length as uint16; reject longer context
433 * before proceeding.
434 */
435 if (contextlen > 0xffff) {
436 ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT);
437 return 0;
438 }
439
440 /*
441 * construct PRF arguments we construct the PRF argument ourself rather
442 * than passing separate values into the TLS PRF to ensure that the
443 * concatenation of values does not create a prohibited label.
444 */
445 vallen = llen + SSL3_RANDOM_SIZE * 2;
446 if (use_context) {
447 vallen += 2 + contextlen;
448 }
449
450 val = OPENSSL_malloc(vallen);
451 if (val == NULL)
452 goto ret;
453 currentvalpos = 0;
454 memcpy(val + currentvalpos, (unsigned char *)label, llen);
455 currentvalpos += llen;
456 memcpy(val + currentvalpos, s->s3.client_random, SSL3_RANDOM_SIZE);
457 currentvalpos += SSL3_RANDOM_SIZE;
458 memcpy(val + currentvalpos, s->s3.server_random, SSL3_RANDOM_SIZE);
459 currentvalpos += SSL3_RANDOM_SIZE;
460
461 if (use_context) {
462 val[currentvalpos] = (contextlen >> 8) & 0xff;
463 currentvalpos++;
464 val[currentvalpos] = contextlen & 0xff;
465 currentvalpos++;
466 if ((contextlen > 0) || (context != NULL)) {
467 memcpy(val + currentvalpos, context, contextlen);
468 }
469 }
470
471 /*
472 * disallow prohibited labels note that SSL3_RANDOM_SIZE > max(prohibited
473 * label len) = 15, so size of val > max(prohibited label len) = 15 and
474 * the comparisons won't have buffer overflow
475 */
476 if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST,
477 TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0)
478 goto err1;
479 if (memcmp(val, TLS_MD_SERVER_FINISH_CONST,
480 TLS_MD_SERVER_FINISH_CONST_SIZE) == 0)
481 goto err1;
482 if (memcmp(val, TLS_MD_MASTER_SECRET_CONST,
483 TLS_MD_MASTER_SECRET_CONST_SIZE) == 0)
484 goto err1;
485 if (memcmp(val, TLS_MD_EXTENDED_MASTER_SECRET_CONST,
486 TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE) == 0)
487 goto err1;
488 if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST,
489 TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0)
490 goto err1;
491
492 rv = tls1_PRF(s,
493 val, vallen,
494 NULL, 0,
495 NULL, 0,
496 NULL, 0,
497 NULL, 0,
498 s->session->master_key, s->session->master_key_length,
499 out, olen, 0);
500
501 goto ret;
502 err1:
503 ERR_raise(ERR_LIB_SSL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL);
504 ret:
505 OPENSSL_clear_free(val, vallen);
506 return rv;
507 }
508
tls1_alert_code(int code)509 int tls1_alert_code(int code)
510 {
511 switch (code) {
512 case SSL_AD_CLOSE_NOTIFY:
513 return SSL3_AD_CLOSE_NOTIFY;
514 case SSL_AD_UNEXPECTED_MESSAGE:
515 return SSL3_AD_UNEXPECTED_MESSAGE;
516 case SSL_AD_BAD_RECORD_MAC:
517 return SSL3_AD_BAD_RECORD_MAC;
518 case SSL_AD_DECRYPTION_FAILED:
519 return TLS1_AD_DECRYPTION_FAILED;
520 case SSL_AD_RECORD_OVERFLOW:
521 return TLS1_AD_RECORD_OVERFLOW;
522 case SSL_AD_DECOMPRESSION_FAILURE:
523 return SSL3_AD_DECOMPRESSION_FAILURE;
524 case SSL_AD_HANDSHAKE_FAILURE:
525 return SSL3_AD_HANDSHAKE_FAILURE;
526 case SSL_AD_NO_CERTIFICATE:
527 return -1;
528 case SSL_AD_BAD_CERTIFICATE:
529 return SSL3_AD_BAD_CERTIFICATE;
530 case SSL_AD_UNSUPPORTED_CERTIFICATE:
531 return SSL3_AD_UNSUPPORTED_CERTIFICATE;
532 case SSL_AD_CERTIFICATE_REVOKED:
533 return SSL3_AD_CERTIFICATE_REVOKED;
534 case SSL_AD_CERTIFICATE_EXPIRED:
535 return SSL3_AD_CERTIFICATE_EXPIRED;
536 case SSL_AD_CERTIFICATE_UNKNOWN:
537 return SSL3_AD_CERTIFICATE_UNKNOWN;
538 case SSL_AD_ILLEGAL_PARAMETER:
539 return SSL3_AD_ILLEGAL_PARAMETER;
540 case SSL_AD_UNKNOWN_CA:
541 return TLS1_AD_UNKNOWN_CA;
542 case SSL_AD_ACCESS_DENIED:
543 return TLS1_AD_ACCESS_DENIED;
544 case SSL_AD_DECODE_ERROR:
545 return TLS1_AD_DECODE_ERROR;
546 case SSL_AD_DECRYPT_ERROR:
547 return TLS1_AD_DECRYPT_ERROR;
548 case SSL_AD_EXPORT_RESTRICTION:
549 return TLS1_AD_EXPORT_RESTRICTION;
550 case SSL_AD_PROTOCOL_VERSION:
551 return TLS1_AD_PROTOCOL_VERSION;
552 case SSL_AD_INSUFFICIENT_SECURITY:
553 return TLS1_AD_INSUFFICIENT_SECURITY;
554 case SSL_AD_INTERNAL_ERROR:
555 return TLS1_AD_INTERNAL_ERROR;
556 case SSL_AD_USER_CANCELLED:
557 return TLS1_AD_USER_CANCELLED;
558 case SSL_AD_NO_RENEGOTIATION:
559 return TLS1_AD_NO_RENEGOTIATION;
560 case SSL_AD_UNSUPPORTED_EXTENSION:
561 return TLS1_AD_UNSUPPORTED_EXTENSION;
562 case SSL_AD_CERTIFICATE_UNOBTAINABLE:
563 return TLS1_AD_CERTIFICATE_UNOBTAINABLE;
564 case SSL_AD_UNRECOGNIZED_NAME:
565 return TLS1_AD_UNRECOGNIZED_NAME;
566 case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
567 return TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
568 case SSL_AD_BAD_CERTIFICATE_HASH_VALUE:
569 return TLS1_AD_BAD_CERTIFICATE_HASH_VALUE;
570 case SSL_AD_UNKNOWN_PSK_IDENTITY:
571 return TLS1_AD_UNKNOWN_PSK_IDENTITY;
572 case SSL_AD_INAPPROPRIATE_FALLBACK:
573 return TLS1_AD_INAPPROPRIATE_FALLBACK;
574 case SSL_AD_NO_APPLICATION_PROTOCOL:
575 return TLS1_AD_NO_APPLICATION_PROTOCOL;
576 case SSL_AD_CERTIFICATE_REQUIRED:
577 return SSL_AD_HANDSHAKE_FAILURE;
578 case TLS13_AD_MISSING_EXTENSION:
579 return SSL_AD_HANDSHAKE_FAILURE;
580 default:
581 return -1;
582 }
583 }
584