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.5030.1647568371868048206 for ; Thu, 17 Mar 2022 18:52:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Cg2I3q9s; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: zhihao.li@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647568372; x=1679104372; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Mh39ujkyy/2IYYJWOsi7zGTxsUkEkATDQ+6VnKHTTJE=; b=Cg2I3q9s8yW0maxdkc6kuWh9BiK7M9j+6V6aOeoASI7X0IEqLIF09lPk NErDhuHixCINhIeChTFf8pfz6R1ED+kvwjPuwBVA30mG1qqb08CXMmPP8 TcBBzM/oyc8sis3wytxyjI03E11wPPaP17NrIy6xqf/3BXPZaElFfbtDc iKQS0x95plno69AZq3nXWIxfkRSiypdH2xKGLEkXm8uTt9++oGaab9fuh Q/GycHmzl0/DsqIuxyTk0srkrhEGVL9ATdc+cQkZYZ/uAhiEnSPfyx55P WrEWeKEakjgACHB3ZyZr3i52+yRvfi6vLnYiMoe717HOZUV9mMI3qrLLM Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="239187897" X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="239187897" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 18:52:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="558197287" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga008.jf.intel.com with ESMTP; 17 Mar 2022 18:52:50 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX605.amr.corp.intel.com (10.22.229.18) 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 18:52:50 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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 18:52:49 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx612.amr.corp.intel.com (10.22.229.25) 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 18:52:49 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.40) by edgegateway.intel.com (134.134.137.103) 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 18:52:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UdpXTZJpQj5c2DFnOV2M1IGiwIlyeytoyDSGwQ+DKitj8kT9l6XL7NxV7zKsjfmAMEZ+uzUzQsT4gB8ZNvzQQpQizlq3yONAzmWgpLG3pXJZZHO4n70nObQKxw3xVSyUTsdT5Qmf2ervo2zFa3Lpr7URRGw2YPQq42uJNv2hTSVNfUdo+1cbJdIa/uacdPvyJoJ/aZCtKjDF9sz4fEPqnPy8Ix/sPo0/1i7jLR+wvpId6zut5wBIaTjNWMKDz7jCEAwxFI1yxo5oeIKmih07wYo15cDjQYqUYRuGXzOvIlDHBsYlJiCVycmL3gLK38SnhrZSD4OM6dqY0ByYYWTtxg== 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=o9ExPaRzuxN8RtzDANeBIMEPm/3ak7cNlxazFzKZGmI=; b=RJWP5mfVIFw/QgzetXmWrqNoM/bWYJQoFrE48P5EIUXsLkX9i//lQebJO7GQQEBxUSvV51+eMLRdwHL7h+xiI4dc6NBsFS/wYuQBJ2MDuxRcl+mZ3i2pnrfvQDTcFs9JixapimFQ8d6j+UhGe72I1xpHs6Dor4GXF5VcbpM2tnYBRkF5vH0zzP3IIJN21ElbmhBjMiGBhvqfAjIJ4hMWxzSpkHId1SwW8eTG/3lFllom1LB7SSTsYv+zvdlAvVGi4C+sekroD3KIoNGBSffA9OyqlbyZp60ieM4qsHgyNOlJtUBZgZVnmaCuqICVfwVgUwsxcGVrMqQ4UGHtuUE7nA== 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 DM6PR11MB4738.namprd11.prod.outlook.com (2603:10b6:5:2a3::18) by BN6PR11MB1554.namprd11.prod.outlook.com (2603:10b6:405:b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Fri, 18 Mar 2022 01:52:45 +0000 Received: from DM6PR11MB4738.namprd11.prod.outlook.com ([fe80::74f3:4efa:c586:a951]) by DM6PR11MB4738.namprd11.prod.outlook.com ([fe80::74f3:4efa:c586:a951%7]) with mapi id 15.20.5081.018; Fri, 18 Mar 2022 01:52:45 +0000 From: "Li, Zhihao" 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. Thread-Topic: [PATCH v6 1/1] CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib. Thread-Index: AQHYObhWpGZOzIXh0ECh0X9gIAaugqzDE/0wgACqfmCAAJPR0IAACryQ Date: Fri, 18 Mar 2022 01:52:45 +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: 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: e282eacd-4b15-404f-ad5a-08da0881ff7a x-ms-traffictypediagnostic: BN6PR11MB1554: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: YUFNaJBgVr0/53CLjskSfLhhodPYPAGj0ilV2nKQRg4J49Srzat/vfBbkFH/v7L/ml68a1XInl0t2XNtqp+Y1QhC/OcVRDetQt33v6dcEMgFwjp4rh/ujAQY9SL3YhyUTc0Ugaha4PkTbJ//K6xFesuiUZZiVUiXCjiPcnQH7waPcmSrCzzIiSsEOqBBoD3aszIKRgEPtlFAfalyP4KkEipPGYow9S0CwCsxcBNOo7vRf+aX+y+J8KWEkbx3hd6fsVrKjgCNoEYt3TdD1BN/WYkX6Ie5KG9R0U+qhomzANRTHuHNfPXEAPSy5OM5TE2L6isXQrrnsAHZTYF8vLJ+a1o92vUZBbMHruhdAvJpFucwMgh9jVWSdbb1oWZAryqsNCRJi/l5V2ESWT2Ne3AxFR3BxyiNOXCqGMPIfAcphO+5WDBAzHpcUssysBiyb7499Tdu+vFg18GfgM/hPrTzIuSxkmp3foR7XZr2COGwXrsC3g2iv4g20a5klQSfqA7B9KCSxBrUkgNoanibeHGVHrEnC2he04wnueZjLotMvh9n3xRZ0mPSLC9poUx9UZJ1bRi3UjbZ85SdxGRFe4BHF9ClexKE9xqHXmohyUWcMHFKb17Wh9xJNw/aRAl/yCTgUZPY/CwC/G6QyadWq1KGRReVQm8tOMJkhnH9D4f6QdrGL0AEJqdVH05G90xBNSz8k/UQqaRfuyUULAcVi99w3OOXTk6A9nnGOJ056HXA/DiXsTdMc/6ORJjt1TbvEYX3k9/0j5rNwGaZCm7Fet63tWewQzXnwZgkrEF6VzhMSENEjdD5XU799e2CljrLrPPXiFm++9BFeI/bPj+K9ctvMA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4738.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(9686003)(7696005)(6506007)(316002)(53546011)(122000001)(66556008)(66476007)(66446008)(66946007)(64756008)(4326008)(8676002)(2906002)(76116006)(38100700002)(54906003)(110136005)(71200400001)(508600001)(45080400002)(83380400001)(8936002)(966005)(186003)(19627235002)(26005)(30864003)(52536014)(55016003)(38070700005)(107886003)(33656002)(5660300002)(86362001)(82960400001)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?EdXd5H9vsMCeUq8oIrwRyN7ggjjeKsUJK78CkAsA0+gucnfQIj7aLUUZwBAi?= =?us-ascii?Q?Psxt3dyQuzFA/gFR42BQJa7xhPU1TMJpTKvtxJQ1+QL0zVhn9Krk1MFBTSIn?= =?us-ascii?Q?ZP1H0r8ie70R+GrOpzWKgfWhug0vOC/V2Gq3oZu61gY7+Q8rh/F/+W71yUHm?= =?us-ascii?Q?ZlsakkDD11dWHi2EuYIw+4QafOmFx/WSDZedC5azHRftApbGclGK4wDZLVoF?= =?us-ascii?Q?JvymwNPeURCMg2ud2L1qiw2XXRUzYxBqQBhQCofBkuBakQb0mPEovUC+pxeM?= =?us-ascii?Q?dWzejOOdRMcPPx9sOt4LbKqNaHe0C+/5pD0AtS+e7YgmBP3Vcyas8vHmFIxr?= =?us-ascii?Q?DhmlsWL/0SNdGi0nwIkvMNqdVZFZdTCmY5cg3kxg9gNHYmn41yH3zBgv1hfq?= =?us-ascii?Q?j0BR3qA2JN7xK9lgJlmqwpn/glh5D6ZL1+rve1xzvuum70XW6jzZMXM6NxDt?= =?us-ascii?Q?uZtDhVvjVWdH9ej3sGxbY/SDiExLKvVCx6G76n+N7Gwo7n1onoUJtyLHhgqR?= =?us-ascii?Q?1KTB++eP0ZftN2jKSqhFu/WhLaTbryFQ2JtlUfXysPdpvoNDpZa/xIxKYIJm?= =?us-ascii?Q?SBRZw4/dXXmHXQKl2ZzzBvPw9853JhD3FbAy1oPmfEtH9sAg1pb6+gOU25cg?= =?us-ascii?Q?RZZxsQI4210NfsatVRNya+B8428N+1qgM3dhkpzFlkn8XNeAO+/aoxbx4kAq?= =?us-ascii?Q?TX8XuEhhJSgZkMmSiBp5RH6anFFU2VsDe5D6GshpjzyPl48KeJj7eyN9ILPM?= =?us-ascii?Q?J/KcIyPqkXqZQN0dwhDCtBImrrrLpQCHvjHGhLQZLe2TNsWg83iCUZyFgiq7?= =?us-ascii?Q?WgSMUHoDYvvFUlpIEdDwejHfbncYlyBtY1uWv8CLcEOGTUYFYBxqBlQ5QsEJ?= =?us-ascii?Q?D4H1L1/yjE/58ubPGiFhyqfFuQ8Wh7NpIeNhbQ8Wk1u8e9jr7pbi/f5dRaRS?= =?us-ascii?Q?9y988S/1uFtJEM9uWWOb0u+bFQ3AnU9k9dnHI3k40/kB6nrTJaS6Q6M5BWEX?= =?us-ascii?Q?JsBp+sM/nCs8Kww1uDSbDW+kI6DijbaiqB99ts4nrs/L0wJG1AJwlrfb++px?= =?us-ascii?Q?x3JuXzl12szLoh6RW3BF2OlezvL+fYAJ+H6mca9a01qgO0doLqfsFoFMQ4In?= =?us-ascii?Q?FRNq9PafmeTXmbNME2LcjouYQqR1qn3YnuASmgVghSb0q8ReUaoNLsG5MbgD?= =?us-ascii?Q?UEzEvI4SSP+SZCsEApNcAYvVZ5QhyyuLw3mC4JE1inGZ/sHeRpwZ1D1DSev3?= =?us-ascii?Q?wSGlDXKP8B22Feq/Wl6hqrjxQjpWBKX3hCb+OvBI/qcGim56kR1hRrPwAgEK?= =?us-ascii?Q?WGJu72qpjHxXDn8nswue6gPksYpPhYJF89waIgdWxfvwoba6EC0c6NbvBPBY?= =?us-ascii?Q?EQ+ALaTbSz40QFkrEGVfUA0xaFdY4ZqBboD7OhhYDZJLEc/mwLkgI3ovZKzW?= =?us-ascii?Q?zkAI2dnZphAzIhKpgrjXngEe1fLqQKgF?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4738.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e282eacd-4b15-404f-ad5a-08da0881ff7a X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2022 01:52:45.4661 (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: MgRVHkxSJprRYb79mpUUU990kdQUF8k+W4un0ccI13YtHyskoMQ328rlFXLUBh2AUJUCkCRs31gL6Nt+7zV65g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1554 Return-Path: zhihao.li@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Build CryptoPei and CryptoSmm driver report this error. INFO - /home/vsts/work/1/s/CryptoPkg/Driver/Crypto.c:4707:3: error: initial= ization of 'BOOLEAN (__attribute__((ms_abi)) *)(void *, const UINT8 *, UINT= N, UINT16, UINT16, UINT8 *, UINTN *)' from incompatible pointer type 'BO= OLEAN (__attribute__((ms_abi)) *)(const void *, UINTN, UINTN, void *, UIN= TN, const void *, UINTN)' [-Werror=3Dincompatible-pointer-types] INFO - 4707 | CryptoServiceParallelHash256HashAll In Crypto.c: const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto =3D { ... CryptoServiceTlsGetHostPrivateKey, CryptoServiceTlsGetCertRevocationList, /// Parallel hash CryptoServiceParallelHash256HashAll }; In Crypto.h struct _EDKII_CRYPTO_PROTOCOL { ... EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST TlsGetCertRevocationLi= st; /// RSA PSS EDKII_CRYPTO_RSA_PSS_SIGN RsaPssSign; EDKII_CRYPTO_RSA_PSS_VERIFY RsaPssVerify; /// Parallel hash EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash256HashAll= ; }; And=20 typedef BOOLEAN (EFIAPI *EDKII_CRYPTO_RSA_PSS_SIGN)( IN VOID *RsaContext, IN CONST UINT8 *Message, IN UINTN MsgSize, IN UINT16 DigestLen, IN UINT16 SaltLen, OUT UINT8 *Signature, IN OUT UINTN *SigSize ); So I think solve this error need to put ParallelHash256HashAll before RsaPs= sSign. And test result is successful. Is there anything wrong with my judgment? > -----Original Message----- > From: Yao, Jiewen > Sent: Friday, March 18, 2022 8:56 AM > 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. >=20 > What is root cause of failure? >=20 > I don't understand. >=20 > > -----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. > > > > Because it will cause patch to fail in CI test while to succeed if foll= ow the > setting. > > Failed test: https://github.com/tianocore/edk2/pull/2535 > > > > I guess it's because data structure EDKII_CRYPTO_PROTOCOL( mEdkiiCrypto= ) > > doesn't have /// RSA PSS members in Crypto.c > > > > > -----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 > TlsGetHostPublicCert; > > > > > > > > EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY > TlsGetHostPrivateKey; > > > > > > > > EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST > > > > TlsGetCertRevocationList; > > > > > > > > + /// Parallel hash > > > > > > > > + EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash2= 56HashAll; > > > > > > > > /// 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.= inf | > > 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 reserve= d.
> > > > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserve= d.
> > > > > > > > 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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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 > cSHAKE- > > > 256 > > > > hash context for > > > > > > > > + subsequent use. > > > > > > > > + > > > > > > > > + @param[out] CShake256Context Pointer to cSHAKE-256 context bein= g > > > > initialized. > > > > > > > > + @param[in] OutputLen The desired number of output lengt= h in > bytes. > > > > > > > > + @param[in] Name Pointer to the function name strin= g. > > > > > > > > + @param[in] NameLen The length of the function name in= bytes. > > > > > > > > + @param[in] Customization Pointer to the customization strin= g. > > > > > > > > + @param[in] CustomizationLen The length of the customization st= ring 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) || ((= NameLen !=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 = equivalent > > to > > > > > > > > + // SHAKE as defined in FIPS 202. > > > > > > > > + // > > > > > > > > + Status =3D (BOOLEAN)KeccakInit ( > > > > > > > > + (Keccak1600_Ctx *)CShake256Context, > > > > > > > > + '\x1f', > > > > > > > > + (KECCAK1600_WIDTH - CSHAKE256_SECURITY_STR= ENGTH * > 2) > > / > > > 8, > > > > > > > > + OutputLen > > > > > > > > + ); > > > > > > > > + > > > > > > > > + return Status; > > > > > > > > + } else { > > > > > > > > + Status =3D (BOOLEAN)KeccakInit ( > > > > > > > > + (Keccak1600_Ctx *)CShake256Context, > > > > > > > > + '\x04', > > > > > > > > + (KECCAK1600_WIDTH - CSHAKE256_SECURITY_STR= ENGTH * > 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 *)CShake256Con= text, > > > > 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 *)CShake256Con= text, > > > > 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 *)CShake256Con= text, > > > > 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 *)CShake256Con= text, > > > > 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 > specified > > > > 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 > context. > > > > > > > > + @param[in] Data Pointer to the buffer contai= ning 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 ch= ecked 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 retrieve= s the > > > > digest value into > > > > > > > > + the specified memory. After this function has been called, the c= SHAKE- > 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 = context > is > > > > undefined. > > > > > > > > + > > > > > > > > + @param[in, out] CShake256Context Pointer to the cSHAKE-256 con= text. > > > > > > > > + @param[out] HashValue Pointer to a buffer that rece= ives 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 = data > > > buffer, > > > > and places > > > > > > > > + the digest value into the specified memory. > > > > > > > > + > > > > > > > > + @param[in] Data Pointer to the buffer containing= the 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 str= ing. > > > > > > > > + @param[in] NameLen Size of the function name in byt= es. > > > > > > > > + @param[in] Customization Pointer to the customization str= ing. > > > > > > > > + @param[in] CustomizationLen Size of the customization string= in bytes. > > > > > > > > + @param[out] HashValue Pointer to a buffer that receive= s 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, > Customization, > > > > 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 := mBlockSize, > > > > > > > > + 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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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) || (Bloc= kSize =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 fl= ag and > > > > SpinLock. > > > > > > > > + // > > > > > > > > + CombinedInputSize =3D EncSizeB + EncSizeN + EncSizeL + mBlockNum= * > > > > mBlockResultSize; > > > > > > > > + CombinedInput =3D AllocateZeroPool (CombinedInputSize); > > > > > > > > + mBlockIsCompleted =3D AllocateZeroPool (mBlockNum * sizeof > (BOOLEAN)); > > > > > > > > + mSpinLockList =3D AllocatePool (mBlockNum * sizeof (SPIN_LOC= K)); > > > > > > > > + if ((CombinedInput =3D=3D NULL) || (mBlockIsCompleted =3D=3D NUL= L) || > > > > (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 ? mBlock= Size : > > > > 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)) ? mLastB= lockSize : mBlockSize, > > > > > > > > + mBlockResultSize, > > > > > > > > + NULL, > > > > > > > > + 0, > > > > > > > > + NULL, > > > > > > > > + 0, > > > > > > > > + mBlockHashResult + Index * mBlockResult= Size > > > > > > > > + ); > > > > > > > > + 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/CryptParallelHashN= ull.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 capabili= ties. > > > > > > > > + > > > > > > > > +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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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 u= se > > > > > > > > +this file except in compliance with the License. You can obtain a= copy > > > > > > > > +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 initi= alized. > > > > > > > > + @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 speci= fied 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 da= ta 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, BlockS= ize); > > > > > > > > + Context->num =3D 0; > > > > > > > > + // Context->buf is processed, Context->num is guaranteed to be= zero. > > > > > > > > + } > > > > > > > > + > > > > > > > > + 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 = digest > > > value > > > > into > > > > > > > > + the specified memory. After this function has been called, the k= eccak > > > context > > > > cannot > > > > > > > > + be used again. > > > > > > > > + > > > > > > > > + @param[in, out] Context Pointer to the keccak context. > > > > > > > > + @param[out] MessageDigest Pointer to a buffer that receive= s 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, BlockSiz= e); > > > > > > > > + > > > > > > > > + SHA3_squeeze (Context->A, MessageDigest, Context->md_size, > BlockSize); > > > > > > > > + > > > > > > > > + 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 an= d > > Gilles > > > > Van Assche. > > > > > > > > +Implementation by the designers, hereby denoted as "the implemente= r". > > > > > > > > +For more information, feedback or questions, please refer to the K= eccak > > > Team > > > > website: > > > > > > > > +https://keccak.team/ > > > > > > > > +To the extent possible under law, the implementer has waived all > copyright > > > > > > > > +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 unambigu= ously > > > parsed > > > > > > > > + from the beginning of the string by inserting the length of the = byte 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 && (BlockNu= m < > 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 unambigu= ously > > > parsed > > > > > > > > + from the end of the string by inserting the length of the byte s= tring 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 capabili= ties. > > > > > > > > + > > > > > > > > +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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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 reserve= d.
> > > > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserve= d.
> > > > > > > > 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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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, InputByteLe= n, > > > > BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FA= LSE); > > > > > > > > +} > > > > > > > > + > > > > > > > > /** > > > > > > > > Retrieves the size, in bytes, of the context buffer required for= SM3 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/ParallelhashTest= s.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-1= 85. > > > > > > > > +// > > > > > > > > +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-1= 85. > > > > > > > > +// > > > > > > > > +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 samp= le2. > > > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN > CustomSample2ByteLen > > =3D > > > > 13; // Customization string length of sampl= e2 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-1= 85. > > > > > > > > +// > > > > > > > > +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 samp= le3. > > > > > > > > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN > CustomSample3ByteLen > > =3D > > > > 13; // Customization string length of sampl= e3 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.y= aml > > > > 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 reserve= d.
> > > > > > > > # 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 co= mpliant > > > > > > > > "Library/Include/CrtLibSupport.h", > > > > > > > > + # This has OpenSSL interfaces that aren't UEFI spec co= mpliant > > > > > > > > + "Library/BaseCryptLib/Hash/CryptParallelHash.h", > > > > > > > > # These directories contain auto-generated OpenSSL con= tent > > > > > > > > "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 UE= FI 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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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= SM3 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 reserve= d.
> > > > > > > > + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserve= d.
> > > > > > > > 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 securi= ty issues > > such > > > as > > > > > > > > # buffer overflow or integer overflow. > > > > > > > > # > > > > > > > > -# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserv= ed.
> > > > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserv= ed.
> > > > > > > > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. = All > 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 u= se > > > > > > > > +this file except in compliance with the License. You can obtain a= copy > > > > > > > > +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 an= d > > Gilles > > > > Van Assche. > > > > > > > > +Implementation by the designers, hereby denoted as "the implemente= r". > > > > > > > > +For more information, feedback or questions, please refer to the K= eccak > > > Team > > > > website: > > > > > > > > +https://keccak.team/ > > > > > > > > +To the extent possible under law, the implementer has waived all > copyright > > > > > > > > +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 = type > 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 cal= ler > > > > > > > > + trouble of calculating the largest multiple of |r|. |r| can be v= iewed > > > > > > > > + as blocksize. It is commonly (1600 - 256*n)/8, e.g. 168, 136, 10= 4, > > > > > > > > + 72, but can also be (1600 - 448)/8 =3D 144. All this means that = message > > > > > > > > + 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 va= lue > > > > > > > > + 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 unambigu= ously > > > parsed > > > > > > > > + from the beginning of the string by inserting the length of the = byte 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 unambigu= ously > > > parsed > > > > > > > > + from the end of the string by inserting the length of the byte s= tring 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 initi= alized. > > > > > > > > + @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 speci= fied 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 da= ta 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 = digest > > > value > > > > into > > > > > > > > + the specified memory. After this function has been called, the k= eccak > > > context > > > > cannot > > > > > > > > + be used again. > > > > > > > > + > > > > > > > > + @param[in, out] Context Pointer to the keccak context. > > > > > > > > + @param[out] MessageDigest Pointer to a buffer that receive= s 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 = data > > > buffer, > > > > and places > > > > > > > > + the digest value into the specified memory. > > > > > > > > + > > > > > > > > + @param[in] Data Pointer to the buffer containing= the 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 str= ing. > > > > > > > > + @param[in] NameLen Size of the function name in byt= es. > > > > > > > > + @param[in] Customization Pointer to the customization str= ing. > > > > > > > > + @param[in] CustomizationLen Size of the customization string= in bytes. > > > > > > > > + @param[out] HashValue Pointer to a buffer that receive= s 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 functi= ons > > are > > > > not > > > > > > > > # supported in this instance. > > > > > > > > # > > > > > > > > -# Copyright (c) 2010 - 2020, Intel Corporation. All rights reserv= ed.
> > > > > > > > +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserv= ed.
> > > > > > > > # 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 fun= ctions, > > and > > > > > > > > # authenticode signature verification functions are not supported= in this > > > > instance. > > > > > > > > # > > > > > > > > -# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserv= ed.
> > > > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserv= ed.
> > > > > > > > # Copyright (c) 2021, Hewlett Packard Enterprise Development LP. = 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/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, Diffi= e- > Hellman > > > > functions, and > > > > > > > > # authenticode signature verification functions are not supported= in this > > > > instance. > > > > > > > > # > > > > > > > > -# Copyright (c) 2010 - 2021, Intel Corporation. All rights reserv= ed.
> > > > > > > > +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserv= ed.
> > > > > > > > # 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.in= f > > > > 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 securi= ty issues > > such > > > as > > > > > > > > # buffer overflow or integer overflow. > > > > > > > > # > > > > > > > > -# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserv= ed.
> > > > > > > > +# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserv= ed.
> > > > > > > > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. = All > 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 t= hird-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= rights > > > > 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 reserve= d.
> > > > > > > > + Copyright (c) 2020 - 2022, Intel Corporation. All rights reserve= d.
> > > > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > > > > > > > **/ > > > > > > > > @@ -21,7 +21,7 @@ > > > > /// the EDK II Crypto Protocol is extended, this version define mu= st 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 Spe= cial > > > Publication > > > > 800-185, > > > > > > > > + published December 2016. > > > > > > > > + > > > > > > > > + @param[in] Input Pointer to the input message (X). > > > > > > > > + @param[in] InputByteLen The number(>0) of input bytes prov= ided 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 strin= g (S). > > > > > > > > + @param[in] CustomByteLen The length of the customization st= ring 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 encod= ing > > > scheme. > > > > > > > > > > > > > > > > @@ -3641,6 +3670,8 @@ struct _EDKII_CRYPTO_PROTOCOL { > > > > EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT > TlsGetHostPublicCert; > > > > > > > > EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY > TlsGetHostPrivateKey; > > > > > > > > EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST > > > > TlsGetCertRevocationList; > > > > > > > > + /// Parallel hash > > > > > > > > + EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash2= 56HashAll; > > > > > > > > /// 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.in= f > > > > > > > > + > > > > > > > > > > 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= .inf > > > > b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost= .inf > > > > index 00c869265080..399db596c2d1 100644 > > > > --- > > a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf > > > > +++ > > > b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.i= nf > > > > @@ -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