From bc3a1377366b2465cebfb61032c1e864c6bbf665 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 7 Oct 2019 17:45:25 +0100 Subject: [PATCH] Don't use internal knowledge about EVP_MD_CTX in and MD BIO There is no need for us to be diving inside the EVP_MD_CTX in the implementation of an MD BIO. We can just use public APIs. By doing this certain calls (such as getting the MD out of the BIO were not working correctly) where providers are in use. Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/10116) --- crypto/evp/bio_md.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c index 8d502d0bf7..aca177e9da 100644 --- a/crypto/evp/bio_md.c +++ b/crypto/evp/bio_md.c @@ -9,11 +9,8 @@ #include #include -#include "internal/cryptlib.h" #include #include -#include "crypto/evp.h" -#include "evp_local.h" #include "internal/bio.h" /* @@ -148,7 +145,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr) switch (cmd) { case BIO_CTRL_RESET: if (BIO_get_init(b)) - ret = EVP_DigestInit_ex(ctx, ctx->digest, NULL); + ret = EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL); else ret = 0; if (ret > 0) @@ -157,7 +154,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_C_GET_MD: if (BIO_get_init(b)) { ppmd = ptr; - *ppmd = ctx->digest; + *ppmd = EVP_MD_CTX_md(ctx); } else ret = 0; break; @@ -223,7 +220,7 @@ static int md_gets(BIO *bp, char *buf, int size) ctx = BIO_get_data(bp); - if (size < ctx->digest->md_size) + if (size < EVP_MD_CTX_size(ctx)) return 0; if (EVP_DigestFinal_ex(ctx, (unsigned char *)buf, &ret) <= 0) -- 2.34.1