2016-05-18 02:18:30 +08:00
|
|
|
/*
|
2024-03-20 20:07:54 +08:00
|
|
|
* Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
|
2017-06-20 22:14:36 +08:00
|
|
|
* Copyright 2005 Nokia. All rights reserved.
|
2002-04-14 06:47:20 +08:00
|
|
|
*
|
2018-12-06 20:08:51 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:18:30 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2002-04-14 06:47:20 +08:00
|
|
|
*/
|
2016-05-18 02:18:30 +08:00
|
|
|
|
1998-12-21 18:56:39 +08:00
|
|
|
#include <stdio.h>
|
2019-09-28 06:45:40 +08:00
|
|
|
#include "ssl_local.h"
|
|
|
|
#include "record/record_local.h"
|
2017-06-01 14:25:47 +08:00
|
|
|
#include "internal/ktls.h"
|
|
|
|
#include "internal/cryptlib.h"
|
2016-03-19 02:30:20 +08:00
|
|
|
#include <openssl/comp.h>
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/evp.h>
|
2016-01-19 21:58:51 +08:00
|
|
|
#include <openssl/kdf.h>
|
2009-12-07 21:31:02 +08:00
|
|
|
#include <openssl/rand.h>
|
2017-06-01 14:25:47 +08:00
|
|
|
#include <openssl/obj_mac.h>
|
2019-08-21 06:01:08 +08:00
|
|
|
#include <openssl/core_names.h>
|
2018-12-12 07:04:44 +08:00
|
|
|
#include <openssl/trace.h>
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2016-01-19 21:58:51 +08:00
|
|
|
/* seed1 through seed5 are concatenated */
|
2022-06-20 23:11:28 +08:00
|
|
|
static int tls1_PRF(SSL_CONNECTION *s,
|
2016-10-05 04:14:24 +08:00
|
|
|
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,
|
2017-11-23 18:37:51 +08:00
|
|
|
unsigned char *out, size_t olen, int fatal)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2015-11-26 02:20:50 +08:00
|
|
|
const EVP_MD *md = ssl_prf_md(s);
|
2019-08-21 06:01:08 +08:00
|
|
|
EVP_KDF *kdf;
|
2019-05-27 07:29:43 +08:00
|
|
|
EVP_KDF_CTX *kctx = NULL;
|
2019-08-21 06:01:08 +08:00
|
|
|
OSSL_PARAM params[8], *p = params;
|
2019-09-08 16:28:56 +08:00
|
|
|
const char *mdname;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2015-11-26 02:20:50 +08:00
|
|
|
if (md == NULL) {
|
2015-03-12 22:37:26 +08:00
|
|
|
/* Should never happen */
|
2017-11-23 18:37:51 +08:00
|
|
|
if (fatal)
|
2020-11-04 21:39:57 +08:00
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
|
2017-11-23 18:37:51 +08:00
|
|
|
else
|
2020-11-04 19:18:33 +08:00
|
|
|
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
|
2015-11-26 02:20:50 +08:00
|
|
|
return 0;
|
2015-03-12 22:37:26 +08:00
|
|
|
}
|
2022-06-20 23:11:28 +08:00
|
|
|
kdf = EVP_KDF_fetch(SSL_CONNECTION_GET_CTX(s)->libctx,
|
|
|
|
OSSL_KDF_NAME_TLS1_PRF,
|
|
|
|
SSL_CONNECTION_GET_CTX(s)->propq);
|
2019-08-21 06:01:08 +08:00
|
|
|
if (kdf == NULL)
|
|
|
|
goto err;
|
2020-06-18 16:30:48 +08:00
|
|
|
kctx = EVP_KDF_CTX_new(kdf);
|
2019-08-21 06:01:08 +08:00
|
|
|
EVP_KDF_free(kdf);
|
|
|
|
if (kctx == NULL)
|
2016-01-19 21:58:51 +08:00
|
|
|
goto err;
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 22:58:08 +08:00
|
|
|
mdname = EVP_MD_get0_name(md);
|
2019-08-21 06:01:08 +08:00
|
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
|
2020-02-05 13:13:49 +08:00
|
|
|
(char *)mdname, 0);
|
2019-08-21 06:01:08 +08:00
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
|
|
|
|
(unsigned char *)sec,
|
|
|
|
(size_t)slen);
|
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
|
|
(void *)seed1, (size_t)seed1_len);
|
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
|
|
(void *)seed2, (size_t)seed2_len);
|
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
|
|
(void *)seed3, (size_t)seed3_len);
|
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
|
|
(void *)seed4, (size_t)seed4_len);
|
|
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
|
|
(void *)seed5, (size_t)seed5_len);
|
|
|
|
*p = OSSL_PARAM_construct_end();
|
2021-02-26 08:06:52 +08:00
|
|
|
if (EVP_KDF_derive(kctx, out, olen, params)) {
|
2020-06-18 16:30:48 +08:00
|
|
|
EVP_KDF_CTX_free(kctx);
|
2019-08-21 06:01:08 +08:00
|
|
|
return 1;
|
2017-11-23 18:37:51 +08:00
|
|
|
}
|
2016-01-19 21:58:51 +08:00
|
|
|
|
2016-08-06 01:03:17 +08:00
|
|
|
err:
|
2019-08-21 06:01:08 +08:00
|
|
|
if (fatal)
|
2020-11-04 21:39:57 +08:00
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
|
2019-08-21 06:01:08 +08:00
|
|
|
else
|
2020-11-04 19:18:33 +08:00
|
|
|
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
|
2020-06-18 16:30:48 +08:00
|
|
|
EVP_KDF_CTX_free(kctx);
|
2019-08-21 06:01:08 +08:00
|
|
|
return 0;
|
2007-08-31 20:42:53 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
static int tls1_generate_key_block(SSL_CONNECTION *s, unsigned char *km,
|
|
|
|
size_t num)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2010-05-17 19:27:22 +08:00
|
|
|
int ret;
|
2017-11-23 18:37:51 +08:00
|
|
|
|
|
|
|
/* Calls SSLfatal() as required */
|
2015-11-26 02:20:50 +08:00
|
|
|
ret = tls1_PRF(s,
|
2007-09-21 14:54:24 +08:00
|
|
|
TLS_MD_KEY_EXPANSION_CONST,
|
2018-12-13 02:09:50 +08:00
|
|
|
TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3.server_random,
|
|
|
|
SSL3_RANDOM_SIZE, s->s3.client_random, SSL3_RANDOM_SIZE,
|
1999-04-20 07:43:11 +08:00
|
|
|
NULL, 0, NULL, 0, s->session->master_key,
|
2017-11-23 18:37:51 +08:00
|
|
|
s->session->master_key_length, km, num, 1);
|
2015-05-12 17:27:53 +08:00
|
|
|
|
2010-05-17 19:27:22 +08:00
|
|
|
return ret;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
|
2020-09-29 23:40:56 +08:00
|
|
|
static int tls_iv_length_within_key_block(const EVP_CIPHER *c)
|
|
|
|
{
|
|
|
|
/* If GCM/CCM mode only part of IV comes from PRF */
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 22:58:08 +08:00
|
|
|
if (EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE)
|
2020-09-29 23:40:56 +08:00
|
|
|
return EVP_GCM_TLS_FIXED_IV_LEN;
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 22:58:08 +08:00
|
|
|
else if (EVP_CIPHER_get_mode(c) == EVP_CIPH_CCM_MODE)
|
2020-09-29 23:40:56 +08:00
|
|
|
return EVP_CCM_TLS_FIXED_IV_LEN;
|
|
|
|
else
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 22:58:08 +08:00
|
|
|
return EVP_CIPHER_get_iv_length(c);
|
2020-09-29 23:40:56 +08:00
|
|
|
}
|
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
int tls1_change_cipher_state(SSL_CONNECTION *s, int which)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2010-06-12 22:13:23 +08:00
|
|
|
unsigned char *p, *mac_secret;
|
2022-04-18 15:57:32 +08:00
|
|
|
unsigned char *key, *iv;
|
1999-04-18 05:25:43 +08:00
|
|
|
const EVP_CIPHER *c;
|
2022-05-18 21:30:24 +08:00
|
|
|
const SSL_COMP *comp = NULL;
|
1999-04-18 05:25:43 +08:00
|
|
|
const EVP_MD *m;
|
2007-06-05 01:04:40 +08:00
|
|
|
int mac_type;
|
2022-04-18 15:57:32 +08:00
|
|
|
size_t mac_secret_size;
|
2016-10-04 05:34:07 +08:00
|
|
|
size_t n, i, j, k, cl;
|
2022-05-11 01:50:00 +08:00
|
|
|
int iivlen;
|
|
|
|
/*
|
|
|
|
* Taglen is only relevant for CCM ciphersuites. Other ciphersuites
|
|
|
|
* ignore this value so we can default it to 0.
|
|
|
|
*/
|
|
|
|
size_t taglen = 0;
|
2022-10-17 22:13:18 +08:00
|
|
|
int direction;
|
2022-04-08 00:35:36 +08:00
|
|
|
|
2018-12-13 02:09:50 +08:00
|
|
|
c = s->s3.tmp.new_sym_enc;
|
|
|
|
m = s->s3.tmp.new_hash;
|
|
|
|
mac_type = s->s3.tmp.new_mac_pkey_type;
|
2005-10-01 07:35:33 +08:00
|
|
|
#ifndef OPENSSL_NO_COMP
|
2018-12-13 02:09:50 +08:00
|
|
|
comp = s->s3.tmp.new_compression;
|
2005-10-01 07:35:33 +08:00
|
|
|
#endif
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2022-04-18 15:57:32 +08:00
|
|
|
p = s->s3.tmp.key_block;
|
|
|
|
i = mac_secret_size = s->s3.tmp.new_mac_secret_size;
|
2017-02-03 22:06:20 +08:00
|
|
|
|
2022-04-18 15:57:32 +08:00
|
|
|
cl = EVP_CIPHER_get_key_length(c);
|
|
|
|
j = cl;
|
2022-05-11 01:50:00 +08:00
|
|
|
iivlen = tls_iv_length_within_key_block(c);
|
|
|
|
if (iivlen < 0) {
|
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
k = iivlen;
|
2022-04-18 15:57:32 +08:00
|
|
|
if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
|
|
|
|
(which == SSL3_CHANGE_CIPHER_SERVER_READ)) {
|
|
|
|
mac_secret = &(p[0]);
|
|
|
|
n = i + i;
|
|
|
|
key = &(p[n]);
|
|
|
|
n += j + j;
|
|
|
|
iv = &(p[n]);
|
|
|
|
n += k + k;
|
|
|
|
} else {
|
|
|
|
n = i;
|
|
|
|
mac_secret = &(p[n]);
|
|
|
|
n += i + j;
|
|
|
|
key = &(p[n]);
|
|
|
|
n += j + k;
|
|
|
|
iv = &(p[n]);
|
|
|
|
n += k;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2022-04-18 15:57:32 +08:00
|
|
|
if (n > s->s3.tmp.key_block_length) {
|
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
|
|
|
|
goto err;
|
|
|
|
}
|
2020-03-30 23:09:24 +08:00
|
|
|
|
2022-10-26 23:55:46 +08:00
|
|
|
switch (EVP_CIPHER_get_mode(c)) {
|
|
|
|
case EVP_CIPH_GCM_MODE:
|
|
|
|
taglen = EVP_GCM_TLS_TAG_LEN;
|
|
|
|
break;
|
|
|
|
case EVP_CIPH_CCM_MODE:
|
2022-05-11 01:50:00 +08:00
|
|
|
if ((s->s3.tmp.new_cipher->algorithm_enc
|
|
|
|
& (SSL_AES128CCM8 | SSL_AES256CCM8)) != 0)
|
|
|
|
taglen = EVP_CCM8_TLS_TAG_LEN;
|
|
|
|
else
|
|
|
|
taglen = EVP_CCM_TLS_TAG_LEN;
|
2022-10-26 23:55:46 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (EVP_CIPHER_is_a(c, "CHACHA20-POLY1305")) {
|
|
|
|
taglen = EVP_CHACHAPOLY_TLS_TAG_LEN;
|
|
|
|
} else {
|
|
|
|
/* MAC secret size corresponds to the MAC output size */
|
|
|
|
taglen = s->s3.tmp.new_mac_secret_size;
|
|
|
|
}
|
|
|
|
break;
|
2022-05-11 01:50:00 +08:00
|
|
|
}
|
|
|
|
|
2022-04-18 15:57:32 +08:00
|
|
|
if (which & SSL3_CC_READ) {
|
2022-05-20 23:54:12 +08:00
|
|
|
if (s->ext.use_etm)
|
|
|
|
s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
|
|
|
|
else
|
|
|
|
s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_READ;
|
2022-04-18 15:57:32 +08:00
|
|
|
|
2022-05-20 23:54:12 +08:00
|
|
|
if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
|
|
|
|
s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM;
|
|
|
|
else
|
|
|
|
s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM;
|
2022-04-18 15:57:32 +08:00
|
|
|
|
2022-05-20 23:54:12 +08:00
|
|
|
if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE)
|
|
|
|
s->mac_flags |= SSL_MAC_FLAG_READ_MAC_TLSTREE;
|
|
|
|
else
|
|
|
|
s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_TLSTREE;
|
2022-04-18 15:57:32 +08:00
|
|
|
|
2022-10-17 22:13:18 +08:00
|
|
|
direction = OSSL_RECORD_DIRECTION_READ;
|
1998-12-21 18:56:39 +08:00
|
|
|
} else {
|
2017-02-03 22:06:20 +08:00
|
|
|
if (s->ext.use_etm)
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
|
2017-02-03 22:06:20 +08:00
|
|
|
else
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE;
|
2017-02-03 22:06:20 +08:00
|
|
|
|
2018-12-13 02:09:50 +08:00
|
|
|
if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC)
|
2007-06-05 01:04:40 +08:00
|
|
|
s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
|
|
|
|
else
|
|
|
|
s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
|
2020-03-30 23:09:24 +08:00
|
|
|
|
|
|
|
if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE)
|
|
|
|
s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_TLSTREE;
|
|
|
|
else
|
|
|
|
s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_TLSTREE;
|
2022-08-19 23:54:09 +08:00
|
|
|
|
2022-10-17 22:13:18 +08:00
|
|
|
direction = OSSL_RECORD_DIRECTION_WRITE;
|
2011-07-11 21:58:59 +08:00
|
|
|
}
|
2018-12-12 07:04:44 +08:00
|
|
|
|
2024-01-05 19:01:00 +08:00
|
|
|
if (SSL_CONNECTION_IS_DTLS(s))
|
|
|
|
dtls1_increment_epoch(s, which);
|
|
|
|
|
2022-10-17 22:13:18 +08:00
|
|
|
if (!ssl_set_new_record_layer(s, s->version, direction,
|
|
|
|
OSSL_RECORD_PROTECTION_LEVEL_APPLICATION,
|
2022-11-14 22:19:53 +08:00
|
|
|
NULL, 0, key, cl, iv, (size_t)k, mac_secret,
|
2022-10-17 22:13:18 +08:00
|
|
|
mac_secret_size, c, taglen, mac_type,
|
2022-11-14 22:19:53 +08:00
|
|
|
m, comp, NULL)) {
|
2020-06-26 20:05:18 +08:00
|
|
|
/* SSLfatal already called */
|
|
|
|
goto err;
|
2020-06-18 00:16:22 +08:00
|
|
|
}
|
2020-06-26 20:05:18 +08:00
|
|
|
|
2018-12-12 07:04:44 +08:00
|
|
|
OSSL_TRACE_BEGIN(TLS) {
|
|
|
|
BIO_printf(trc_out, "which = %04X, key:\n", which);
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 22:58:08 +08:00
|
|
|
BIO_dump_indent(trc_out, key, EVP_CIPHER_get_key_length(c), 4);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "iv:\n");
|
|
|
|
BIO_dump_indent(trc_out, iv, k, 4);
|
|
|
|
} OSSL_TRACE_END(TLS);
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2017-10-09 19:05:58 +08:00
|
|
|
return 1;
|
1998-12-21 18:56:39 +08:00
|
|
|
err:
|
2017-10-17 22:04:09 +08:00
|
|
|
return 0;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
int tls1_setup_key_block(SSL_CONNECTION *s)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2016-01-19 21:58:51 +08:00
|
|
|
unsigned char *p;
|
1999-04-18 05:25:43 +08:00
|
|
|
const EVP_CIPHER *c;
|
|
|
|
const EVP_MD *hash;
|
Updates to the new SSL compression code
[Eric A. Young, (from changes to C2Net SSLeay, integrated by Mark Cox)]
Fix so that the version number in the master secret, when passed
via RSA, checks that if TLS was proposed, but we roll back to SSLv3
(because the server will not accept higher), that the version number
is 0x03,0x01, not 0x03,0x00
[Eric A. Young, (from changes to C2Net SSLeay, integrated by Mark Cox)]
Submitted by:
Reviewed by:
PR:
1999-02-16 17:22:21 +08:00
|
|
|
SSL_COMP *comp;
|
2016-10-04 06:22:07 +08:00
|
|
|
int mac_type = NID_undef;
|
|
|
|
size_t num, mac_secret_size = 0;
|
2010-05-17 19:27:22 +08:00
|
|
|
int ret = 0;
|
2022-05-11 01:50:00 +08:00
|
|
|
int ivlen;
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2018-12-13 02:09:50 +08:00
|
|
|
if (s->s3.tmp.key_block_length != 0)
|
2017-10-09 19:05:58 +08:00
|
|
|
return 1;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
if (!ssl_cipher_get_evp(SSL_CONNECTION_GET_CTX(s), s->session, &c, &hash,
|
|
|
|
&mac_type, &mac_secret_size, &comp,
|
|
|
|
s->ext.use_etm)) {
|
2020-11-21 06:07:56 +08:00
|
|
|
/* Error is already recorded */
|
|
|
|
SSLfatal_alert(s, SSL_AD_INTERNAL_ERROR);
|
2017-10-17 22:04:09 +08:00
|
|
|
return 0;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2020-01-16 20:14:27 +08:00
|
|
|
ssl_evp_cipher_free(s->s3.tmp.new_sym_enc);
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.tmp.new_sym_enc = c;
|
2020-01-16 20:14:27 +08:00
|
|
|
ssl_evp_md_free(s->s3.tmp.new_hash);
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.tmp.new_hash = hash;
|
|
|
|
s->s3.tmp.new_mac_pkey_type = mac_type;
|
|
|
|
s->s3.tmp.new_mac_secret_size = mac_secret_size;
|
2022-05-11 01:50:00 +08:00
|
|
|
ivlen = tls_iv_length_within_key_block(c);
|
|
|
|
if (ivlen < 0) {
|
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
num = mac_secret_size + EVP_CIPHER_get_key_length(c) + ivlen;
|
1998-12-21 18:56:39 +08:00
|
|
|
num *= 2;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
1998-12-21 18:56:39 +08:00
|
|
|
ssl3_cleanup_key_block(s);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2016-01-19 21:58:51 +08:00
|
|
|
if ((p = OPENSSL_malloc(num)) == NULL) {
|
2022-09-29 19:57:34 +08:00
|
|
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_CRYPTO_LIB);
|
1998-12-21 18:56:39 +08:00
|
|
|
goto err;
|
2010-05-17 19:27:22 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.tmp.key_block_length = num;
|
|
|
|
s->s3.tmp.key_block = p;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2018-12-12 07:04:44 +08:00
|
|
|
OSSL_TRACE_BEGIN(TLS) {
|
2021-03-12 06:30:33 +08:00
|
|
|
BIO_printf(trc_out, "key block length: %zu\n", num);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "client random\n");
|
2018-12-13 02:09:50 +08:00
|
|
|
BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "server random\n");
|
2018-12-13 02:09:50 +08:00
|
|
|
BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "master key\n");
|
|
|
|
BIO_dump_indent(trc_out,
|
|
|
|
s->session->master_key,
|
|
|
|
s->session->master_key_length, 4);
|
|
|
|
} OSSL_TRACE_END(TLS);
|
|
|
|
|
2017-11-23 18:37:51 +08:00
|
|
|
if (!tls1_generate_key_block(s, p, num)) {
|
|
|
|
/* SSLfatal() already called */
|
2010-05-17 19:27:22 +08:00
|
|
|
goto err;
|
2017-11-23 18:37:51 +08:00
|
|
|
}
|
2018-12-12 07:04:44 +08:00
|
|
|
|
|
|
|
OSSL_TRACE_BEGIN(TLS) {
|
|
|
|
BIO_printf(trc_out, "key block\n");
|
|
|
|
BIO_dump_indent(trc_out, p, num, 4);
|
|
|
|
} OSSL_TRACE_END(TLS);
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2010-05-17 19:27:22 +08:00
|
|
|
ret = 1;
|
1998-12-21 18:56:39 +08:00
|
|
|
err:
|
2017-10-17 22:04:09 +08:00
|
|
|
return ret;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
size_t tls1_final_finish_mac(SSL_CONNECTION *s, const char *str,
|
|
|
|
size_t slen, unsigned char *out)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2016-10-04 06:22:07 +08:00
|
|
|
size_t hashlen;
|
2015-11-26 02:20:50 +08:00
|
|
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
2020-03-30 23:09:24 +08:00
|
|
|
size_t finished_size = TLS1_FINISH_MAC_LENGTH;
|
|
|
|
|
|
|
|
if (s->s3.tmp.new_cipher->algorithm_mkey & SSL_kGOST18)
|
|
|
|
finished_size = 32;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2017-11-23 18:37:51 +08:00
|
|
|
if (!ssl3_digest_cached_records(s, 0)) {
|
|
|
|
/* SSLfatal() already called */
|
2015-06-16 21:44:29 +08:00
|
|
|
return 0;
|
2017-11-23 18:37:51 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2017-11-23 18:37:51 +08:00
|
|
|
if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
|
|
|
|
/* SSLfatal() already called */
|
2015-01-23 10:37:27 +08:00
|
|
|
return 0;
|
2017-11-23 18:37:51 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2016-01-19 21:58:51 +08:00
|
|
|
if (!tls1_PRF(s, str, slen, hash, hashlen, NULL, 0, NULL, 0, NULL, 0,
|
2010-05-17 19:27:22 +08:00
|
|
|
s->session->master_key, s->session->master_key_length,
|
2020-03-30 23:09:24 +08:00
|
|
|
out, finished_size, 1)) {
|
2017-11-23 18:37:51 +08:00
|
|
|
/* SSLfatal() already called */
|
2007-09-21 14:54:24 +08:00
|
|
|
return 0;
|
2017-11-23 18:37:51 +08:00
|
|
|
}
|
2015-03-09 21:59:58 +08:00
|
|
|
OPENSSL_cleanse(hash, hashlen);
|
2020-03-30 23:09:24 +08:00
|
|
|
return finished_size;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
int tls1_generate_master_secret(SSL_CONNECTION *s, unsigned char *out,
|
|
|
|
unsigned char *p, size_t len,
|
|
|
|
size_t *secret_size)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
2017-02-24 17:34:32 +08:00
|
|
|
if (s->session->flags & SSL_SESS_FLAG_EXTMS) {
|
2015-01-23 10:49:16 +08:00
|
|
|
unsigned char hash[EVP_MAX_MD_SIZE * 2];
|
2016-10-04 06:22:07 +08:00
|
|
|
size_t hashlen;
|
2016-08-06 01:03:17 +08:00
|
|
|
/*
|
2019-12-01 07:18:47 +08:00
|
|
|
* Digest cached records keeping record buffer (if present): this won't
|
2016-08-06 01:03:17 +08:00
|
|
|
* affect client auth because we're freezing the buffer at the same
|
|
|
|
* point (after client key exchange and before certificate verify)
|
2015-06-16 21:44:29 +08:00
|
|
|
*/
|
2017-11-22 01:18:43 +08:00
|
|
|
if (!ssl3_digest_cached_records(s, 1)
|
|
|
|
|| !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
|
|
|
|
/* SSLfatal() already called */
|
2016-10-04 06:22:07 +08:00
|
|
|
return 0;
|
2017-11-22 01:18:43 +08:00
|
|
|
}
|
2018-12-12 07:04:44 +08:00
|
|
|
OSSL_TRACE_BEGIN(TLS) {
|
|
|
|
BIO_printf(trc_out, "Handshake hashes:\n");
|
|
|
|
BIO_dump(trc_out, (char *)hash, hashlen);
|
|
|
|
} OSSL_TRACE_END(TLS);
|
2017-11-23 18:37:51 +08:00
|
|
|
if (!tls1_PRF(s,
|
|
|
|
TLS_MD_EXTENDED_MASTER_SECRET_CONST,
|
|
|
|
TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE,
|
|
|
|
hash, hashlen,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0, p, len, out,
|
|
|
|
SSL3_MASTER_SECRET_SIZE, 1)) {
|
|
|
|
/* SSLfatal() already called */
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-23 10:49:16 +08:00
|
|
|
OPENSSL_cleanse(hash, hashlen);
|
|
|
|
} else {
|
2017-11-23 18:37:51 +08:00
|
|
|
if (!tls1_PRF(s,
|
|
|
|
TLS_MD_MASTER_SECRET_CONST,
|
|
|
|
TLS_MD_MASTER_SECRET_CONST_SIZE,
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.client_random, SSL3_RANDOM_SIZE,
|
2017-11-23 18:37:51 +08:00
|
|
|
NULL, 0,
|
2018-12-13 02:09:50 +08:00
|
|
|
s->s3.server_random, SSL3_RANDOM_SIZE,
|
2017-11-23 18:37:51 +08:00
|
|
|
NULL, 0, p, len, out,
|
|
|
|
SSL3_MASTER_SECRET_SIZE, 1)) {
|
|
|
|
/* SSLfatal() already called */
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-23 10:49:16 +08:00
|
|
|
}
|
2018-12-12 07:04:44 +08:00
|
|
|
|
|
|
|
OSSL_TRACE_BEGIN(TLS) {
|
|
|
|
BIO_printf(trc_out, "Premaster Secret:\n");
|
|
|
|
BIO_dump_indent(trc_out, p, len, 4);
|
|
|
|
BIO_printf(trc_out, "Client Random:\n");
|
2018-12-13 02:09:50 +08:00
|
|
|
BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "Server Random:\n");
|
2018-12-13 02:09:50 +08:00
|
|
|
BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4);
|
2018-12-12 07:04:44 +08:00
|
|
|
BIO_printf(trc_out, "Master Secret:\n");
|
|
|
|
BIO_dump_indent(trc_out,
|
|
|
|
s->session->master_key,
|
|
|
|
SSL3_MASTER_SECRET_SIZE, 4);
|
|
|
|
} OSSL_TRACE_END(TLS);
|
2007-09-21 14:54:24 +08:00
|
|
|
|
2016-10-04 06:22:07 +08:00
|
|
|
*secret_size = SSL3_MASTER_SECRET_SIZE;
|
|
|
|
return 1;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
|
2022-06-20 23:11:28 +08:00
|
|
|
int tls1_export_keying_material(SSL_CONNECTION *s, unsigned char *out,
|
|
|
|
size_t olen, const char *label, size_t llen,
|
2012-02-22 23:06:56 +08:00
|
|
|
const unsigned char *context,
|
|
|
|
size_t contextlen, int use_context)
|
2011-11-16 07:50:52 +08:00
|
|
|
{
|
2011-12-13 23:57:39 +08:00
|
|
|
unsigned char *val = NULL;
|
2015-06-01 02:46:44 +08:00
|
|
|
size_t vallen = 0, currentvalpos;
|
2022-09-29 19:57:34 +08:00
|
|
|
int rv = 0;
|
2011-11-16 07:50:52 +08:00
|
|
|
|
2023-10-23 12:56:53 +08:00
|
|
|
/*
|
|
|
|
* RFC 5705 embeds context length as uint16; reject longer context
|
|
|
|
* before proceeding.
|
|
|
|
*/
|
|
|
|
if (contextlen > 0xffff) {
|
|
|
|
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-16 07:50:52 +08:00
|
|
|
/*
|
|
|
|
* construct PRF arguments we construct the PRF argument ourself rather
|
|
|
|
* than passing separate values into the TLS PRF to ensure that the
|
|
|
|
* concatenation of values does not create a prohibited label.
|
|
|
|
*/
|
|
|
|
vallen = llen + SSL3_RANDOM_SIZE * 2;
|
2012-02-22 23:06:56 +08:00
|
|
|
if (use_context) {
|
|
|
|
vallen += 2 + contextlen;
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2011-11-16 07:50:52 +08:00
|
|
|
val = OPENSSL_malloc(vallen);
|
|
|
|
if (val == NULL)
|
2022-09-29 19:57:34 +08:00
|
|
|
goto ret;
|
2011-11-16 07:50:52 +08:00
|
|
|
currentvalpos = 0;
|
|
|
|
memcpy(val + currentvalpos, (unsigned char *)label, llen);
|
|
|
|
currentvalpos += llen;
|
2018-12-13 02:09:50 +08:00
|
|
|
memcpy(val + currentvalpos, s->s3.client_random, SSL3_RANDOM_SIZE);
|
2011-11-16 07:50:52 +08:00
|
|
|
currentvalpos += SSL3_RANDOM_SIZE;
|
2018-12-13 02:09:50 +08:00
|
|
|
memcpy(val + currentvalpos, s->s3.server_random, SSL3_RANDOM_SIZE);
|
2011-11-16 07:50:52 +08:00
|
|
|
currentvalpos += SSL3_RANDOM_SIZE;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2012-02-22 23:06:56 +08:00
|
|
|
if (use_context) {
|
|
|
|
val[currentvalpos] = (contextlen >> 8) & 0xff;
|
|
|
|
currentvalpos++;
|
|
|
|
val[currentvalpos] = contextlen & 0xff;
|
|
|
|
currentvalpos++;
|
|
|
|
if ((contextlen > 0) || (context != NULL)) {
|
|
|
|
memcpy(val + currentvalpos, context, contextlen);
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2012-02-22 23:06:56 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2011-11-16 07:50:52 +08:00
|
|
|
/*
|
|
|
|
* disallow prohibited labels note that SSL3_RANDOM_SIZE > max(prohibited
|
|
|
|
* label len) = 15, so size of val > max(prohibited label len) = 15 and
|
|
|
|
* the comparisons won't have buffer overflow
|
|
|
|
*/
|
2011-11-22 06:28:29 +08:00
|
|
|
if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST,
|
2011-11-16 07:50:52 +08:00
|
|
|
TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0)
|
|
|
|
goto err1;
|
2011-11-22 06:28:29 +08:00
|
|
|
if (memcmp(val, TLS_MD_SERVER_FINISH_CONST,
|
2011-11-16 07:50:52 +08:00
|
|
|
TLS_MD_SERVER_FINISH_CONST_SIZE) == 0)
|
|
|
|
goto err1;
|
2011-11-22 06:28:29 +08:00
|
|
|
if (memcmp(val, TLS_MD_MASTER_SECRET_CONST,
|
2011-11-16 07:50:52 +08:00
|
|
|
TLS_MD_MASTER_SECRET_CONST_SIZE) == 0)
|
|
|
|
goto err1;
|
2015-01-23 10:49:16 +08:00
|
|
|
if (memcmp(val, TLS_MD_EXTENDED_MASTER_SECRET_CONST,
|
|
|
|
TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE) == 0)
|
|
|
|
goto err1;
|
2011-11-22 06:28:29 +08:00
|
|
|
if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST,
|
2011-11-16 07:50:52 +08:00
|
|
|
TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0)
|
|
|
|
goto err1;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2015-11-26 02:20:50 +08:00
|
|
|
rv = tls1_PRF(s,
|
2012-02-22 23:06:56 +08:00
|
|
|
val, vallen,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0,
|
|
|
|
s->session->master_key, s->session->master_key_length,
|
2017-11-23 18:37:51 +08:00
|
|
|
out, olen, 0);
|
2011-11-16 07:50:52 +08:00
|
|
|
|
|
|
|
goto ret;
|
|
|
|
err1:
|
2020-11-04 19:18:33 +08:00
|
|
|
ERR_raise(ERR_LIB_SSL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL);
|
2011-11-16 07:50:52 +08:00
|
|
|
ret:
|
2016-02-17 09:24:25 +08:00
|
|
|
OPENSSL_clear_free(val, vallen);
|
2017-10-17 22:04:09 +08:00
|
|
|
return rv;
|
2011-11-16 07:50:52 +08:00
|
|
|
}
|
|
|
|
|
1999-04-20 05:31:43 +08:00
|
|
|
int tls1_alert_code(int code)
|
1998-12-21 18:56:39 +08:00
|
|
|
{
|
|
|
|
switch (code) {
|
|
|
|
case SSL_AD_CLOSE_NOTIFY:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_CLOSE_NOTIFY;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_UNEXPECTED_MESSAGE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_UNEXPECTED_MESSAGE;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_BAD_RECORD_MAC:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_BAD_RECORD_MAC;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_DECRYPTION_FAILED:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_DECRYPTION_FAILED;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_RECORD_OVERFLOW:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_RECORD_OVERFLOW;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_DECOMPRESSION_FAILURE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_DECOMPRESSION_FAILURE;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_HANDSHAKE_FAILURE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_HANDSHAKE_FAILURE;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_NO_CERTIFICATE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return -1;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_BAD_CERTIFICATE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_BAD_CERTIFICATE;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_UNSUPPORTED_CERTIFICATE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_UNSUPPORTED_CERTIFICATE;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_CERTIFICATE_REVOKED:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_CERTIFICATE_REVOKED;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_CERTIFICATE_EXPIRED:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_CERTIFICATE_EXPIRED;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_CERTIFICATE_UNKNOWN:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_CERTIFICATE_UNKNOWN;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_ILLEGAL_PARAMETER:
|
2017-10-17 22:04:09 +08:00
|
|
|
return SSL3_AD_ILLEGAL_PARAMETER;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_UNKNOWN_CA:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_UNKNOWN_CA;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_ACCESS_DENIED:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_ACCESS_DENIED;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_DECODE_ERROR:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_DECODE_ERROR;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_DECRYPT_ERROR:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_DECRYPT_ERROR;
|
2000-02-04 07:23:24 +08:00
|
|
|
case SSL_AD_EXPORT_RESTRICTION:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_EXPORT_RESTRICTION;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_PROTOCOL_VERSION:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_PROTOCOL_VERSION;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_INSUFFICIENT_SECURITY:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_INSUFFICIENT_SECURITY;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_INTERNAL_ERROR:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_INTERNAL_ERROR;
|
2000-02-04 07:23:24 +08:00
|
|
|
case SSL_AD_USER_CANCELLED:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_USER_CANCELLED;
|
1998-12-21 18:56:39 +08:00
|
|
|
case SSL_AD_NO_RENEGOTIATION:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_NO_RENEGOTIATION;
|
2006-01-08 04:33:16 +08:00
|
|
|
case SSL_AD_UNSUPPORTED_EXTENSION:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_UNSUPPORTED_EXTENSION;
|
2006-01-08 04:33:16 +08:00
|
|
|
case SSL_AD_CERTIFICATE_UNOBTAINABLE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_CERTIFICATE_UNOBTAINABLE;
|
2006-01-08 04:29:50 +08:00
|
|
|
case SSL_AD_UNRECOGNIZED_NAME:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_UNRECOGNIZED_NAME;
|
2006-01-08 04:33:16 +08:00
|
|
|
case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
|
2006-01-08 04:33:16 +08:00
|
|
|
case SSL_AD_BAD_CERTIFICATE_HASH_VALUE:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_BAD_CERTIFICATE_HASH_VALUE;
|
2006-03-11 07:06:27 +08:00
|
|
|
case SSL_AD_UNKNOWN_PSK_IDENTITY:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_UNKNOWN_PSK_IDENTITY;
|
2014-10-15 10:03:28 +08:00
|
|
|
case SSL_AD_INAPPROPRIATE_FALLBACK:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_INAPPROPRIATE_FALLBACK;
|
2015-09-22 21:20:26 +08:00
|
|
|
case SSL_AD_NO_APPLICATION_PROTOCOL:
|
2017-10-17 22:04:09 +08:00
|
|
|
return TLS1_AD_NO_APPLICATION_PROTOCOL;
|
2017-03-10 23:09:24 +08:00
|
|
|
case SSL_AD_CERTIFICATE_REQUIRED:
|
|
|
|
return SSL_AD_HANDSHAKE_FAILURE;
|
2021-05-22 01:25:00 +08:00
|
|
|
case TLS13_AD_MISSING_EXTENSION:
|
|
|
|
return SSL_AD_HANDSHAKE_FAILURE;
|
1998-12-21 18:56:39 +08:00
|
|
|
default:
|
2017-10-17 22:04:09 +08:00
|
|
|
return -1;
|
1998-12-21 18:56:39 +08:00
|
|
|
}
|
|
|
|
}
|