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 33586AC1A41 for ; Mon, 18 Mar 2024 20:44:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=K7dmFGDmW/OZCskSXonZ9RMvameZS1FXkzxnuniXb5E=; 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=1710794663; v=1; b=SopyWBglNvgUpmA3hS1jpCnvVb3L31eF7cEsMmKtsveDrrXoiBXNiIsQyd0SeU/RD/VHXIlI mmaMleQgXe3K06JXFTtGSbdzEdSr/WKTN4jAQb8QR1l616nh5IYQhp+kfuBk0cFiqkHGAxpvh6f AU24aUf7vrbTA6QOcC1N2yiyFCefRABgh1IPMUe/hzDVp4Hv4m66iXMNGbBulikdB7lFtmPjn9y UVjYuRC3fNFeZkJA/Lk/OxrO4EniU16BvNjstDqMhQ7febIWYYoxiRL3SoZqm7Gp7zqn5eqQ3cW alKB1U2RtX5Bs2lPaCZduLmZ5WlHBBUaI9tzlvmbCDXeA== X-Received: by 127.0.0.2 with SMTP id gWChYY7687511x5Re4J0v9Vd; Mon, 18 Mar 2024 13:44:23 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.133]) by mx.groups.io with SMTP id smtpd.web11.56335.1710794662931017416 for ; Mon, 18 Mar 2024 13:44:23 -0700 X-Received: from AS8PR08MB7791.eurprd08.prod.outlook.com (2603:10a6:20b:52d::6) by AM8PR08MB6545.eurprd08.prod.outlook.com (2603:10a6:20b:368::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 20:44:20 +0000 X-Received: from AS8PR08MB7791.eurprd08.prod.outlook.com ([fe80::8ed9:ec8b:75b7:f127]) by AS8PR08MB7791.eurprd08.prod.outlook.com ([fe80::8ed9:ec8b:75b7:f127%6]) with mapi id 15.20.7386.025; Mon, 18 Mar 2024 20:44:20 +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 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Thread-Topic: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Thread-Index: AQHaQykneGJ5rJAfqE6xgM8jISiNXbE+Y70g Date: Mon, 18 Mar 2024 20:44:20 +0000 Message-ID: References: <20240109182053.2540542-1-stuart.yoder@arm.com> <20240109182053.2540542-7-stuart.yoder@arm.com> In-Reply-To: <20240109182053.2540542-7-stuart.yoder@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: AB539D41B7F3E14B9E8D836046542E9A.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: ydRdbqI0MQzbLBiaPMNRIICbrDQzs6OisDDzSlpY6dW1GPCADwzPuXrBfAnkxITYZlibf20jnDVidMeHIHZA5u1cR95/1Tf5uNvpMWwWqQZP4izKECdVUhoQVnoEs5d0NMxyhavLpObZcr5l0txv7TDdE/4+WfRztPYEUdJ9ZG+taY/AvskaS+C6IPsty4ZhO5PmOfPJow+Kq7EjitrRMeHiMb3CRQ6iQiWeHF2M1F+DmbdehSbX3fMnvF83T8nUpJTKvpQp9ahNNJ5/2C5lPPfegFwNPEk4xCN29mJ/D7y0VgLnIAp2AmxY2V4VQesN5yzgTWsg+mvEw0e/W9YOd3NoAffEKj0eTvFFVEhVvtiyDac8c3zGbYAyeo7U5DeML2Vcm5TQO9ffD4I6pNeC1i5eHnxObm68VbrowNWguedxP9t351wddArbEMO6f4SK3wveKOcuUq0a+Jk3qV8LQKpBAdmbxKd4w6ayLBFOb+aCfaT1tLUZOsKB9pngv42gCXQ1ihQx2AhSUWAks5acJK9YagyAi+A9DGUOcfMQhJV6wpkb0SjUXJ27d/LkEvElpQ6R5ulun/jyvRvWm7qmnqq+wmw0pJCp9TIJfRDLTis= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?O9dqrfwA6Z0jpc5jy452KUBJdyCsKrM42vqLBzH3TWq198ehkJLf2QMURDVd?= =?us-ascii?Q?LAZLCIuqqGnyCEXNbvZexYbN7eq7Q82R0TbFsSdmicDxGiivgSaAvUgQrPMC?= =?us-ascii?Q?dGx9ooaXMZf5AFkBQgPMLqmr+5j8yijmcTjO7yiPjvfLSxmtc+78uOsv6UHm?= =?us-ascii?Q?tsmi1cBCxuNyhk0wtPjYCctCwo2u13WGGZsE18Fi6A3R+QrfVirp1EJcWNn+?= =?us-ascii?Q?1GaKELvNtHfoTW8qGVGkk33XE8fBWR+o6qZ+lwSRJEhal81OLsbd2XNIRA0O?= =?us-ascii?Q?16c6yLI65fh/EM+AoTnUZ0ZVYNcZIcs2zOaEb3B0dGF3rpMCnr3vokpCdIwj?= =?us-ascii?Q?hUodBm1K7DM5qhQEBkyWvgL9d9Dv22uQFvlwBJT1rTSxC3IbZzqpkdf5fe2D?= =?us-ascii?Q?9tboMUrJ3HFyViMO8/I3yGMmf2d+aDvK05uJWY8knkGPy+SpWUAd/2lPHh8G?= =?us-ascii?Q?TAtcjnzT1EgDmsZbuAnXj5bN0zlh13uXBzgEJCG1fDeehg9sRZVcQSV3tBCM?= =?us-ascii?Q?FefpnDo2gDd5OXnGpa2mCL02aD4IFkBieikU3s3g2PNTpwyf75soRPkiY6xJ?= =?us-ascii?Q?bTABpv8r0sUCkses9duCTVBB9p3iQ9Oh7rn14J5naVFnT7W/R1r35TBBLPzb?= =?us-ascii?Q?ebdVFUx5+Wy/+lVaGx5aAl9RWwkqQrcaLXefvx/2HfMCjSRzLJtn1c1HEU3i?= =?us-ascii?Q?geenB+aZBKGwQy0hTXiHQ2BWdRwCWuvjG/Q6rkm3ud6x0bBLxL62OgbGhCHJ?= =?us-ascii?Q?Am7pxF9zPqmlQc342wi1qS+jJ0/Y3YkWk4+OCQs5GEjLcYz6u84ZKLcjdCDE?= =?us-ascii?Q?whge5aw64FalCWdvCGYzNthSLUrKeHkMXkA4SjiiqTqXqUFImm3rgze6Dye7?= =?us-ascii?Q?qq8y+c9sXJiFlKQ9mL9qAsu98LsOcpqSzcPPQ2EublcslkeSm6EGPWf9EJiJ?= =?us-ascii?Q?EtUwSC5crWS3CSTWZR9UatZ1kMiUHvTuwstqOR9D4VTJuSxi+RyYbsNtVc2B?= =?us-ascii?Q?OS6ZUnTwGasfl6D4JmSS/74F1LD9PVC6gZf22AHyHHDfMbzb1NKh+PcUbKWj?= =?us-ascii?Q?c1CZyvcDrwUk6Y7jjP/79Ic4MauMm3cUMZ8KeGr/xXt49WISaH7ok/1u+ciM?= =?us-ascii?Q?ymqpknAVIhjD80n6HgaWx79OzCSKj3C3c0tJWcZGU+kKH976S8X1ataL3M3N?= =?us-ascii?Q?jrC8PJCEe7PWSSr8zZcUIRLaOuQc1mU117QKNR6sWpqrsUJU05TRgs4zjdNp?= =?us-ascii?Q?f4MqhUY3ZozsxoLOcMA2E7uduOxLZsmC1f5qKYBekIrHTRol33KBk8DrMvlO?= =?us-ascii?Q?0G1/Ko01h1R/LpiB9J100Tq5ab8tRYLbpf9uoRbK7Hg9WH88b+a/iK4gUcVB?= =?us-ascii?Q?dwLjqvKjDKk0pBUGVhxt2Xr72bcKHUxwKAQcBincqSqtxL3tKPEE/i9KGXWt?= =?us-ascii?Q?L4zpT2Kxd0NLWIgj1XtjHNQ/o5hcpUuHQYlVqgO4Uf52gJrWcwJmWCviBIg7?= =?us-ascii?Q?cLRr0MknAfij58QTfoQQd8xf0Wrj7lgT61PBBo8m7jaPHIMvdC9OXfwTEYZ8?= =?us-ascii?Q?Zl0JUZdBooZV6ITBHvA=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: 3d687e57-72f4-4e70-eb48-08dc478c2fdd X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 20:44:20.3330 (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: BPu63YRBLCZERJL5/GGf/2gbPAcfEA+aZyxRRfwvHnWBoaa/lxS5AlJZnniq/jwlVS920lCZaUun7t8/+A6HAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6545 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 18 Mar 2024 13:44:23 -0700 Reply-To: devel@edk2.groups.io,Sunny.Wang@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: bDoxuuKCTCC5vUzpoLixVkfSx7686176AA= 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=SopyWBgl; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Looks good to me. For others' reference, the change has been already verified by running Syst= emReady SIE (Security Interface extension) tests on multiple SystemReady ce= rtified Arm systems. Reviewed-by: Sunny Wang -----Original Message----- From: devel@edk2.groups.io On Behalf Of Stuart Yoder= via groups.io Sent: Tuesday, January 9, 2024 12:21 PM To: devel@edk2.groups.io; G Edhaya Chandran ; gaoj= ie@byosoft.com.cn Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer E= l-Haj-Mahmoud ; Jiewen.Yao@intel.com Subject: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add Su= bmitCommand test From: Joseph Hemann Add test verifying the functionality of the SubmitCommand function using the TPM command TPM2_HASH_COMMAND. Signed-off-by: Joseph Hemann Signed-off-by: Stuart Yoder --- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h = | 5 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTest.h | 71 ++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c = | 2 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTestConformance.c | 173 ++++++++++++++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolB= BTestMain.c | 9 + 5 files changed, 260 insertions(+) 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 746ff83f899c..044e549ce8f0 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 @@ -105,3 +105,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid015; { 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0= x76 }} extern EFI_GUID gTcg2ConformanceTestAssertionGuid016; + +#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID \ +{ 0x3aac8b9a, 0x312a, 0x4dcf, {0x12, 0x76, 0x54, 0x55, 0x32, 0xcd, 0x3a, 0= xea }} + +extern EFI_GUID gTcg2ConformanceTestAssertionGuid017; 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 5ce275dc6258..f8880599f150 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 @@ -54,6 +54,64 @@ Abstract: #define PE_COFF_IMAGE 0x0000000000000010 +// ST_NO_SESSION as defined in Table 19 of TPM Library Part 2: Structures +#define ST_NO_SESSIONS (UINT16) 0x8001 + +// TPM_RC_SUCCESS as defined in Table 16 of TPM Library Spec Part 2: Struc= tures +#define TPM_RC_SUCCESS (UINT32) 0x0000000 + +// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structur= es +#define TPM_CC_Hash (UINT32)(0x0000017D) + +#define TPM_RH_NULL (UINT32) 0x40000007 + +#define TPM_ALG_SHA256 (UINT16) 0x000B + +#define SHA256_LENGTH (UINT16) 0x0020 + +#pragma pack(1) +// TPM2B_MAX_BUFFER as defined in Table 86 of TPM Library Spec Part 2: Str= uctures +// Size of buffer in spec is variable length, but hash test will always us= e a fixed length string +// of length 43 +#define TEST_STRING_LEN 43 +typedef struct { + UINT16 size; + UINT8 buffer[TEST_STRING_LEN]; +} TPM2B_MAX_BUFFER; + +#pragma pack(1) +// TPM2B_DIGEST as defined in Table 73 of TPM Library Spec Part 2: Structu= res +typedef struct { + UINT16 size; + UINT8 digest[32]; // Size of buffer in spec is defined to be variable = length but for this test will always be 32 +} TPM2B_DIGEST; + +typedef struct { + UINT16 tag; + UINT32 hierarchy; + UINT16 digest; // Size of buffer in spec is defined to be var= iable length but for this test will always be UINT16 +} TPMT_TK_HASHCHECK; + +// TPM2_Hash command Structure as defined in Section 15.4 of TPM Spec Part= 3: Commands +typedef struct { + UINT16 Tag; + UINT32 CommandSize; + UINT32 CommandCode; + TPM2B_MAX_BUFFER data; + UINT16 hashAlg; + UINT32 hierarchy; +} TPM2_HASH_COMMAND; + +// TPM2_Hash Response Structure as defined in Section 15.4 of TPM Spec Par= t 3: Commands +typedef struct { + UINT16 Tag; + UINT32 ResponseSize; + UINT32 ResponseCode; + TPM2B_DIGEST data; + TPMT_TK_HASHCHECK validation; +} TPM2_HASH_RESPONSE; +#pragma + EFI_STATUS EFIAPI BBTestTCG2ProtocolUnload ( @@ -120,6 +178,12 @@ BBTestGetEventLogConformanceTestCheckpoint2 ( IN EFI_TCG2_PROTOCOL *TCG2 ); +EFI_STATUS +BBTestSubmitCommandConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ); + EFI_STATUS BBTestGetCapabilityConformanceTest ( IN EFI_BB_TEST_PROTOCOL *This, @@ -144,3 +208,10 @@ BBTestHashLogExtendEventConformanceTest ( IN EFI_HANDLE SupportHandle ); +EFI_STATUS +BBTestSubmitCommandConformanceTest ( + 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 index 8c528aa8ddfc..9aa5315e670e 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 @@ -59,3 +59,5 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid014 =3D EFI_TES= T_TCG2CONFORMANCE_ASSERTI EFI_GUID gTcg2ConformanceTestAssertionGuid015 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_015_GUID; EFI_GUID gTcg2ConformanceTestAssertionGuid016 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_016_GUID; + +EFI_GUID gTcg2ConformanceTestAssertionGuid017 =3D EFI_TEST_TCG2CONFORMANCE= _ASSERTION_017_GUID; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/T= CG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol= /TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c index ebe04d42aff5..5abf8e7934cf 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 @@ -197,6 +197,56 @@ BBTestHashLogExtendEventConformanceTest ( return EFI_SUCCESS; } +/** + * @brief Entrypoint for SubmitCommand() Function Test. + * 1 checkpoint 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 +BBTestSubmitCommandConformanceTest ( + 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 GetRandom TPM Command + BBTestSubmitCommandConformanceTestCheckpoint1 (StandardLib, TCG2); + + return EFI_SUCCESS; +} + EFI_STATUS BBTestGetCapabilityConformanceTestCheckpoint1 ( IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, @@ -1006,3 +1056,126 @@ BBTestGetEventLogConformanceTestCheckpoint2 ( return EFI_SUCCESS; } + +// Expected SHA256 Hash of the string "The quick brown fox jumps over the= lazy dog" +UINT8 Tpm2HashOut[32] =3D {0xd7,0xa8,0xfb,0xb3,0x07,0xd7,0x80,0x94,0x69,0x= ca,0x9a,0xbc,0xb0,0x08,0x2e,0x4f, \ +0x8d,0x56,0x51,0xe4,0x6d,0x3c,0xdb,0x76,0x2d,0x02,0xd0,0xbf,0x37,0xc9,0xe5= ,0x92}; + +EFI_STATUS +BBTestSubmitCommandConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TCG2_PROTOCOL *TCG2 + ) +{ + EFI_TEST_ASSERTION AssertionType; + EFI_STATUS Status; + TPM2_HASH_RESPONSE CommandResponse; + TPM2_HASH_COMMAND CommandInput; + CHAR8 *Str =3D"The quick brown fox jumps over the lazy dog"; + + // Build TPM2 Hash command to hash test string + CommandInput.Tag =3D SctSwapBytes16(ST_NO_SESSIONS); + CommandInput.CommandSize =3D SctSwapBytes32(sizeof(TPM2_HASH_COMMAND)); + CommandInput.CommandCode =3D SctSwapBytes32(TPM_CC_Hash); + CommandInput.data.size =3D SctSwapBytes16(SctAsciiStrLen(Str)); + SctAsciiStrCpy((CHAR8 *)CommandInput.data.buffer, Str); + CommandInput.hashAlg =3D SctSwapBytes16(TPM_ALG_SHA256); + CommandInput.hierarchy =3D SctSwapBytes32(TPM_RH_NULL); + + // allocate buffer for response + SctZeroMem(&CommandResponse, sizeof(TPM2_HASH_RESPONSE)); + + Status =3D TCG2->SubmitCommand ( + TCG2, + sizeof(TPM2_HASH_COMMAND), + (UINT8 *)&CommandInput, + sizeof(TPM2_HASH_RESPONSE), + (UINT8 *)&CommandResponse); + + + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + + // Verify SubmitCommand returns EFI_SUCCESS + if (Status !=3D EFI_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand= should return EFI_SUCCESS, Status =3D %r", + Status + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify SubmitCommand returns correct Response Tag + if (SctSwapBytes16(CommandResponse.Tag) !=3D ST_NO_SESSIONS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand= should return ST_NO_SESSIONS response Tag" + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Verify SubmitCommand returns correct Response Code + if (SctSwapBytes32(CommandResponse.ResponseCode) !=3D TPM_RC_SUCCESS) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand= should return Correct ResponseCode, ResponseCode =3D %x", + SctSwapBytes32(CommandResponse.ResponseCode) + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + + // Verify SubmitCommand returns correct Response Size + if (SctSwapBytes32(CommandResponse.ResponseSize) !=3D sizeof(TPM2_HASH_R= ESPONSE)) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand= should return Correct ResponseSize, Size =3D %x", + SctSwapBytes32(CommandResponse.ResponseSize) + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Check that the size of the buffer returned is size of SHA256 hash + if (SctSwapBytes16(CommandResponse.data.size) !=3D 32) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand= should return correct size digest for SHA256, Size =3D %x", + SctSwapBytes16(CommandResponse.data.size) + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + // Ensure Hash returned matches expected response for input + if (0 !=3D SctCompareMem(Tpm2HashOut, CommandResponse.data.digest, SHA25= 6_LENGTH) ) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand s= hould return expected Hash for data that was hashed." + ); + + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTcg2ConformanceTestAssertionGuid017, + L"EFI_TCG2_PROTOCOL. SubmitComand() - SubmitCommand() sha= ll populate the response buffer and return with a status of EFI_SUCCESS whe= n valid command parameters are passed in.", + 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 index f7b9e487eda2..25c3eab2cccd 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 @@ -65,6 +65,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] =3D { EFI_TEST_CASE_AUTO, BBTestHashLogExtendEventConformanceTest }, + { + EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104, + L"SubmitCommand_Conf", + L"Test the SubmitCommmand API", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestSubmitCommandConformanceTest + }, 0 }; -- 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113492): https://edk2.groups.io/g/devel/message/113492 Mute This Topic: https://groups.io/mt/103625307/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 (#116850): https://edk2.groups.io/g/devel/message/116850 Mute This Topic: https://groups.io/mt/103625307/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-