]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - ssl/s3_enc.c
Move the SSLv3 crypto code into the new record layer
[thirdparty/openssl.git] / ssl / s3_enc.c
index d575d28dcdfa0a1268a8a5881328daf69aca20ab..26471c3784bfee06aacc2b0fc504f514114bed88 100644 (file)
@@ -92,13 +92,11 @@ int ssl3_change_cipher_state(SSL_CONNECTION *s, int which)
     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;
 
@@ -145,6 +143,9 @@ int ssl3_change_cipher_state(SSL_CONNECTION *s, int which)
         goto err;
     }
 
+    if ((which & SSL3_CC_WRITE) != 0)
+        s->statem.enc_write_state = ENC_WRITE_STATE_INVALID;
+
     if (!ssl_set_new_record_layer(s, SSL3_VERSION,
                                   direction,
                                   OSSL_RECORD_PROTECTION_LEVEL_APPLICATION,
@@ -154,56 +155,6 @@ int ssl3_change_cipher_state(SSL_CONNECTION *s, int which)
         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)) {
-        /* SSLfatal already called */
-        goto err;
-    }
-
     s->statem.enc_write_state = ENC_WRITE_STATE_VALID;
     return 1;
  err: