From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.23115.1641761912626353376 for ; Sun, 09 Jan 2022 12:58:32 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: joseph.hemann@arm.com) 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 174AE139F; Sun, 9 Jan 2022 12:58:32 -0800 (PST) Received: from u203013-lin.austin.arm.com (u203013-lin.austin.arm.com [10.118.28.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A25E3F766; Sun, 9 Jan 2022 12:58:32 -0800 (PST) From: "Joseph Hemann" To: devel@edk2.groups.io Cc: nd@arm.com, Joseph Hemann Subject: [PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test Date: Sun, 9 Jan 2022 14:58:23 -0600 Message-Id: <20220109205827.3608758-3-Joseph.hemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220109205827.3608758-1-Joseph.hemann@arm.com> References: <20220109205827.3608758-1-Joseph.hemann@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable -implement initial infrastructure for the TCG2 protocol test including updates to .dsc file, inf file, GUID source files, update to Category.ini. -add initial TCG2 protocol test for GetCapability(), as defined in the TCG EFI Protocol Spec 6.4.4. -checkpoint for NULL pointer passed for buffer -checkpoint for validating fields of the struct returned by GetCapabilty() V2: -adds checkpoint for verifying GetCapablity() when size < Capablity Struct -adds check to ensure ActivePcrBanks is subset of HashAlgorithmBitmap -adds checks for returned status by function Signed-off-by: Joseph Hemann Change-Id: Iaeefecb1a468264daf57c3a0476035d8cac4f05d --- uefi-sct/SctPkg/CommonGenFramework.sh | 1 + uefi-sct/SctPkg/Config/Data/Category.ini | 7 + .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 35 ++ .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 43 +++ .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 71 ++++ .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf | 51 +++ .../TCG2ProtocolBBTestConformance.c | 321 ++++++++++++++++++ .../BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 ++++++ uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 1 + 9 files changed, 632 insertions(+) create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/Guid.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/Guid.h create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/TCG2ProtocolBBTest.h create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/TCG2ProtocolBBTest.inf create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/TCG2ProtocolBBTestConformance.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBo= xTest/TCG2ProtocolBBTestMain.c diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/Common= GenFramework.sh index 779a6a44..997d8ba1 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 af27e362..c239fe4b 100644 --- a/uefi-sct/SctPkg/Config/Data/Category.ini +++ b/uefi-sct/SctPkg/Config/Data/Category.ini @@ -1026,3 +1026,10 @@ InterfaceGuid =3D 8D59D32B-C655-4AE9-9B15-F25904992A= 43 Name =3D IHV\ConsoleSupportTest\AbsolutePointerProtocolTest=0D Description =3D Absolute Pointer Protocol Test on IHV Drivers=0D =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=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 00000000..206662ee --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c @@ -0,0 +1,35 @@ +/** @file=0D +=0D + Copyright 2006 - 2013 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021, Arm Inc. All rights reserved.
=0D=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 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 00000000..b675756b --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h @@ -0,0 +1,43 @@ +/** @file=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021, Arm Inc. All rights reserved.
=0D=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 +{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0= x0c }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \=0D +{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0= x57 }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;=0D +=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 00000000..aecc5e1d --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTest.h @@ -0,0 +1,71 @@ +/** @file=0D +=0D + Copyright 2006 - 2017 Unified EFI, Inc.
=0D + Copyright (c) 2013, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2021, Arm Inc. All rights reserved.
=0D=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 +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/T= CG2ProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/Bla= ckBoxTest/TCG2ProtocolBBTest.inf new file mode 100644 index 00000000..f41d84b3 --- /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, Arm Inc. All rights reserved.
=0D=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/T= CG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol= /TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c new file mode 100644 index 00000000..a74b29b7 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestConformance.c @@ -0,0 +1,321 @@ +/** @file=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2021, Arm Inc. All rights reserved.
=0D=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 +/**=0D + * @brief Entrypoint for GetCapability() Function Test.=0D + * 3 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 + // init=0D + //=0D + TCG2 =3D (EFI_TCG2_PROTOCOL*)ClientInterface;=0D + + // Ensure Protocol not NULL + if (TCG2 =3D=3D NULL) + return EFI_UNSUPPORTED; + + //=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 + + // Test Using NULL BootCapablity Pointer=0D + BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2);=0D + + // Test Using Capability struct with struct size less than full size + BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2); + + // Test for validating fields of struct returned by GetCapability() + BBTestGetCapabilityConformanceTestCheckpoint3 (StandardLib, TCG2);=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 + + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + BootServiceCapPtr);=0D +=0D + // Ensure GetCapablity returns Invalid Parameter when passing in NULL po= inter=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 +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 + char StructureVersionMajor;=0D + char StructureVersionMinor;=0D + char ProtocolVersionMajor;=0D + char ProtocolVersionMinor;=0D +=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D + BootServiceCap.Size =3D sizeof(UINT8) + (sizeof(EFI_TCG2_VERSION) * 2);= =0D +=0D + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + &BootServiceCap);=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D +=0D + // If the input ProtocolCapability.Size < sizeof(EFI_TCG2_BOOT_SERVICE_C= APABILITY) the function should return EFI_BUFFER_TOO_SMALL=0D + if (Status !=3D EFI_BUFFER_TOO_SMALL) {=0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: Did not return= Status =3D=3D EFI_BUFFER_TOO_SMALL with input ProtocolCapability.Size < si= zeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D + + StructureVersionMajor =3D BootServiceCap.StructureVersion.Major;=0D + StructureVersionMinor =3D BootServiceCap.StructureVersion.Minor;=0D +=0D + // If the input ProtocolCapability.Size < sizeof(EFI_TCG2_BOOT_SERVICE_C= APABILITY) the function will initialize the fields included in ProtocolCapa= bility.Size.=0D + if ((StructureVersionMajor !=3D 1) | (StructureVersionMinor !=3D 1)) {=0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: Unexpected str= uct version numbers returned"=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 + if ((ProtocolVersionMajor !=3D 1) | (ProtocolVersionMinor !=3D 1)) {=0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: Unexpected pro= tocol version numbers returned."=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() shall p= opulate the included structure elements and return with a Status of EFI_BUF= FER_TOO_SMALL when structure size is set to less than the size of EFI_TCG_B= OOT_SERVICE_CAPABILITY.", + 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 + char StructureVersionMajor;=0D + char StructureVersionMinor;=0D + char ProtocolVersionMajor;=0D + char ProtocolVersionMinor;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D + + BootServiceCap.Size =3D sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);=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=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: GetCapabilty s= hould return EFI_SUCCESS"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=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=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: GetCapabilty s= hould have StructureVersion 1.1"=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=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: protocol versi= on must be 1.1"=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=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: GetCapabilty m= ust support TCG2 event log format"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + if (BootServiceCap.NumberOfPcrBanks < 1 ) {=0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: expect at leas= t 1 PCR bank"=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=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: unexpected has= h algorithms reported =3D %x",=0D + BootServiceCap.HashAlgorithmBitmap=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + if (!(~BootServiceCap.ActivePcrBanks & BootServiceCap.HashAlgorithmBitma= p) =3D=3D 0) {=0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: ActivePcrBanks= is not a subset of HashAlgorithmBitmap" + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } + + if (!(BootServiceCap.ActivePcrBanks & EFI_TCG2_BOOT_HASH_ALG_SHA256)) {= =0D + StandardLib->RecordMessage (=0D=0D + StandardLib,=0D=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D=0D + L"\r\nTCG2 Protocol GetCapablity Test: unexpected act= ive PCR banks reported =3D %x",=0D + BootServiceCap.ActivePcrBanks=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid003,=0D + L"TCG2_PROTOCOL.GetCapability - GetCapability() shall pop= ulate all structure elements and return with a Status of EFI_SUCCESS when t= he structure size includes all of the EFI_TCG_BOOT_SERVICE_CAPABILITY struc= ture",=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 00000000..97da8f58 --- /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, Arm Inc. All rights reserved.
=0D=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/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_= SCT.dsc index 5b3e5307..3d3e9704 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc @@ -288,6 +288,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 --=20 2.25.1