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 7826DD806C6 for ; Tue, 5 Mar 2024 23:36:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lJxzjYIld/T6hbaJ3YKrOn5rhnT7b5VFds/gpjbPIzg=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1709681808; v=1; b=nC8jFJMLzVAOWlE3dgWwuUlSUxIRrlJd9ZVZhUsjtyLlpz+U+jtp+Kmmko3zQbhMDJO7n8ql s0zsqi9eFvyeWoIJOLZCI5CNsHSZ2oJjCsjGsRJSjeNhJYv4ktoKrt6wMPDvAkWXigGGMShT2rL kgI7foG+SeQU+CjeJ64My6sx21nKeMZdItfWrGSYXBEl46JTZW2dTFZ9HFNNpp1na0R8Mlh8DVV Fu6/3bA6ofiNK5OQvTvLnNIPW2XoshV0HBpJWONnqv4YfYFsXn2yPbjo+hZBJDmpvnYzxJAgBI3 BIJ1WaorCoh1uQL9PJ7PR1Hd9MMo7wf9EZgkJlvJ97KjA== X-Received: by 127.0.0.2 with SMTP id OmuPYY7687511xAUDLhKlO2H; Tue, 05 Mar 2024 15:36:48 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3766.1709681807595879614 for ; Tue, 05 Mar 2024 15:36:47 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 22B891FB; Tue, 5 Mar 2024 15:37:24 -0800 (PST) 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 F3E003F73F; Tue, 5 Mar 2024 15:36:46 -0800 (PST) From: "Abhimanyu Singh" To: devel@edk2.groups.io Cc: Abhi Singh , G Edhaya Chandran , Barton Gao , Carolyn Gjertsen , Abhi Singh , Stuart Yoder Subject: [edk2-devel] [PATCH v4 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with Key State Test Date: Tue, 5 Mar 2024 17:36:22 -0600 Message-Id: <20240305233622.747522-7-Abhi.Singh@arm.com> In-Reply-To: <20240305233622.747522-1-Abhi.Singh@arm.com> References: <20240305233622.747522-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: kVB4ud4clQaBN6OgfR6oEYtVx7686176AA= 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=nC8jFJML; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) 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 32 - 49 from SCT spec -Add Test Case to MemoryOverwriteRequestFunctionTest Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Signed-off-by: Abhi Singh Reviewed-by: Stuart Yoder --- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.h | 96 ++- 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 | 39 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 669 ++++++++++++= ++++++++ 4 files changed, 805 insertions(+), 10 deletions(-) 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 612e6ee436e0..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 @@ -85,8 +85,6 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID \=0D { 0x2eba284a, 0xf701, 0x4c19, {0xbe, 0x5c, 0x39, 0x27, 0xb0, 0x68, 0x4f, 0= xd7 }}=0D =0D -<<<<<<< HEAD=0D -=3D=3D=3D=3D=3D=3D=3D=0D #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID \=0D { 0x9a1b44ae, 0x08ce, 0x474c, {0xa5, 0x8e, 0xa6, 0xe2, 0xcf, 0xaf, 0x91, 0= x2c }}=0D =0D @@ -120,7 +118,60 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID \=0D { 0xe88b22ce, 0x3de6, 0x49b0, {0xb2, 0x46, 0x9e, 0x35, 0x98, 0x2b, 0x9b, 0= x1c }}=0D =0D ->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=0D +#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 @@ -160,8 +211,6 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionA= ssertionGuid018; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020;=0D -<<<<<<< HEAD=0D -=3D=3D=3D=3D=3D=3D=3D=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021;=0D =0D @@ -184,4 +233,39 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunction= AssertionGuid029; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;=0D ->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=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 7e00224c325c..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 @@ -67,8 +67,6 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionG= uid018 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_019_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_020_GUID;=0D -<<<<<<< HEAD=0D -=3D=3D=3D=3D=3D=3D=3D=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_021_GUID;=0D =0D @@ -91,4 +89,39 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertion= Guid029 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_030_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_031_GUID;=0D ->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=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 7780b390a5f2..f5418c20d4a5 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 @@ -192,6 +192,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( }=0D CheckpointStepMatched =3D TRUE;=0D }=0D + if (ResetData->CheckpointStep =3D=3D LOCK_WITH_KEY_STATE_TEST) {=0D + //=0D + // Test Checkpoint LOCK_WITH_KEY_STATE_TEST=0D + //=0D + Status =3D TCGMemoryOverwriteRequestControlLockLockedWithKeyState (Sta= ndardLib, RecoveryLib, ResetData);=0D + if(EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D + CheckpointStepMatched =3D TRUE;=0D + }=0D =0D if (!CheckpointStepMatched) {=0D return EFI_INVALID_PARAMETER; // incase of invalid CheckpointStep, ret= urn EFI_INVALID_PARAMETER=0D @@ -1719,3 +1729,662 @@ 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 + //=0D + // Check Step to see which part of test remains to be executed=0D + //=0D + switch (ResetData->Step) {=0D + case 0:=0D + goto INITIAL_RESET;=0D + case 1:=0D + goto MORLOCK_LOCKED_KEY_STATE;=0D + default:=0D + return EFI_INVALID_PARAMETER;=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 +=0D + SctPrint (L"System will cold reset after 1 second and test will be resum= ed after reboot.");=0D + Status =3D gtBS->Stall(1000000);=0D + if (EFI_ERROR(Status)) {=0D + // Handle stall error=0D + SctPrint(L"Error: Failed to stall the system.\n");=0D + return Status;=0D + }=0D + gtRT->ResetSystem (=0D + EfiResetCold,=0D + EFI_SUCCESS,=0D + 0,=0D + NULL=0D + );=0D + SctPrint(L"Error: Failed to perform a cold reset.\n");=0D + return EFI_DEVICE_ERROR;=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= with-key using key value =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is now = locked-with-key with key value =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Currently locked-with-key, invoke SetVariable() with the same valid 8= byte 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034,= =0D + L"MemoryOverwriteRequestControlLock - Unlocking the lock= using key value =3D 0x11111111 when locked with the same key returns EFI_S= UCCESS",=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035,= =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 remain =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= with-key using key value =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037,= =0D + L"MemoryOverwriteRequestControlLock - Attempting to unlo= ck by passing an 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039,= =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041,= =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =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 MOR and setting the bit 0=0D + MemoryOverwriteRequestControlDataCached =3D MemoryOverwriteRequestContro= lData;=0D + MemoryOverwriteRequestControlData |=3D MOR_BIT_HIGH << MOR_CLEAR_MEMORY_= BIT_OFFSET;=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043,= =0D + L"MemoryOverwriteRequestControl - SetVariable() returns = EFI_ACCESS_DENIED when MORLOCK is locked-with-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 SetVariable()= =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044,= =0D + L"MemoryOverwriteRequestControl - After SetVariable(), M= OR value remains unchanged when MORLOCK is locked-with-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-with-key, MOR cannot be deleted=0D + // SetVariable() call to set MOR with DataSize =3D=3D 0 must return EFI_= ACCESS_DENIED=0D + // MemoryOverwriteControlData is a don't care in this case=0D + DataSize =3D 0;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=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 || EFI_INVALID_PARAMETER) {=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 - When MORLOCK is locked= -with-key, an attempt to delete the MOR variable must return either EFI_ACC= ESS_DENIED or EFI_INVALID_PARAMETER",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // When locked-with-key, in this case key =3D 0x11111111,=0D + // SetVariable() with an invalid 8 byte key !=3D 0x11111111, must return= EFI_ACCESS_DENIED=0D + // and lock must be updated to Locked without key (Data value =3D 0x01) = to prevent dictonary 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;=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 + // MORLOCK 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 initial k= ey used to set to lock-with-key state=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 = 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 (#116412): https://edk2.groups.io/g/devel/message/116412 Mute This Topic: https://groups.io/mt/104756657/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-