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 4/4] CryptoPkg/BaseCryptLib: avoid using SHA512()
Date: Mon, 13 Feb 2023 20:19:58 +0100	[thread overview]
Message-ID: <20230213191958.913689-5-kraxel@redhat.com> (raw)
In-Reply-To: <20230213191958.913689-1-kraxel@redhat.com>

In openssl 3.0 SHA512() 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>
---
 .../Library/BaseCryptLib/Hash/CryptSha512.c      | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c
index 2ab7188035e8..dee8f35c41ad 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c
@@ -430,6 +430,8 @@ Sha512HashAll (
   OUT  UINT8       *HashValue
   )
 {
+  SHA512_CTX  Context;
+
   //
   // Check input parameters.
   //
@@ -444,9 +446,17 @@ Sha512HashAll (
   //
   // OpenSSL SHA-512 Hash Computation.
   //
-  if (SHA512 (Data, DataSize, HashValue) == NULL) {
+  if (!SHA512_Init (&Context)) {
     return FALSE;
-  } else {
-    return TRUE;
   }
+
+  if (!SHA512_Update (&Context, Data, DataSize)) {
+    return FALSE;
+  }
+
+  if (!SHA512_Final (HashValue, &Context)) {
+    return FALSE;
+  }
+
+  return TRUE;
 }
-- 
2.39.1


  parent 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 ` [PATCH 1/4] CryptoPkg/BaseCryptLib: avoid using SHA1() Gerd Hoffmann
2023-02-13 22:14   ` [edk2-devel] " 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 ` Gerd Hoffmann [this message]
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-5-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