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:50:17 +0000 (22:50 +0100)
This restores the 1.0.2 behaviour

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Benjamin Kaduk <bkaduk@akamai.com>
GH: #4613

crypto/evp/evp_enc.c

index d353084a9a8f08a7157edfc96bbc400c8621552f..f89cff6f60c9b02201e03194c253da85f210a902 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);
 }