Ensure that MDs created via EVP_MD_meth_new() go down the legacy route
authorMatt Caswell <matt@openssl.org>
Fri, 10 Dec 2021 16:53:02 +0000 (16:53 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 10 Jan 2022 16:38:35 +0000 (16:38 +0000)
MDs created via EVP_MD_meth_new() are inherently legacy and therefore
need to go down the legacy route when they are used.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/17255)

crypto/evp/digest.c

index 322cfe7646152a9af6f5a7a473dc6fb2d9b7ae2d..5fe80a63f49ebb6798f7db720e2e1d77e4724647 100644 (file)
@@ -208,7 +208,8 @@ static int evp_md_init_internal(EVP_MD_CTX *ctx, const EVP_MD *type,
             || tmpimpl != NULL
 # endif
 #endif
-            || (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) != 0) {
+            || (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) != 0
+            || type->origin == EVP_ORIG_METH) {
         if (ctx->digest == ctx->fetched_digest)
             ctx->digest = NULL;
         EVP_MD_free(ctx->fetched_digest);