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.133.124]) by mx.groups.io with SMTP id smtpd.web11.24582.1676316003987385945 for ; Mon, 13 Feb 2023 11:20:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X864oAYU; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676316002; 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=5SK+iW1SmFkHUoGcQMguvBqsJRsJB9EIkNUc3CoYxY8=; b=X864oAYUXYRqbbo/UdNRgVHSp0QaSEhZbf61jpoCLkrHG0VLsx91K2PotxraTLPdBBqgRw gz4ZS9T4H3liYZI8eOgT5n4B9tccafiXqzchi9fgo7+FZb8XrvlkPSbrZJ9ieERB17WSUS DLwtfDJ9mjUs/e2ilLg3+jDPRTceuMI= 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-76-6GjJDboPNHKK0RlHSoskYg-1; Mon, 13 Feb 2023 14:20:01 -0500 X-MC-Unique: 6GjJDboPNHKK0RlHSoskYg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AD9E1C09041 for ; Mon, 13 Feb 2023 19:20:01 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08B191121318; Mon, 13 Feb 2023 19:20:01 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 198F9180039F; 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 2/4] CryptoPkg/BaseCryptLib: avoid using SHA256() Date: Mon, 13 Feb 2023 20:19:56 +0100 Message-Id: <20230213191958.913689-3-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.3 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 SHA256() 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/CryptSha256.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c index f105e6e57708..4d7d92812c4d 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c @@ -202,6 +202,8 @@ Sha256HashAll ( OUT UINT8 *HashValue ) { + SHA256_CTX Context; + // // Check input parameters. // @@ -216,9 +218,17 @@ Sha256HashAll ( // // OpenSSL SHA-256 Hash Computation. // - if (SHA256 (Data, DataSize, HashValue) == NULL) { + if (!SHA256_Init (&Context)) { return FALSE; - } else { - return TRUE; } + + if (!SHA256_Update (&Context, Data, DataSize)) { + return FALSE; + } + + if (!SHA256_Final (HashValue, &Context)) { + return FALSE; + } + + return TRUE; } -- 2.39.1