Skip to content

Commit

Permalink
uefi-sct/SctPkg: Correct check image test behavior
Browse files Browse the repository at this point in the history
Now, in our SCT test case "CheckImage" behavior have some problems.Once
tool need to check the "EFI_SECURITY_VIOLATION" have correct return from
"EFI_FIRMWARE_MANAGEMENT_PROTOCOL->CheckImage" function, the function wil
because tool behavior probability return EFI_BUFFER_TOO_SMALL,so we should
gave it a correct header info to make the test item can process correctly.

Cc: ArvinX Chen <arvinx.chen@intel.com>
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Signed-off-by: ArvinX Chen <arvinx.chen@intel.com>

Reviewed-By: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Reviewed-by: G Edhaya Chandran<edhaya.chandran@arm.com>
  • Loading branch information
devel@edk2.groups.io authored and edhay committed Dec 7, 2020
1 parent 58c61e7 commit 7be3e2d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2901,14 +2901,16 @@ BBTestCheckImageConformanceTestCheckpoint2 (
UINTN i;
EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
UINTN FunctionTested;

EFI_FIRMWARE_IMAGE_AUTHENTICATION *EFIA;
EFI_GUID gEfiCertPkcs7Guid;
//
// Init
//

Status = EFI_SUCCESS;
AssertionType = EFI_TEST_ASSERTION_PASSED;
TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid012;
gEfiCertPkcs7Guid = gFirmwareManagementBBTestConformanceSupportGuid005;
ResultMessageLabel = L"CheckImage, conformance checkpoint #2";

BufferImageInfo = NULL;
Expand Down Expand Up @@ -3020,6 +3022,13 @@ BBTestCheckImageConformanceTestCheckpoint2 (
ResultMessageData = L"test case initialization failure.";
goto Exit;
}

EFIA = Image;
EFIA->AuthInfo.Hdr.dwLength = sizeof(WIN_CERTIFICATE_UEFI_GUID)+0x10;
EFIA->AuthInfo.Hdr.wRevision = 0x0200;
EFIA->AuthInfo.Hdr.wCertificateType = WIN_CERT_TYPE_EFI_GUID;
for (i=0; i<sizeof(EFI_GUID); ((UINT8*)&EFIA->AuthInfo.CertType)[i]=((UINT8*)&gEfiCertPkcs7Guid)[i], i++);

BufferImage = Image;
FunctionTested++;
Status = FirmwareManagement->CheckImage (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid001=EFI_TEST_FIRMWAREMAN
EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_002_GUID;
EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_003_GUID;
EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_004_GUID;
EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid005=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_005_GUID;

EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_001_GUID;
EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_002_GUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003;

extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004;

#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_005_GUID \
{ 0x4aafd29d, 0x68df, 0x49ee, {0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7 }}

extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid005;

// ****************************************************************************
// Conformance - Assertion
// ****************************************************************************
Expand Down
23 changes: 23 additions & 0 deletions uefi-sct/SctPkg/UEFI/Protocol/FirmwareManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ UINT64 AttributesSetting;
UINT64 Compatibilities;
} EFI_FIRMWARE_IMAGE_DESCRIPTOR;

typedef struct {
///
/// It is included in the signature of AuthInfo. It is used to ensure freshness/no replay.
/// It is incremented during each firmware image operation.
///
UINT64 MonotonicCount;
///
/// Provides the authorization for the firmware image operations. It is a signature across
/// the image data and the Monotonic Count value. Caller uses the private key that is
/// associated with a public key that has been provisioned via the key exchange.
/// Because this is defined as a signature, WIN_CERTIFICATE_UEFI_GUID.CertType must
/// be EFI_CERT_TYPE_PKCS7_GUID.
///
WIN_CERTIFICATE_UEFI_GUID AuthInfo;
} EFI_FIRMWARE_IMAGE_AUTHENTICATION;

//
// Image Attribute Definitions
//
Expand All @@ -79,6 +95,13 @@ UINT64 Compatibilities;

#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 1

//
// _WIN_CERTIFICATE.wCertificateType
//
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
#define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0
#define WIN_CERT_TYPE_EFI_GUID 0x0EF1

/*++
//
// Image Attribute Authentication Required
Expand Down

0 comments on commit 7be3e2d

Please sign in to comment.