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 3BFF0AC1899 for ; Thu, 21 Sep 2023 16:38:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lG9SasLtIuRxm39GoV762FEdgYPixKUlHS/ZLbbzzqs=; c=relaxed/simple; d=groups.io; h=From:To: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=1695314279; v=1; b=wsFV+oub+fRxCZwajxPXJOyPe2oBvdrMPtLZXJ7NF96dvrwQsQuEGuBWN1Ux2/G+QqtCYTbm McYFsvMCkVbvIM+KLnnaQ8oUxRoWImm7Xe7aHGPu0SOQYwwHK/L9I1kJqCPAX+mkzgw+/zrNsHj fng5dEc7tBKgb261KFFh7blM= X-Received: by 127.0.0.2 with SMTP id MIaYYY7687511xabVQvWNowH; Thu, 21 Sep 2023 09:37:59 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.162.1695314273974482631 for ; Thu, 21 Sep 2023 09:37:54 -0700 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 13C211AED for ; Thu, 21 Sep 2023 09:38:30 -0700 (PDT) X-Received: from beelzebub.ast.arm.com (abhsin07-ThinkStation-P720.austin.arm.com [10.118.30.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D49D93F59C for ; Thu, 21 Sep 2023 09:37:52 -0700 (PDT) From: "Abhimanyu Singh" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with Key State Test Date: Thu, 21 Sep 2023 11:37:48 -0500 Message-Id: <20230921163748.275971-7-Abhi.Singh@arm.com> In-Reply-To: <20230921163748.275971-1-Abhi.Singh@arm.com> References: <20230921163748.275971-1-Abhi.Singh@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,Abhi.Singh@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: eaB617QgBBUtlaTaXauoIPmcx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=wsFV+oub; 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 SCT spec: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4374 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4419 -Implement MemoryOverwriteRequestControlLock Locked with Key State test cases -Add remaining Assertions 33 - 49 from SCT spec -Add Test Case to MemoryOverwriteRequestFunctionTest Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Signed-off-by: Abhi Singh Change-Id: Ifade96b0c6ec9e7f9bfb0eba8ceeb92380271e8b --- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.h | 85 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 11 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.c | 34 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 623 ++++++++++++= ++++++++ 4 files changed, 752 insertions(+), 1 deletion(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Runti= meServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h index 023e7a37322c..cf7f3e180f54 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.h @@ -121,6 +121,57 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_032_GUID \=0D { 0xc8894201, 0x7a3a, 0x47d4, {0xa8, 0x8d, 0xdf, 0x4b, 0x03, 0xff, 0xde, 0= x4f }}=0D =0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_033_GUID \=0D +{ 0x38a813ac, 0x8eb9, 0x46ce, {0xa8, 0x6b, 0x40, 0x8c, 0x07, 0x5f, 0xc7, 0= xed }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_034_GUID \=0D +{ 0x919b8392, 0xcb78, 0x49ff, {0xa3, 0x18, 0x49, 0x78, 0x76, 0xe0, 0xf8, 0= xf8 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_035_GUID \=0D +{ 0x219abaf2, 0x04a9, 0x407c, {0xb5, 0xde, 0xa0, 0x03, 0x6e, 0x65, 0xb0, 0= xb9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_036_GUID \=0D +{ 0x9a51640a, 0xff14, 0x402b, {0xb0, 0x57, 0xa0, 0xc4, 0xf7, 0x20, 0x8e, 0= x44 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_037_GUID \=0D +{ 0x8ccd0dbb, 0x9b0a, 0x4bfb, {0xa0, 0x7e, 0xc6, 0x06, 0x8b, 0x91, 0x0d, 0= xfb }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_038_GUID \=0D +{ 0xde6f4e17, 0xe375, 0x4dcb, {0x8f, 0x07, 0x77, 0x7e, 0x62, 0x49, 0xea, 0= x2c }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_039_GUID \=0D +{ 0x4ab6927b, 0x5ee4, 0x4748, {0xa4, 0x9d, 0x2d, 0xf3, 0x70, 0x01, 0x41, 0= xd5 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_040_GUID \=0D +{ 0x33142ecf, 0x0f92, 0x4625, {0xb7, 0xf6, 0x7f, 0x15, 0x25, 0x74, 0xd3, 0= x03 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_041_GUID \=0D +{ 0xf73c04df, 0x2e42, 0x4174, {0x82, 0x18, 0x0f, 0x25, 0x46, 0x4a, 0x55, 0= xe9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_042_GUID \=0D +{ 0xd4eacf82, 0x55d1, 0x4ba1, {0xbe, 0x89, 0x6a, 0x2e, 0x44, 0x0f, 0xc7, 0= xc0 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_043_GUID \=0D +{ 0xfd88fe63, 0x5ed4, 0x482a, {0x98, 0x44, 0x23, 0x90, 0xf9, 0x09, 0x1c, 0= x20 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_044_GUID \=0D +{ 0x176f16cb, 0xf3a4, 0x4f12, {0x8f, 0x96, 0x4a, 0xc1, 0x8b, 0xdd, 0x6e, 0= x3c }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_045_GUID \=0D +{ 0xf0d5e7b3, 0xdc0f, 0x4a18, {0xb9, 0x78, 0x09, 0x3b, 0x15, 0x55, 0x66, 0= xbf }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_046_GUID \=0D +{ 0x9bf14c4b, 0x2950, 0x4c4e, {0x8b, 0xa3, 0x06, 0x46, 0xf1, 0x27, 0x8c, 0= x05 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_047_GUID \=0D +{ 0xb0468dee, 0xb1d0, 0x4795, {0x9f, 0xbf, 0xbe, 0x3f, 0x40, 0x2f, 0x3d, 0= x6f }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_048_GUID \=0D +{ 0x1f7dd903, 0xcd58, 0x4d6f, {0x80, 0xd6, 0x4f, 0x6d, 0xcb, 0x4a, 0xd6, 0= xc9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_049_GUID \=0D +{ 0x439179c2, 0x744d, 0x43bc, {0xb0, 0x67, 0x7b, 0x65, 0x60, 0x62, 0x6f, 0= x5e }}=0D +=0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;=0D @@ -184,3 +235,37 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunction= AssertionGuid030; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049;=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h b/uefi-sct= /SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBo= xTest/TCGMemoryOverwriteRequestBBTestMain.h index 94ed476f86ad..76b3c76340cf 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h @@ -50,11 +50,13 @@ typedef struct _RESET_DATA { =0D #define MOR_LOCK_DATA_UNLOCKED 0x0=0D #define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY 0x1=0D +#define MOR_LOCK_DATA_LOCKED_WITH_KEY 0x2=0D =0D +#define MOR_LOCK_NO_KEY_SIZE 1=0D #define MOR_LOCK_WITH_KEY_SIZE 8=0D =0D #define MOR_LOCK_TEST_KEY 0x11111111=0D -=0D +#define MOR_LOCK_INVALID_TEST_KEY 0x22222222=0D =0D //=0D // TEST GUID for TCG Platform Reset Attack Mitigation MemoryOverwriteReque= st (MOR) Test=0D @@ -118,6 +120,13 @@ TCGMemoryOverwriteRequestControlLockLockedNoKeyState ( IN RESET_DATA *ResetData=0D );=0D =0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlLockLockedWithKeyState (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,=0D + IN RESET_DATA *ResetData=0D + );=0D +=0D // ***********************************************************************= *****=0D // Entry GUIDs for Test=0D // ***********************************************************************= *****=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Runti= meServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c index 11d49306059d..6bde8f686a16 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.c @@ -91,3 +91,37 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertion= Guid030 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_031_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_032_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_033_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_034_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_035_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_036_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_037_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_038_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_039_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_040_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_041_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_042_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_043_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_044_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_045_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_046_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_047_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_048_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_049_GUID;=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c b/uefi= -sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/Bla= ckBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c index 5f5f369124f2..32f3a9cb58d5 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c @@ -170,6 +170,15 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( return Status;=0D }=0D }=0D + if (ResetData->CheckpointStep =3D=3D LOCK_WITH_KEY_STATE_TEST) {=0D + //=0D + // Test Checkpoint LOCK_WITH_KEY_STATE_TEST=0D + //=0D + TCGMemoryOverwriteRequestControlLockLockedWithKeyState (StandardLib, R= ecoveryLib, ResetData);=0D + if(EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D + }=0D //=0D // After all Checkpoints have run=0D //=0D @@ -1664,3 +1673,617 @@ MORLOCK_LOCKED_STATE: =0D return EFI_SUCCESS;=0D }=0D +=0D +=0D +/**=0D + * MemoryOverwriteRequestControlLock in Locked with Key State Test=0D + * When Unlocked, a valid SetVariable() with an 8 byte key must return EF= I_SUCCESS=0D + * and the Lock value must be 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY), in or= der to =0D + * unlock, the same 8 byte key must be passed.=0D + * =0D + * When Locked with an 8 byte key, SetVariable() with the same 8 byte key= =0D + * must return EFI_SUCCESS and the Lock value must be 0x00 or MOR_LOCK_DA= TA_UNLOCKED.=0D + *=0D + * When Locked with an 8 byte Key, SetVariable() with DataSize !=3D 8 and= =0D + * Data =3D 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_KEY) or 0x00 (MOR_LOCK_DAT= A_UNLOCKED)=0D + * must return EFI_ACCESS_DENIED=0D + * and value must still equal to 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY).=0D + *=0D + * When Locked with an 8 byte Key, SetVariable() with 8 byte key !=3D key= used to set=0D + * the lock, in this case 0x11111111 (MOR_LOCK_TEST_KEY), must return EFI= _ACCESS_DENIED=0D + * and lock value must be updated to 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY)=0D + * to prevent dictonary attack.=0D + *=0D + * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL= =0D + * instance.=0D + * @param RecoveryLib A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL= =0D + * instance.=0D + * @param ResetData A pointer to the ResetData Buffer which is used = throughout=0D + * the test=0D + * @return EFI_SUCCESS Successfully.=0D + * @return Other value Something failed.=0D + */=0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlLockLockedWithKeyState (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,=0D + IN RESET_DATA *ResetData=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_TEST_ASSERTION Result;=0D + UINTN DataSize;=0D + UINT8 MemoryOverwriteRequestControlLockDa= ta;=0D + UINTN MemoryOverwriteControlLockKeyValue;= =0D + UINT8 MemoryOverwriteRequestControlData;= =0D + UINT8 MemoryOverwriteRequestControlDataCa= ched;=0D + UINT32 Attributes;=0D +=0D + if (ResetData->Step =3D=3D 0) {=0D + goto INITIAL_RESET;=0D + } else if (ResetData->Step =3D=3D 1) {=0D + goto MORLOCK_LOCKED_KEY_STATE;=0D + }=0D +=0D +INITIAL_RESET:=0D + //=0D + // Reset MORLock variable by performing a cold reset=0D + //=0D +=0D + ResetData->Step =3D 1;=0D + ResetData->CheckpointStep =3D LOCK_WITH_KEY_STATE_TEST;=0D + Status =3D RecoveryLib->WriteResetRecord (=0D + RecoveryLib,=0D + sizeof (RESET_DATA),=0D + (UINT8*)ResetData=0D + );=0D + if (EFI_ERROR(Status)) {=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + EFI_TEST_ASSERTION_FAILED,=0D + gTestGenericFailureGuid,=0D + L"TestRecoveryLib - WriteResetRecord",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + return Status;=0D + }=0D + SctPrint (L"System will cold reset after 1 second...");=0D + gtBS->Stall (1000000);=0D + gtRT->ResetSystem (=0D + EfiResetCold,=0D + EFI_SUCCESS,=0D + 0,=0D + NULL=0D + );=0D +=0D +MORLOCK_LOCKED_KEY_STATE:=0D + //=0D + // MORLOCK Reboot system to clear Lock, and invoke SetVariable() with va= lid 8 byte key=0D + // In this case =3D 0x11111111, must return EFI_SUCCESS and GetVariable(= ) value must =3D 0x02=0D + //=0D +=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_SUCCESS) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033,= =0D + L"MemoryOverwriteRequestControlLock - Setting to Locked = with key =3D 0x11111111 when Unlocked returns EFI_SUCCESS",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITH_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is now = Locked and Key =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Locked with 8 byte key, invoke SetVariable() with the same valid 8 by= te key used to lock=0D + // In this case =3D 0x11111111, must return EFI_SUCCESS and GetVariable(= ) value must =3D 0x00=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_SUCCESS) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035,= =0D + L"MemoryOverwriteRequestControlLock - Setting to unlocke= d with key =3D 0x11111111 when Locked with the same key returns EFI_SUCCESS= ",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_UNLOCKED)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is now = Unlocked",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Lock with same 8 byte key again, verify EFI_SUCCESS is returned=0D + // unlock attempt: invoke SetVariable() with the same valid 8 byte =0D + // key used to lock =3D 0x11111111, but with invalid DataSize =3D=3D 1=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must =3D 0x02=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_SUCCESS) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037,= =0D + L"MemoryOverwriteRequestControlLock - Setting to Locked = with key =3D 0x11111111 when Unlocked returns EFI_SUCCESS",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D MOR_LOCK_NO_KEY_SIZE; // invalid datasize =3D=3D 1=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038,= =0D + L"MemoryOverwriteRequestControlLock - Attempting to unlo= ck by passing Invalid DataSize returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITH_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is stil= l Locked with Key =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // invoke MORLOCK SetVariable() with Data value =3D 0x00 to change to un= locked=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must still =3D = 0x02=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_UNLOCKED;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040,= =0D + L"MemoryOverwriteRequestControlLock - Setting to Unlocke= d when Locked with key returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITH_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is stil= l Locked with Key =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // invoke MORLOCK SetVariable() with Data value =3D 0x01 to change to lo= cked without key=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must still =3D = 0x02=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042,= =0D + L"MemoryOverwriteRequestControlLock - Setting to Locked = without key when Locked with key returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITH_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is stil= l Locked with Key =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once Locked with key, MOR SetVariable() call to set MOR Bit 0 must re= turn EFI_ACCESS_DENIED=0D + // and MOR value must not change=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + // getting current MOR value that will be used to check that the variabl= e is unchanged=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + &Attributes, // Attributes=0D + &DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + // caching variable and setting the bit 0=0D + MemoryOverwriteRequestControlDataCached =3D MemoryOverwriteRequestContro= lData;=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlData |=3D MOR_BIT_HIGH << MOR_CLEAR_MEMORY_= BIT_OFFSET;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + Attributes, // Attributes=0D + DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044,= =0D + L"MemoryOverwriteRequestControl - SetVariable() returns = EFI_ACCESS_DENIED when Lock is Set with no key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + &Attributes, // Attributes=0D + &DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D +=0D + // verifying that the variable has not been modified with SetVar=0D + if (MemoryOverwriteRequestControlDataCached =3D=3D MemoryOverwriteReques= tControlData) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045,= =0D + L"MemoryOverwriteRequestControl - SetVariable() value re= mains unchanged when Lock is Set with no key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // When Locked with an 8 byte Key, SetVariable() with 8 byte key !=3D ke= y used to set=0D + // the lock, in this case 0x11111111, must return EFI_ACCESS_DENIED and = lock must=0D + // be updated Locked without key (Data value =3D 0x01) to prevent dicton= ary attack=0D + // The invalid key to be used to attempt unlock is =3D 0x22222222=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_INVALID_TEST_KEY; //INVA= LID KEY !=3D 0x11111111=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046,= =0D + L"MemoryOverwriteRequestControlLock - Unlocking Lock wit= h Invalid key !=3D 0x11111111 returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is now = locked without key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Lock has been updated to Locked without key (Data value =3D 0x01) to = prevent dictonary attack=0D + // Now check to see if the Lock can still be unlocked with the corect Ke= y from assertion 37=0D + // The key to be used to attempt unlock is =3D 0x11111111=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048,= =0D + L"MemoryOverwriteRequestControlLock - Attempt to unlock = Lock after dictionary attack mitigation returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049,= =0D + L"MemoryOverwriteRequestControlLock - Lock State is stil= l locked without key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108954): https://edk2.groups.io/g/devel/message/108954 Mute This Topic: https://groups.io/mt/101504341/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-