From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ml01.01.org (Postfix) with ESMTP id 6D5B11A1DFE for ; Wed, 17 Aug 2016 22:08:14 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 17 Aug 2016 22:08:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,537,1464678000"; d="scan'208";a="750261166" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 17 Aug 2016 22:08:13 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 17 Aug 2016 22:08:13 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 17 Aug 2016 22:08:13 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.116]) with mapi id 14.03.0248.002; Thu, 18 Aug 2016 13:05:06 +0800 From: "Zhang, Chao B" To: "Wu, Hao A" , "edk2-devel@lists.01.org" , "Gao, Liming" CC: "Yao, Jiewen" Thread-Topic: [PATCH v2 6/6] SecurityPkg Tcg2: Remove use of module internal API InternalIsZeroBuffer() Thread-Index: AQHR+QykoyR8vA7A3kmq5MdQ3Ro956BOKffA Date: Thu, 18 Aug 2016 05:05:05 +0000 Message-ID: References: <1471496040-11796-1-git-send-email-hao.a.wu@intel.com> <1471496040-11796-7-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1471496040-11796-7-git-send-email-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDhjNGMzZjYtZDljMy00YzNjLWEwNjUtZjBlNzhiN2QwZGM2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImFKZlFxR3cyZm1jeTByNTBUNVNodDliWklYeHBLVG9leWZYTFloQ1dEaDA9In0= x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 6/6] SecurityPkg Tcg2: Remove use of module internal API InternalIsZeroBuffer() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2016 05:08:14 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Serial reviewed-by: Chao Zhang Thanks & Best regards Chao Zhang -----Original Message----- From: Wu, Hao A=20 Sent: Thursday, August 18, 2016 12:54 PM To: edk2-devel@lists.01.org; Gao, Liming Cc: Wu, Hao A; Yao, Jiewen; Zhang, Chao B Subject: [PATCH v2 6/6] SecurityPkg Tcg2: Remove use of module internal API= InternalIsZeroBuffer() This commit removes the internal implementation of the function InternalIsZeroBuffer(). Instead, it will use the API IsZeroBuffer() from BaseMemoryLib in MdePkg. Cc: Jiewen Yao Cc: Chao Zhang Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 29 +--------------------- SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 37 ++++---------------------= ---- SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 37 ++++---------------------= ---- 3 files changed, 11 insertions(+), 92 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c b/SecurityPkg/Tcg/= Tcg2Config/Tcg2ConfigImpl.c index 7a97f6b..5f4420c 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c @@ -617,33 +617,6 @@ FillBufferWithTCG2EventLogFormat ( } =20 /** - Check if buffer is all zero. - - @param[in] Buffer Buffer to be checked. - @param[in] BufferSize Size of buffer to be checked. - - @retval TRUE Buffer is all zero. - @retval FALSE Buffer is not all zero. -**/ -BOOLEAN -InternalIsZeroBuffer ( - IN VOID *Buffer, - IN UINTN BufferSize - ) -{ - UINT8 *BufferData; - UINTN Index; - - BufferData =3D Buffer; - for (Index =3D 0; Index < BufferSize; Index++) { - if (BufferData[Index] !=3D 0) { - return FALSE; - } - } - return TRUE; -} - -/** This function publish the TCG2 configuration Form for TPM device. =20 @param[in, out] PrivateData Points to TCG2 configuration private data= . @@ -735,7 +708,7 @@ InstallTcg2ConfigForm ( } else { TempBuffer[0] =3D 0; for (Index =3D 0; Index < Pcrs.count; Index++) { - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs= .pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSele= ctions[Index].sizeofSelect)) { AppendBufferWithTpmAlgHash (TempBuffer, sizeof(TempBuffer), Pcrs.p= crSelections[Index].hash); } } diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tc= g2Dxe.c index 5d97556..319f245 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c @@ -202,33 +202,6 @@ InternalDumpHex ( } =20 /** - Check if buffer is all zero. - - @param[in] Buffer Buffer to be checked. - @param[in] BufferSize Size of buffer to be checked. - - @retval TRUE Buffer is all zero. - @retval FALSE Buffer is not all zero. -**/ -BOOLEAN -InternalIsZeroBuffer ( - IN VOID *Buffer, - IN UINTN BufferSize - ) -{ - UINT8 *BufferData; - UINTN Index; - - BufferData =3D Buffer; - for (Index =3D 0; Index < BufferSize; Index++) { - if (BufferData[Index] !=3D 0) { - return FALSE; - } - } - return TRUE; -} - -/** Get All processors EFI_CPU_LOCATION in system. LocationBuf is allocated = inside the function Caller is responsible to free LocationBuf. =20 @@ -2471,31 +2444,31 @@ DriverEntry ( switch (Pcrs.pcrSelections[Index].hash) { case TPM_ALG_SHA1: TpmHashAlgorithmBitmap |=3D EFI_TCG2_BOOT_HASH_ALG_SHA1; - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePCRBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA1; } =20 break; case TPM_ALG_SHA256: TpmHashAlgorithmBitmap |=3D EFI_TCG2_BOOT_HASH_ALG_SHA256; - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePCRBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA256; } break; case TPM_ALG_SHA384: TpmHashAlgorithmBitmap |=3D EFI_TCG2_BOOT_HASH_ALG_SHA384; - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePCRBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA384; } break; case TPM_ALG_SHA512: TpmHashAlgorithmBitmap |=3D EFI_TCG2_BOOT_HASH_ALG_SHA512; - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePCRBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA512; } break; case TPM_ALG_SM3_256: TpmHashAlgorithmBitmap |=3D EFI_TCG2_BOOT_HASH_ALG_SM3_256; - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePCRBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SM3_256; } break; diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tc= g2Pei.c index 2cffed4..0d779f1 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c @@ -225,33 +225,6 @@ EndofPeiSignalNotifyCallBack ( } =20 /** - Check if buffer is all zero. - - @param[in] Buffer Buffer to be checked. - @param[in] BufferSize Size of buffer to be checked. - - @retval TRUE Buffer is all zero. - @retval FALSE Buffer is not all zero. -**/ -BOOLEAN -InternalIsZeroBuffer ( - IN VOID *Buffer, - IN UINTN BufferSize - ) -{ - UINT8 *BufferData; - UINTN Index; - - BufferData =3D Buffer; - for (Index =3D 0; Index < BufferSize; Index++) { - if (BufferData[Index] !=3D 0) { - return FALSE; - } - } - return TRUE; -} - -/** Get TPML_DIGEST_VALUES data size. =20 @param[in] DigestList TPML_DIGEST_VALUES data. @@ -383,27 +356,27 @@ SetTpm2HashMask ( DEBUG ((EFI_D_INFO, "hash - %x\n", Pcrs.pcrSelections[Index].hash)); switch (Pcrs.pcrSelections[Index].hash) { case TPM_ALG_SHA1: - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePcrBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA1; } =20 break; case TPM_ALG_SHA256: - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePcrBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA256; } break; case TPM_ALG_SHA384: - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePcrBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA384; } break; case TPM_ALG_SHA512: - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePcrBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SHA512; } break; case TPM_ALG_SM3_256: - if (!InternalIsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pc= rs.pcrSelections[Index].sizeofSelect)) { + if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSe= lections[Index].sizeofSelect)) { ActivePcrBanks |=3D EFI_TCG2_BOOT_HASH_ALG_SM3_256; } break; --=20 1.9.5.msysgit.0