/*
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2005 Nokia. All rights reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
unsigned char *p, *mac_secret;
size_t md_len;
unsigned char *key, *iv;
- EVP_CIPHER_CTX *dd;
const EVP_CIPHER *ciph;
const SSL_COMP *comp = NULL;
const EVP_MD *md;
int mdi;
size_t n, iv_len, key_len;
- int reuse_dd = 0;
int direction = (which & SSL3_CC_READ) != 0 ? OSSL_RECORD_DIRECTION_READ
: OSSL_RECORD_DIRECTION_WRITE;
md_len = (size_t)mdi;
key_len = EVP_CIPHER_get_key_length(ciph);
iv_len = EVP_CIPHER_get_iv_length(ciph);
+
if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
(which == SSL3_CHANGE_CIPHER_SERVER_READ)) {
mac_secret = &(p[0]);
if (!ssl_set_new_record_layer(s, SSL3_VERSION,
direction,
OSSL_RECORD_PROTECTION_LEVEL_APPLICATION,
- key, key_len, iv, iv_len, mac_secret,
- md_len, ciph, 0, NID_undef, md, comp)) {
- /* SSLfatal already called */
- goto err;
- }
-
- if (which & SSL3_CC_READ) {
- s->statem.enc_write_state = ENC_WRITE_STATE_VALID;
- return 1;
- }
-
- s->statem.enc_write_state = ENC_WRITE_STATE_INVALID;
- if (s->enc_write_ctx != NULL) {
- reuse_dd = 1;
- } else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL) {
- SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
- goto err;
- } else {
- /* make sure it's initialised in case we exit later with an error */
- EVP_CIPHER_CTX_reset(s->enc_write_ctx);
- }
- dd = s->enc_write_ctx;
- if (ssl_replace_hash(&s->write_hash, md) == NULL) {
- SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_SSL_LIB);
- goto err;
- }
-#ifndef OPENSSL_NO_COMP
- /* COMPRESS */
- COMP_CTX_free(s->compress);
- s->compress = NULL;
- if (comp != NULL) {
- s->compress = COMP_CTX_new(comp->method);
- if (s->compress == NULL) {
- SSLfatal(s, SSL_AD_INTERNAL_ERROR,
- SSL_R_COMPRESSION_LIBRARY_ERROR);
- goto err;
- }
- }
-#endif
- RECORD_LAYER_reset_write_sequence(&s->rlayer);
- memcpy(&(s->s3.write_mac_secret[0]), mac_secret, md_len);
-
- if (reuse_dd)
- EVP_CIPHER_CTX_reset(dd);
-
- if (!EVP_CipherInit_ex(dd, ciph, NULL, key, iv, (which & SSL3_CC_WRITE))) {
- SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
- goto err;
- }
-
- if (EVP_CIPHER_get0_provider(ciph) != NULL
- && !tls_provider_set_tls_params(s, dd, ciph, md)) {
+ NULL, 0, key, key_len, iv, iv_len, mac_secret,
+ md_len, ciph, 0, NID_undef, md, comp, NULL)) {
/* SSLfatal already called */
goto err;
}
- s->statem.enc_write_state = ENC_WRITE_STATE_VALID;
return 1;
err:
return 0;
unsigned char *p,
size_t len, size_t *secret_size)
{
- static const unsigned char *salt[3] = {
+ static const unsigned char *const salt[3] = {
#ifndef CHARSET_EBCDIC
(const unsigned char *)"A",
(const unsigned char *)"BB",