From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.24583.1676316005176050179 for ; Mon, 13 Feb 2023 11:20:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UN+L/u7r; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676316004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y53MJt6xdS+BbB7e5qrKKVO5gnC7CE/Cth6p0hmXY6U=; b=UN+L/u7rRiDJbmxqqFNPURqnfzXDHGewY8HJs8LXsM217VuVb/IsrBcyIe/q0CdcqmD0RD oPd8t0hYU+9w8xOaCpuYPYT//fwTa36mdyJDnSEhdqck12LtBl/ojrJmBZCrSKIVS8IsNS yr8d/M0NG6KIDSDVHZfHFVCgv5GzO8M= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-5-cHbQG_iSOPK-dm-E0MSjEA-1; Mon, 13 Feb 2023 14:20:03 -0500 X-MC-Unique: cHbQG_iSOPK-dm-E0MSjEA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD2621C09044 for ; Mon, 13 Feb 2023 19:20:02 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95255C16023; Mon, 13 Feb 2023 19:20:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 208DD180061A; Mon, 13 Feb 2023 20:19:58 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Pawel Polawski , Gerd Hoffmann Subject: [PATCH 4/4] CryptoPkg/BaseCryptLib: avoid using SHA512() Date: Mon, 13 Feb 2023 20:19:58 +0100 Message-Id: <20230213191958.913689-5-kraxel@redhat.com> In-Reply-To: <20230213191958.913689-1-kraxel@redhat.com> References: <20230213191958.913689-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 --- .../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