public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Oliver Steffen <osteffen@redhat.com>,
	Pawel Polawski <ppolawsk@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 1/4] CryptoPkg/BaseCryptLib: avoid using SHA1()
Date: Mon, 13 Feb 2023 20:19:55 +0100	[thread overview]
Message-ID: <20230213191958.913689-2-kraxel@redhat.com> (raw)
In-Reply-To: <20230213191958.913689-1-kraxel@redhat.com>

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>
---
 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 1e071ce2b325..cfe1f4bc44c9 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
-- 
2.39.1


  reply	other threads:[~2023-02-13 19:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 19:19 [PATCH 0/4] CryptoPkg/BaseCryptLib: avoid certain openssl library calls Gerd Hoffmann
2023-02-13 19:19 ` Gerd Hoffmann [this message]
2023-02-13 22:14   ` [edk2-devel] [PATCH 1/4] CryptoPkg/BaseCryptLib: avoid using SHA1() Michael D Kinney
2023-02-14  2:23     ` Yao, Jiewen
2023-02-13 19:19 ` [PATCH 2/4] CryptoPkg/BaseCryptLib: avoid using SHA256() Gerd Hoffmann
2023-02-13 19:19 ` [PATCH 3/4] CryptoPkg/BaseCryptLib: avoid using SHA384() Gerd Hoffmann
2023-02-13 19:19 ` [PATCH 4/4] CryptoPkg/BaseCryptLib: avoid using SHA512() Gerd Hoffmann
2023-02-14  1:17 ` [edk2-devel] [PATCH 0/4] CryptoPkg/BaseCryptLib: avoid certain openssl library calls Yao, Jiewen
2023-02-14 10:13   ` Gerd Hoffmann
2023-02-15  8:15 ` Yao, Jiewen
2023-03-07  6:54   ` Gerd Hoffmann
2023-03-07  7:59     ` Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230213191958.913689-2-kraxel@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox