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 86037D80127 for ; Mon, 18 Mar 2024 20:43:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=qrfrR1pBZNDTx70AvWge/Nvj+QyHFUVGWGAmaIbNFkg=; 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=1710794606; v=1; b=eshEim3y9yo0f3kbBMDGuHEHVutZ7aWmwHqX+bsCHlUzE+hYT5N/5kcX6e6MIyAmqjbYnCzk n9RW0xhaAXoeeWrYrR97wUz8QDWUOCVyKxTo9pQ8YMsWRNtFKQ4FQi+g1+mLNwuY1ro2G/S2mba PjJUOAxwzvX3LrXWef8CP5Eog95Aa7ejJC3pvoNgBbDGH0FlNk0S83GFVrNPkbVFQzqeaxj01y5 b3Gnxj+rat9vlccncOaHZj/pb7XJEy8wsKaC9+KSZUNK4GDETajIMDCPT8ew7cCvjfEnRTkqX3b 348lSQCI1+Wba6F7Lh2t8u+sm3eTXNO+dNALiE6Pkpgfw== X-Received: by 127.0.0.2 with SMTP id lvtqYY7687511xTsHnNplTgc; Mon, 18 Mar 2024 13:43:26 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.115]) by mx.groups.io with SMTP id smtpd.web11.56303.1710794605230719285 for ; Mon, 18 Mar 2024 13:43:25 -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:43:21 +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:43:21 +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 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Thread-Topic: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Thread-Index: AQHaQyj9TPS+RfnJNECA43B03IM9rLE+Y1Jw Date: Mon, 18 Mar 2024 20:43:21 +0000 Message-ID: References: <20240109182053.2540542-1-stuart.yoder@arm.com> <20240109182053.2540542-3-stuart.yoder@arm.com> In-Reply-To: <20240109182053.2540542-3-stuart.yoder@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 48B7017C84499A41A596520FEEE69DD0.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: nXeAECBhWl5QkirhMS2+LJfxpIFjBEmmANUCka1u+jYZPE6Wi9u+QbUjgK3cBrs//7oU9wlfJAL2NoLhGaX6qhwbd/+lW66sJ6xyc4XHumblP+UeE3xAXr0k0wJAIKXqeMIIxvo5/vzOK1Y7lAFnFLjf99ybETRpuIfRmPqt8WOe81uUpr9+L87pL9xOVlg46EGQU1Jv0akUUHnQagyEwtRUGteFHwUdj1caAkVHEoEnsacND4wI6N+zqnSmPooBPB0qlF3tNx45wuPfntyRm4AJDNusPn6W7nIezP3XxCE8cUPOFHz2q62K1g/hinqauOSLuLtcGKN0JjKAxnjszp4gUcaNqB5bQ9pPuU2vwvv2ueTK8eEZZWM03i6ib3lyS7GBhJHa1aQNtmAVIwrhmFH2r/Rek2hF8UbEBwTbOj8Z+LANChehCck2i/dCtQTfk1kQY5pjjXCYusch6El/bazVnBFRWH7wfDkSOi+tm47/dGGnk8cTQ/oESkCacN0JGkwRVqTbcE4pe32BOZ1to+6gDxx8H96DB/0OVCntiEvCGmtEDbc+jOZcWd25r7NyEVANk787AgGl/PF/PxJkcwIreZyMJ2TKRhXFcv5Rpws= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ndY2okphu/2NjWDi+v/3SsZy94JAUH1KpitCiXWbap8lwP2H6HRTyDNKtJx0?= =?us-ascii?Q?YNDoZodAR73oPrlM21VgUtJmJdumHnzNLSwQn54I9ZEsbMniHgqFlwLlw00g?= =?us-ascii?Q?4D7IxbEwGCtah7vDMzxLtGwcwI6FZ4Cp7Pqhd5HNulTq/GBd+1xfZR6b7mrY?= =?us-ascii?Q?N0QcagHHPlJ1so0k7oqTyrrDBxXyb/tOXBJCWn8rNMGr71xjDbapsuAhtdy+?= =?us-ascii?Q?frD2015NjfM/TtasIDlIsLP9nGGNuEldaVpupypQpJe5wrqRD98Jo4BTbbtR?= =?us-ascii?Q?tQ95GLZI/rGLrFDAnnmR+nGFu/0WFSeg4RUvdZuw3bVN+T9P50JauRknj7dD?= =?us-ascii?Q?dTHIuWeCiR8MWloX3vzLh290OqopQYfLUdiexjtnJQD4UrvDmDx2ed3VZnaL?= =?us-ascii?Q?O+O+22E13AYs4JqXaiBCCmK2rvAo8z/2FDaNNTlnG0KEIayH+9qKppvPAePr?= =?us-ascii?Q?jdj8yWEcogEzEjUsVsb5mgnCTYB7L8FZF9fi1C6kqtgTqg/nUtY80bmoTAZJ?= =?us-ascii?Q?vvWHPu1cFJ0E2VGT3DWKPdQ0ozBUfgztLOgsw9eOsWb2zkQEd/jfNB6kJKZv?= =?us-ascii?Q?EXsWa5T6v2pSvHgu+lIBhWNOWNkQThXBhVfrM1fmqdJigT2Uw6pYYfzGxs8X?= =?us-ascii?Q?AEWtp/pkD8FwUtqO3DTuuKPE0cRY7ir/mt1V85Rr3X9cjY133CE+C6VczN/x?= =?us-ascii?Q?iU39X9nB2VLjcwbgpDnAOPJmz1YHRCrE5kxG9NkrnTQl81NKTKDCojVF9jCB?= =?us-ascii?Q?vwmz1brUV0P65F6QM45b4/9qlpJy+QucEGgSzEH448oPxEva0a2N6zUAwYQp?= =?us-ascii?Q?51rt39sQqLosuOuZqBnsaiIcUkINkcGGLLJwxQV4JOCtPX6E+7QgeMru3iSg?= =?us-ascii?Q?GN3bmb6F0C/ZGfpu89Q/w9It6o0aa9xXckK8EMICXyh+QYaur/Lr4boH9Vg2?= =?us-ascii?Q?hagHifSbKwKioPfr0TYF3UvAxp9WE6b6YRLoH666giTpjRUtiVuPdEZg+aZq?= =?us-ascii?Q?jmvo20T3mx+ORlwOMzIXTwMGi4ScVV1mgDpZ8RJeR6YL8OicRihxpKIUGOfm?= =?us-ascii?Q?RGJTjOK5/sJ+ZAWlO0+Tr8Btnvzf0T19dJAa5WkpP6CO7NVZmtNNPqP2c5CM?= =?us-ascii?Q?0vi87taia7RTNDG1yiK0GnqtqFFOaPWD3Pj3NazN/SZGR6ApUz2OHgjmCGGH?= =?us-ascii?Q?+AOHavxwIJbbow+yNPZrFB5eJgpBFZCngvBtYaa6VghiWVmhYtusrRZbn0e+?= =?us-ascii?Q?4AcPZWa2rq2TCouzyqe7dmtPAN8RPUhPWqAhdF7WfYJfJuRcsFkG3uNdudxR?= =?us-ascii?Q?eEdYPospb97bmozcT11DANTsThmk0FBVGvl8gtIpTk85nY4Nv7gMRFcVZ3jb?= =?us-ascii?Q?nhrou6v3ooQAoAEyAvO3aeoRnX6HJ/waf/3FB1lxe7g+dwNeRwmVmHriQ+Wz?= =?us-ascii?Q?ei9QRr4+kIhKhmZy+j7GuABF7wubyVgTqZA/1/ZiVtRNzvgzgDxpKS+1T0Qk?= =?us-ascii?Q?1HP/6gdlKp04jJCzZEBf7f1mMichULrWbPKP9UFqzjEZ/WwOQhsWl9hCwi6N?= =?us-ascii?Q?EwhAm2wahTYM9Iet1M4=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: 94b28a21-e9b9-426c-3b3a-08dc478c0cba X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 20:43:21.4068 (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: 14fHAoSNheNKP/3sU6EP2k1AajvoXv06tTFFEnd89lYdba4aLvy/IZGAVlbufOsyg5GYjeCToA9P3leE5gUUYQ== 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:43:25 -0700 Reply-To: devel@edk2.groups.io,Sunny.Wang@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: uwxW0RnF7DJV1pVhjLY96Z1gx7686176AA= 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=eshEim3y; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) 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 2/6] uefi-sct/SctPkg: TCG2 Protocol: add te= st infrastructure and GetCapability Test From: Joseph Hemann -implement initial infrastructure for the TCG2 protocol test including updates to .dsc file, inf file, GUID source files, update to Category.ini. -add test case for GetCapability(), as defined in the TCG EFI Protocol Spec 6.4.4. -add checkpoint for NULL pointer passed for buffer -add checkpoint for validating fields of the struct returned by GetCapabili= ty() Signed-off-by: Joseph Hemann Signed-off-by: Stuart Yoder --- uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc = | 1 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTest.inf | 51 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h = | 47 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTest.h | 77 +++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c = | 37 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTestConformance.c | 361 ++++++++++++++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTestMain.c | 102 ++++++ uefi-sct/SctPkg/CommonGenFramework.sh = | 1 + uefi-sct/SctPkg/Config/Data/Category.ini = | 7 + 9 files changed, 684 insertions(+) diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_= SCT.dsc index 155490fa39d3..96c93e73992c 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc @@ -301,6 +301,7 @@ SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityComman= d/BlackBoxTest/StorageSec SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProt= ocolBBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocol= BBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBB= Test.inf +SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/T= CG2ProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/Bla= ckBoxTest/TCG2ProtocolBBTest.inf new file mode 100644 index 000000000000..563d81b7e859 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTest.inf @@ -0,0 +1,51 @@ +## @file +# +# Copyright 2006 - 2015 Unified EFI, Inc.
+# Copyright (c) 2013, Intel Corporation. All rights reserved.
+# Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +# +## +#/*++ +# +# Module Name: +# +# TCG2ProtocolBBTest.inf +# +# Abstract: +# +# Component description file for TCG2 Protocol Black-Box Test. +# +#--*/ + +[defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D TCG2ProtocolBBTest + FILE_GUID =3D BD8CB762-3935-434C-AC3F-462244910A2D + MODULE_TYPE =3D UEFI_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeBBTestTCG2Protocol + +[sources.common] + Guid.c + TCG2ProtocolBBTestMain.c + TCG2ProtocolBBTestConformance.c + +[Packages] + MdePkg/MdePkg.dec + SctPkg/SctPkg.dec + SctPkg/UEFI/UEFI.dec + +[LibraryClasses] + UefiDriverEntryPoint + SctLib + EfiTestLib + +[Protocols] 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 new file mode 100644 index 000000000000..50b14272939f --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h @@ -0,0 +1,47 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +/*++ + +Module Name: + + guid.h + +Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID \ +{ 0xca93b02a, 0xe897, 0x4400, {0x81, 0x38, 0xc8, 0xa8, 0xcb, 0x2f, 0xc1, 0= xed }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid001; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID \ +{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0= x57 }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid002; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \ +{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0= x0c }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid003; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \ +{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0= x5f }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid004; 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 new file mode 100644 index 000000000000..a7ce2db322d9 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTest.h @@ -0,0 +1,77 @@ +/** @file + + Copyright 2006 - 2017 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +/*++ + +Module Name: + TCG2ProtocolBBTest.h + +Abstract: + head file of test driver of EFI TCG2 Protocol Test + +--*/ + +#include "SctLib.h" +#include +#include +#include "Guid.h" + +#define EFI_TCG2_TEST_REVISION 0x00010000 + +//////////////////////////////////////////////////////////////////////////= //// +// +// Entry GUIDs for Function Test +// +#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \ + {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0= x67} } + +EFI_STATUS +EFIAPI +BBTestTCG2ProtocolUnload ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + +EFI_STATUS +BBTestGetCapabilityConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + 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 new file mode 100644 index 000000000000..3e75ffdc0a60 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c @@ -0,0 +1,37 @@ +/** @file + + Copyright 2006 - 2013 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +/*++ + +Module Name: + + guid.c + +Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +#include "Efi.h" +#include "Guid.h" + +EFI_GUID gTcg2ConformanceTestAssertionGuid001 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_001_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid002 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_002_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid003 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_003_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid004 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_004_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 new file mode 100644 index 000000000000..686cf4baebcd --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestConformance.c @@ -0,0 +1,361 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +/*++ + +Module Name: + + TCG2BBTestConformance.c + +Abstract: + + for EFI Driver TCG2 Protocol's Basic Test + +--*/ + +#include "TCG2ProtocolBBTest.h" + +#define offsetof(st, m) __builtin_offsetof(st, m) + +/** + * @brief Entrypoint for GetCapability() Function Test. + * 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 + * @param SupportHandle A handle containing protocols required + * @return EFI_SUCCESS + * @return EFI_NOT_FOUND + */ + +EFI_STATUS +BBTestGetCapabilityConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_TCG2_PROTOCOL *TCG2; + + // + // init + // + TCG2 =3D (EFI_TCG2_PROTOCOL*)ClientInterface; + + // Ensure Protocol not NULL + if (TCG2 =3D=3D NULL) + return EFI_UNSUPPORTED; + + // + // Get the Standard Library Interface + // + Status =3D gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // Test Using NULL BootCapability Pointer + BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2); + + // Test for validating fields of struct returned by GetCapability() + BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2); + + // Test Using Capability struct with struct size less than 1.0 size + BBTestGetCapabilityConformanceTestCheckpoint3 (StandardLib, TCG2); + + // Test Using Capability struct with struct size equal to 1.0 size + BBTestGetCapabilityConformanceTestCheckpoint4 (StandardLib, TCG2); + + return EFI_SUCCESS; +} + + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + EFI_TCG2_BOOT_SERVICE_CAPABILITY *BootServiceCapPtr =3D NULL; + + Status =3D TCG2->GetCapability ( + TCG2, + BootServiceCapPtr); + + // Ensure GetCapability returns Invalid Parameter when passing in NULL p= ointer + if (EFI_INVALID_PARAMETER =3D=3D Status) { + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + } else { + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid001, + L"TCG2_PROTOCOL.GetCapability - GetCapability() returns E= FI_INVALID_PARAMETER with NULL pointer Capability Struct Passed in", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + CHAR8 StructureVersionMajor; + CHAR8 StructureVersionMinor; + CHAR8 ProtocolVersionMajor; + CHAR8 ProtocolVersionMinor; + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap; + + BootServiceCap.Size =3D sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY); + + Status =3D TCG2->GetCapability ( + TCG2, + &BootServiceCap); + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + if (Status !=3D EFI_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should return EFI_SUCCESS" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StructureVersionMajor =3D BootServiceCap.StructureVersion.Major; + StructureVersionMinor =3D BootServiceCap.StructureVersion.Minor; + + // TCG EFI Protocol spec 6.4.4 #4 + if ((StructureVersionMajor !=3D 1) | (StructureVersionMinor !=3D 1)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should have StructureVersion 1.1, reported value =3D %d.%d", + StructureVersionMajor, + StructureVersionMinor + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + ProtocolVersionMajor =3D BootServiceCap.ProtocolVersion.Major; + ProtocolVersionMinor =3D BootServiceCap.ProtocolVersion.Minor; + + // TCG EFI Protocol spec 6.4.4 #4 + if ((ProtocolVersionMajor !=3D 1) | (ProtocolVersionMinor !=3D 1)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should have ProtocolVersion 1.1, reported value =3D %d.%d", + ProtocolVersionMajor, + ProtocolVersionMinor + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + if (!(BootServiceCap.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256= )) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: unexpected ha= sh algorithms reported =3D %x", + BootServiceCap.HashAlgorithmBitmap + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + if (!(BootServiceCap.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG= _2)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= must support TCG2 event log format" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + for (int i =3D 0; i < sizeof(BootServiceCap.ActivePcrBanks); i++) { + if (((BootServiceCap.ActivePcrBanks & (1u << i)) !=3D 0) && + ((BootServiceCap.HashAlgorithmBitmap & (1u << i)) =3D=3D 0)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBank= s is not a subset of HashAlgorithmBitmap. Reported ActivePcrBanks:0x%x Hash= AlgorithmBitmap=3D0x%x", + BootServiceCap.ActivePcrBanks, + BootServiceCap.HashAlgorithmBitmap + ); + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + } + + if (BootServiceCap.NumberOfPcrBanks < 1 ) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: expect at lea= st 1 PCR bank" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify that ActivePcrBanks includes SHA256, SHA384, or SHA512 + EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos =3D EFI_TCG2_BOOT_HASH_= ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512; + + if (!(BootServiceCap.ActivePcrBanks & HashBitMapAlgos)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBank= s doesn't includes SHA256, SHA384, or SHA512", + BootServiceCap.ActivePcrBanks + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid002, + L"TCG2_PROTOCOL.GetCapability - GetCapability() populates= all elements of EFI_TCG_BOOT_SERVICE_CAPABILITY", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap; + + // set size to be value less than 1.0 or 1.1 struct + BootServiceCap.Size =3D 4; + + Status =3D TCG2->GetCapability ( + TCG2, + &BootServiceCap); + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + if (Status !=3D EFI_BUFFER_TOO_SMALL && BootServiceCap.Size !=3D sizeof(= EFI_TCG2_BOOT_SERVICE_CAPABILITY)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: Did not retur= n Status =3D=3D EFI_BUFFER_TOO_SMALL and Size =3D=3D sizeof(EFI_TCG2_BOOT_S= ERVICE_CAPABILITY)" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid003, + L"TCG2_PROTOCOL.GetCapability() - GetCapability() handlin= g of input struct size less than the size of EFI_TCG2_BOOT_SERVICE_CAPABILI= TY up to and including the ManufacturerID field", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BBTestGetCapabilityConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap; + + // set size of struct to be up to and including the ManufacturerID + // (this acts like a client with a 1.0 version of the struct) + BootServiceCap.Size =3D offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, Numbe= rOfPcrBanks); + + Status =3D TCG2->GetCapability ( + TCG2, + &BootServiceCap); + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + if (Status !=3D EFI_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: 1.0 Compatibi= lity. GetCapability should return EFI_SUCCESS" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify returned Size equals the size of EFI_TCG2_BOOT_SERVICE_CAPABIL= ITY up to and including the ManufacturerID field. + if (BootServiceCap.Size !=3D offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, = NumberOfPcrBanks)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol GetCapability Test: Did not retur= n Size =3D=3D EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the Manu= facturerID field" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid004, + L"TCG2_PROTOCOL.GetCapability - GetCapability() backwards= compatibility check for 1.0 version of EFI_TCG_BOOT_SERVICE_CAPABILITY", + L"%a:%d: Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/T= CG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/B= lackBoxTest/TCG2ProtocolBBTestMain.c new file mode 100644 index 000000000000..1de87e9d4c66 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestMain.c @@ -0,0 +1,102 @@ +/** @file + + Copyright 2006 - 2017 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +/*++ + +Module Name: + TCG2ProtocolBBTestMain.c + +Abstract: + for EFI TCG2 Protocol Test + +--*/ + +#include "TCG2ProtocolBBTest.h" + +EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField =3D { + EFI_TCG2_TEST_REVISION, + EFI_TCG2_PROTOCOL_GUID, + L"Testing For EFI TCG2 Protocol", + L"Total # test cases for the EFI TCG2 Protocol" +}; + +EFI_GUID gSupportProtocolGuid1[2] =3D { + EFI_STANDARD_TEST_LIBRARY_GUID, + EFI_NULL_GUID +}; + +EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] =3D { + { + EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101, + L"GetCapability_Conf", + L"Test the GetCapablity API", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestGetCapabilityConformanceTest + }, + 0 +}; + +EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface; + +/** + * Creates/installs the BlackBox Interface and eminating Entry Point + * node list. + * @param ImageHandle The test driver image handle + * @param SystemTable Pointer to System Table + * @return EFI_SUCCESS Indicates the interface was installed + * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could = not be allocated + * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid va= lue. + */ +EFI_STATUS +EFIAPI +InitializeBBTestTCG2Protocol ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EfiInitializeTestLib (ImageHandle, SystemTable); + + // + // initialize test utility lib + // + SctInitializeLib (ImageHandle, SystemTable); + + return EfiInitAndInstallBBTestInterface ( + &ImageHandle, + &gBBTestProtocolField, + gBBTestEntryField, + BBTestTCG2ProtocolUnload, + &gBBTestProtocolInterface + ); +} + +/** + * The driver's Unload function + * @param ImageHandle The test driver image handle + * @return EFI_SUCCESS Indicates the interface was Uninstalled +*/ +EFI_STATUS +EFIAPI +BBTestTCG2ProtocolUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + return EfiUninstallAndFreeBBTestInterface ( + ImageHandle, + gBBTestProtocolInterface + ); +} diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/Common= GenFramework.sh index fb9043b56bca..9c8662d841ae 100755 --- a/uefi-sct/SctPkg/CommonGenFramework.sh +++ b/uefi-sct/SctPkg/CommonGenFramework.sh @@ -210,6 +210,7 @@ then cp $ProcessorType/DiskIo2BBTest.efi $Framework/= Test/ > NUL cp $ProcessorType/TimeStampBBTest.efi $Framework/= Test/ > NUL cp $ProcessorType/RandomNumberBBTest.efi $Framework/= Test/ > NUL + cp $ProcessorType/TCG2ProtocolBBTest.efi $Framework/= Test/ > NUL cp $ProcessorType/Hash2BBTest.efi $Framework/= Test/ > NUL cp $ProcessorType/Pkcs7BBTest.efi $Framework/= Test/ > NUL cp $ProcessorType/ConfigKeywordHandlerBBTest.efi $Framework/= Test/ > NUL diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Con= fig/Data/Category.ini index b34d35db9ac8..4a53115b4d7d 100644 --- a/uefi-sct/SctPkg/Config/Data/Category.ini +++ b/uefi-sct/SctPkg/Config/Data/Category.ini @@ -1032,3 +1032,10 @@ CategoryGuid =3D CCD15FEC-6F73-4EEC-8395-3E69E4B940= BF InterfaceGuid =3D CCD15FEC-6F73-4EEC-8395-3E69E4B940BF Name =3D RiscvBootProtocolTest Description =3D RISC-V Boot Protocol Test + +[Category Data] +Revision =3D 0x00010000 +CategoryGuid =3D 607f766c-7455-42be-930b-e4d76db2720f +InterfaceGuid =3D 607f766c-7455-42be-930b-e4d76db2720f +Name =3D TCG2ProtocolTest +Description =3D TCG2 Protocol Test -- 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113489): https://edk2.groups.io/g/devel/message/113489 Mute This Topic: https://groups.io/mt/103625304/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 (#116846): https://edk2.groups.io/g/devel/message/116846 Mute This Topic: https://groups.io/mt/103625304/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-