Only reset the ctx when a cipher is given
authorKurt Roeckx <kurt@roeckx.be>
Sun, 29 Oct 2017 14:13:43 +0000 (15:13 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Mon, 30 Oct 2017 21:51:40 +0000 (22:51 +0100)
This restores the 1.0.2 behaviour

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Benjamin Kaduk <bkaduk@akamai.com>
GH: #4613
(cherry picked from commit ffd23209933ea0ad5543f15ca6303d63d8dac826)

crypto/evp/evp_enc.c

index f829e8dccdc45f8e7632941795ea6da85d73dd85..5ea14cd1cdc481ac9297e38d01586dcecad91134 100644 (file)
@@ -50,7 +50,8 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
                    const unsigned char *key, const unsigned char *iv, int enc)
 {
-    EVP_CIPHER_CTX_reset(ctx);
+    if (cipher != NULL)
+        EVP_CIPHER_CTX_reset(ctx);
     return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
 }