summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2023-02-14 03:19:55 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-07 09:59:50 +0000
commit437ed29f278687140c29e00f1a0e4204f25e2d33 (patch)
tree740f5ba10ec24301a5a7834782262f287c68c288
parentc7c25997595aa34ce0a7a21ca2e1fc5b0f9b38a6 (diff)
downloadedk2-437ed29f278687140c29e00f1a0e4204f25e2d33.tar.gz
edk2-437ed29f278687140c29e00f1a0e4204f25e2d33.tar.bz2
edk2-437ed29f278687140c29e00f1a0e4204f25e2d33.zip
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 <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c16
1 files 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