From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.4454.1647564968165809641 for ; Thu, 17 Mar 2022 17:56:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=lX7Kr4m7; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647564968; x=1679100968; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nF2bsQchDRLaGyoyI7asTzqlTKM4nPqWKW8loOMzJPg=; b=lX7Kr4m7Q4Nj5B+fhhOVZV80aQXtUDCuHSPJ93mNYoT5/ILq82mzqJ4p /cHzOg9iAsLrsBIChb2O72ACtj8/PLobV1VEsO4m7uxL+B+imFw2fPvJ2 ZEBXUlhn2FGSpIPaBS7muPcnoafqlsO34jHA0nbbHz/saaAYA5w6IIddT f9QmoQvcCk3N89sJ2vqd42pNf9i+F8b3ntk5kxyNbR89Tk25mpU5cGGE1 1szQCWXuKNdef8c/Afb82JetgBO5GOCVRFBFIerohvpa9d7aztlSoMqhZ lnAUV/4rXuTxDxAlD1qHQK05Bu8KqsOTwCYJKWMUqNrVZsxS6U+Y9KMJq Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="239180055" X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="239180055" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 17:56:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="516986319" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 17 Mar 2022 17:56:06 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Mar 2022 17:56:06 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 17 Mar 2022 17:56:06 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 17 Mar 2022 17:56:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEgQSIFXZS1xReCwsGXYKcUxY6wAp09QF3GcVrWPhYe7aJzl+Yrfj8yYtMkqHpb9hi9KR7/dO6zODL3sNkhfxs22xvFOsQw9BCaIbTNGC5+C6ICIcCLgRJEWZfO2LJTejgojIFQpWB0xk2V3w9lPq6tPWCE8eziMEC7oOv72qg7ig7L97PE7tpmYBNsz9xPCm/8IZJyvFL3DhSR0DoawvKd81uZMnNBQeJrewv8IzYfdvegbFqcKiV4NxZgUnaJKQcC/jWnKZ78dqvfgGWCyHSRjNexWlX0rvH/AF1FNkU99BYL/MO9/INxpLqcpJDuyvoGP4lfuiROKdfQ+I75jgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JPXhiHhvC9BXuL4+B70ytzqLomL7TqVj5usLTFBU9Mk=; b=i7ZrQIn4PQrcRY4dLnoYvzTJdoPcwlj1fYW8Vgy3yTyf4/W0HJfZW3LKc2MXL8IPVVRDDLdFHSPeDhExua7I/8z13J/M8lJMvNhTCvjbYc4O8gSSf7B4dtdafD0A8pVtPk1jVuT7w99mUB6ObLp2H8iYjFpVVF4i41NyDRR3RPMGhRsRSaXQ1I93UDv56auOu8drFH4YWaaF3b5vV/xhju3MbAb4ZEAND+InlG4Wp+w9pgWij0wldVNh0XGN8Ij9Ivy1gg4ZORVmWILX7LqWBNM7Q/qLthtwcpZBAHORAj0EYNMvuj4MKWhloj3iGaJXQka8ZH30pHkpb7yVCexXTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by BN6PR11MB1442.namprd11.prod.outlook.com (2603:10b6:405:9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Fri, 18 Mar 2022 00:56:01 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::752f:fdc8:905f:3fec]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::752f:fdc8:905f:3fec%6]) with mapi id 15.20.5081.017; Fri, 18 Mar 2022 00:56:01 +0000 From: "Yao, Jiewen" To: "Li, Zhihao" , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Lu, Xiaoyu1" , "Jiang, Guomin" , "Fu, Siyuan" Subject: Re: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib. Thread-Topic: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib. Thread-Index: AQHYObhWpGZOzIXh0ECh0X9gIAaugqzDE/0wgACqfmCAAJPR0A== Date: Fri, 18 Mar 2022 00:56:01 +0000 Message-ID: References: <20220317043430.1002-1-zhihao.li@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.401.20 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d3af9920-78dd-4827-d228-08da087a129f x-ms-traffictypediagnostic: BN6PR11MB1442:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /u2Fyv2Vj/FQ8nYOmGw/785cCiFizvS7/urFikAgM5yv4lhFqqJzyhSkyfIpKgNlQ/axbAiDoB9qSzT+rwunCzK13+sCDRz7WitTx15xbos1JUspkPER7V7vKPRA7quB63AzpBNyf7zIDHl1/dl6aSuKTucp0pi6zzpR/jPnr1KSmK9CfcK3JnB9wscDT9SRUEUiL5dzd0oo+e0HXuKw2PY2VcWjn8SozIH0RycY8mKJrl1U6LJPLZFRbinKf1ZY4NAZjA+qGO/MBmG7sMGOi3+sqaKtQu70H7ZMD8RDJBRXbQ+1wXzfQA01nGpMNRmiPvT75RViX7TMmHI2JIAoEHJk+W8FJSnXShJEJJ4Dr5JdBPJANk633BXNzDCKBOSVRTyJUWPHqlLvKEABfEkhr5sXfT2ixObS+zdGwBsrbxJupReRPIqmmzfV4BG92zU9L9VRlVOsq0sYEDGpjjNCZAg3P2ZB+do/bzYZe29Mi1/Q7N3h5DxPkSiYKAo5N7I1grmFXEM4rTRDXmn5ocnKm6WJLSVwZcV7FOT8bBpyIdhA3BEdDFSJ7GgZFx2XF3ndAllScNUFth4zBlaTwC0KOQHizxGnAZ/4yym3s9QeRhh/KkUNGJpXMhEAEIV8/yOdzbJcSA2ndw77MH7dv7B0n9W0Os718zDgH2IH2De3TxMn9rihkEIMBPYgB6Alk/CSWy41L3JIFBBfWmINi3+XZdPjB6mhEGjzIX0pASQuxBooFpOoj04VqppTHT3oqogvcftAbpleIN+TeMmIYNmLNKTMwgMdecVLfQOs5wNUJ/s9PtuZyo58I3k6OvC2zPILEnJFcWLOi1nEUyRcD/V5mQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(107886003)(19627235002)(52536014)(110136005)(26005)(316002)(9686003)(186003)(33656002)(86362001)(71200400001)(55016003)(4326008)(66446008)(64756008)(66946007)(66476007)(8676002)(66556008)(7696005)(76116006)(6506007)(54906003)(38070700005)(45080400002)(966005)(8936002)(2906002)(30864003)(5660300002)(53546011)(83380400001)(38100700002)(122000001)(82960400001)(508600001)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UReqCnlzfgE8y2cNSQkw7kwSbqZeAU0ccZOOZmpi0lrGUGbp/Uzlvb6VVttc?= =?us-ascii?Q?RgXMO7a0Zc5nYqg120AXJYpt91RLf2oxwI3tzsfiYwZHKy1VMICMBgIt/67B?= =?us-ascii?Q?VrNs7zoYBw0Q7NCYwpZsG+pI0PFZ7jGwFFaDPDEgChZLjvEC/CwPMe9R6oRx?= =?us-ascii?Q?ARB1Z4ESTXc6+ezggQ+UxZIhAR6p2ZlElBWyXju83fz8sCCHNB+F1gD4wuM7?= =?us-ascii?Q?L+8TOQQ6Ip/55fNKNDlrLh0NHYqvfZ1CWxEknzA7UdDZMMKVUPVrLOND2usg?= =?us-ascii?Q?KkXEOBFZoyqaqqiIABMOxblzFFsbRMtJg3w0ZMPGcuJvXS/g5BX5bptWI8nQ?= =?us-ascii?Q?47H4/yqHjz0a5bp3rgPrlntiMD+cXHVu+5+zqKbtiYnb6KEKErFN6th+L/ll?= =?us-ascii?Q?Qhqq3iQpB/mkI+7L7Dlc6f+77aUxUo6ceKkw4+BSSvkbD4Ra6cyJJBVVFyW2?= =?us-ascii?Q?n3F9uGTVSNdv3TDjZJD6duaPFc/6UlXjONursnSQlNjSDczrm22izGheX1Jr?= =?us-ascii?Q?bApNnH8hLIw0W9JRU4rXTYFxDxyOgpLtsPeoxm3zTDFDp6aEKjNAuIculuko?= =?us-ascii?Q?3RY1UVSkG2NNOWZYfLhutYfWuIG/JuK6hvOZufUcah6Ws01Vnh8ei6vWc1Mw?= =?us-ascii?Q?s0/DbF7AdVE0fyKl8XVPD7eLdv+76+8jiBMjyjDJY1sJUgbC23SpTHupzmvX?= =?us-ascii?Q?ZJb/Q/U5CYd5uaohW8SkmVD0cxw2y5ClHrzmumoyJDmJHpy1NaWJLe34b8+Y?= =?us-ascii?Q?8G15z9YNUfAGiU/iPVzRNJBGx8Q0JGXXiHpN0wOt8XiBKTNM2fovStXAijvn?= =?us-ascii?Q?2vCQEP2KEiaDc3hyMWbWzvBqeM7SLG06dL4vSLRKlae03C9Gc1x12nkjZ2vt?= =?us-ascii?Q?69zbxStXQefWNJ+zkrmAIomm20AKxPoK4QbV5gF9WTjX30yM0SZBpTNm6CuT?= =?us-ascii?Q?CD3j9HpwzBJHpmYbyRQJ4MS6uDr+Aku8XVcfFpY6B8DyTaNF01JgYSIydrFi?= =?us-ascii?Q?ioEg1KeOazGaCKoGAteJKybWYRAI777b90iX+F//a+uZ+Yhe9RuSx1SRugqb?= =?us-ascii?Q?m60U9cf5jeLMxZXtHNQ51Nzo7jzt0wRCg0+3A2ry1rNBYGucJenTbtNR8ACv?= =?us-ascii?Q?YIdenbLeUb9/5Y2sOSNoBodikjd5988rjSkgfMfefaQK+pd91nGwDuHfDiM0?= =?us-ascii?Q?TlznvCHesLeiNdNCtVNmo61h9kEfU2r+dJfcgqet+flhtbhplsgJKSBF6XrX?= =?us-ascii?Q?PBaFN1LYYggJLVFD2eLYB4verg3KBSmHJi/22rjTrOTxm8sjndiRHWf/JhCs?= =?us-ascii?Q?rqz1OP2pPBZLqfSsfqTvHT2RNeS3lh7SJ+ays3veGlq0cyJB5L4comLSkTwW?= =?us-ascii?Q?Ua51F757cDBNJH0iAq0NZ2xroo2+g9hnNDXhg5H12giWkUY5Ytysvdgldpk4?= =?us-ascii?Q?y6ZFFDMO7FFbxQk+o3qWHj0jnUh0FjGl?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3af9920-78dd-4827-d228-08da087a129f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2022 00:56:01.5811 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bsgUuyzDUWcEdmUfT12pt8WHP5C4tATwzOsSfQe4xMW7xDlvkxty48FFR/mVnMAR74NWCJakXa2NImUZBeM/8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1442 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable What is root cause of failure? I don't understand. > -----Original Message----- > From: Li, Zhihao > Sent: Friday, March 18, 2022 12:27 AM > To: Yao, Jiewen ; devel@edk2.groups.io > Cc: Wang, Jian J ; Lu, Xiaoyu1 ; > Jiang, Guomin ; Fu, Siyuan > Subject: RE: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm > ParallelHash256HashAll in BaseCryptLib. >=20 > Because it will cause patch to fail in CI test while to succeed if follow= the setting. > Failed test: https://github.com/tianocore/edk2/pull/2535 >=20 > I guess it's because data structure EDKII_CRYPTO_PROTOCOL( mEdkiiCrypto) > doesn't have /// RSA PSS members in Crypto.c >=20 > > -----Original Message----- > > From: Yao, Jiewen > > Sent: Thursday, March 17, 2022 10:13 PM > > To: Li, Zhihao ; devel@edk2.groups.io > > Cc: Wang, Jian J ; Lu, Xiaoyu1 > ; > > Jiang, Guomin ; Fu, Siyuan > > Subject: RE: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm > > ParallelHash256HashAll in BaseCryptLib. > > > > Hey > > Are you following the guideline - don't put new field in the middle ? > > > > ParallelHash256HashAll API is still in the middle...... > > > > > > > @@ -3641,6 +3670,8 @@ struct _EDKII_CRYPTO_PROTOCOL { > > > EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT TlsGetHostPubli= cCert; > > > > > > EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY TlsGetHostPriva= teKey; > > > > > > EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST > > > TlsGetCertRevocationList; > > > > > > + /// Parallel hash > > > > > > + EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash256= HashAll; > > > > > > /// RSA PSS > > > > > > EDKII_CRYPTO_RSA_PSS_SIGN RsaPssSign; > > > > > > EDKII_CRYPTO_RSA_PSS_VERIFY RsaPssVerify; > > > > > > > > > > -----Original Message----- > > > From: Li, Zhihao > > > Sent: Thursday, March 17, 2022 12:35 PM > > > To: devel@edk2.groups.io > > > Cc: Yao, Jiewen ; Wang, Jian J > > ; > > > Lu, Xiaoyu1 ; Jiang, Guomin > > ; > > > Fu, Siyuan > > > Subject: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm > > > ParallelHash256HashAll in BaseCryptLib. > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3596 > > > > > > Parallel hash function ParallelHash256HashAll, as defined in NIST's > > > Special Publication 800-185, published December 2016. It utilizes > > > multi-process to calculate the digest. > > > > > > Passed CI test. > > > Onprotocol version code passed test. > > > > > > Cc: Jiewen Yao > > > Cc: Jian J Wang > > > Cc: Xiaoyu Lu > > > Cc: Guomin Jiang > > > Cc: Siyuan Fu > > > Cc: Zhihao Li > > > > > > Signed-off-by: Zhihao Li > > > --- > > > CryptoPkg/Driver/Crypto.c = | 38 ++- > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c = | 282 > > > ++++++++++++++++++++ > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c = | 278 > > > +++++++++++++++++++ > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHashNull.c = | 40 > +++ > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c = | 166 > > > ++++++++++++ > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c = | 107 > > ++++++++ > > > CryptoPkg/Library/BaseCryptLibNull/Hash/CryptParallelHashNull.c = | 40 > > +++ > > > CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c = | 34 ++- > > > CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.c = | 145 > > > ++++++++++ > > > CryptoPkg/CryptoPkg.ci.yaml = | 4 +- > > > CryptoPkg/Include/Library/BaseCryptLib.h = | 31 ++- > > > CryptoPkg/Include/Pcd/PcdCryptoServiceFamilyEnable.h = | 8 +- > > > CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf = | 3 +- > > > CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.h = | 201 > > > ++++++++++++++ > > > CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf = | 3 +- > > > CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf = | 3 +- > > > CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf = | 8 +- > > > CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf = | 3 +- > > > CryptoPkg/Library/Include/CrtLibSupport.h = | 3 +- > > > CryptoPkg/Private/Protocol/Crypto.h = | 35 ++- > > > CryptoPkg/Test/CryptoPkgHostUnitTest.dsc = | 4 + > > > CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.in= f | > 4 > > + > > > 22 files changed, 1426 insertions(+), 14 deletions(-) > > > > > > diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c > > > index d5d6aa8e5820..5a9245c07cc5 100644 > > > --- a/CryptoPkg/Driver/Crypto.c > > > +++ b/CryptoPkg/Driver/Crypto.c > > > @@ -3,7 +3,7 @@ > > > from BaseCryptLib and TlsLib. > > > > > > > > > > > > Copyright (C) Microsoft Corporation. All rights reserved. > > > > > > - Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.=
> > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.=
> > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > **/ > > > > > > @@ -4470,6 +4470,38 @@ CryptoServiceTlsGetCertRevocationList ( > > > return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, > > > TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED); > > > > > > } > > > > > > > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval TRUE ParallelHash256 digest computation succeeded. > > > > > > + @retval FALSE ParallelHash256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CryptoServiceParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ) > > > > > > +{ > > > > > > + return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, > > > ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, > > OutputByteLen, > > > Customization, CustomByteLen), FALSE); > > > > > > +} > > > > > > + > > > > > > const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto =3D { > > > > > > /// Version > > > > > > CryptoServiceGetCryptoVersion, > > > > > > @@ -4670,5 +4702,7 @@ const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto =3D > { > > > CryptoServiceTlsGetCaCertificate, > > > > > > CryptoServiceTlsGetHostPublicCert, > > > > > > CryptoServiceTlsGetHostPrivateKey, > > > > > > - CryptoServiceTlsGetCertRevocationList > > > > > > + CryptoServiceTlsGetCertRevocationList, > > > > > > + /// Parallel hash > > > > > > + CryptoServiceParallelHash256HashAll > > > > > > }; > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c > > > new file mode 100644 > > > index 000000000000..2a9eaf9eec40 > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c > > > @@ -0,0 +1,282 @@ > > > +/** @file > > > > > > + cSHAKE-256 Digest Wrapper Implementations. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "CryptParallelHash.h" > > > > > > + > > > > > > +#define CSHAKE256_SECURITY_STRENGTH 256 > > > > > > +#define CSHAKE256_RATE_IN_BYTES 136 > > > > > > + > > > > > > +CONST CHAR8 mZeroPadding[CSHAKE256_RATE_IN_BYTES] =3D { 0 }; > > > > > > + > > > > > > +/** > > > > > > + CShake256 initial function. > > > > > > + > > > > > > + Initializes user-supplied memory pointed by CShake256Context as cS= HAKE- > > 256 > > > hash context for > > > > > > + subsequent use. > > > > > > + > > > > > > + @param[out] CShake256Context Pointer to cSHAKE-256 context being > > > initialized. > > > > > > + @param[in] OutputLen The desired number of output length = in bytes. > > > > > > + @param[in] Name Pointer to the function name string. > > > > > > + @param[in] NameLen The length of the function name in b= ytes. > > > > > > + @param[in] Customization Pointer to the customization string. > > > > > > + @param[in] CustomizationLen The length of the customization stri= ng in > > > bytes. > > > > > > + > > > > > > + @retval TRUE cSHAKE-256 context initialization succeeded. > > > > > > + @retval FALSE cSHAKE-256 context initialization failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CShake256Init ( > > > > > > + OUT VOID *CShake256Context, > > > > > > + IN UINTN OutputLen, > > > > > > + IN CONST VOID *Name, > > > > > > + IN UINTN NameLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomizationLen > > > > > > + ) > > > > > > +{ > > > > > > + BOOLEAN Status; > > > > > > + UINT8 EncBuf[sizeof (UINTN) + 1]; > > > > > > + UINTN EncLen; > > > > > > + UINTN AbsorbLen; > > > > > > + UINTN PadLen; > > > > > > + > > > > > > + // > > > > > > + // Check input parameters. > > > > > > + // > > > > > > + if ((CShake256Context =3D=3D NULL) || (OutputLen =3D=3D 0) || ((Na= meLen !=3D 0) > && > > > (Name =3D=3D NULL)) || ((CustomizationLen !=3D 0) && (Customization = =3D=3D NULL))) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Initialize KECCAK context with pad value and block size. > > > > > > + // > > > > > > + if ((NameLen =3D=3D 0) && (CustomizationLen =3D=3D 0)) { > > > > > > + // > > > > > > + // When N and S are both empty strings, cSHAKE(X, L, N, S) is eq= uivalent > to > > > > > > + // SHAKE as defined in FIPS 202. > > > > > > + // > > > > > > + Status =3D (BOOLEAN)KeccakInit ( > > > > > > + (Keccak1600_Ctx *)CShake256Context, > > > > > > + '\x1f', > > > > > > + (KECCAK1600_WIDTH - CSHAKE256_SECURITY_STREN= GTH * 2) > / > > 8, > > > > > > + OutputLen > > > > > > + ); > > > > > > + > > > > > > + return Status; > > > > > > + } else { > > > > > > + Status =3D (BOOLEAN)KeccakInit ( > > > > > > + (Keccak1600_Ctx *)CShake256Context, > > > > > > + '\x04', > > > > > > + (KECCAK1600_WIDTH - CSHAKE256_SECURITY_STREN= GTH * 2) > / > > 8, > > > > > > + OutputLen > > > > > > + ); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen =3D 0; > > > > > > + // > > > > > > + // Absorb Absorb bytepad(.., rate). > > > > > > + // > > > > > > + EncLen =3D LeftEncode (EncBuf, CSHAKE256_RATE_IN_BYTES); > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx *)CShake256Conte= xt, > > > EncBuf, EncLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen +=3D EncLen; > > > > > > + > > > > > > + // > > > > > > + // Absorb encode_string(N). > > > > > > + // > > > > > > + EncLen =3D LeftEncode (EncBuf, NameLen * 8); > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx *)CShake256Conte= xt, > > > EncBuf, EncLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen +=3D EncLen; > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx > *)CShake256Context, > > > Name, NameLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen +=3D NameLen; > > > > > > + > > > > > > + // > > > > > > + // Absorb encode_string(S). > > > > > > + // > > > > > > + EncLen =3D LeftEncode (EncBuf, CustomizationLen * 8); > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx *)CShake256Conte= xt, > > > EncBuf, EncLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen +=3D EncLen; > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx > *)CShake256Context, > > > Customization, CustomizationLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + AbsorbLen +=3D CustomizationLen; > > > > > > + > > > > > > + // > > > > > > + // Absorb zero padding up to rate. > > > > > > + // > > > > > > + PadLen =3D CSHAKE256_RATE_IN_BYTES - AbsorbLen % > > > CSHAKE256_RATE_IN_BYTES; > > > > > > + Status =3D (BOOLEAN)Sha3Update ((Keccak1600_Ctx *)CShake256Conte= xt, > > > mZeroPadding, PadLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + return TRUE; > > > > > > + } > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Digests the input data and updates cSHAKE-256 context. > > > > > > + > > > > > > + This function performs cSHAKE-256 digest on a data buffer of the s= pecified > > > size. > > > > > > + It can be called multiple times to compute the digest of long or > > discontinuous > > > data streams. > > > > > > + cSHAKE-256 context should be already correctly initialized by > > CShake256Init(), > > > and should not be finalized > > > > > > + by CShake256Final(). Behavior with invalid context is undefined. > > > > > > + > > > > > > + @param[in, out] CShake256Context Pointer to the cSHAKE-256 cont= ext. > > > > > > + @param[in] Data Pointer to the buffer containi= ng the data to > be > > > hashed. > > > > > > + @param[in] DataSize Size of Data buffer in bytes. > > > > > > + > > > > > > + @retval TRUE cSHAKE-256 data digest succeeded. > > > > > > + @retval FALSE cSHAKE-256 data digest failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CShake256Update ( > > > > > > + IN OUT VOID *CShake256Context, > > > > > > + IN CONST VOID *Data, > > > > > > + IN UINTN DataSize > > > > > > + ) > > > > > > +{ > > > > > > + // > > > > > > + // Check input parameters. > > > > > > + // > > > > > > + if (CShake256Context =3D=3D NULL) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Check invalid parameters, in case that only DataLength was chec= ked in > > > OpenSSL. > > > > > > + // > > > > > > + if ((Data =3D=3D NULL) && (DataSize !=3D 0)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + return (BOOLEAN)(Sha3Update ((Keccak1600_Ctx *)CShake256Context, > > Data, > > > DataSize)); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Completes computation of the cSHAKE-256 digest value. > > > > > > + > > > > > > + This function completes cSHAKE-256 hash computation and retrieves = the > > > digest value into > > > > > > + the specified memory. After this function has been called, the cSH= AKE-256 > > > context cannot > > > > > > + be used again. > > > > > > + cSHAKE-256 context should be already correctly initialized by > > CShake256Init(), > > > and should not be > > > > > > + finalized by CShake256Final(). Behavior with invalid cSHAKE-256 co= ntext is > > > undefined. > > > > > > + > > > > > > + @param[in, out] CShake256Context Pointer to the cSHAKE-256 conte= xt. > > > > > > + @param[out] HashValue Pointer to a buffer that receiv= es the > > cSHAKE- > > > 256 digest > > > > > > + value. > > > > > > + > > > > > > + @retval TRUE cSHAKE-256 digest computation succeeded. > > > > > > + @retval FALSE cSHAKE-256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CShake256Final ( > > > > > > + IN OUT VOID *CShake256Context, > > > > > > + OUT UINT8 *HashValue > > > > > > + ) > > > > > > +{ > > > > > > + // > > > > > > + // Check input parameters. > > > > > > + // > > > > > > + if ((CShake256Context =3D=3D NULL) || (HashValue =3D=3D NULL)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // cSHAKE-256 Hash Finalization. > > > > > > + // > > > > > > + return (BOOLEAN)(Sha3Final ((Keccak1600_Ctx *)CShake256Context, > > > HashValue)); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Computes the CSHAKE-256 message digest of a input data buffer. > > > > > > + > > > > > > + This function performs the CSHAKE-256 message digest of a given da= ta > > buffer, > > > and places > > > > > > + the digest value into the specified memory. > > > > > > + > > > > > > + @param[in] Data Pointer to the buffer containing t= he data to be > > > hashed. > > > > > > + @param[in] DataSize Size of Data buffer in bytes. > > > > > > + @param[in] OutputLen Size of output in bytes. > > > > > > + @param[in] Name Pointer to the function name strin= g. > > > > > > + @param[in] NameLen Size of the function name in bytes= . > > > > > > + @param[in] Customization Pointer to the customization strin= g. > > > > > > + @param[in] CustomizationLen Size of the customization string i= n bytes. > > > > > > + @param[out] HashValue Pointer to a buffer that receives = the > CSHAKE- > > > 256 digest > > > > > > + value. > > > > > > + > > > > > > + @retval TRUE CSHAKE-256 digest computation succeeded. > > > > > > + @retval FALSE CSHAKE-256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CShake256HashAll ( > > > > > > + IN CONST VOID *Data, > > > > > > + IN UINTN DataSize, > > > > > > + IN UINTN OutputLen, > > > > > > + IN CONST VOID *Name, > > > > > > + IN UINTN NameLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomizationLen, > > > > > > + OUT UINT8 *HashValue > > > > > > + ) > > > > > > +{ > > > > > > + BOOLEAN Status; > > > > > > + Keccak1600_Ctx Ctx; > > > > > > + > > > > > > + // > > > > > > + // Check input parameters. > > > > > > + // > > > > > > + if (HashValue =3D=3D NULL) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + if ((Data =3D=3D NULL) && (DataSize !=3D 0)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + Status =3D CShake256Init (&Ctx, OutputLen, Name, NameLen, Customiz= ation, > > > CustomizationLen); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + Status =3D CShake256Update (&Ctx, Data, DataSize); > > > > > > + if (!Status) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + return CShake256Final (&Ctx, HashValue); > > > > > > +} > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c > > > new file mode 100644 > > > index 000000000000..f7ce9dbf523e > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c > > > @@ -0,0 +1,278 @@ > > > +/** @file > > > > > > + ParallelHash Implementation. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "CryptParallelHash.h" > > > > > > +#include > > > > > > +#include > > > > > > + > > > > > > +#define PARALLELHASH_CUSTOMIZATION "ParallelHash" > > > > > > + > > > > > > +UINTN mBlockNum; > > > > > > +UINTN mBlockSize; > > > > > > +UINTN mLastBlockSize; > > > > > > +UINT8 *mInput; > > > > > > +UINTN mBlockResultSize; > > > > > > +UINT8 *mBlockHashResult; > > > > > > +BOOLEAN *mBlockIsCompleted; > > > > > > +SPIN_LOCK *mSpinLockList; > > > > > > + > > > > > > +/** > > > > > > + Complete computation of digest of each block. > > > > > > + > > > > > > + Each AP perform the function called by BSP. > > > > > > + > > > > > > + @param[in] ProcedureArgument Argument of the procedure. > > > > > > +**/ > > > > > > +VOID > > > > > > +EFIAPI > > > > > > +ParallelHashApExecute ( > > > > > > + IN VOID *ProcedureArgument > > > > > > + ) > > > > > > +{ > > > > > > + UINTN Index; > > > > > > + BOOLEAN Status; > > > > > > + > > > > > > + for (Index =3D 0; Index < mBlockNum; Index++) { > > > > > > + if (AcquireSpinLockOrFail (&mSpinLockList[Index])) { > > > > > > + // > > > > > > + // Completed, try next one. > > > > > > + // > > > > > > + if (mBlockIsCompleted[Index]) { > > > > > > + ReleaseSpinLock (&mSpinLockList[Index]); > > > > > > + continue; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Calculate CShake256 for this block. > > > > > > + // > > > > > > + Status =3D CShake256HashAll ( > > > > > > + mInput + Index * mBlockSize, > > > > > > + (Index =3D=3D (mBlockNum - 1)) ? mLastBlockSize : m= BlockSize, > > > > > > + mBlockResultSize, > > > > > > + NULL, > > > > > > + 0, > > > > > > + NULL, > > > > > > + 0, > > > > > > + mBlockHashResult + Index * mBlockResultSize > > > > > > + ); > > > > > > + if (!EFI_ERROR (Status)) { > > > > > > + mBlockIsCompleted[Index] =3D TRUE; > > > > > > + } > > > > > > + > > > > > > + ReleaseSpinLock (&mSpinLockList[Index]); > > > > > > + } > > > > > > + } > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Dispatch the block task to each AP in SMM mode. > > > > > > + > > > > > > +**/ > > > > > > +VOID > > > > > > +EFIAPI > > > > > > +MmDispatchBlockToAP ( > > > > > > + VOID > > > > > > + ) > > > > > > +{ > > > > > > + UINTN Index; > > > > > > + > > > > > > + for (Index =3D 0; Index < gMmst->NumberOfCpus; Index++) { > > > > > > + if (Index !=3D gMmst->CurrentlyExecutingCpu) { > > > > > > + gMmst->MmStartupThisAp (ParallelHashApExecute, Index, NULL); > > > > > > + } > > > > > > + } > > > > > > + > > > > > > + return; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval TRUE ParallelHash256 digest computation succeeded. > > > > > > + @retval FALSE ParallelHash256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +ParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ) > > > > > > +{ > > > > > > + UINT8 EncBufB[sizeof (UINTN)+1]; > > > > > > + UINTN EncSizeB; > > > > > > + UINT8 EncBufN[sizeof (UINTN)+1]; > > > > > > + UINTN EncSizeN; > > > > > > + UINT8 EncBufL[sizeof (UINTN)+1]; > > > > > > + UINTN EncSizeL; > > > > > > + UINTN Index; > > > > > > + UINT8 *CombinedInput; > > > > > > + UINTN CombinedInputSize; > > > > > > + BOOLEAN AllCompleted; > > > > > > + UINTN Offset; > > > > > > + BOOLEAN ReturnValue; > > > > > > + > > > > > > + if ((InputByteLen =3D=3D 0) || (OutputByteLen =3D=3D 0) || (BlockS= ize =3D=3D 0)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + if ((Input =3D=3D NULL) || (Output =3D=3D NULL)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + if ((CustomByteLen !=3D 0) && (Customization =3D=3D NULL)) { > > > > > > + return FALSE; > > > > > > + } > > > > > > + > > > > > > + mBlockSize =3D BlockSize; > > > > > > + > > > > > > + // > > > > > > + // Calculate block number n. > > > > > > + // > > > > > > + mBlockNum =3D InputByteLen % mBlockSize =3D=3D 0 ? InputByteLen / > mBlockSize : > > > InputByteLen / mBlockSize + 1; > > > > > > + > > > > > > + // > > > > > > + // Set hash result size of each block in bytes. > > > > > > + // > > > > > > + mBlockResultSize =3D OutputByteLen; > > > > > > + > > > > > > + // > > > > > > + // Encode B, n, L to string and record size. > > > > > > + // > > > > > > + EncSizeB =3D LeftEncode (EncBufB, mBlockSize); > > > > > > + EncSizeN =3D RightEncode (EncBufN, mBlockNum); > > > > > > + EncSizeL =3D RightEncode (EncBufL, OutputByteLen * CHAR_BIT); > > > > > > + > > > > > > + // > > > > > > + // Allocate buffer for combined input (newX), Block completed flag= and > > > SpinLock. > > > > > > + // > > > > > > + CombinedInputSize =3D EncSizeB + EncSizeN + EncSizeL + mBlockNum * > > > mBlockResultSize; > > > > > > + CombinedInput =3D AllocateZeroPool (CombinedInputSize); > > > > > > + mBlockIsCompleted =3D AllocateZeroPool (mBlockNum * sizeof (BOOLEA= N)); > > > > > > + mSpinLockList =3D AllocatePool (mBlockNum * sizeof (SPIN_LOCK)= ); > > > > > > + if ((CombinedInput =3D=3D NULL) || (mBlockIsCompleted =3D=3D NULL)= || > > > (mSpinLockList =3D=3D NULL)) { > > > > > > + ReturnValue =3D FALSE; > > > > > > + goto Exit; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Fill LeftEncode(B). > > > > > > + // > > > > > > + CopyMem (CombinedInput, EncBufB, EncSizeB); > > > > > > + > > > > > > + // > > > > > > + // Prepare for parallel hash. > > > > > > + // > > > > > > + mBlockHashResult =3D CombinedInput + EncSizeB; > > > > > > + mInput =3D (UINT8 *)Input; > > > > > > + mLastBlockSize =3D InputByteLen % mBlockSize =3D=3D 0 ? mBlockSi= ze : > > > InputByteLen % mBlockSize; > > > > > > + > > > > > > + // > > > > > > + // Initialize SpinLock for each result block. > > > > > > + // > > > > > > + for (Index =3D 0; Index < mBlockNum; Index++) { > > > > > > + InitializeSpinLock (&mSpinLockList[Index]); > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Dispatch blocklist to each AP. > > > > > > + // > > > > > > + if (gMmst !=3D NULL) { > > > > > > + MmDispatchBlockToAP (); > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Wait until all block hash completed. > > > > > > + // > > > > > > + do { > > > > > > + AllCompleted =3D TRUE; > > > > > > + for (Index =3D 0; Index < mBlockNum; Index++) { > > > > > > + if (AcquireSpinLockOrFail (&mSpinLockList[Index])) { > > > > > > + if (!mBlockIsCompleted[Index]) { > > > > > > + AllCompleted =3D FALSE; > > > > > > + ReturnValue =3D CShake256HashAll ( > > > > > > + mInput + Index * mBlockSize, > > > > > > + (Index =3D=3D (mBlockNum - 1)) ? mLastBlo= ckSize : mBlockSize, > > > > > > + mBlockResultSize, > > > > > > + NULL, > > > > > > + 0, > > > > > > + NULL, > > > > > > + 0, > > > > > > + mBlockHashResult + Index * mBlockResultSi= ze > > > > > > + ); > > > > > > + if (ReturnValue) { > > > > > > + mBlockIsCompleted[Index] =3D TRUE; > > > > > > + } > > > > > > + > > > > > > + ReleaseSpinLock (&mSpinLockList[Index]); > > > > > > + break; > > > > > > + } > > > > > > + > > > > > > + ReleaseSpinLock (&mSpinLockList[Index]); > > > > > > + } else { > > > > > > + AllCompleted =3D FALSE; > > > > > > + break; > > > > > > + } > > > > > > + } > > > > > > + } while (!AllCompleted); > > > > > > + > > > > > > + // > > > > > > + // Fill LeftEncode(n). > > > > > > + // > > > > > > + Offset =3D EncSizeB + mBlockNum * mBlockResultSize; > > > > > > + CopyMem (CombinedInput + Offset, EncBufN, EncSizeN); > > > > > > + > > > > > > + // > > > > > > + // Fill LeftEncode(L). > > > > > > + // > > > > > > + Offset +=3D EncSizeN; > > > > > > + CopyMem (CombinedInput + Offset, EncBufL, EncSizeL); > > > > > > + > > > > > > + ReturnValue =3D CShake256HashAll ( > > > > > > + CombinedInput, > > > > > > + CombinedInputSize, > > > > > > + OutputByteLen, > > > > > > + PARALLELHASH_CUSTOMIZATION, > > > > > > + AsciiStrLen (PARALLELHASH_CUSTOMIZATION), > > > > > > + Customization, > > > > > > + CustomByteLen, > > > > > > + Output > > > > > > + ); > > > > > > + > > > > > > +Exit: > > > > > > + ZeroMem (CombinedInput, CombinedInputSize); > > > > > > + > > > > > > + if (CombinedInput !=3D NULL) { > > > > > > + FreePool (CombinedInput); > > > > > > + } > > > > > > + > > > > > > + if (mSpinLockList !=3D NULL) { > > > > > > + FreePool ((VOID *)mSpinLockList); > > > > > > + } > > > > > > + > > > > > > + if (mBlockIsCompleted !=3D NULL) { > > > > > > + FreePool (mBlockIsCompleted); > > > > > > + } > > > > > > + > > > > > > + return ReturnValue; > > > > > > +} > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHashNul= l.c > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHashNull.c > > > new file mode 100644 > > > index 000000000000..2bf89594def5 > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHashNull.c > > > @@ -0,0 +1,40 @@ > > > +/** @file > > > > > > + ParallelHash Implementation which does not provide real capabiliti= es. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "InternalCryptLib.h" > > > > > > + > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +ParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ) > > > > > > +{ > > > > > > + ASSERT (FALSE); > > > > > > + return FALSE; > > > > > > +} > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c > > > new file mode 100644 > > > index 000000000000..6abafc3c00e6 > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c > > > @@ -0,0 +1,166 @@ > > > +/** @file > > > > > > + SHA3 realted functions from OpenSSL. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. > > > > > > +Licensed under the OpenSSL license (the "License"). You may not use > > > > > > +this file except in compliance with the License. You can obtain a c= opy > > > > > > +in the file LICENSE in the source distribution or at > > > > > > +https://www.openssl.org/source/license.html > > > > > > +**/ > > > > > > + > > > > > > +#include "CryptParallelHash.h" > > > > > > + > > > > > > +/** > > > > > > + Keccak initial fuction. > > > > > > + > > > > > > + Set up state with specified capacity. > > > > > > + > > > > > > + @param[out] Context Pointer to the context being initial= ized. > > > > > > + @param[in] Pad Delimited Suffix. > > > > > > + @param[in] BlockSize Size of context block. > > > > > > + @param[in] MessageDigestLen Size of message digest in bytes. > > > > > > + > > > > > > + @retval 1 Initialize successfully. > > > > > > + @retval 0 Fail to initialize. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +KeccakInit ( > > > > > > + OUT Keccak1600_Ctx *Context, > > > > > > + IN UINT8 Pad, > > > > > > + IN UINTN BlockSize, > > > > > > + IN UINTN MessageDigestLen > > > > > > + ) > > > > > > +{ > > > > > > + if (BlockSize <=3D sizeof (Context->buf)) { > > > > > > + memset (Context->A, 0, sizeof (Context->A)); > > > > > > + > > > > > > + Context->num =3D 0; > > > > > > + Context->block_size =3D BlockSize; > > > > > > + Context->md_size =3D MessageDigestLen; > > > > > > + Context->pad =3D Pad; > > > > > > + > > > > > > + return 1; > > > > > > + } > > > > > > + > > > > > > + return 0; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Sha3 update fuction. > > > > > > + > > > > > > + This function performs Sha3 digest on a data buffer of the specifi= ed size. > > > > > > + It can be called multiple times to compute the digest of long or > > discontinuous > > > data streams. > > > > > > + > > > > > > + @param[in,out] Context Pointer to the Keccak context. > > > > > > + @param[in] Data Pointer to the buffer containing the data= to be > > hashed. > > > > > > + @param[in] DataSize Size of Data buffer in bytes. > > > > > > + > > > > > > + @retval 1 Update successfully. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +Sha3Update ( > > > > > > + IN OUT Keccak1600_Ctx *Context, > > > > > > + IN const VOID *Data, > > > > > > + IN UINTN DataSize > > > > > > + ) > > > > > > +{ > > > > > > + const UINT8 *DataCopy; > > > > > > + UINTN BlockSize; > > > > > > + UINTN Num; > > > > > > + UINTN Rem; > > > > > > + > > > > > > + DataCopy =3D Data; > > > > > > + BlockSize =3D (UINT8)(Context->block_size); > > > > > > + > > > > > > + if (DataSize =3D=3D 0) { > > > > > > + return 1; > > > > > > + } > > > > > > + > > > > > > + if ((Num =3D Context->num) !=3D 0) { > > > > > > + // > > > > > > + // process intermediate buffer > > > > > > + // > > > > > > + Rem =3D BlockSize - Num; > > > > > > + > > > > > > + if (DataSize < Rem) { > > > > > > + memcpy (Context->buf + Num, DataCopy, DataSize); > > > > > > + Context->num +=3D DataSize; > > > > > > + return 1; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // We have enough data to fill or overflow the intermediate > > > > > > + // buffer. So we append |Rem| bytes and process the block, > > > > > > + // leaving the rest for later processing. > > > > > > + // > > > > > > + memcpy (Context->buf + Num, DataCopy, Rem); > > > > > > + DataCopy +=3D Rem; > > > > > > + DataSize -=3D Rem; > > > > > > + (void)SHA3_absorb (Context->A, Context->buf, BlockSize, BlockSiz= e); > > > > > > + Context->num =3D 0; > > > > > > + // Context->buf is processed, Context->num is guaranteed to be z= ero. > > > > > > + } > > > > > > + > > > > > > + if (DataSize >=3D BlockSize) { > > > > > > + Rem =3D SHA3_absorb (Context->A, DataCopy, DataSize, BlockSize); > > > > > > + } else { > > > > > > + Rem =3D DataSize; > > > > > > + } > > > > > > + > > > > > > + if (Rem > 0) { > > > > > > + memcpy (Context->buf, DataCopy + DataSize - Rem, Rem); > > > > > > + Context->num =3D Rem; > > > > > > + } > > > > > > + > > > > > > + return 1; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Completes computation of Sha3 message digest. > > > > > > + > > > > > > + This function completes sha3 hash computation and retrieves the di= gest > > value > > > into > > > > > > + the specified memory. After this function has been called, the kec= cak > > context > > > cannot > > > > > > + be used again. > > > > > > + > > > > > > + @param[in, out] Context Pointer to the keccak context. > > > > > > + @param[out] MessageDigest Pointer to a buffer that receives = the > > > message digest. > > > > > > + > > > > > > + @retval 1 Meaasge digest computation succeeded. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +Sha3Final ( > > > > > > + IN OUT Keccak1600_Ctx *Context, > > > > > > + OUT UINT8 *MessageDigest > > > > > > + ) > > > > > > +{ > > > > > > + UINTN BlockSize; > > > > > > + UINTN Num; > > > > > > + > > > > > > + BlockSize =3D Context->block_size; > > > > > > + Num =3D Context->num; > > > > > > + > > > > > > + if (Context->md_size =3D=3D 0) { > > > > > > + return 1; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // Pad the data with 10*1. Note that |Num| can be |BlockSize - 1| > > > > > > + // in which case both byte operations below are performed on > > > > > > + // same byte. > > > > > > + // > > > > > > + memset (Context->buf + Num, 0, BlockSize - Num); > > > > > > + Context->buf[Num] =3D Context->pad; > > > > > > + Context->buf[BlockSize - 1] |=3D 0x80; > > > > > > + > > > > > > + (void)SHA3_absorb (Context->A, Context->buf, BlockSize, BlockSize)= ; > > > > > > + > > > > > > + SHA3_squeeze (Context->A, MessageDigest, Context->md_size, BlockSi= ze); > > > > > > + > > > > > > + return 1; > > > > > > +} > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c > > > new file mode 100644 > > > index 000000000000..12c46cfbcd59 > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c > > > @@ -0,0 +1,107 @@ > > > +/** @file > > > > > > + Encode realted functions from Xkcp. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +Copyright 2022 The eXtended Keccak Code Package (XKCP) > > > > > > +https://github.com/XKCP/XKCP > > > > > > +Keccak, designed by Guido Bertoni, Joan Daemen, Michael Peeters and > Gilles > > > Van Assche. > > > > > > +Implementation by the designers, hereby denoted as "the implementer"= . > > > > > > +For more information, feedback or questions, please refer to the Kec= cak > > Team > > > website: > > > > > > +https://keccak.team/ > > > > > > +To the extent possible under law, the implementer has waived all cop= yright > > > > > > +and related or neighboring rights to the source code in this file. > > > > > > +http://creativecommons.org/publicdomain/zero/1.0/ > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "CryptParallelHash.h" > > > > > > + > > > > > > +/** > > > > > > + Encode function from XKCP. > > > > > > + > > > > > > + Encodes the input as a byte string in a way that can be unambiguou= sly > > parsed > > > > > > + from the beginning of the string by inserting the length of the by= te string > > > > > > + before the byte string representation of input. > > > > > > + > > > > > > + @param[out] EncBuf Result of left encode. > > > > > > + @param[in] Value Input of left encode. > > > > > > + > > > > > > + @retval EncLen Size of encode result in bytes. > > > > > > +**/ > > > > > > +UINTN > > > > > > +EFIAPI > > > > > > +LeftEncode ( > > > > > > + OUT UINT8 *EncBuf, > > > > > > + IN UINTN Value > > > > > > + ) > > > > > > +{ > > > > > > + UINT32 BlockNum; > > > > > > + UINT32 EncLen; > > > > > > + UINT32 Index; > > > > > > + UINTN ValueCopy; > > > > > > + > > > > > > + for ( ValueCopy =3D Value, BlockNum =3D 0; ValueCopy && (BlockNum = < sizeof > > > (UINTN)); ++BlockNum, ValueCopy >>=3D 8 ) { > > > > > > + // > > > > > > + // Empty > > > > > > + // > > > > > > + } > > > > > > + > > > > > > + if (BlockNum =3D=3D 0) { > > > > > > + BlockNum =3D 1; > > > > > > + } > > > > > > + > > > > > > + for (Index =3D 1; Index <=3D BlockNum; ++Index) { > > > > > > + EncBuf[Index] =3D (UINT8)(Value >> (8 * (BlockNum - Index))); > > > > > > + } > > > > > > + > > > > > > + EncBuf[0] =3D (UINT8)BlockNum; > > > > > > + EncLen =3D BlockNum + 1; > > > > > > + > > > > > > + return EncLen; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Encode function from XKCP. > > > > > > + > > > > > > + Encodes the input as a byte string in a way that can be unambiguou= sly > > parsed > > > > > > + from the end of the string by inserting the length of the byte str= ing after > > > > > > + the byte string representation of input. > > > > > > + > > > > > > + @param[out] EncBuf Result of right encode. > > > > > > + @param[in] Value Input of right encode. > > > > > > + > > > > > > + @retval EncLen Size of encode result in bytes. > > > > > > +**/ > > > > > > +UINTN > > > > > > +EFIAPI > > > > > > +RightEncode ( > > > > > > + OUT UINT8 *EncBuf, > > > > > > + IN UINTN Value > > > > > > + ) > > > > > > +{ > > > > > > + UINT32 BlockNum; > > > > > > + UINT32 EncLen; > > > > > > + UINT32 Index; > > > > > > + UINTN ValueCopy; > > > > > > + > > > > > > + for (ValueCopy =3D Value, BlockNum =3D 0; ValueCopy && (BlockNum <= sizeof > > > (UINTN)); ++BlockNum, ValueCopy >>=3D 8) { > > > > > > + // > > > > > > + // Empty > > > > > > + // > > > > > > + } > > > > > > + > > > > > > + if (BlockNum =3D=3D 0) { > > > > > > + BlockNum =3D 1; > > > > > > + } > > > > > > + > > > > > > + for (Index =3D 1; Index <=3D BlockNum; ++Index) { > > > > > > + EncBuf[Index-1] =3D (UINT8)(Value >> (8 * (BlockNum-Index))); > > > > > > + } > > > > > > + > > > > > > + EncBuf[BlockNum] =3D (UINT8)BlockNum; > > > > > > + EncLen =3D BlockNum + 1; > > > > > > + > > > > > > + return EncLen; > > > > > > +} > > > > > > diff --git > a/CryptoPkg/Library/BaseCryptLibNull/Hash/CryptParallelHashNull.c > > > b/CryptoPkg/Library/BaseCryptLibNull/Hash/CryptParallelHashNull.c > > > new file mode 100644 > > > index 000000000000..2bf89594def5 > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLibNull/Hash/CryptParallelHashNull.c > > > @@ -0,0 +1,40 @@ > > > +/** @file > > > > > > + ParallelHash Implementation which does not provide real capabiliti= es. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "InternalCryptLib.h" > > > > > > + > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +ParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ) > > > > > > +{ > > > > > > + ASSERT (FALSE); > > > > > > + return FALSE; > > > > > > +} > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c > > > b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c > > > index c8df259ea963..8ee1b53cf957 100644 > > > --- a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c > > > +++ b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c > > > @@ -3,7 +3,7 @@ > > > Protocol/PPI. > > > > > > > > > > > > Copyright (C) Microsoft Corporation. All rights reserved. > > > > > > - Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.=
> > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.=
> > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > **/ > > > > > > @@ -870,6 +870,38 @@ Sha512HashAll ( > > > CALL_CRYPTO_SERVICE (Sha512HashAll, (Data, DataSize, HashValue), > FALSE); > > > > > > } > > > > > > > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval TRUE ParallelHash256 digest computation succeeded. > > > > > > + @retval FALSE ParallelHash256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +ParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ) > > > > > > +{ > > > > > > + CALL_CRYPTO_SERVICE (ParallelHash256HashAll, (Input, InputByteLen, > > > BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALS= E); > > > > > > +} > > > > > > + > > > > > > /** > > > > > > Retrieves the size, in bytes, of the context buffer required for S= M3 hash > > > operations. > > > > > > > > > > > > diff --git > a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.c > > > b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.c > > > new file mode 100644 > > > index 000000000000..fb57e91a9f16 > > > --- /dev/null > > > +++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.= c > > > @@ -0,0 +1,145 @@ > > > +/** @file > > > > > > + Application for Parallelhash Function Validation. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +**/ > > > > > > + > > > > > > +#include "TestBaseCryptLib.h" > > > > > > + > > > > > > +// > > > > > > +// Parallelhash Test Sample common parameters. > > > > > > +// > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINTN OutputByteLen =3D 64; > > > > > > + > > > > > > +// > > > > > > +// Parallelhash Test Sample #1 from NIST Special Publication 800-185= . > > > > > > +// > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 InputSample1[] =3D { > > > > > > + // input data of sample1. > > > > > > + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, = 0x13, > > 0x14, > > > 0x15, 0x16, 0x17, > > > > > > + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 > > > > > > +}; > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN InputSample1ByteLen =3D > > 24; > > > // Length of sample1 input data in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST VOID > > *CustomizationSample1 > > > =3D ""; // Customization string (S) of sample1. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN CustomSample1ByteLen > =3D > > 0; > > > // Customization string length of sample1 in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN BlockSizeSample1 =3D= 8; > > > // Block size of sample1. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 > > ExpectOutputSample1[] > > > =3D { > > > > > > + // Expected output data of sample1. > > > > > > + 0xbc, 0x1e, 0xf1, 0x24, 0xda, 0x34, 0x49, 0x5e, 0x94, 0x8e, 0xad, = 0x20, > > 0x7d, > > > 0xd9, 0x84, 0x22, > > > > > > + 0x35, 0xda, 0x43, 0x2d, 0x2b, 0xbc, 0x54, 0xb4, 0xc1, 0x10, 0xe6, = 0x4c, > > 0x45, > > > 0x11, 0x05, 0x53, > > > > > > + 0x1b, 0x7f, 0x2a, 0x3e, 0x0c, 0xe0, 0x55, 0xc0, 0x28, 0x05, 0xe7, = 0xc2, > 0xde, > > > 0x1f, 0xb7, 0x46, > > > > > > + 0xaf, 0x97, 0xa1, 0xd0, 0x01, 0xf4, 0x3b, 0x82, 0x4e, 0x31, 0xb8, = 0x76, > 0x12, > > > 0x41, 0x04, 0x29 > > > > > > +}; > > > > > > + > > > > > > +// > > > > > > +// Parallelhash Test Sample #2 from NIST Special Publication 800-185= . > > > > > > +// > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 *InputSample2 =3D > > > InputSample1; // Input of sample2 is same as sample1. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN InputSample2ByteLen =3D > > 24; > > > // Length of sample2 input data in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST VOID > > *CustomizationSample2 > > > =3D "Parallel Data"; // Customization string (S) of sample= 2. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN CustomSample2ByteLen > =3D > > > 13; // Customization string length of sample2= in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN BlockSizeSample2 =3D= 8; > > > // Block size of sample2. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 > > ExpectOutputSample2[] > > > =3D { > > > > > > + // Expected output data of sample2. > > > > > > + 0xcd, 0xf1, 0x52, 0x89, 0xb5, 0x4f, 0x62, 0x12, 0xb4, 0xbc, 0x27, = 0x05, > 0x28, > > > 0xb4, 0x95, 0x26, > > > > > > + 0x00, 0x6d, 0xd9, 0xb5, 0x4e, 0x2b, 0x6a, 0xdd, 0x1e, 0xf6, 0x90, = 0x0d, > > 0xda, > > > 0x39, 0x63, 0xbb, > > > > > > + 0x33, 0xa7, 0x24, 0x91, 0xf2, 0x36, 0x96, 0x9c, 0xa8, 0xaf, 0xae, = 0xa2, > 0x9c, > > > 0x68, 0x2d, 0x47, > > > > > > + 0xa3, 0x93, 0xc0, 0x65, 0xb3, 0x8e, 0x29, 0xfa, 0xe6, 0x51, 0xa2, = 0x09, > 0x1c, > > > 0x83, 0x31, 0x10 > > > > > > +}; > > > > > > + > > > > > > +// > > > > > > +// Parallelhash Test Sample #3 from NIST Special Publication 800-185= . > > > > > > +// > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 InputSample3[] =3D { > > > > > > + // input data of sample3. > > > > > > + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, = 0x0b, > > 0x10, > > > 0x11, 0x12, 0x13, > > > > > > + 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x20, 0x21, 0x22, = 0x23, > > 0x24, > > > 0x25, 0x26, 0x27, > > > > > > + 0x28, 0x29, 0x2a, 0x2b, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, = 0x37, > > 0x38, > > > 0x39, 0x3a, 0x3b, > > > > > > + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, = 0x4b, > > 0x50, > > > 0x51, 0x52, 0x53, > > > > > > + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b > > > > > > +}; > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN InputSample3ByteLen =3D > > 72; > > > // Length of sample3 input data in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST VOID > > *CustomizationSample3 > > > =3D "Parallel Data"; // Customization string (S) of sample= 3. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN CustomSample3ByteLen > =3D > > > 13; // Customization string length of sample3= in bytes. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN BlockSizeSample3 =3D > 12; > > > // Block size of sample3. > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 > > ExpectOutputSample3[] > > > =3D { > > > > > > + // Expected output data of sample3. > > > > > > + 0x69, 0xd0, 0xfc, 0xb7, 0x64, 0xea, 0x05, 0x5d, 0xd0, 0x93, 0x34, = 0xbc, > 0x60, > > > 0x21, 0xcb, 0x7e, > > > > > > + 0x4b, 0x61, 0x34, 0x8d, 0xff, 0x37, 0x5d, 0xa2, 0x62, 0x67, 0x1c, = 0xde, > 0xc3, > > > 0xef, 0xfa, 0x8d, > > > > > > + 0x1b, 0x45, 0x68, 0xa6, 0xcc, 0xe1, 0x6b, 0x1c, 0xad, 0x94, 0x6d, = 0xdd, > > 0xe2, > > > 0x7f, 0x6c, 0xe2, > > > > > > + 0xb8, 0xde, 0xe4, 0xcd, 0x1b, 0x24, 0x85, 0x1e, 0xbf, 0x00, 0xeb, = 0x90, > > 0xd4, > > > 0x38, 0x13, 0xe9 > > > > > > +}; > > > > > > + > > > > > > +UNIT_TEST_STATUS > > > > > > +EFIAPI > > > > > > +TestVerifyParallelHash256HashAll ( > > > > > > + IN UNIT_TEST_CONTEXT Context > > > > > > + ) > > > > > > +{ > > > > > > + BOOLEAN Status; > > > > > > + UINT8 Output[64]; > > > > > > + > > > > > > + // > > > > > > + // Test #1 using sample1. > > > > > > + // > > > > > > + Status =3D ParallelHash256HashAll ( > > > > > > + InputSample1, > > > > > > + InputSample1ByteLen, > > > > > > + BlockSizeSample1, > > > > > > + Output, > > > > > > + OutputByteLen, > > > > > > + CustomizationSample1, > > > > > > + CustomSample1ByteLen > > > > > > + ); > > > > > > + UT_ASSERT_TRUE (Status); > > > > > > + > > > > > > + // Check the output with the expected output. > > > > > > + UT_ASSERT_MEM_EQUAL (Output, ExpectOutputSample1, > OutputByteLen); > > > > > > + > > > > > > + // > > > > > > + // Test #2 using sample2. > > > > > > + // > > > > > > + Status =3D ParallelHash256HashAll ( > > > > > > + InputSample2, > > > > > > + InputSample2ByteLen, > > > > > > + BlockSizeSample2, > > > > > > + Output, > > > > > > + OutputByteLen, > > > > > > + CustomizationSample2, > > > > > > + CustomSample2ByteLen > > > > > > + ); > > > > > > + UT_ASSERT_TRUE (Status); > > > > > > + > > > > > > + // Check the output with the expected output. > > > > > > + UT_ASSERT_MEM_EQUAL (Output, ExpectOutputSample2, > OutputByteLen); > > > > > > + > > > > > > + // > > > > > > + // Test #3 using sample3. > > > > > > + // > > > > > > + Status =3D ParallelHash256HashAll ( > > > > > > + InputSample3, > > > > > > + InputSample3ByteLen, > > > > > > + BlockSizeSample3, > > > > > > + Output, > > > > > > + OutputByteLen, > > > > > > + CustomizationSample3, > > > > > > + CustomSample3ByteLen > > > > > > + ); > > > > > > + UT_ASSERT_TRUE (Status); > > > > > > + > > > > > > + // Check the output with the expected output. > > > > > > + UT_ASSERT_MEM_EQUAL (Output, ExpectOutputSample3, > OutputByteLen); > > > > > > + > > > > > > + return EFI_SUCCESS; > > > > > > +} > > > > > > + > > > > > > +TEST_DESC mParallelhashTest[] =3D { > > > > > > + // > > > > > > + // -----Description------------------------------Class------------= ---------- > Function-- > > -- > > > -------------Pre---Post--Context > > > > > > + // > > > > > > + { "TestVerifyParallelHash256HashAll()", > > > "CryptoPkg.BaseCryptLib.ParallelHash256HashAll", > > > TestVerifyParallelHash256HashAll, NULL, NULL, NULL }, > > > > > > +}; > > > > > > + > > > > > > +UINTN mParallelhashTestNum =3D ARRAY_SIZE (mParallelhashTest); > > > > > > diff --git a/CryptoPkg/CryptoPkg.ci.yaml b/CryptoPkg/CryptoPkg.ci.yam= l > > > index eeb388ae71c5..e21fafac1efe 100644 > > > --- a/CryptoPkg/CryptoPkg.ci.yaml > > > +++ b/CryptoPkg/CryptoPkg.ci.yaml > > > @@ -2,7 +2,7 @@ > > > # CI configuration for CryptoPkg > > > > > > # > > > > > > # Copyright (c) Microsoft Corporation > > > > > > -# Copyright (c) 2020, Intel Corporation. All rights reserved.
> > > > > > +# Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.=
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > ## > > > > > > { > > > > > > @@ -34,6 +34,8 @@ > > > "Library/OpensslLib/rand_pool.c", > > > > > > # This has OpenSSL interfaces that aren't UEFI spec comp= liant > > > > > > "Library/Include/CrtLibSupport.h", > > > > > > + # This has OpenSSL interfaces that aren't UEFI spec comp= liant > > > > > > + "Library/BaseCryptLib/Hash/CryptParallelHash.h", > > > > > > # These directories contain auto-generated OpenSSL conte= nt > > > > > > "Library/OpensslLib", > > > > > > "Library/IntrinsicLib", > > > > > > diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h > > > b/CryptoPkg/Include/Library/BaseCryptLib.h > > > index f4bc7c0d73d9..7d1499350a49 100644 > > > --- a/CryptoPkg/Include/Library/BaseCryptLib.h > > > +++ b/CryptoPkg/Include/Library/BaseCryptLib.h > > > @@ -4,7 +4,7 @@ > > > primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI= security > > > > > > functionality enabling. > > > > > > > > > > > > -Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved. > > > > > > +Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved. > > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > **/ > > > > > > @@ -753,6 +753,35 @@ Sha512HashAll ( > > > OUT UINT8 *HashValue > > > > > > ); > > > > > > > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval TRUE ParallelHash256 digest computation succeeded. > > > > > > + @retval FALSE ParallelHash256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +ParallelHash256HashAll ( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ); > > > > > > + > > > > > > /** > > > > > > Retrieves the size, in bytes, of the context buffer required for S= M3 hash > > > operations. > > > > > > > > > > > > diff --git a/CryptoPkg/Include/Pcd/PcdCryptoServiceFamilyEnable.h > > > b/CryptoPkg/Include/Pcd/PcdCryptoServiceFamilyEnable.h > > > index 5186a54759ae..77330961352e 100644 > > > --- a/CryptoPkg/Include/Pcd/PcdCryptoServiceFamilyEnable.h > > > +++ b/CryptoPkg/Include/Pcd/PcdCryptoServiceFamilyEnable.h > > > @@ -2,7 +2,7 @@ > > > Defines the PCD_CRYPTO_SERVICE_FAMILY_ENABLE structure associated > > with > > > > > > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable. > > > > > > > > > > > > - Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.=
> > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.=
> > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > **/ > > > > > > @@ -288,6 +288,12 @@ typedef struct { > > > } Services; > > > > > > UINT32 Family; > > > > > > } TlsGet; > > > > > > + union { > > > > > > + struct { > > > > > > + UINT8 HashAll : 1; > > > > > > + } Services; > > > > > > + UINT32 Family; > > > > > > + } ParallelHash; > > > > > > } PCD_CRYPTO_SERVICE_FAMILY_ENABLE; > > > > > > > > > > > > #endif > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf > > > b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf > > > index 49703fa4c963..15cf3dab105c 100644 > > > --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf > > > +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf > > > @@ -6,7 +6,7 @@ > > > # This external input must be validated carefully to avoid security= issues > such > > as > > > > > > # buffer overflow or integer overflow. > > > > > > # > > > > > > -# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved= .
> > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved= .
> > > > > > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. Al= l rights > > > reserved.
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > @@ -34,6 +34,7 @@ > > > Hash/CryptSha256.c > > > > > > Hash/CryptSha512.c > > > > > > Hash/CryptSm3.c > > > > > > + Hash/CryptParallelHashNull.c > > > > > > Hmac/CryptHmacSha256.c > > > > > > Kdf/CryptHkdf.c > > > > > > Cipher/CryptAes.c > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.h > > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.h > > > new file mode 100644 > > > index 000000000000..fe08d4928e8d > > > --- /dev/null > > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.h > > > @@ -0,0 +1,201 @@ > > > +/** @file > > > > > > + ParallelHash related function and type declaration. > > > > > > + > > > > > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > + > > > > > > +Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. > > > > > > +Licensed under the OpenSSL license (the "License"). You may not use > > > > > > +this file except in compliance with the License. You can obtain a c= opy > > > > > > +in the file LICENSE in the source distribution or at > > > > > > +https://www.openssl.org/source/license.html > > > > > > + > > > > > > +Copyright 2022 The eXtended Keccak Code Package (XKCP) > > > > > > +https://github.com/XKCP/XKCP > > > > > > +Keccak, designed by Guido Bertoni, Joan Daemen, Michael Peeters and > Gilles > > > Van Assche. > > > > > > +Implementation by the designers, hereby denoted as "the implementer"= . > > > > > > +For more information, feedback or questions, please refer to the Kec= cak > > Team > > > website: > > > > > > +https://keccak.team/ > > > > > > +To the extent possible under law, the implementer has waived all cop= yright > > > > > > +and related or neighboring rights to the source code in this file. > > > > > > +http://creativecommons.org/publicdomain/zero/1.0/ > > > > > > +**/ > > > > > > + > > > > > > +#include "InternalCryptLib.h" > > > > > > + > > > > > > +#define KECCAK1600_WIDTH 1600 > > > > > > + > > > > > > +// > > > > > > +// This struct referring to m_sha3.c from opessl and modified its ty= pe name. > > > > > > +// > > > > > > +typedef struct { > > > > > > + uint64_t A[5][5]; > > > > > > + size_t block_size; /* cached ctx->digest->block_size */ > > > > > > + size_t md_size; /* output length, variable in XOF */ > > > > > > + size_t num; /* used bytes in below buffer */ > > > > > > + unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; > > > > > > + unsigned char pad; > > > > > > +} Keccak1600_Ctx; > > > > > > + > > > > > > +/** > > > > > > + SHA3_absorb can be called multiple times, but at each invocation > > > > > > + largest multiple of |r| out of |len| bytes are processed. Then > > > > > > + remaining amount of bytes is returned. This is done to spare calle= r > > > > > > + trouble of calculating the largest multiple of |r|. |r| can be vie= wed > > > > > > + as blocksize. It is commonly (1600 - 256*n)/8, e.g. 168, 136, 104, > > > > > > + 72, but can also be (1600 - 448)/8 =3D 144. All this means that me= ssage > > > > > > + padding and intermediate sub-block buffering, byte- or bitwise, is > > > > > > + caller's responsibility. > > > > > > +**/ > > > > > > +size_t > > > > > > +SHA3_absorb ( > > > > > > + uint64_t A[5][5], > > > > > > + const unsigned char *inp, > > > > > > + size_t len, > > > > > > + size_t r > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + SHA3_squeeze is called once at the end to generate |out| hash valu= e > > > > > > + of |len| bytes. > > > > > > +**/ > > > > > > +void > > > > > > +SHA3_squeeze ( > > > > > > + uint64_t A[5][5], > > > > > > + unsigned char *out, > > > > > > + size_t len, > > > > > > + size_t r > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Encode function from XKCP. > > > > > > + > > > > > > + Encodes the input as a byte string in a way that can be unambiguou= sly > > parsed > > > > > > + from the beginning of the string by inserting the length of the by= te string > > > > > > + before the byte string representation of input. > > > > > > + > > > > > > + @param[out] EncBuf Result of left encode. > > > > > > + @param[in] Value Input of left encode. > > > > > > + > > > > > > + @retval EncLen Size of encode result in bytes. > > > > > > +**/ > > > > > > +UINTN > > > > > > +EFIAPI > > > > > > +LeftEncode ( > > > > > > + OUT UINT8 *EncBuf, > > > > > > + IN UINTN Value > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Encode function from XKCP. > > > > > > + > > > > > > + Encodes the input as a byte string in a way that can be unambiguou= sly > > parsed > > > > > > + from the end of the string by inserting the length of the byte str= ing after > > > > > > + the byte string representation of input. > > > > > > + > > > > > > + @param[out] EncBuf Result of right encode. > > > > > > + @param[in] Value Input of right encode. > > > > > > + > > > > > > + @retval EncLen Size of encode result in bytes. > > > > > > +**/ > > > > > > +UINTN > > > > > > +EFIAPI > > > > > > +RightEncode ( > > > > > > + OUT UINT8 *EncBuf, > > > > > > + IN UINTN Value > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Keccak initial fuction. > > > > > > + > > > > > > + Set up state with specified capacity. > > > > > > + > > > > > > + @param[out] Context Pointer to the context being initial= ized. > > > > > > + @param[in] Pad Delimited Suffix. > > > > > > + @param[in] BlockSize Size of context block. > > > > > > + @param[in] MessageDigestLen Size of message digest in bytes. > > > > > > + > > > > > > + @retval 1 Initialize successfully. > > > > > > + @retval 0 Fail to initialize. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +KeccakInit ( > > > > > > + OUT Keccak1600_Ctx *Context, > > > > > > + IN UINT8 Pad, > > > > > > + IN UINTN BlockSize, > > > > > > + IN UINTN MessageDigstLen > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Sha3 update fuction. > > > > > > + > > > > > > + This function performs Sha3 digest on a data buffer of the specifi= ed size. > > > > > > + It can be called multiple times to compute the digest of long or > > discontinuous > > > data streams. > > > > > > + > > > > > > + @param[in,out] Context Pointer to the Keccak context. > > > > > > + @param[in] Data Pointer to the buffer containing the data= to be > > hashed. > > > > > > + @param[in] DataSize Size of Data buffer in bytes. > > > > > > + > > > > > > + @retval 1 Update successfully. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +Sha3Update ( > > > > > > + IN OUT Keccak1600_Ctx *Context, > > > > > > + IN const VOID *Data, > > > > > > + IN UINTN DataSize > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Completes computation of Sha3 message digest. > > > > > > + > > > > > > + This function completes sha3 hash computation and retrieves the di= gest > > value > > > into > > > > > > + the specified memory. After this function has been called, the kec= cak > > context > > > cannot > > > > > > + be used again. > > > > > > + > > > > > > + @param[in, out] Context Pointer to the keccak context. > > > > > > + @param[out] MessageDigest Pointer to a buffer that receives = the > > > message digest. > > > > > > + > > > > > > + @retval 1 Meaasge digest computation succeeded. > > > > > > +**/ > > > > > > +UINT8 > > > > > > +EFIAPI > > > > > > +Sha3Final ( > > > > > > + IN OUT Keccak1600_Ctx *Context, > > > > > > + OUT UINT8 *MessageDigest > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Computes the CSHAKE-256 message digest of a input data buffer. > > > > > > + > > > > > > + This function performs the CSHAKE-256 message digest of a given da= ta > > buffer, > > > and places > > > > > > + the digest value into the specified memory. > > > > > > + > > > > > > + @param[in] Data Pointer to the buffer containing t= he data to be > > > hashed. > > > > > > + @param[in] DataSize Size of Data buffer in bytes. > > > > > > + @param[in] OutputLen Size of output in bytes. > > > > > > + @param[in] Name Pointer to the function name strin= g. > > > > > > + @param[in] NameLen Size of the function name in bytes= . > > > > > > + @param[in] Customization Pointer to the customization strin= g. > > > > > > + @param[in] CustomizationLen Size of the customization string i= n bytes. > > > > > > + @param[out] HashValue Pointer to a buffer that receives = the > CSHAKE- > > > 256 digest > > > > > > + value. > > > > > > + > > > > > > + @retval TRUE CSHAKE-256 digest computation succeeded. > > > > > > + @retval FALSE CSHAKE-256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +BOOLEAN > > > > > > +EFIAPI > > > > > > +CShake256HashAll ( > > > > > > + IN CONST VOID *Data, > > > > > > + IN UINTN DataSize, > > > > > > + IN UINTN OutputLen, > > > > > > + IN CONST VOID *Name, > > > > > > + IN UINTN NameLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomizationLen, > > > > > > + OUT UINT8 *HashValue > > > > > > + ); > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf > > > b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf > > > index 0cab5f3ce36c..bf1563b06407 100644 > > > --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf > > > +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf > > > @@ -13,7 +13,7 @@ > > > # PEM handler functions, and pseudorandom number generator function= s > are > > > not > > > > > > # supported in this instance. > > > > > > # > > > > > > -# Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved= .
> > > > > > +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved= .
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > ## > > > > > > @@ -40,6 +40,7 @@ > > > Hash/CryptSha256.c > > > > > > Hash/CryptSm3.c > > > > > > Hash/CryptSha512.c > > > > > > + Hash/CryptParallelHashNull.c > > > > > > Hmac/CryptHmacSha256.c > > > > > > Kdf/CryptHkdf.c > > > > > > Cipher/CryptAesNull.c > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf > > > b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf > > > index fdbb6edfd23e..6742da0be4fe 100644 > > > --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf > > > +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf > > > @@ -11,7 +11,7 @@ > > > # functions, PKCS#7 SignedData sign functions, Diffie-Hellman funct= ions, > and > > > > > > # authenticode signature verification functions are not supported i= n this > > > instance. > > > > > > # > > > > > > -# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved= .
> > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved= .
> > > > > > # Copyright (c) 2021, Hewlett Packard Enterprise Development LP. Al= l rights > > > reserved.
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > @@ -40,6 +40,7 @@ > > > Hash/CryptSha256.c > > > > > > Hash/CryptSm3.c > > > > > > Hash/CryptSha512.c > > > > > > + Hash/CryptParallelHashNull.c > > > > > > Hmac/CryptHmacSha256.c > > > > > > Kdf/CryptHkdf.c > > > > > > Cipher/CryptAes.c > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf > > > b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf > > > index e6470d7a2127..8f39517f78b7 100644 > > > --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf > > > +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf > > > @@ -10,7 +10,7 @@ > > > # RSA external functions, PKCS#7 SignedData sign functions, Diffie-= Hellman > > > functions, and > > > > > > # authenticode signature verification functions are not supported i= n this > > > instance. > > > > > > # > > > > > > -# Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved= .
> > > > > > +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved= .
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > ## > > > > > > @@ -38,6 +38,10 @@ > > > Hash/CryptSha256.c > > > > > > Hash/CryptSm3.c > > > > > > Hash/CryptSha512.c > > > > > > + Hash/CryptSha3.c > > > > > > + Hash/CryptXkcp.c > > > > > > + Hash/CryptCShake256.c > > > > > > + Hash/CryptParallelHash.c > > > > > > Hmac/CryptHmacSha256.c > > > > > > Kdf/CryptHkdfNull.c > > > > > > Cipher/CryptAes.c > > > > > > @@ -85,6 +89,8 @@ > > > OpensslLib > > > > > > IntrinsicLib > > > > > > PrintLib > > > > > > + MmServicesTableLib > > > > > > + SynchronizationLib > > > > > > > > > > > > # > > > > > > # Remove these [BuildOptions] after this library is cleaned up > > > > > > diff --git a/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf > > > b/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf > > > index faf959827b90..63d1d82d1914 100644 > > > --- a/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf > > > +++ b/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf > > > @@ -6,7 +6,7 @@ > > > # This external input must be validated carefully to avoid security= issues > such > > as > > > > > > # buffer overflow or integer overflow. > > > > > > # > > > > > > -# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved= .
> > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved= .
> > > > > > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. Al= l rights > > > reserved.
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > @@ -34,6 +34,7 @@ > > > Hash/CryptSha256Null.c > > > > > > Hash/CryptSha512Null.c > > > > > > Hash/CryptSm3Null.c > > > > > > + Hash/CryptParallelHashNull.c > > > > > > Hmac/CryptHmacSha256Null.c > > > > > > Kdf/CryptHkdfNull.c > > > > > > Cipher/CryptAesNull.c > > > > > > diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h > > > b/CryptoPkg/Library/Include/CrtLibSupport.h > > > index d257dca8fa9b..b76b140a7acf 100644 > > > --- a/CryptoPkg/Library/Include/CrtLibSupport.h > > > +++ b/CryptoPkg/Library/Include/CrtLibSupport.h > > > @@ -2,7 +2,7 @@ > > > Root include file of C runtime library to support building the thi= rd-party > > > > > > cryptographic library. > > > > > > > > > > > > -Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. > > > > > > +Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved. > > > > > > Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All r= ights > > > reserved.
> > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > @@ -111,6 +111,7 @@ typedef UINT8 u_char; > > > typedef UINT32 uid_t; > > > > > > typedef UINT32 gid_t; > > > > > > typedef CHAR16 wchar_t; > > > > > > +typedef UINT64 uint64_t; > > > > > > > > > > > > // > > > > > > // File operations are not required for EFI building, > > > > > > diff --git a/CryptoPkg/Private/Protocol/Crypto.h > > > b/CryptoPkg/Private/Protocol/Crypto.h > > > index e378a8a8c60e..de45778c7d42 100644 > > > --- a/CryptoPkg/Private/Protocol/Crypto.h > > > +++ b/CryptoPkg/Private/Protocol/Crypto.h > > > @@ -2,7 +2,7 @@ > > > This Protocol provides Crypto services to DXE modules > > > > > > > > > > > > Copyright (C) Microsoft Corporation. All rights reserved. > > > > > > - Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.=
> > > > > > + Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.=
> > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > **/ > > > > > > @@ -21,7 +21,7 @@ > > > /// the EDK II Crypto Protocol is extended, this version define must= be > > > > > > /// increased. > > > > > > /// > > > > > > -#define EDKII_CRYPTO_VERSION 7 > > > > > > +#define EDKII_CRYPTO_VERSION 8 > > > > > > > > > > > > /// > > > > > > /// EDK II Crypto Protocol forward declaration > > > > > > @@ -3383,6 +3383,35 @@ EFI_STATUS > > > IN OUT UINTN *DataSize > > > > > > ); > > > > > > > > > > > > +/** > > > > > > + Parallel hash function ParallelHash256, as defined in NIST's Speci= al > > Publication > > > 800-185, > > > > > > + published December 2016. > > > > > > + > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > + @param[in] InputByteLen The number(>0) of input bytes provid= ed for > the > > > input data. > > > > > > + @param[in] BlockSize The size of each block (B). > > > > > > + @param[out] Output Pointer to the output buffer. > > > > > > + @param[in] OutputByteLen The desired number of output bytes (= L). > > > > > > + @param[in] Customization Pointer to the customization string = (S). > > > > > > + @param[in] CustomByteLen The length of the customization stri= ng in > > bytes. > > > > > > + > > > > > > + @retval TRUE ParallelHash256 digest computation succeeded. > > > > > > + @retval FALSE ParallelHash256 digest computation failed. > > > > > > + @retval FALSE This interface is not supported. > > > > > > + > > > > > > +**/ > > > > > > +typedef > > > > > > +BOOLEAN > > > > > > +(EFIAPI *EDKII_CRYPTO_PARALLEL_HASH_ALL)( > > > > > > + IN CONST VOID *Input, > > > > > > + IN UINTN InputByteLen, > > > > > > + IN UINTN BlockSize, > > > > > > + OUT VOID *Output, > > > > > > + IN UINTN OutputByteLen, > > > > > > + IN CONST VOID *Customization, > > > > > > + IN UINTN CustomByteLen > > > > > > + ); > > > > > > + > > > > > > /** > > > > > > Carries out the RSA-SSA signature generation with EMSA-PSS encodin= g > > scheme. > > > > > > > > > > > > @@ -3641,6 +3670,8 @@ struct _EDKII_CRYPTO_PROTOCOL { > > > EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT TlsGetHostPubli= cCert; > > > > > > EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY TlsGetHostPriva= teKey; > > > > > > EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST > > > TlsGetCertRevocationList; > > > > > > + /// Parallel hash > > > > > > + EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash256= HashAll; > > > > > > /// RSA PSS > > > > > > EDKII_CRYPTO_RSA_PSS_SIGN RsaPssSign; > > > > > > EDKII_CRYPTO_RSA_PSS_VERIFY RsaPssVerify; > > > > > > diff --git a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc > > > b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc > > > index ff0af36bcc80..c50a9cc4dc9f 100644 > > > --- a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc > > > +++ b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc > > > @@ -2,6 +2,7 @@ > > > # CryptoPkg DSC file used to build host-based unit tests. > > > > > > # > > > > > > # Copyright (c) Microsoft Corporation.
> > > > > > +# Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > # > > > > > > ## > > > > > > @@ -21,6 +22,9 @@ > > > [LibraryClasses] > > > > > > OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf > > > > > > > BaseCryptLib|CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf > > > > > > + > > > > > > MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib > > > .inf > > > > > > + > > > > > > SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizat= i > > > onLib.inf > > > > > > + > > > > > > TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat > > > e.inf > > > > > > > > > > > > [LibraryClasses.AARCH64, LibraryClasses.ARM] > > > > > > RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > > > > > > diff --git > > > a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.i= nf > > > b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.i= nf > > > index 00c869265080..399db596c2d1 100644 > > > --- > a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf > > > +++ > > b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf > > > @@ -2,6 +2,7 @@ > > > # Host-based UnitTest for BaseCryptLib > > > > > > # > > > > > > # Copyright (c) Microsoft Corporation.
> > > > > > +# Copyright (c) 2022, Intel Corporation. All rights reserved.
> > > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > ## > > > > > > > > > > > > @@ -35,6 +36,7 @@ > > > Pkcs7EkuTests.c > > > > > > OaepEncryptTests.c > > > > > > RsaPssTests.c > > > > > > + ParallelhashTests.c > > > > > > > > > > > > [Packages] > > > > > > MdePkg/MdePkg.dec > > > > > > @@ -45,3 +47,5 @@ > > > DebugLib > > > > > > BaseCryptLib > > > > > > UnitTestLib > > > > > > + MmServicesTableLib > > > > > > + SynchronizationLib > > > > > > -- > > > 2.26.2.windows.1