From 437ed29f278687140c29e00f1a0e4204f25e2d33 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 14 Feb 2023 03:19:55 +0800 Subject: CryptoPkg/BaseCryptLib: avoid using SHA1() In openssl 3.0 SHA1() 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/CryptSha1.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c index 1e071ce2b3..cfe1f4bc44 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c @@ -204,6 +204,8 @@ Sha1HashAll ( OUT UINT8 *HashValue ) { + SHA_CTX Context; + // // Check input parameters. // @@ -218,11 +220,19 @@ Sha1HashAll ( // // OpenSSL SHA-1 Hash Computation. // - if (SHA1 (Data, DataSize, HashValue) == NULL) { + if (!SHA1_Init (&Context)) { return FALSE; - } else { - return TRUE; } + + if (!SHA1_Update (&Context, Data, DataSize)) { + return FALSE; + } + + if (!SHA1_Final (HashValue, &Context)) { + return FALSE; + } + + return TRUE; } #endif -- cgit