From 7fc183df71b0aa2106139677258227662ce1f004 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 14 Feb 2023 03:19:56 +0800 Subject: CryptoPkg/BaseCryptLib: avoid using SHA256() In openssl 3.0 SHA256() goes through the provider logic, requiring a huge amount of openssl code. The individual functions do not, so use them instead. Signed-off-by: Gerd Hoffmann Reviewed-by: Jiewen Yao --- CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c') diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c index f105e6e577..4d7d92812c 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c @@ -202,6 +202,8 @@ Sha256HashAll ( OUT UINT8 *HashValue ) { + SHA256_CTX Context; + // // Check input parameters. // @@ -216,9 +218,17 @@ Sha256HashAll ( // // OpenSSL SHA-256 Hash Computation. // - if (SHA256 (Data, DataSize, HashValue) == NULL) { + if (!SHA256_Init (&Context)) { return FALSE; - } else { - return TRUE; } + + if (!SHA256_Update (&Context, Data, DataSize)) { + return FALSE; + } + + if (!SHA256_Final (HashValue, &Context)) { + return FALSE; + } + + return TRUE; } -- cgit v1.2.3