Cache constants for fetched EVP_cipher
[oweals/openssl.git] / crypto / evp / evp_enc.c
index da6dde0c4d069a840b72af3dbee3e079d274009e..96eb3506235b747bfe3abdcc6fda220ed3a85f92 100644 (file)
@@ -1524,6 +1524,10 @@ EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm,
                           evp_cipher_from_dispatch, evp_cipher_up_ref,
                           evp_cipher_free);
 
+    if (cipher != NULL && !evp_cipher_cache_constants(cipher)) {
+        EVP_CIPHER_free(cipher);
+        cipher = NULL;
+    }
     return cipher;
 }