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.24584.1676316007500659141 for ; Mon, 13 Feb 2023 11:20:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NYVJ3BX1; 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=1676316006; 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=b/bIFtVkq1Ti4ZAtudJs5Q78QJ4bfLNUEw9mKaqImAQ=; b=NYVJ3BX16xqFzIrZCqE8zcmTeMaUUWcG9cH3gL6RCymgfmSpaQCXhbgdaa0VblHO4BwZaI fA1FJ/krNkGj7qO2gDegA1kZv05Z1dpWhO0J3LbpidLEJz+fnxycIwKtRnfOuOAG44UJ9+ 6RUp05kUbdbUD614JtzkXlqy9+VgPz0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-uLpOGi5YMyGn7jQLlK5nxQ-1; Mon, 13 Feb 2023 14:19:59 -0500 X-MC-Unique: uLpOGi5YMyGn7jQLlK5nxQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FF5585CCE0 for ; Mon, 13 Feb 2023 19:19:59 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D1C32026D4B; Mon, 13 Feb 2023 19:19:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 142461800084; 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 1/4] CryptoPkg/BaseCryptLib: avoid using SHA1() Date: Mon, 13 Feb 2023 20:19:55 +0100 Message-Id: <20230213191958.913689-2-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.4 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 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 --- 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