From nobody Mon Feb 9 20:35:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52387+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52387+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1576707402; cv=none; d=zohomail.com; s=zohoarc; b=VnKMNUlDh9EWtbZPIzvdV4XQ/nns1SvtAmw0tzRdwfjlOkBfghYWE1T9qVRlonkdGHHBCdIn9d4CPAAopQUm+FQUW2mD/+ewkzCvD52z07Og4cUn+737LBH6GpfzzI48lCvWABerDHU74AdCGRA+xTUYG2e8sWQJWF/q2lo5UNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576707402; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FR1WBiSV0O3mEmCIk4Y9CxCPqHNRobB1sZrobNyBShs=; b=X3s65hOuY486/rn2paXSqRn8l8xMOKEqLSSKrwTzoyANewARfMP9a7ZClW6Ps9SCgCtE3p3o7hY12v5/lmzhben/0Zy22WqyzgttyZwY85IuxrRyYInWnPLkJZVQNhGt5BTMNUxf7xQepAAI/vggwJxRP/xMlY5RY96au6PvdTk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52387+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576707402048372.6541719268955; Wed, 18 Dec 2019 14:16:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DlvhYY1788612xRPIX072ync; Wed, 18 Dec 2019 14:16:41 -0800 X-Received: from mga02.intel.com (mga02.intel.com []) by mx.groups.io with SMTP id smtpd.web12.1767.1576704760204204400 for ; Wed, 18 Dec 2019 13:32:50 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2019 13:32:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="212815455" X-Received: from ansukerk-mobl.amr.corp.intel.com ([10.78.16.174]) by fmsmga007.fm.intel.com with ESMTP; 18 Dec 2019 13:32:49 -0800 From: "Sukerkar, Amol N" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH v1 5/6] SecurityPkg/BaseHashLib: Modified the Registation Mechanism for BaseHashLib Date: Wed, 18 Dec 2019 14:32:35 -0700 Message-Id: <20191218213236.1563-6-amol.n.sukerkar@intel.com> In-Reply-To: <20191218213236.1563-1-amol.n.sukerkar@intel.com> References: <20191218213236.1563-1-amol.n.sukerkar@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,amol.n.sukerkar@intel.com X-Gm-Message-State: tnsLExj66fEXFnjfr5i3HB3xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576707401; bh=9JiK8APLGkxPs6QWURHR5187V5dZVqywzBtAFScplKU=; h=Date:From:Reply-To:Subject:To; b=nIwaYIeUUBoa530BNXq906gzJy/Ia4sULY5ExH70U27P+crJeqIQJvBrYyts3mUpHCD nrsffbKZsF23mbm5kMNkqlogRaUIuv35f0kn9ANtPqIlnlc5EkLQwRtHrC3FkIOOqsc2b +ca5Y21BVvoChvcEcbFvH6YlG8a32ZlW/QA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" A gEfiCallerIdGuid needs to be introduced in the BaseHashLibPei method to s= ave the hash mask of registered API instances of hashing algorithms. gEfiCallerIdGuid saves the last registered hash mask as a HOB that can be modified or updated with the subsequent registration of API instances of hashing algorithms based on PcdSystemHashPolicy. Signed-off-by: Sukerkar, Amol N --- SecurityPkg/Library/BaseHashLib/BaseHashLib.c | 236 --= ----------- SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.c | 210 ++= +++++++++- SecurityPkg/Library/BaseHashLib/BaseHashLibPei.c | 348 ++= +++++++++++++++++- SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.c | 2 +- SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha256.c | 2 +- SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c | 2 +- SecurityPkg/Include/Library/BaseHashLib.h | 153 ++= +++++++ SecurityPkg/Include/Library/HashLib.h | 83 --= --- SecurityPkg/Library/BaseHashLib/BaseHashLib.h | 85 --= --- SecurityPkg/Library/BaseHashLib/BaseHashLibCommon.h | 35 ++ SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.inf | 2 - SecurityPkg/Library/BaseHashLib/BaseHashLibPei.inf | 4 +- SecurityPkg/SecurityPkg.dec | 9 - SecurityPkg/SecurityPkg.uni | 9 - 14 files changed, 733 insertions(+), 447 deletions(-) diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLib.c b/SecurityPkg/Li= brary/BaseHashLib/BaseHashLib.c deleted file mode 100644 index 2ad83387799d..000000000000 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLib.c +++ /dev/null @@ -1,236 +0,0 @@ -/** @file - Implement image verification services for secure boot service - - Caution: This file requires additional review when modified. - This library will have external input - PE/COFF image. - This external input must be validated carefully to avoid security issue = like - buffer overflow, integer overflow. - - DxeImageVerificationLibImageRead() function will make sure the PE/COFF i= mage content - read is within the image buffer. - - DxeImageVerificationHandler(), HashPeImageByType(), HashPeImage() functi= on will accept - untrusted PE/COFF image and validate its data structure within this imag= e buffer before use. - -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD = License -which accompanies this distribution. The full text of the license may be = found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. - -**/ - -#include -#include -#include -#include -#include -#include - -//#include "BaseHashLib.h" - -typedef struct { - EFI_GUID Guid; - UINT32 Mask; -} HASH_MASK; - -HASH_MASK mHashMask[] =3D { - {HASH_ALGORITHM_SHA1_GUID, HASH_ALG_SHA1}, - {HASH_ALGORITHM_SHA256_GUID, HASH_ALG_SHA256}, - {HASH_ALGORITHM_SHA384_GUID, HASH_ALG_SHA384}, - {HASH_ALGORITHM_SHA512_GUID, HASH_ALG_SHA512}, -}; - -HASH_INTERFACE_UNIFIED_API mHashOps[HASH_COUNT] =3D {{{0}, NULL, NULL, NUL= L}}; - -UINTN mHashInterfaceCount =3D 0; -UINT32 mCurrentHashMask =3D 0; - -UINT32 -EFIAPI -GetApiHashMaskFromAlgo ( - IN EFI_GUID *HashGuid - ) -{ - UINTN Index; - - for (Index =3D 0; Index < sizeof(mHashMask)/sizeof(mHashMask[0]); Index+= +) { - if (CompareGuid (HashGuid, &mHashMask[Index].Guid)) { - return mHashMask[Index].Mask; - } - } - return 0; -} - -/** - Init hash sequence. - - @param HashHandle Hash handle. - - @retval EFI_SUCCESS Hash start and HashHandle returned. - @retval EFI_UNSUPPORTED System has no HASH library registered. -**/ -EFI_STATUS -EFIAPI -HashApiInit ( - OUT HASH_HANDLE *HashHandle -) -{ - HASH_HANDLE *HashCtx; - UINTN Index; - UINT32 HashMask; - - if (mHashInterfaceCount =3D=3D 0) { - return EFI_UNSUPPORTED; - } - - HashCtx =3D AllocatePool (sizeof(*HashCtx)); - ASSERT (HashCtx !=3D NULL); - - for (Index =3D 0; Index < mHashInterfaceCount; Index++) { - HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); - if ((HashMask & PcdGet32 (PcdHashAlgorithmBitmap)) !=3D 0 && - (HashMask & PcdGet32 (PcdSystemHashPolicy)) !=3D 0) { - mHashOps[Index].HashInit (HashCtx); - } - } - - *HashHandle =3D (HASH_HANDLE)HashCtx; - - return EFI_SUCCESS; -} - -/** - Update hash data. - - @param HashHandle Hash handle. - @param DataToHash Data to be hashed. - @param DataToHashLen Data size. - - @retval EFI_SUCCESS Hash updated. - @retval EFI_UNSUPPORTED System has no HASH library registered. -**/ -EFI_STATUS -EFIAPI -HashApiUpdate ( - IN HASH_HANDLE HashHandle, - IN VOID *DataToHash, - IN UINTN DataToHashLen -) -{ - HASH_HANDLE *HashCtx; - UINTN Index; - UINT32 HashMask; - - if (mHashInterfaceCount =3D=3D 0) { - return EFI_UNSUPPORTED; - } - - HashCtx =3D (HASH_HANDLE *)HashHandle; - - for (Index =3D 0; Index < mHashInterfaceCount; Index++) { - HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); - if ((HashMask & PcdGet32 (PcdHashAlgorithmBitmap)) !=3D 0 && - (HashMask & PcdGet32 (PcdSystemHashPolicy)) !=3D 0) { - mHashOps[Index].HashUpdate (HashCtx[0], DataToHash, DataToHashLen); - } - } - - return EFI_SUCCESS; -} - -/** - Hash complete. - - @param HashHandle Hash handle. - @param Digest Hash Digest. - - @retval EFI_SUCCESS Hash complete and Digest is returned. -**/ -EFI_STATUS -EFIAPI -HashApiFinal ( - IN HASH_HANDLE HashHandle, - OUT UINT8 *Digest -) -{ - HASH_HANDLE *HashCtx; - UINTN Index; - UINT32 HashMask; - - if (mHashInterfaceCount =3D=3D 0) { - return EFI_UNSUPPORTED; - } - - HashCtx =3D (HASH_HANDLE *)HashHandle; - - for (Index =3D 0; Index < mHashInterfaceCount; Index++) { - HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); - if ((HashMask & PcdGet32 (PcdHashAlgorithmBitmap)) !=3D 0 && - (HashMask & PcdGet32 (PcdSystemHashPolicy)) !=3D 0) { - mHashOps[Index].HashFinal (HashCtx[0], &Digest); - } - } - - return EFI_SUCCESS; -} - -/** - This service registers Hash Interface. - - @param HashInterface Hash interface - - @retval EFI_SUCCESS This hash interface is registered successfu= lly. - @retval EFI_UNSUPPORTED System does not support register this inter= face. - @retval EFI_ALREADY_STARTED System already register this interface. -**/ -EFI_STATUS -EFIAPI -RegisterHashApiLib ( - IN HASH_INTERFACE_UNIFIED_API *HashInterface - ) -{ - EFI_STATUS Status; - UINTN Index; - UINT32 HashMask; - - // - // Check Allow - // - HashMask =3D GetApiHashMaskFromAlgo (&HashInterface->HashGuid); - - // check if Hash Mask is supported - if ((HashMask & PcdGet32 (PcdTpm2HashMask)) =3D=3D 0) { - return EFI_UNSUPPORTED; - } - - if (mHashInterfaceCount >=3D sizeof(mHashOps)/sizeof(mHashOps[0])) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Check duplication - // - for (Index =3D 0; Index < mHashInterfaceCount; Index++) { - if (CompareGuid (&mHashOps[Index].HashGuid, &HashInterface->HashGuid))= { - DEBUG ((DEBUG_ERROR, "Hash Interface (%g) has been registered\n", &H= ashInterface->HashGuid)); - return EFI_ALREADY_STARTED; - } - } - - // - // Register the Hash Algo. - // - mCurrentHashMask =3D PcdGet32 (PcdHashAlgorithmBitmap) | HashMask; - Status =3D PcdSet32S (PcdHashAlgorithmBitmap, mCurrentHashMask); - ASSERT_EFI_ERROR (Status); - - CopyMem (&mHashOps[mHashInterfaceCount], HashInterface, sizeof(*HashInte= rface)); - mHashInterfaceCount ++; - - return EFI_SUCCESS; -} \ No newline at end of file diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.c b/SecurityPkg= /Library/BaseHashLib/BaseHashLibDxe.c index 5de94d80fad5..f292558e3e40 100644 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.c +++ b/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.c @@ -29,9 +29,204 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include -#include +#include =20 -#include "BaseHashLib.h" +#include "BaseHashLibCommon.h" + + +HASH_INTERFACE_UNIFIED_API mHashOps[HASH_ALGO_COUNT] =3D {{{0}, NULL, NULL= , NULL}}; + +UINTN mBaseHashInterfaceCount =3D 0; +UINT32 mCurrentHashMask =3D 0; + +UINT32 +EFIAPI +GetApiHashMaskFromAlgo ( + IN EFI_GUID *HashGuid + ) +{ + UINTN Index; + + for (Index =3D 0; Index < sizeof(mHashMask)/sizeof(mHashMask[0]); Index+= +) { + if (CompareGuid (HashGuid, &mHashMask[Index].Guid)) { + return mHashMask[Index].Mask; + } + } + return 0; +} + +/** + Init hash sequence. + + @param HashHandle Hash handle. + + @retval EFI_SUCCESS Hash start and HashHandle returned. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiInit ( + OUT HASH_HANDLE *HashHandle +) +{ + HASH_HANDLE *HashCtx; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((mBaseHashInterfaceCount =3D=3D 0) || !(mCurrentHashMask & HashPolic= y)) { + return EFI_UNSUPPORTED; + } + + HashCtx =3D AllocatePool (sizeof(*HashCtx)); + ASSERT (HashCtx !=3D NULL); + + for (Index =3D 0; Index < mBaseHashInterfaceCount; Index++) { + HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); + if ((HashMask & HashPolicy) !=3D 0) { + mHashOps[Index].HashInit (HashCtx); + break; + } + } + + *HashHandle =3D (HASH_HANDLE)HashCtx; + + return EFI_SUCCESS; +} + +/** + Update hash data. + + @param HashHandle Hash handle. + @param DataToHash Data to be hashed. + @param DataToHashLen Data size. + + @retval EFI_SUCCESS Hash updated. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiUpdate ( + IN HASH_HANDLE HashHandle, + IN VOID *DataToHash, + IN UINTN DataToHashLen +) +{ + HASH_HANDLE *HashCtx; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((mBaseHashInterfaceCount =3D=3D 0) || !(mCurrentHashMask & HashPolic= y)) { + return EFI_UNSUPPORTED; + } + + HashCtx =3D (HASH_HANDLE *)HashHandle; + + for (Index =3D 0; Index < mBaseHashInterfaceCount; Index++) { + HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); + if ((HashMask & HashPolicy) !=3D 0) { + mHashOps[Index].HashUpdate (HashCtx[0], DataToHash, DataToHashLen); + break; + } + } + + return EFI_SUCCESS; +} + +/** + Hash complete. + + @param HashHandle Hash handle. + @param Digest Hash Digest. + + @retval EFI_SUCCESS Hash complete and Digest is returned. +**/ +EFI_STATUS +EFIAPI +HashApiFinal ( + IN HASH_HANDLE HashHandle, + OUT UINT8 *Digest +) +{ + HASH_HANDLE *HashCtx; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((mBaseHashInterfaceCount =3D=3D 0) || !(mCurrentHashMask & HashPolic= y)) { + return EFI_UNSUPPORTED; + } + + HashCtx =3D (HASH_HANDLE *)HashHandle; + + for (Index =3D 0; Index < mBaseHashInterfaceCount; Index++) { + HashMask =3D GetApiHashMaskFromAlgo (&mHashOps[Index].HashGuid); + if ((HashMask & HashPolicy) !=3D 0) { + mHashOps[Index].HashFinal (HashCtx[0], &Digest); + break; + } + } + + return EFI_SUCCESS; +} + +/** + This service registers Hash Interface. + + @param HashInterface Hash interface + + @retval EFI_SUCCESS This hash interface is registered successfu= lly. + @retval EFI_UNSUPPORTED System does not support register this inter= face. + @retval EFI_ALREADY_STARTED System already register this interface. +**/ +EFI_STATUS +EFIAPI +RegisterHashApiLib ( + IN HASH_INTERFACE_UNIFIED_API *HashInterface + ) +{ + UINTN Index; + UINT32 HashMask; + + // + // Check Allow + // + HashMask =3D GetApiHashMaskFromAlgo (&HashInterface->HashGuid); + + + if (mBaseHashInterfaceCount >=3D sizeof(mHashOps)/sizeof(mHashOps[0])) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Check duplication + // + for (Index =3D 0; Index < mBaseHashInterfaceCount; Index++) { + if (CompareGuid (&mHashOps[Index].HashGuid, &HashInterface->HashGuid))= { + DEBUG ((DEBUG_ERROR, "Hash Interface (%g) has already been registere= d\n", &HashInterface->HashGuid)); + return EFI_ALREADY_STARTED; + } + } + + // + // Register the Hash Algo. + // + mCurrentHashMask =3D mCurrentHashMask | HashMask; + + CopyMem (&mHashOps[mBaseHashInterfaceCount], HashInterface, sizeof(*Hash= Interface)); + mBaseHashInterfaceCount ++; + + DEBUG ((DEBUG_INFO,"RegisterHashApiLib: mBaseHashInterfaceCount update t= o 0x%x \n", mBaseHashInterfaceCount)); + + return EFI_SUCCESS; +} =20 /** The constructor function of BaseHashLib Dxe. @@ -45,18 +240,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. **/ EFI_STATUS EFIAPI -BaseHashLibApiPeiConstructor ( +BaseHashLibApiDxeConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - - // - // Set PcdHashAlgorithmBitmap to 0 in CONSTRUCTOR for CURRENT module. - // - Status =3D PcdSet32S (PcdHashAlgorithmBitmap, 0); - ASSERT_EFI_ERROR (Status); + mBaseHashInterfaceCount =3D 0; + mCurrentHashMask =3D 0; =20 return EFI_SUCCESS; } \ No newline at end of file diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.c b/SecurityPkg= /Library/BaseHashLib/BaseHashLibPei.c index 8ffe356b60e7..0fd0e2f42612 100644 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.c +++ b/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.c @@ -30,8 +30,318 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include +#include +#include =20 -#include "BaseHashLib.h" +#include +#include "BaseHashLibCommon.h" + +#define BASEHASH_LIB_PEI_ROUTER_GUID \ + { 0x19ea22c7, 0xf870, 0x4b5e, { 0x98, 0x86, 0x9c, 0x29, 0xb2, 0x20, 0xf0= , 0x39 } } + + +EFI_GUID mBaseHashLibPeiRouterGuid =3D BASEHASH_LIB_PEI_ROUTER_GUID; + +typedef struct { + // + // If gZeroGuid, SupportedHashMask is 0 for FIRST module which consumes = HashLib + // or the hash algorithm bitmap of LAST module which consumes HashLib. + // HashInterfaceCount and HashInterface are all 0. + // If gEfiCallerIdGuid, HashInterfaceCount, HashInterface and SupportedH= ashMask + // are the hash interface information of CURRENT module which consumes= HashLib. + // + EFI_GUID Identifier; + UINTN HashInterfaceCount; + HASH_INTERFACE_UNIFIED_API HashInterface[HASH_ALGO_COUNT]; + UINT32 SupportedHashMask; +} HASH_INTERFACE_HOB; + + +UINT32 +EFIAPI +GetApiHashMaskFromAlgo ( + IN EFI_GUID *HashGuid + ) +{ + UINTN Index; + + for (Index =3D 0; Index < sizeof(mHashMask)/sizeof(mHashMask[0]); Index+= +) { + if (CompareGuid (HashGuid, &mHashMask[Index].Guid)) { + return mHashMask[Index].Mask; + } + } + return 0; +} + +/** + This function gets hash interface hob. + + @param Identifier Identifier to get hash interface hob. + + @retval hash interface hob. +**/ +HASH_INTERFACE_HOB * +InternalGetBaseHashInterfaceHob ( + EFI_GUID *Identifier + ) +{ + EFI_PEI_HOB_POINTERS Hob; + HASH_INTERFACE_HOB *HashInterfaceHob; + + Hob.Raw =3D GetFirstGuidHob (&mBaseHashLibPeiRouterGuid); + while (Hob.Raw !=3D NULL) { + HashInterfaceHob =3D GET_GUID_HOB_DATA (Hob); + if (CompareGuid (&HashInterfaceHob->Identifier, Identifier)) { + // + // Found the matched one. + // + return HashInterfaceHob; + } + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextGuidHob (&mBaseHashLibPeiRouterGuid, Hob.Raw); + } + + return NULL; +} + +/** + This function creates hash interface hob. + + @param Identifier Identifier to create hash interface hob. + + @retval hash interface hob. +**/ +HASH_INTERFACE_HOB * +InternalCreateBaseHashInterfaceHob ( + EFI_GUID *Identifier + ) +{ + HASH_INTERFACE_HOB LocalHashInterfaceHob; + + ZeroMem (&LocalHashInterfaceHob, sizeof(LocalHashInterfaceHob)); + CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier); + return BuildGuidDataHob (&mBaseHashLibPeiRouterGuid, &LocalHashInterface= Hob, sizeof(LocalHashInterfaceHob)); +} + +/** + Init hash sequence. + + @param HashHandle Hash handle. + + @retval EFI_SUCCESS Hash start and HashHandle returned. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiInit ( + OUT HASH_HANDLE *HashHandle +) +{ + HASH_HANDLE *HashCtx; + HASH_INTERFACE_HOB *HashInterfaceHob; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gEfiCallerIdGuid); + if (HashInterfaceHob =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((HashInterfaceHob->HashInterfaceCount =3D=3D 0) || !(HashInterfaceHo= b->SupportedHashMask & HashPolicy)) { + DEBUG ((DEBUG_INFO,"Unsupported Hash Type 0x%x \n", HashPolicy)); + return EFI_UNSUPPORTED; + } + + HashCtx =3D AllocatePool (sizeof(*HashCtx)); + ASSERT (HashCtx !=3D NULL); + + for (Index =3D 0; Index < HashInterfaceHob->HashInterfaceCount; Index++)= { + HashMask =3D GetApiHashMaskFromAlgo (&HashInterfaceHob->HashInterface[= Index].HashGuid); + if ((HashMask & HashPolicy) !=3D 0) { + HashInterfaceHob->HashInterface[Index].HashInit (HashCtx); + break; + } + } + + // Check for hash type supported + if(Index =3D=3D HashInterfaceHob->HashInterfaceCount) + return EFI_UNSUPPORTED; + + *HashHandle =3D (HASH_HANDLE)HashCtx; + + return EFI_SUCCESS; +} + +/** + Update hash data. + + @param HashHandle Hash handle. + @param DataToHash Data to be hashed. + @param DataToHashLen Data size. + + @retval EFI_SUCCESS Hash updated. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiUpdate ( + IN HASH_HANDLE HashHandle, + IN VOID *DataToHash, + IN UINTN DataToHashLen +) +{ + HASH_INTERFACE_HOB *HashInterfaceHob; + HASH_HANDLE *HashCtx; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gEfiCallerIdGuid); + if (HashInterfaceHob =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((HashInterfaceHob->HashInterfaceCount =3D=3D 0) || !(HashInterfaceHo= b->SupportedHashMask & HashPolicy)) { + DEBUG ((DEBUG_INFO,"Unsupported Hash Type 0x%x \n", HashPolicy)); + return EFI_UNSUPPORTED; + } + + HashCtx =3D (HASH_HANDLE *)HashHandle; + + for (Index =3D 0; Index < HashInterfaceHob->HashInterfaceCount; Index++)= { + HashMask =3D GetApiHashMaskFromAlgo (&HashInterfaceHob->HashInterface[= Index].HashGuid); + if ((HashMask & HashPolicy) !=3D 0) { + HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[0], DataT= oHash, DataToHashLen); + break; + } + } + + // Check for hash type supported + if(Index =3D=3D HashInterfaceHob->HashInterfaceCount) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Hash complete. + + @param HashHandle Hash handle. + @param Digest Hash Digest. + + @retval EFI_SUCCESS Hash complete and Digest is returned. +**/ +EFI_STATUS +EFIAPI +HashApiFinal ( + IN HASH_HANDLE HashHandle, + OUT UINT8 *Digest +) +{ + HASH_INTERFACE_HOB *HashInterfaceHob; + HASH_HANDLE *HashCtx; + UINTN Index; + UINT32 HashMask; + UINT32 HashPolicy; + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gEfiCallerIdGuid); + if (HashInterfaceHob =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + HashPolicy =3D PcdGet32 (PcdSystemHashPolicy); + + if ((HashInterfaceHob->HashInterfaceCount =3D=3D 0) || !(HashInterfaceHo= b->SupportedHashMask & HashPolicy)) { + DEBUG ((DEBUG_INFO,"Unsupported Hash Type 0x%x \n", HashPolicy)); + return EFI_UNSUPPORTED; + } + + HashCtx =3D (HASH_HANDLE *)HashHandle; + + for (Index =3D 0; Index < HashInterfaceHob->HashInterfaceCount; Index++)= { + HashMask =3D GetApiHashMaskFromAlgo (&HashInterfaceHob->HashInterface[= Index].HashGuid); + if (HashMask & HashPolicy) { + HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[0], &Diges= t); + break; + } + } + + // Check for hash type supported + if(Index =3D=3D HashInterfaceHob->HashInterfaceCount){ + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + This service registers Hash Interface. + + @param HashInterface Hash interface + + @retval EFI_SUCCESS This hash interface is registered successfu= lly. + @retval EFI_UNSUPPORTED System does not support register this inter= face. + @retval EFI_ALREADY_STARTED System already register this interface. +**/ +EFI_STATUS +EFIAPI +RegisterHashApiLib ( + IN HASH_INTERFACE_UNIFIED_API *HashInterface + ) +{ +// EFI_STATUS Status; + UINTN Index; + UINT32 HashMask; + HASH_INTERFACE_HOB *HashInterfaceHob; + + // + // Check Allow + // + HashMask =3D GetApiHashMaskFromAlgo (&HashInterface->HashGuid); + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gEfiCallerIdGuid); + if (HashInterfaceHob =3D=3D NULL) { + HashInterfaceHob =3D InternalCreateBaseHashInterfaceHob (&gEfiCallerId= Guid); + if (HashInterfaceHob =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } else { + // Initialize SupportedHashMask + HashInterfaceHob->SupportedHashMask =3D 0; + } + } + + if (HashInterfaceHob->HashInterfaceCount >=3D HASH_COUNT) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Check duplication + // + for (Index =3D 0; Index < HashInterfaceHob->HashInterfaceCount; Index++)= { + if (CompareGuid (&HashInterfaceHob->HashInterface[Index].HashGuid, &Ha= shInterface->HashGuid)) { + DEBUG ((DEBUG_ERROR, "Hash Interface (%g) has been already registere= d\n", &HashInterface->HashGuid)); + return EFI_ALREADY_STARTED; + } + } + + // + // Register the Hash Algo. + // + HashInterfaceHob->SupportedHashMask =3D HashInterfaceHob->SupportedHashM= ask | HashMask; + + CopyMem (&HashInterfaceHob->HashInterface[HashInterfaceHob->HashInterfac= eCount], HashInterface, sizeof(*HashInterface)); + HashInterfaceHob->HashInterfaceCount ++; + + DEBUG ((DEBUG_INFO,"RegisterHashApiLib: HashInterfaceCount 0x%x Support= edHashMask 0x%x \n", HashInterfaceHob->HashInterfaceCount, HashInterfaceHo= b->SupportedHashMask)); + + return EFI_SUCCESS; +} =20 /** The constructor function of BaseHashLib Pei. @@ -50,13 +360,37 @@ BaseHashLibApiPeiConstructor ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; +// EFI_STATUS Status; + HASH_INTERFACE_HOB *HashInterfaceHob; =20 - // - // Set PcdHashAlgorithmBitmap to 0 in CONSTRUCTOR for CURRENT module. - // - Status =3D PcdSet32S (PcdHashAlgorithmBitmap, 0); - ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO,"Calling BaseHashLibApiPeiConstructor.. \n")); + + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gZeroGuid); + if (HashInterfaceHob =3D=3D NULL) { + // + // No HOB with gZeroGuid Identifier has been created, + // this is FIRST module which consumes HashLib. + // Create the HOB with gZeroGuid Identifier. + // + HashInterfaceHob =3D InternalCreateBaseHashInterfaceHob (&gZeroGuid); + if (HashInterfaceHob =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + + HashInterfaceHob =3D InternalGetBaseHashInterfaceHob (&gEfiCallerIdGuid); + if (HashInterfaceHob !=3D NULL) { + // + // In PEI phase, some modules may call RegisterForShadow and will be + // shadowed and executed again after memory is discovered. + // This is the second execution of this module, clear the hash interfa= ce + // information registered at its first execution. + // + ZeroMem (&HashInterfaceHob->HashInterface, sizeof (HashInterfaceHob->H= ashInterface)); + HashInterfaceHob->HashInterfaceCount =3D 0; + HashInterfaceHob->SupportedHashMask =3D 0; + } =20 return EFI_SUCCESS; } \ No newline at end of file diff --git a/SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.c = b/SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.c index 06e88f00d70b..175499e7609c 100644 --- a/SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.c +++ b/SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.c @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include +#include =20 /** Start hash sequence. diff --git a/SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha25= 6.c b/SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha256.c index 129d60a387fd..9222a12a3273 100644 --- a/SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha256.c +++ b/SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha256.c @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include +#include =20 /** Start hash sequence. diff --git a/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha38= 4.c b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c index 0d1b8f3e877a..c23b1a567172 100644 --- a/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c +++ b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include +#include =20 /** Start hash sequence. diff --git a/SecurityPkg/Include/Library/BaseHashLib.h b/SecurityPkg/Includ= e/Library/BaseHashLib.h new file mode 100644 index 000000000000..36dd2912d7eb --- /dev/null +++ b/SecurityPkg/Include/Library/BaseHashLib.h @@ -0,0 +1,153 @@ +/** @file + The internal header file includes the common header files, defines + internal structure and functions used by ImageVerificationLib. + +Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD = License +which accompanies this distribution. The full text of the license may be = found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#ifndef __BASEHASHLIB_H_ +#define __BASEHASHLIB_H_ + +#include +#include +#include + +// +// Hash Algorithms +// +#define HASH_ALG_DEFAULT 0x00000000 +#define HASH_ALG_SHA1 0x00000001 +#define HASH_ALG_SHA256 0x00000002 +#define HASH_ALG_SHA384 0x00000004 +#define HASH_ALG_SHA512 0x00000008 +#define HASH_ALG_SM3_256 0x00000010 + + +/** + Init hash sequence. + + @param HashType Type of hash algorithm. + @param HashHandle Hash handle. + + @retval EFI_SUCCESS Hash start and HashHandle returned. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiInit ( + IN UINT32 HashType, + OUT HASH_HANDLE *HashHandle +); + +/** + Update hash data. + + @param HashHandle Hash handle. + @param HashType Type of hash algorithm. + @param DataToHash Data to be hashed. + @param DataToHashLen Data size. + + @retval EFI_SUCCESS Hash updated. + @retval EFI_UNSUPPORTED System has no HASH library registered. +**/ +EFI_STATUS +EFIAPI +HashApiUpdate ( + IN HASH_HANDLE HashHandle, + IN UINT32 HashType, + IN VOID *DataToHash, + IN UINTN DataToHashLen +); + +/** + Hash complete. + + @param HashHandle Hash handle. + @param HashType Type of hash algorithm. + @param Digest Hash Digest. + + @retval EFI_SUCCESS Hash complete and Digest is returned. +**/ +EFI_STATUS +EFIAPI +HashApiFinal ( + IN HASH_HANDLE HashHandle, + IN UINT32 HashType, + OUT UINT8 *Digest +); + +/** + Start hash sequence. + + @param HashHandle Hash handle. + + @retval EFI_SUCCESS Hash sequence start and HandleHandle return= ed. + @retval EFI_OUT_OF_RESOURCES No enough resource to start hash. +**/ +typedef +EFI_STATUS +(EFIAPI *BASE_HASH_INIT) ( + OUT HASH_HANDLE *HashHandle + ); + +/** + Update hash sequence data. + + @param HashHandle Hash handle. + @param DataToHash Data to be hashed. + @param DataToHashLen Data size. + + @retval EFI_SUCCESS Hash sequence updated. +**/ +typedef +EFI_STATUS +(EFIAPI *BASE_HASH_UPDATE) ( + IN HASH_HANDLE HashHandle, + IN VOID *DataToHash, + IN UINTN DataToHashLen + ); + +/** + Hash complete. + @param HashHandle Hash handle. + @param Digest Hash Digest. + @retval EFI_SUCCESS Hash complete and Digest is returned. +**/ +typedef +EFI_STATUS +(EFIAPI *BASE_HASH_FINAL_EX) ( + IN HASH_HANDLE HashHandle, + OUT UINT8 **Digest + ); + +typedef struct { + EFI_GUID HashGuid; + BASE_HASH_INIT HashInit; + BASE_HASH_UPDATE HashUpdate; + BASE_HASH_FINAL_EX HashFinal; +} HASH_INTERFACE_UNIFIED_API; + +/** + This service registers Hash Interface. + + @param HashInterface Hash interface + + @retval EFI_SUCCESS This hash interface is registered successfu= lly. + @retval EFI_UNSUPPORTED System does not support register this inter= face. + @retval EFI_ALREADY_STARTED System already register this interface. +**/ +EFI_STATUS +EFIAPI +RegisterHashApiLib ( + IN HASH_INTERFACE_UNIFIED_API *HashInterface +); + +#endif \ No newline at end of file diff --git a/SecurityPkg/Include/Library/HashLib.h b/SecurityPkg/Include/Li= brary/HashLib.h index 740cb8188e51..6ad960ad70ee 100644 --- a/SecurityPkg/Include/Library/HashLib.h +++ b/SecurityPkg/Include/Library/HashLib.h @@ -87,53 +87,6 @@ HashAndExtend ( OUT TPML_DIGEST_VALUES *DigestList ); =20 -/** - Init hash sequence. - - @param HashHandle Hash handle. - - @retval EFI_SUCCESS Hash start and HashHandle returned. - @retval EFI_UNSUPPORTED System has no HASH library registered. -**/ -EFI_STATUS -EFIAPI -HashApiInit ( - OUT HASH_HANDLE *HashHandle -); - -/** - Update hash data. - - @param HashHandle Hash handle. - @param DataToHash Data to be hashed. - @param DataToHashLen Data size. - - @retval EFI_SUCCESS Hash updated. - @retval EFI_UNSUPPORTED System has no HASH library registered. -**/ -EFI_STATUS -EFIAPI -HashApiUpdate ( - IN HASH_HANDLE HashHandle, - IN VOID *DataToHash, - IN UINTN DataToHashLen -); - -/** - Hash complete. - - @param HashHandle Hash handle. - @param Digest Hash Digest. - - @retval EFI_SUCCESS Hash complete and Digest is returned. -**/ -EFI_STATUS -EFIAPI -HashApiFinal ( - IN HASH_HANDLE HashHandle, - OUT UINT8 *Digest -); - /** Start hash sequence. =20 @@ -180,21 +133,6 @@ EFI_STATUS OUT TPML_DIGEST_VALUES *DigestList ); =20 -/** - Hash complete. - - @param HashHandle Hash handle. - @param Digest Hash Digest. - - @retval EFI_SUCCESS Hash complete and Digest is returned. -**/ -typedef -EFI_STATUS -(EFIAPI *HASH_FINAL_EX) ( - IN HASH_HANDLE HashHandle, - OUT UINT8 **Digest - ); - #define HASH_ALGORITHM_SHA1_GUID EFI_HASH_ALGORITHM_SHA1_GUID #define HASH_ALGORITHM_SHA256_GUID EFI_HASH_ALGORITHM_SHA256_GUID #define HASH_ALGORITHM_SHA384_GUID EFI_HASH_ALGORITHM_SHA384_GUID @@ -211,13 +149,6 @@ typedef struct { HASH_FINAL HashFinal; } HASH_INTERFACE; =20 -typedef struct { - EFI_GUID HashGuid; - HASH_INIT HashInit; - HASH_UPDATE HashUpdate; - HASH_FINAL_EX HashFinal; -} HASH_INTERFACE_UNIFIED_API; - /** This service register Hash. =20 @@ -233,18 +164,4 @@ RegisterHashInterfaceLib ( IN HASH_INTERFACE *HashInterface ); =20 -/** - This service registers Hash Interface. - - @param HashInterface Hash interface - - @retval EFI_SUCCESS This hash interface is registered successfu= lly. - @retval EFI_UNSUPPORTED System does not support register this inter= face. - @retval EFI_ALREADY_STARTED System already register this interface. -**/ -EFI_STATUS -EFIAPI -RegisterHashApiLib ( - IN HASH_INTERFACE_UNIFIED_API *HashInterface -); #endif diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLib.h b/SecurityPkg/Li= brary/BaseHashLib/BaseHashLib.h deleted file mode 100644 index 70676c1716c3..000000000000 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLib.h +++ /dev/null @@ -1,85 +0,0 @@ -/** @file - The internal header file includes the common header files, defines - internal structure and functions used by ImageVerificationLib. - -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD = License -which accompanies this distribution. The full text of the license may be = found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. - -**/ - -#ifndef __BASEHASHLIB_H_ -#define __BASEHASHLIB_H_ - -#define HASH_ALGO_COUNT 7 - -// -// Hash Algorithms -// -#define HASH_ALG_SHA1 0x00000001 -#define HASH_ALG_SHA256 0x00000002 -#define HASH_ALG_SHA384 0x00000004 -#define HASH_ALG_SHA512 0x00000008 -#define HASH_ALG_SM3_256 0x00000010 -#if 0 -typedef=20 -UINTN -(EFIAPI *GET_HASH_CTX_SIZE) ( - VOID - ); - -typedef -BOOLEAN -(EFIAPI *_HASH_INIT) ( - OUT VOID *ShaContext - ); - -typedef -BOOLEAN -(EFIAPI *_HASH_DUPLICATE) ( - IN CONST VOID *ShaContext, - OUT VOID *NewShaContext - ); - -typedef -BOOLEAN -(EFIAPI *_HASH_UPDATE) ( - IN OUT VOID *ShaContext, - IN CONST VOID *Data, - IN UINTN DataSize - ); - -typedef -BOOLEAN -(EFIAPI *_HASH_FINAL) ( - IN OUT VOID *ShaContext, - OUT UINT8 *HashValue - ); - -HASH_ALGO_IDX -GetHashAlgoIndex ( - VOID -); - -typedef struct { - HASH_ALGO_IDX HashAlgo; - GET_HASH_CTX_SIZE GetHashCtxSize; - _HASH_INIT HashInit; - _HASH_DUPLICATE HashDuplicate; - _HASH_UPDATE HashUpdate; - _HASH_FINAL HashFinal; -} HASH_OPERATIONS; - - -EFI_STATUS -EFIAPI -RegisterHashLib ( - IN HASH_OPERATIONS *HashInterface -); -#endif -#endif \ No newline at end of file diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLibCommon.h b/Security= Pkg/Library/BaseHashLib/BaseHashLibCommon.h new file mode 100644 index 000000000000..dc4839d16600 --- /dev/null +++ b/SecurityPkg/Library/BaseHashLib/BaseHashLibCommon.h @@ -0,0 +1,35 @@ +/** @file + The internal header file includes the common header files, defines + internal structure and functions used by ImageVerificationLib. + +Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD = License +which accompanies this distribution. The full text of the license may be = found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#ifndef __BASEHASHLIB_COMMON_H_ +#define __BASEHASHLIB_COMMON_H_ + +#define HASH_ALGO_COUNT 5 + + +typedef struct { + EFI_GUID Guid; + UINT32 Mask; +} HASH_MASK; + +HASH_MASK mHashMask[] =3D { + {HASH_ALGORITHM_SHA1_GUID, HASH_ALG_SHA1}, + {HASH_ALGORITHM_SHA256_GUID, HASH_ALG_SHA256}, + {HASH_ALGORITHM_SHA384_GUID, HASH_ALG_SHA384}, + {HASH_ALGORITHM_SHA512_GUID, HASH_ALG_SHA512}, + {HASH_ALGORITHM_SM3_256_GUID, HASH_ALG_SM3_256}, +}; + +#endif \ No newline at end of file diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.inf b/SecurityP= kg/Library/BaseHashLib/BaseHashLibDxe.inf index f5dcbedb2cd9..a8d6c0f37570 100644 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.inf +++ b/SecurityPkg/Library/BaseHashLib/BaseHashLibDxe.inf @@ -43,7 +43,5 @@ [LibraryClasses] PcdLib =20 [Pcd] - gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask ## CONSUMES - gEfiSecurityPkgTokenSpaceGuid.PcdHashAlgorithmBitmap ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdSystemHashPolicy ## CONSUMES =20 diff --git a/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.inf b/SecurityP= kg/Library/BaseHashLib/BaseHashLibPei.inf index 07e95a5a9c0f..872989f2352d 100644 --- a/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.inf +++ b/SecurityPkg/Library/BaseHashLib/BaseHashLibPei.inf @@ -44,7 +44,5 @@ [LibraryClasses] PcdLib =20 [Pcd] - gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask ## CONSUMES - gEfiSecurityPkgTokenSpaceGuid.PcdHashAlgorithmBitmap ## CONSUMES - gEfiSecurityPkgTokenSpaceGuid.PcdSystemHashPolicy ## CONSUMES + gEfiSecurityPkgTokenSpaceGuid.PcdSystemHashPolicy ## CONSUMES =20 diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index b03677a5411c..2f31b0192fdb 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -515,14 +515,5 @@ [PcdsDynamic, PcdsDynamicEx] # @ValidRange 0x80000001 | 0x00000000 - 0x00000005 gEfiSecurityPkgTokenSpaceGuid.PcdSystemHashPolicy|0x02|UINT32|0x00010024 =20 - ## This PCD indicated final BIOS supported Hash mask for Base Hash API. - # Bios may choose to register a subset of PcdTpm2HashMask. - # This PCD is final value of how many hash algo are registered with - # Base Hash API. - # This PCD will start with value 0 by the Base Hash API constructor and - # the value will be updated as Hash Algo are registered. - # @Prompt Hash Algorithm bitmap for Base Hash API. - gEfiSecurityPkgTokenSpaceGuid.PcdHashAlgorithmBitmap|0xFFFFFFFF|UINT32|0= x00010025 - [UserExtensions.TianoCore."ExtraFiles"] SecurityPkgExtra.uni diff --git a/SecurityPkg/SecurityPkg.uni b/SecurityPkg/SecurityPkg.uni index 2dc77279210c..c9d12535b5f4 100644 --- a/SecurityPkg/SecurityPkg.uni +++ b/SecurityPkg/SecurityPkg.uni @@ -309,12 +309,3 @@ = "0x00000003 - SHA384.
\n" = "0x00000004 - SHA512.
\n" = "0x00000005 - SM3.
" - -#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdHashAlgorithmBitmap_PROMPT #= language en-US "Hash Algorithm bitmap for Base Hash API." - -#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdHashAlgorithmBitmap_HELP #la= nguage en-US "This PCD indicated final BIOS supported Hash mask for Base Ha= sh API.\n" - = "Bios may choose to register a subset of PcdTpm2HashMask.
= \n" - = "This PCD is final value of how many hash algo are registered= with\n" - = "Base Hash API.
\n" - = "This PCD will start with value 0 by the Base Hash API constr= uctor and\n" - = "the value will be updated as Hash Algo are registered.
\n" --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52387): https://edk2.groups.io/g/devel/message/52387 Mute This Topic: https://groups.io/mt/68808208/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-