From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7C3CFAC1A41 for ; Mon, 18 Mar 2024 20:44:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zDRE3FGb1NqE5z7TS9nmH/2xyQg+zxE1d7UlWm/59g4=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:nodisclaimer:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1710794653; v=1; b=40ZZtWj1+eUzGWdyEMankoCDRrAIDu6gdRaK/q6xLUWKBThOQeWkB3nge6MVs77evAMLNLrV 2t96i5vHvxNmkgfd5YQe57tZSpA+2L4CNqS0wHaHWGGujnWkWAS6jxbbemzA0MfGrVb1wagMvO9 hOWtJLesg+oO2WAFyCM/FWA0q61WRQD/T4458LB0LnH7GEQCoTrw2+AeYCaqD//eUtfI8+hbkcY BlymjL6jB64MpcTW7veqbO3PoJLZEwg3pVRSQlLHjO/Y6d3AaxMHOZ7cCP9qWqK2O0pfbIbXTon IaheRh72tvqoVLZ/j/DEdIPfOU1/1J2bU4sqIsBeA2Xhg== X-Received: by 127.0.0.2 with SMTP id 70VqYY7687511xdGJybAl8dI; Mon, 18 Mar 2024 13:44:13 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.123]) by mx.groups.io with SMTP id smtpd.web11.56329.1710794652209564845 for ; Mon, 18 Mar 2024 13:44:12 -0700 X-Received: from AS8PR08MB7791.eurprd08.prod.outlook.com (2603:10a6:20b:52d::6) by AM8PR08MB6545.eurprd08.prod.outlook.com (2603:10a6:20b:368::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 20:44:09 +0000 X-Received: from AS8PR08MB7791.eurprd08.prod.outlook.com ([fe80::8ed9:ec8b:75b7:f127]) by AS8PR08MB7791.eurprd08.prod.outlook.com ([fe80::8ed9:ec8b:75b7:f127%6]) with mapi id 15.20.7386.025; Mon, 18 Mar 2024 20:44:09 +0000 From: "Sunny Wang" To: "devel@edk2.groups.io" , Stuart Yoder , G Edhaya Chandran , "gaojie@byosoft.com.cn" CC: "ilias.apalodimas@linaro.org" , "heinrich.schuchardt@canonical.com" , Samer El-Haj-Mahmoud , "Jiewen.Yao@intel.com" , Sunny Wang Subject: Re: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Thread-Topic: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Thread-Index: AQHaQylUmnH1QcLiC0GQE7Eio5Ru3bE+Y6uA Date: Mon, 18 Mar 2024 20:44:09 +0000 Message-ID: References: <20240109182053.2540542-1-stuart.yoder@arm.com> <20240109182053.2540542-6-stuart.yoder@arm.com> In-Reply-To: <20240109182053.2540542-6-stuart.yoder@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 46144AA0C3B27B47A44A67496E1F6EF8.0 x-checkrecipientchecked: true x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS8PR08MB7791:EE_|AM8PR08MB6545:EE_ nodisclaimer: true x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 1k1PNrGkJQjNCTYCpT+cKLR5xl3wwC2fujmxUMyTzFNj9LYj+bld/q4d0rN5Qi1T1TCrXEiAM5hvHsdrZGDkRmPVuNSrkyKuIsuRSqUDqONW5y4JbSVGiEFSiepIjbB42ZaRrb3QKP/hlfeH9hNbift0O5zdoJ74f0DcAoTOdVqn7xvp4x54qPYQIVcwK2hifcFxFr02DJ8ydQzuOejPI5ne0HN7XBBNv7rcHCvvbf+oNwFqjjFXOMWXIthC/9V+STlYwR/y0o1NJEB6roEgzGMtAVqkTOycGa1YWYSaKv3GYAdYy/DVWDrLfblFDHUH22oV7EN9YmO43WF/uzeTpbhkacLAtKItLVxRRx9Fjvr+wcfDZpOoQEFddOey5EzjF1WnBJ6NJ+7H7EcGWWSJoiHOFraeWaTPR/5srlmVewmGi6edyt7ZHEiS+fDO9q9GwZCng37cHGTfxnyX6xwcP59TgbM11TATllbwn2p8asWshcMaQZi+LsTyrkuvwFXQAfxx6GGTnlY4NgDqP25dpYoU/f/pHMj59KlVGsP+XFXi3GxTiyoetV82OpP1n/wbd73IBllExO4LCLS7eafmmxK31mEnJMMION6ss10Xfjo= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?vspqdb2ZJzqaZTFmyfRYZUR+A7KLIoYnH2qjj52ncf9MSee/7t0DmT8H56Lv?= =?us-ascii?Q?8b4jJtU+mfgSvyc4v0ltwZrv/bS58Meo5SgqadDSDCR1HEetErjg26OHeNUi?= =?us-ascii?Q?cvhDimXT/4VFmq14FSmohjNRpiKEVOFFxQSPZluWQ/mF7IG2ixbPcuKYGMa0?= =?us-ascii?Q?g0Uk2RZfIIfM5KzZY1VwKqbq0PhoCLbkwIOaKdfLJqcnFDRSEYAr6OO0Cs7l?= =?us-ascii?Q?0YbfB+AvSuJohzPkjDCcHz7b8ne17OFbuKA6b4DROIuPUM1wrQ8bEE7RyhXT?= =?us-ascii?Q?tbvvuRkOgEtZRjsza3KwXucgjbakYEOsPp8SyljAkNLNCdXY+Hx0V9Hxk2vg?= =?us-ascii?Q?37AUNqUiSHbbjMQAt2/JXQTddBF6TLop5XLqWH5tXrLSEyhXRfXYxOSZoLrX?= =?us-ascii?Q?kHqqHMN+39ye8is2Aabi5c/f8sEbZH2fKx5h8kHIQp/4ZrXdw0XVHIKymvUA?= =?us-ascii?Q?CduuJ1YIXgumEdUjxUN2GRAekGgpnMiDTsh3T6VZ/udGyof4QnARPOYRegOI?= =?us-ascii?Q?8C88HjqlUcsJ7SBY3vd3lzYeS56R7aVEs0Gb8/ARt9PcxqoYjJWCycjU9e8q?= =?us-ascii?Q?8JMZ3dLdWmDTl10wsPi7r45cHw1bEmO7nWuN/T3PDJmhGsdg7phMcrc8/3Ln?= =?us-ascii?Q?nrDcBA8W+znPwl8uqzLz1OVQKyofcor3ib5vr+d+Bj3g8zDC/1ssSl71oi3K?= =?us-ascii?Q?lhy19Y8rzCfat+uRLMJ2I3TE4s1vomvgvobtB9SVMmc103ze7DYnJBnKTgx6?= =?us-ascii?Q?8rv4QA6BQmznIRc4T9ILuZnArbwqo6YxEdwsm7ZM1yrPxdkRWjviUMfJgNaS?= =?us-ascii?Q?Ej6QEKxBUmhLMC9g3IpQ9mwyk2ZDXAZICjXWlZkO96coPBqnnCC8DgQVhYHk?= =?us-ascii?Q?NPuxRiKE8hlpICWmxAWe0M5sVpknabDu7HHUHg9JswGNSIejqH2ItZimaliA?= =?us-ascii?Q?O5HYzSDuHcKRcDTz8ZfDAO4DeHu0LcrtfR46DwxrZR7KZl0mzSYCj42PIumr?= =?us-ascii?Q?C1skVSjOAd35yjVHcdqotFxpv7yPQ+B6dKPo+mcK2Ski9hktqoUKbHMerV6k?= =?us-ascii?Q?kMEEabQXGpDLnlHJ8Njhcqtz8hQ9q6T7t1jw2EazhFhci50n6voemDFGULIE?= =?us-ascii?Q?92EVgLE4ImZ1jlCCE5Qk50qTJjjMnoZN8mKnnFtQWfIBL0jDayUc9RF/je3z?= =?us-ascii?Q?w55UgLg5WWwGjmvTPP5Fpuy9QEF37Q3gHdiK7K0l68qaX2fhTomEL3AL7lIH?= =?us-ascii?Q?Upb0MQZZquaPPGcB+aD/j5PJAd7skWM0jfuJS0AxBLkJTH09qzIMSMCYB1qt?= =?us-ascii?Q?DiJDxbeyXY6o+pv6M9xDgH2MbedDO3xsA/xiyWMrmzdX1gap+hHxy3UXfNdW?= =?us-ascii?Q?Tl1zO/19m66CWgaEkhGcpFrmNptopFBGWGxOL0uYfgjM4rMQWKp+UgqqJ2g4?= =?us-ascii?Q?7ftgnoQlmNRNVj1OT04QagTwr0ui88W87LeBK93kFV6k6M5k8BL1w84MXw7J?= =?us-ascii?Q?h3P3Cq9uNP+t9CAh4tX7p9spW9KzVgzmDwJMcd6GqYqpzTC0Eajkxp5NBi3Y?= =?us-ascii?Q?S5atcEg27m3gIVnEIdA=3D?= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7791.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f2df3eb-22b2-4b3c-fc61-08dc478c294c X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 20:44:09.3593 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6PdITkEloX9hBswNzm2TCevkzfH2cEFwcgK5MhEoM6Cca6i6EOJSEl9DPk68BPesm3gwS8s0QIQIphPvia7aUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6545 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 18 Mar 2024 13:44:12 -0700 Reply-To: devel@edk2.groups.io,Sunny.Wang@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zhrxrSITp9e5XKqpVcUUqbgIx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=40ZZtWj1; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Looks good to me. For others' reference, the change has been already verified by running Syst= emReady SIE (Security Interface extension) tests on multiple SystemReady ce= rtified Arm systems. Reviewed-by: Sunny Wang -----Original Message----- From: devel@edk2.groups.io On Behalf Of Stuart Yoder= via groups.io Sent: Tuesday, January 9, 2024 12:21 PM To: devel@edk2.groups.io; G Edhaya Chandran ; gaoj= ie@byosoft.com.cn Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer E= l-Haj-Mahmoud ; Jiewen.Yao@intel.com Subject: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add Ge= tEventLog test From: Joseph Hemann -add test for GetEventLog() -test for valid and invalid event log format -test event log header -verify expected event log entry Signed-off-by: Joseph Hemann Signed-off-by: Stuart Yoder --- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h = | 20 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTest.h | 17 ++ uefi-sct/SctPkg/UEFI/Protocol/TCG2.h = | 46 +++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c = | 8 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTestConformance.c | 207 +++++++++++++++++++- 5 files changed, 297 insertions(+), 1 deletion(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/G= uid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h index dcfd5919acda..746ff83f899c 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h @@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011; { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0= x08 }} extern EFI_GUID gTcg2ConformanceTestAssertionGuid012; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \ +{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0= x35 }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid013; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \ +{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0= x90 }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid014; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \ +{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0= x51 }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid015; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \ +{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0= x76 }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid016; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/T= CG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/Black= BoxTest/TCG2ProtocolBBTest.h index cbbadef4a5c7..5ce275dc6258 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTest.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTest.h @@ -43,8 +43,13 @@ Abstract: #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0= x46} } +#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \ + {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0= x26} } + #define EV_POST_CODE 0x01 +#define EV_NO_ACTION 0x03 + #define EFI_TCG2_EXTEND_ONLY 0x0000000000000001 #define PE_COFF_IMAGE 0x0000000000000010 @@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 ( IN EFI_TCG2_PROTOCOL *TCG2 ); +EFI_STATUS +BBTestGetEventLogConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + +EFI_STATUS +BBTestGetEventLogConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + EFI_STATUS BBTestGetCapabilityConformanceTest ( IN EFI_BB_TEST_PROTOCOL *This, diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Pr= otocol/TCG2.h index e62ecd85cbe9..fd31204a9299 100644 --- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h +++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h @@ -50,6 +50,8 @@ Abstract: #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 +#define HASH_NUMBER 0x04 + typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP; @@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT { UINT8 Event[]; } EFI_TCG2_EVENT; +typedef struct { + UINT16 hashAlg; + UINT8 digest[]; +} TPMT_HA; + +typedef struct tdTPML_DIGEST_VALUES { + UINT32 Count; // number of digests + TPMT_HA Digests[HASH_NUMBER]; // Count digests +} TPML_DIGEST_VALUES; + +// This Declaration is for parsing the eventlog header which is defined to= be 20 bytes in TCG EFI Protocol Spec +typedef UINT8 TCG_DIGEST[20]; + +typedef struct tdTCG_PCR_EVENT2 { + TCG_PCRINDEX PCRIndex; // PCRIndex event extended to + TCG_EVENTTYPE EventType; // Type of event (see [2]) + TPML_DIGEST_VALUES Digests; // List of digests extended to //PCRIndex + UINT32 EventSize; // Size of the event data + UINT8 *Event; // The event data +} TCG_PCR_EVENT2; + +typedef struct tdTCG_PCR_EVENT { + UINT32 PCRIndex; // PCRIndex event extended to + UINT32 EventType; // Type of event (see EFI specs) + TCG_DIGEST Digest; // Value extended into PCRIndex + UINT32 EventSize; // Size of the event data + UINT8 Event[0]; // The event data +} TCG_PCR_EVENT; +// Structure to be added to the Event Log + +typedef struct tdTCG_EfiSpecIdEventAlgorithmSize { + UINT16 algorithmId; + UINT16 digestSize; +} TCG_EfiSpecIdEventAlgorithmSize; + +typedef struct tdTCG_EfiSpecIdEventStruct { + UINT8 signature[16]; + UINT32 platformClass; + UINT8 specVersionMinor; + UINT8 specVersionMajor; + UINT8 specErrata; + UINT8 uintnSize; +} TCG_EfiSpecIDEventStruct; + #pragma pack() typedef diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/G= uid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c index ccc20259d128..8c528aa8ddfc 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c @@ -51,3 +51,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid010 =3D EFI_TE= ST_TCG2CONFORMANCE_ASSERTI EFI_GUID gTcg2ConformanceTestAssertionGuid011 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_011_GUID; EFI_GUID gTcg2ConformanceTestAssertionGuid012 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_012_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid013 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_013_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid014 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_014_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid015 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_015_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid016 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_016_GUID; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/T= CG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol= /TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c index 2768eef725e8..ebe04d42aff5 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestConformance.c @@ -142,7 +142,7 @@ BBTestGetActivePcrBanksConformanceTest ( /** * @brief Entrypoint for HashLogExtendEvent() Function Test. - * 2 checkpoints will be tested. + * 4 checkpoints will be tested. * @param This a pointer of EFI_BB_TEST_PROTOCOL * @param ClientInterface A pointer to the interface array under test * @param TestLevel Test "thoroughness" control @@ -188,6 +188,12 @@ BBTestHashLogExtendEventConformanceTest ( // Test HashLogExtendEvent with valid arguments BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2); + // Test GetEventLog using invalid EventLog Format + BBTestGetEventLogConformanceTestCheckpoint1 (StandardLib, TCG2); + + // Test GetEventLog using valid EventLog Format + BBTestGetEventLogConformanceTestCheckpoint2 (StandardLib, TCG2); + return EFI_SUCCESS; } @@ -801,3 +807,202 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 ( return EFI_SUCCESS; } + +#define EFI_TCG2_INVALID_EVENT_LOG_FORMAT 0x20 + +EFI_STATUS +BBTestGetEventLogConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat; + EFI_PHYSICAL_ADDRESS EventLogLocation; + EFI_PHYSICAL_ADDRESS EventLogLastEntry; + BOOLEAN EventLogTruncated; + + // Ensure Get EventLog returns Invalid Parameter when passed invalid for= mat + EventLogFormat =3D EFI_TCG2_INVALID_EVENT_LOG_FORMAT; + + Status =3D TCG2->GetEventLog ( + TCG2, + EventLogFormat, + &EventLogLocation, + &EventLogLastEntry, + &EventLogTruncated); + + if (EFI_INVALID_PARAMETER !=3D Status) { + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } else { + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid013, + L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return= EFI_INVALID_PARAMETER when passed in invalid EventLog Format", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BBTestGetEventLogConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat; + EFI_PHYSICAL_ADDRESS EventLogLocation; + EFI_PHYSICAL_ADDRESS EventLogLastEntry; + BOOLEAN EventLogTruncated; + TCG_PCR_EVENT *EventLogHeader; + TCG_EfiSpecIDEventStruct *EventLogHeaderSpecEvent; + TCG_PCR_EVENT2 *LastEvent; + // signature as defined in the EFI protocol spec: "Spec ID Event03" + UINT8 signature[] =3D {0x53, 0x70, 0x65, 0x63, 0x20, 0x49, 0x44, 0x20, 0= x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x33, 0x00}; + + EventLogFormat =3D EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; + + // Call GetEventLog with valid EventLogFormat + Status =3D TCG2->GetEventLog ( + TCG2, + EventLogFormat, + &EventLogLocation, + &EventLogLastEntry, + &EventLogTruncated); + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + // Verify GetEventLog returns EFI_SUCCESS + if (Status !=3D EFI_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: GetEventLog sho= uld return EFI_SUCCESS with valid EventLogFormat, Status =3D %r", + Status + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid014, + L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return= EFI_SUCCESS", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + // If GetEventLog doesn't return EFI_SUCCESS abort test + if (Status !=3D EFI_SUCCESS) { + return Status; + } + + EventLogHeader =3D (TCG_PCR_EVENT *) EventLogLocation; + EventLogHeaderSpecEvent =3D (TCG_EfiSpecIDEventStruct *) EventLogHeader-= >Event; + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + + // Verify valid eventlog header is returned + // Verify EventLogHeader PCR index =3D=3D 0 + if (EventLogHeader->PCRIndex !=3D 0) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader = should have PCR index =3D=3D 0" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify EventLogHeader event type =3D EV_NO_ACTION + if (EventLogHeader->EventType !=3D EV_NO_ACTION) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader = should be EventType =3D=3D EV_NO_ACTION" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify EventLog Signature + Status =3D SctCompareMem(EventLogHeaderSpecEvent->signature, signature, = sizeof(signature)); + + if (Status !=3D EFI_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader = Signature did not match \'Spec ID Event03\'" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid015, + L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return= correct EventLogHeader", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + // Verify that the event log created by HashLogExtendEvent in the + // BBTestHashLogExtendEventConformanceTestCheckpoint2 function + // is actually in Eventlog + LastEvent =3D (TCG_PCR_EVENT2 *) EventLogLastEntry; + Status =3D EFI_SUCCESS; + + // Verify Last Event PCR =3D 16 + if (LastEvent->PCRIndex !=3D 16) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of La= st event should be 16" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify last event type =3D EV_POST_CODE + if (LastEvent->EventType !=3D EV_POST_CODE) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of la= st event should be type EV_POST_CODE" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid016, + L"TCG2_PROTOCOL.GetEventLog - verify that event log has e= xpected entry from previous HashLogExtendEvent", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} -- 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113491): https://edk2.groups.io/g/devel/message/113491 Mute This Topic: https://groups.io/mt/103625306/5985097 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com] -=3D-=3D-=3D-=3D-=3D-=3D IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you. -=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 (#116849): https://edk2.groups.io/g/devel/message/116849 Mute This Topic: https://groups.io/mt/103625306/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-