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.web09.23087.1641761913074734995 for ; Sun, 09 Jan 2022 12:58:33 -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 AE86313A1; 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 A5D083F766; 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 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Date: Sun, 9 Jan 2022 14:58:24 -0600 Message-Id: <20220109205827.3608758-4-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 -add initial TCG2 protocol test for GetActivePcrBanks() -checkpoint for NULL pointer passed for buffer -checkpoint for test of function with proper input V2: -add check to verify ActivePcrBanks returned by GetCapability matches that = returned by GetActivePcrBanks() Signed-off-by: Joseph Hemann Change-Id: I626bc21fb3e96692f3c63043651a8e1027c6f611 --- .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 4 + .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 10 ++ .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 23 +++ .../TCG2ProtocolBBTestConformance.c | 159 ++++++++++++++++++ .../BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 + 5 files changed, 205 insertions(+) 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 206662ee..0497f08f 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 @@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 =3D EFI_TES= T_TCG2CONFORMANCE_ASSERTI 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 +=0D +EFI_GUID gTcg2ConformanceTestAssertionGuid005 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_005_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 index b675756b..f470255c 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 @@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002; =0D extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;=0D =0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \=0D +{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0= x26 }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;=0D +=0D +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \=0D +{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0= x2c }}=0D +=0D +extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;=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 index aecc5e1d..ed65bc97 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 @@ -37,6 +37,9 @@ Abstract: #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \=0D {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0= x67} }=0D =0D +#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \=0D + {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0= x54} }=0D +=0D EFI_STATUS=0D EFIAPI=0D BBTestTCG2ProtocolUnload (=0D @@ -61,6 +64,18 @@ BBTestGetCapabilityConformanceTestCheckpoint3 ( IN EFI_TCG2_PROTOCOL *TCG2=0D );=0D =0D +EFI_STATUS=0D +BBTestGetActivePcrBanksConformanceTestCheckpoint1 (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TCG2_PROTOCOL *TCG2=0D + );=0D +=0D +EFI_STATUS=0D +BBTestGetActivePcrBanksConformanceTestCheckpoint2 (=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 @@ -69,3 +84,11 @@ BBTestGetCapabilityConformanceTest ( IN EFI_HANDLE SupportHandle=0D );=0D =0D +EFI_STATUS=0D +BBTestGetActivePcrBanksConformanceTest (=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= CG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol= /TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c index a74b29b7..c7b326cd 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 @@ -82,6 +82,58 @@ BBTestGetCapabilityConformanceTest ( return EFI_SUCCESS;=0D }=0D =0D +/**=0D + * @brief Entrypoint for GetActivePcrBanks() Function Test.=0D + * 2 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 +BBTestGetActivePcrBanksConformanceTest (=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; + + // + // 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 Pointer=0D + BBTestGetActivePcrBanksConformanceTestCheckpoint1 (StandardLib, TCG2);=0D +=0D + // Test with correct size field=0D=0D + BBTestGetActivePcrBanksConformanceTestCheckpoint2 (StandardLib, TCG2);=0D +=0D + return EFI_SUCCESS;=0D +}=0D =0D EFI_STATUS=0D BBTestGetCapabilityConformanceTestCheckpoint1 (=0D @@ -319,3 +371,110 @@ BBTestGetCapabilityConformanceTestCheckpoint3 ( return EFI_SUCCESS;=0D }=0D =0D +EFI_STATUS=0D +BBTestGetActivePcrBanksConformanceTestCheckpoint1 (=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 +=0D + EFI_TCG2_EVENT_ALGORITHM_BITMAP *ActivePcrBanks =3D NULL;=0D + Status =3D TCG2->GetActivePcrBanks (=0D + TCG2,=0D + ActivePcrBanks);=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 + gTcg2ConformanceTestAssertionGuid004,=0D + L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks() r= eturns EFI_INVALID_PARAMETER with NULL pointer 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 +BBTestGetActivePcrBanksConformanceTestCheckpoint2 (=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_EVENT_ALGORITHM_BITMAP ActivePcrBanks;=0D + EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;=0D + + Status =3D TCG2->GetActivePcrBanks (=0D + TCG2,=0D + &ActivePcrBanks);=0D +=0D + // Ensure GetActivePcrBanks returns EFI_SUCCESS=0D + if (Status =3D=3D EFI_SUCCESS) {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActive= PcrBanks should return EFI_SUCCESS" + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + EFI_TCG2_EVENT_ALGORITHM_BITMAP BitMapAlgos =3D EFI_TCG2_BOOT_HASH_ALG_= SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;=0D +=0D + // Ensure ActivePcrBanks has SHA256/384/512 in its Bitmap=0D + if (!(ActivePcrBanks & BitMapAlgos)) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActive= PcrBanks should have SHA256/384/512 Algorithm in its Bitmap. ActivePcrBanks= =3D %x",=0D + ActivePcrBanks=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + BootServiceCap.Size =3D sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);=0D + + Status =3D TCG2->GetCapability (=0D + TCG2,=0D + &BootServiceCap);=0D + + // Ensure ActivePcrBanks is the same returned as GetCapability()=0D + if (ActivePcrBanks !=3D BootServiceCap.ActivePcrBanks) {=0D + StandardLib->RecordMessage (=0D + StandardLib,=0D + EFI_VERBOSE_LEVEL_DEFAULT,=0D + L"\r\nTCG2 Protocol GetActivePcrBanks Test:Returned A= ctivePcrBanks should match the one returned by GetCapabilty()"=0D + );=0D +=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D + + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gTcg2ConformanceTestAssertionGuid005,=0D + L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks sho= uld return with EFI_SUCCESS and have SHA256/384/512 Algoritms in its Bitmap= ",=0D + L"%a:%d: Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=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 index 97da8f58..4e7b1593 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2Prot= ocolBBTestMain.c @@ -47,6 +47,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] =3D { EFI_TEST_CASE_AUTO,=0D BBTestGetCapabilityConformanceTest=0D },=0D + {=0D + EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102,=0D + L"GetActivePcrBanks_Conf",=0D + L"Test the GetActivePcrBanks API",=0D + EFI_TEST_LEVEL_DEFAULT,=0D + gSupportProtocolGuid1,=0D + EFI_TEST_CASE_AUTO,=0D + BBTestGetActivePcrBanksConformanceTest=0D + },=0D 0=0D };=0D =0D --=20 2.25.1