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 8BC83941DB0 for ; Tue, 9 Jan 2024 18:21:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Lx6AVr595AbGp0y6ae1AFd+W0NJ9lu/TlaIlL5V44eo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704824468; v=1; b=t4aEJhLUTLeGAGRMi1UoZ5pwsKTIvzBQ+vcTUuI6VRmRVdLYs97nsNDed7R1vUTnx8Zyae6b 0WC8EBjTAwDb/uKwiWG3BaMrLfShzT55sKSR/B5bpnb078LWMMp6vj4TEVyhQ3RVAgLtZhgu/cP iljF7+DthxrnRlNPo/GTxwIs= X-Received: by 127.0.0.2 with SMTP id x0AIYY7687511xe4k4OV2nBP; Tue, 09 Jan 2024 10:21:08 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.24492.1704824465367807103 for ; Tue, 09 Jan 2024 10:21:05 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8772F14BF; Tue, 9 Jan 2024 10:21:50 -0800 (PST) X-Received: from beelzebub.ast.arm.com (unknown [10.118.29.240]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF7F53F5A1; Tue, 9 Jan 2024 10:21:04 -0800 (PST) From: "Stuart Yoder" To: devel@edk2.groups.io, Edhaya.Chandran@arm.com, gaojie@byosoft.com.cn Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com, Samer.El-Haj-Mahmoud@arm.com, Jiewen.Yao@intel.com Subject: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Date: Tue, 9 Jan 2024 12:20:49 -0600 Message-Id: <20240109182053.2540542-3-stuart.yoder@arm.com> In-Reply-To: <20240109182053.2540542-1-stuart.yoder@arm.com> References: <20240109182053.2540542-1-stuart.yoder@arm.com> MIME-Version: 1.0 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 Reply-To: devel@edk2.groups.io,stuart.yoder@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Ul8KGv3taBSdTRIzbjcECGrdx7686176AA= Content-Transfer-Encoding: quoted-printable X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=t4aEJhLU; 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 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=0D SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocol= BBTest.inf=0D SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBB= Test.inf=0D +SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf= =0D =0D SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf=0D SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf= =0D 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=0D +#=0D +# Copyright 2006 - 2015 Unified EFI, Inc.
=0D +# Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +#=0D +# This program and the accompanying materials=0D +# are licensed and made available under the terms and conditions of the B= SD License=0D +# which accompanies this distribution. The full text of the license may = be found at=0D +# http://opensource.org/licenses/bsd-license.php=0D +#=0D +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED.=0D +#=0D +##=0D +#/*++=0D +#=0D +# Module Name:=0D +#=0D +# TCG2ProtocolBBTest.inf=0D +#=0D +# Abstract:=0D +#=0D +# Component description file for TCG2 Protocol Black-Box Test.=0D +#=0D +#--*/=0D +=0D +[defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D TCG2ProtocolBBTest=0D + FILE_GUID =3D BD8CB762-3935-434C-AC3F-462244910A2D=0D + MODULE_TYPE =3D UEFI_DRIVER=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D InitializeBBTestTCG2Protocol=0D +=0D +[sources.common]=0D + Guid.c=0D + TCG2ProtocolBBTestMain.c=0D + TCG2ProtocolBBTestConformance.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + SctPkg/SctPkg.dec=0D + SctPkg/UEFI/UEFI.dec=0D +=0D +[LibraryClasses]=0D + UefiDriverEntryPoint=0D + SctLib=0D + EfiTestLib=0D +=0D +[Protocols]=0D 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=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D +=0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + guid.h=0D +=0D +Abstract:=0D +=0D + GUIDs auto-generated for EFI test assertion.=0D +=0D +--*/=0D +=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID \=0D +{ 0xca93b02a, 0xe897, 0x4400, {0x81, 0x38, 0xc8, 0xa8, 0xcb, 0x2f, 0xc1, 0= xed }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid001;=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID \=0D +{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0= x57 }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \=0D +{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0= x0c }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \=0D +{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0= x5f }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;=0D 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=0D +=0D + Copyright 2006 - 2017 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D +=0D +**/=0D +/*++=0D +=0D +Module Name:=0D + TCG2ProtocolBBTest.h=0D +=0D +Abstract:=0D + head file of test driver of EFI TCG2 Protocol Test=0D +=0D +--*/=0D +=0D +#include "SctLib.h"=0D +#include =0D +#include =0D +#include "Guid.h"=0D +=0D +#define EFI_TCG2_TEST_REVISION 0x00010000=0D +=0D +//////////////////////////////////////////////////////////////////////////= ////=0D +//=0D +// Entry GUIDs for Function Test=0D +//=0D +#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \=0D + {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0= x67} }=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +BBTestTCG2ProtocolUnload (=0D + IN EFI_HANDLE ImageHandle=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint1 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint2 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint3 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint4 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTest (=0D + IN EFI_BB_TEST_PROTOCOL *This,=0D + IN VOID *ClientInterface,=0D + IN EFI_TEST_LEVEL TestLevel,=0D + IN EFI_HANDLE SupportHandle=0D + );=0D +=0D 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=0D +=0D + Copyright 2006 - 2013 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D +=0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + guid.c=0D +=0D +Abstract:=0D +=0D + GUIDs auto-generated for EFI test assertion.=0D +=0D +--*/=0D +=0D +#include "Efi.h"=0D +#include "Guid.h"=0D +=0D +EFI_GUID gTcg2ConformanceTestAssertionGuid001 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_001_GUID;=0D +=0D +EFI_GUID gTcg2ConformanceTestAssertionGuid002 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_002_GUID;=0D +=0D +EFI_GUID gTcg2ConformanceTestAssertionGuid003 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_003_GUID;=0D +=0D +EFI_GUID gTcg2ConformanceTestAssertionGuid004 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_004_GUID;=0D 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=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D +=0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + TCG2BBTestConformance.c=0D +=0D +Abstract:=0D +=0D + for EFI Driver TCG2 Protocol's Basic Test=0D +=0D +--*/=0D +=0D +#include "TCG2ProtocolBBTest.h"=0D +=0D +#define offsetof(st, m) __builtin_offsetof(st, m)=0D +=0D +/**=0D + * @brief Entrypoint for GetCapability() Function Test.=0D + * 4 checkpoints will be tested.=0D + * @param This a pointer of EFI_BB_TEST_PROTOCOL=0D + * @param ClientInterface A pointer to the interface array under test=0D + * @param TestLevel Test "thoroughness" control=0D + * @param SupportHandle A handle containing protocols required=0D + * @return EFI_SUCCESS=0D + * @return EFI_NOT_FOUND=0D + */=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTest (=0D + IN EFI_BB_TEST_PROTOCOL *This,=0D + IN VOID *ClientInterface,=0D + IN EFI_TEST_LEVEL TestLevel,=0D + IN EFI_HANDLE SupportHandle=0D + )=0D +{=0D + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;=0D + EFI_STATUS Status;=0D + EFI_TCG2_PROTOCOL *TCG2;=0D +=0D + //=0D + // init=0D + //=0D + TCG2 =3D (EFI_TCG2_PROTOCOL*)ClientInterface;=0D +=0D + // Ensure Protocol not NULL=0D + if (TCG2 =3D=3D NULL)=0D + return EFI_UNSUPPORTED;=0D +=0D + //=0D + // Get the Standard Library Interface=0D + //=0D + Status =3D gtBS->HandleProtocol (=0D + SupportHandle,=0D + &gEfiStandardTestLibraryGuid,=0D + (VOID **) &StandardLib=0D + );=0D + if (EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D +=0D + // Test Using NULL BootCapability Pointer=0D + BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2);=0D +=0D + // Test for validating fields of struct returned by GetCapability()=0D + BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2);=0D +=0D + // Test Using Capability struct with struct size less than 1.0 size=0D + BBTestGetCapabilityConformanceTestCheckpoint3 (StandardLib, TCG2);=0D +=0D + // Test Using Capability struct with struct size equal to 1.0 size=0D + BBTestGetCapabilityConformanceTestCheckpoint4 (StandardLib, TCG2);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint1 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + )=0D +{=0D + EFI_TEST_ASSERTION AssertionType;=0D + EFI_STATUS Status;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY *BootServiceCapPtr =3D NULL;=0D +=0D + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + BootServiceCapPtr);=0D +=0D + // Ensure GetCapability returns Invalid Parameter when passing in NULL p= ointer=0D + if (EFI_INVALID_PARAMETER =3D=3D Status) {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid001,=0D + L"TCG2_PROTOCOL.GetCapability - GetCapability() returns E= FI_INVALID_PARAMETER with NULL pointer Capability Struct Passed in",=0D + L"%a:%d: Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint2 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + )=0D +{=0D + EFI_TEST_ASSERTION AssertionType;=0D + EFI_STATUS Status;=0D + CHAR8 StructureVersionMajor;=0D + CHAR8 StructureVersionMinor;=0D + CHAR8 ProtocolVersionMajor;=0D + CHAR8 ProtocolVersionMinor;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D +=0D + BootServiceCap.Size =3D sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);=0D +=0D + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + &BootServiceCap);=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D +=0D + if (Status !=3D EFI_SUCCESS) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should return EFI_SUCCESS"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StructureVersionMajor =3D BootServiceCap.StructureVersion.Major;=0D + StructureVersionMinor =3D BootServiceCap.StructureVersion.Minor;=0D +=0D + // TCG EFI Protocol spec 6.4.4 #4=0D + if ((StructureVersionMajor !=3D 1) | (StructureVersionMinor !=3D 1)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should have StructureVersion 1.1, reported value =3D %d.%d",=0D + StructureVersionMajor,=0D + StructureVersionMinor=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + ProtocolVersionMajor =3D BootServiceCap.ProtocolVersion.Major;=0D + ProtocolVersionMinor =3D BootServiceCap.ProtocolVersion.Minor;=0D +=0D + // TCG EFI Protocol spec 6.4.4 #4=0D + if ((ProtocolVersionMajor !=3D 1) | (ProtocolVersionMinor !=3D 1)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= should have ProtocolVersion 1.1, reported value =3D %d.%d",=0D + ProtocolVersionMajor,=0D + ProtocolVersionMinor=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + if (!(BootServiceCap.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256= )) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: unexpected ha= sh algorithms reported =3D %x",=0D + BootServiceCap.HashAlgorithmBitmap=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + if (!(BootServiceCap.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG= _2)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: GetCapability= must support TCG2 event log format"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + for (int i =3D 0; i < sizeof(BootServiceCap.ActivePcrBanks); i++) {=0D + if (((BootServiceCap.ActivePcrBanks & (1u << i)) !=3D 0) &&=0D + ((BootServiceCap.HashAlgorithmBitmap & (1u << i)) =3D=3D 0)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBank= s is not a subset of HashAlgorithmBitmap. Reported ActivePcrBanks:0x%x Hash= AlgorithmBitmap=3D0x%x",=0D + BootServiceCap.ActivePcrBanks,=0D + BootServiceCap.HashAlgorithmBitmap=0D + );=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D + }=0D +=0D + if (BootServiceCap.NumberOfPcrBanks < 1 ) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: expect at lea= st 1 PCR bank"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + // Verify that ActivePcrBanks includes SHA256, SHA384, or SHA512=0D + 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;= =0D +=0D + if (!(BootServiceCap.ActivePcrBanks & HashBitMapAlgos)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBank= s doesn't includes SHA256, SHA384, or SHA512",=0D + BootServiceCap.ActivePcrBanks=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid002,=0D + L"TCG2_PROTOCOL.GetCapability - GetCapability() populates= all elements of EFI_TCG_BOOT_SERVICE_CAPABILITY",=0D + L"%a:%d: Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint3 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + )=0D +{=0D + EFI_TEST_ASSERTION AssertionType;=0D + EFI_STATUS Status;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D +=0D + // set size to be value less than 1.0 or 1.1 struct=0D + BootServiceCap.Size =3D 4;=0D +=0D + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + &BootServiceCap);=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D +=0D + if (Status !=3D EFI_BUFFER_TOO_SMALL && BootServiceCap.Size !=3D sizeof(= EFI_TCG2_BOOT_SERVICE_CAPABILITY)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + 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)"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid003,=0D + 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",=0D + L"%a:%d: Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +EFI_STATUS=0D +BBTestGetCapabilityConformanceTestCheckpoint4 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + )=0D +{=0D + EFI_TEST_ASSERTION AssertionType;=0D + EFI_STATUS Status;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D +=0D + // set size of struct to be up to and including the ManufacturerID=0D + // (this acts like a client with a 1.0 version of the struct)=0D + BootServiceCap.Size =3D offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, Numbe= rOfPcrBanks);=0D +=0D + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + &BootServiceCap);=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D +=0D + if (Status !=3D EFI_SUCCESS) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetCapability Test: 1.0 Compatibi= lity. GetCapability should return EFI_SUCCESS"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + // Verify returned Size equals the size of EFI_TCG2_BOOT_SERVICE_CAPABIL= ITY up to and including the ManufacturerID field.=0D + if (BootServiceCap.Size !=3D offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, = NumberOfPcrBanks)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + 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"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid004,=0D + L"TCG2_PROTOCOL.GetCapability - GetCapability() backwards= compatibility check for 1.0 version of EFI_TCG_BOOT_SERVICE_CAPABILITY",=0D + L"%a:%d: Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D 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=0D +=0D + Copyright 2006 - 2017 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D +=0D +**/=0D +/*++=0D +=0D +Module Name:=0D + TCG2ProtocolBBTestMain.c=0D +=0D +Abstract:=0D + for EFI TCG2 Protocol Test=0D +=0D +--*/=0D +=0D +#include "TCG2ProtocolBBTest.h"=0D +=0D +EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField =3D {=0D + EFI_TCG2_TEST_REVISION,=0D + EFI_TCG2_PROTOCOL_GUID,=0D + L"Testing For EFI TCG2 Protocol",=0D + L"Total # test cases for the EFI TCG2 Protocol"=0D +};=0D +=0D +EFI_GUID gSupportProtocolGuid1[2] =3D {=0D + EFI_STANDARD_TEST_LIBRARY_GUID,=0D + EFI_NULL_GUID=0D +};=0D +=0D +EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] =3D {=0D + {=0D + EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101,=0D + L"GetCapability_Conf",=0D + L"Test the GetCapablity API",=0D + EFI_TEST_LEVEL_DEFAULT,=0D + gSupportProtocolGuid1,=0D + EFI_TEST_CASE_AUTO,=0D + BBTestGetCapabilityConformanceTest=0D + },=0D + 0=0D +};=0D +=0D +EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;=0D +=0D +/**=0D + * Creates/installs the BlackBox Interface and eminating Entry Point=0D + * node list.=0D + * @param ImageHandle The test driver image handle=0D + * @param SystemTable Pointer to System Table=0D + * @return EFI_SUCCESS Indicates the interface was installed=0D + * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could = not be allocated=0D + * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid va= lue.=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +InitializeBBTestTCG2Protocol (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EfiInitializeTestLib (ImageHandle, SystemTable);=0D +=0D + //=0D + // initialize test utility lib=0D + //=0D + SctInitializeLib (ImageHandle, SystemTable);=0D +=0D + return EfiInitAndInstallBBTestInterface (=0D + &ImageHandle,=0D + &gBBTestProtocolField,=0D + gBBTestEntryField,=0D + BBTestTCG2ProtocolUnload,=0D + &gBBTestProtocolInterface=0D + );=0D +}=0D +=0D +/**=0D + * The driver's Unload function=0D + * @param ImageHandle The test driver image handle=0D + * @return EFI_SUCCESS Indicates the interface was Uninstalled=0D +*/=0D +EFI_STATUS=0D +EFIAPI=0D +BBTestTCG2ProtocolUnload (=0D + IN EFI_HANDLE ImageHandle=0D + )=0D +{=0D + return EfiUninstallAndFreeBBTestInterface (=0D + ImageHandle,=0D + gBBTestProtocolInterface=0D + );=0D +}=0D 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 +=0D +[Category Data]=0D +Revision =3D 0x00010000=0D +CategoryGuid =3D 607f766c-7455-42be-930b-e4d76db2720f=0D +InterfaceGuid =3D 607f766c-7455-42be-930b-e4d76db2720f=0D +Name =3D TCG2ProtocolTest=0D +Description =3D TCG2 Protocol Test=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-