From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 120EB82009 for ; Sun, 5 Feb 2017 16:57:38 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 05 Feb 2017 16:57:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="62194129" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 05 Feb 2017 16:57:37 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 5 Feb 2017 16:57:37 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 5 Feb 2017 16:57:36 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Mon, 6 Feb 2017 08:57:35 +0800 From: "Zhang, Chao B" To: "Long, Qin" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH 1/2] SecurityPkg: Tcg2Dxe: Log EV_NO_ACTION event in TCG_PCR_EVENT2 format Thread-Index: AQHSfoaoE7jLSeX7ekixlJwFAIUW/KFYBSWAgAMlSJA= Date: Mon, 6 Feb 2017 00:57:34 +0000 Message-ID: References: <20170204013304.16360-1-chao.b.zhang@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/2] SecurityPkg: Tcg2Dxe: Log EV_NO_ACTION event in TCG_PCR_EVENT2 format 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: Mon, 06 Feb 2017 00:57:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Qin:=20 Thanks for your comments. I will follow TCG EFI Protocol spec to use Dige= sts. As for TCG_PCR_EVENT2 structure, I will keep Digest field unchanged, since it is an incompatible change. -----Original Message----- From: Long, Qin=20 Sent: Saturday, February 4, 2017 4:53 PM To: Zhang, Chao B ; edk2-devel@lists.01.org Cc: Yao, Jiewen Subject: RE: [PATCH 1/2] SecurityPkg: Tcg2Dxe: Log EV_NO_ACTION event in TC= G_PCR_EVENT2 format Please check the "Digests" and "Digest" in HDR definition, as my previous c= omment. Reviewed-by: Long Qin Best Regards & Thanks, LONG, Qin > -----Original Message----- > From: Zhang, Chao B > Sent: Saturday, February 04, 2017 9:33 AM > To: edk2-devel@lists.01.org > Cc: Long, Qin; Yao, Jiewen; Zhang, Chao B > Subject: [PATCH 1/2] SecurityPkg: Tcg2Dxe: Log EV_NO_ACTION event in > TCG_PCR_EVENT2 format >=20 > All the event log entry in TCG2 Event log format should be=20 > TCG_PCR_EVENT2 except event log header. Defined by TCG EFI Spec 2.0=20 > 00.13 > https://trustedcomputinggroup.org/wp-content/uploads/EFI-Protocol- > Specification-rev13-160330final.pdf >=20 > Cc: Long Qin > Cc: Yao Jiewen > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Chao Zhang > --- > SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 114 > ++++++++++++++++++++++++++++++++------ > 1 file changed, 96 insertions(+), 18 deletions(-) >=20 > diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c > b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c > index 860ee59..08c40db 100644 > --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c > +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c > @@ -169,6 +169,82 @@ InternalDumpData ( >=20 > /** >=20 > + This function initialize TCG_PCR_EVENT2 for EV_NO_ACTION Event Type=20 > + other than EFI Specification ID event The behavior is defined by=20 > + TCG PC Client PFP Spec. Section 9.3.4 EV_NO_ACTION Event Types > + > + @param[in, out] NoActionEvent Event Header of EV_NO_ACTION Event > + @param[in] EventSize Event Size of the EV_NO_ACTION Event > + > +**/ > +VOID > +InitNoActionEvent ( > + IN OUT TCG_PCR_EVENT2_HDR *NoActionEvent, > + IN UINT32 EventSize > + ) > +{ > + UINT32 DigestListCount; > + TPMI_ALG_HASH HashAlgId; > + UINT8 *DigestBuffer; > + > + DigestBuffer =3D (UINT8 *)NoActionEvent->Digest.digests; > + DigestListCount =3D 0; > + > + NoActionEvent->PCRIndex =3D 0; > + NoActionEvent->EventType =3D EV_NO_ACTION; > + > + // > + // Set Hash count & hashAlg accordingly, while=20 > + Digest.digests[n].digest to all 0 // ZeroMem=20 > + (&NoActionEvent->Digest, sizeof(NoActionEvent->Digest)); > + > + if ((mTcgDxeData.BsCap.ActivePcrBanks & > EFI_TCG2_BOOT_HASH_ALG_SHA1) !=3D 0) { > + HashAlgId =3D TPM_ALG_SHA1; > + CopyMem (DigestBuffer, &HashAlgId, sizeof(TPMI_ALG_HASH)); > + DigestBuffer +=3D sizeof(TPMI_ALG_HASH) + GetHashSizeFromAlgo > (HashAlgId); > + DigestListCount++; > + } > + > + if ((mTcgDxeData.BsCap.ActivePcrBanks & > EFI_TCG2_BOOT_HASH_ALG_SHA256) !=3D 0) { > + HashAlgId =3D TPM_ALG_SHA256; > + CopyMem (DigestBuffer, &HashAlgId, sizeof(TPMI_ALG_HASH)); > + DigestBuffer +=3D sizeof(TPMI_ALG_HASH) + GetHashSizeFromAlgo > (HashAlgId); > + DigestListCount++; > + } > + > + if ((mTcgDxeData.BsCap.ActivePcrBanks & > EFI_TCG2_BOOT_HASH_ALG_SHA384) !=3D 0) { > + HashAlgId =3D TPM_ALG_SHA384; > + CopyMem (DigestBuffer, &HashAlgId, sizeof(TPMI_ALG_HASH)); > + DigestBuffer +=3D sizeof(TPMI_ALG_HASH) + GetHashSizeFromAlgo > (HashAlgId); > + DigestListCount++; > + } > + > + if ((mTcgDxeData.BsCap.ActivePcrBanks & > EFI_TCG2_BOOT_HASH_ALG_SHA512) !=3D 0) { > + HashAlgId =3D TPM_ALG_SHA512; > + CopyMem (DigestBuffer, &HashAlgId, sizeof(TPMI_ALG_HASH)); > + DigestBuffer +=3D sizeof(TPMI_ALG_HASH) + GetHashSizeFromAlgo > (HashAlgId); > + DigestListCount++; > + } > + > + if ((mTcgDxeData.BsCap.ActivePcrBanks & > EFI_TCG2_BOOT_HASH_ALG_SM3_256) !=3D 0) { > + HashAlgId =3D TPM_ALG_SM3_256; > + CopyMem (DigestBuffer, &HashAlgId, sizeof(TPMI_ALG_HASH)); > + DigestBuffer +=3D sizeof(TPMI_ALG_HASH) + GetHashSizeFromAlgo > (HashAlgId); > + DigestListCount++; > + } > + > + // > + // Set Digests Count > + // > + WriteUnaligned32 ((UINT32 *)&NoActionEvent->Digest.count,=20 > + DigestListCount); > + > + // > + // Set Event Size > + // > + WriteUnaligned32((UINT32 *)DigestBuffer, EventSize); } > + > +/** > + > This function dump raw data with colume format. >=20 > @param Data raw data > @@ -1381,7 +1457,8 @@ SetupEventLog ( > UINT32 HashAlgorithmMaskCopied; > TCG_EfiSpecIDEventStruct *TcgEfiSpecIdEventStruct; > UINT8 TempBuf[sizeof(TCG_EfiSpecIDEventStruc= t) + > sizeof(UINT32) + (HASH_COUNT *=20 > sizeof(TCG_EfiSpecIdEventAlgorithmSize)) > + sizeof(UINT8)]; > - TCG_PCR_EVENT_HDR NoActionEvent; > + TCG_PCR_EVENT_HDR SpecIdEvent; > + TCG_PCR_EVENT2_HDR NoActionEvent; > TCG_EfiSpecIdEventAlgorithmSize *DigestSize; > TCG_EfiSpecIdEventAlgorithmSize *TempDigestSize; > UINT8 *VendorInfoSize; > @@ -1469,25 +1546,26 @@ SetupEventLog ( > VendorInfoSize =3D (UINT8 *)TempDigestSize; > *VendorInfoSize =3D 0; >=20 > - NoActionEvent.PCRIndex =3D 0; > - NoActionEvent.EventType =3D EV_NO_ACTION; > - ZeroMem (&NoActionEvent.Digest, sizeof(NoActionEvent.Digest)); > - NoActionEvent.EventSize =3D (UINT32)GetTcgEfiSpecIdEventStructSi= ze > (TcgEfiSpecIdEventStruct); > + SpecIdEvent.PCRIndex =3D 0; > + SpecIdEvent.EventType =3D EV_NO_ACTION; > + ZeroMem (&SpecIdEvent.Digest, sizeof(SpecIdEvent.Digest)); > + SpecIdEvent.EventSize =3D=20 > + (UINT32)GetTcgEfiSpecIdEventStructSize > + (TcgEfiSpecIdEventStruct); >=20 > // > - // Log TcgEfiSpecIdEventStruct as the first Event > + // Log TcgEfiSpecIdEventStruct as the first Event. Event=20 > + format is > TCG_PCR_EVENT. > + // TCG EFI Protocol Spec. Section 5.3 Event Log Header > // TCG PC Client PFP spec. Section 9.2 Measurement Event Entri= es and > Log > // > Status =3D TcgDxeLogEvent ( > mTcg2EventInfo[Index].LogFormat, > - &NoActionEvent, > - sizeof(NoActionEvent), > + &SpecIdEvent, > + sizeof(SpecIdEvent), > (UINT8 *)TcgEfiSpecIdEventStruct, > - NoActionEvent.EventSize > + SpecIdEvent.EventSize > ); >=20 > // > - // EfiStartupLocalityEvent > + // EfiStartupLocalityEvent. Event format is TCG_PCR_EVENT2 > // > GuidHob.Guid =3D GetFirstGuidHob (&gTpm2StartupLocalityHobGuid); > if (GuidHob.Guid !=3D NULL) { > @@ -1496,25 +1574,25 @@ SetupEventLog ( > // > StartupLocalityEvent.StartupLocality =3D *(UINT8=20 > *)(GET_GUID_HOB_DATA (GuidHob.Guid)); > CopyMem (StartupLocalityEvent.Signature,=20 > TCG_EfiStartupLocalityEvent_SIGNATURE, > sizeof(StartupLocalityEvent.Signature)); > - > - NoActionEvent.PCRIndex =3D 0; > - NoActionEvent.EventType =3D EV_NO_ACTION; > - ZeroMem (&NoActionEvent.Digest, sizeof(NoActionEvent.Digest)); > - NoActionEvent.EventSize =3D sizeof(StartupLocalityEvent); > - > DEBUG ((DEBUG_INFO, "SetupEventLog: Set Locality from HOB=20 > into StartupLocalityEvent 0x%02x\n",=20 > StartupLocalityEvent.StartupLocality)); >=20 > // > + // Initialize StartupLocalityEvent > + // > + InitNoActionEvent(&NoActionEvent,=20 > + sizeof(StartupLocalityEvent)); > + > + // > // Log EfiStartupLocalityEvent as the second Event > // TCG PC Client PFP spec. Section 9.3.4.3 Startup Locality = Event > // > Status =3D TcgDxeLogEvent ( > mTcg2EventInfo[Index].LogFormat, > &NoActionEvent, > - sizeof(NoActionEvent), > + sizeof(NoActionEvent.PCRIndex) + > + sizeof(NoActionEvent.EventType) + GetDigestListBinSize > + (&NoActionEvent.Digest) + sizeof(NoActionEvent.EventSize), > (UINT8 *)&StartupLocalityEvent, > - NoActionEvent.EventSize > + sizeof(StartupLocalityEvent) > ); > + > } > } > } > -- > 1.9.5.msysgit.1