Skip to content

Commit

Permalink
DeviceSecurityTestPkg: Test LIBSPDM_MAX_ROOT_CERT_SUPPORT.
Browse files Browse the repository at this point in the history
1. there is only one SignatureList in database.
2. The total number of RootCert in database exceed the
 LIBSPDM_MAX_ROOT_CERT_SUPPORT.
3. Then fail to set multiple root certificates as
 trust anchors in SPDM context.
4. Finally fail to create a connection with the SPDM device
 and extend some error in PCR.

Signed-off-by: Zhao, Zhiqiang <zhiqiang.zhao@intel.com>
  • Loading branch information
Zhiqiang520 committed Dec 21, 2022
1 parent 8453ff0 commit 584e0cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions DeviceSecurityTestPkg/Include/Test/TestConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
#define TEST_CONFIG_NO_EFI_CERT_X509_GUID_IN_DB 23
#define TEST_CONFIG_SPDM_MESSAGE_VERSION_11 24
#define TEST_CONFIG_SPDM_MESSAGE_VERSION_10 25
#define TEST_CONFIG_MAX_ROOT_CERT_SUPPORT_IN_DB 26

#endif
14 changes: 14 additions & 0 deletions DeviceSecurityTestPkg/Test/DeployCert/DeployCert.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ MainEntryPoint (
ShaHashAllFunc ShaHashAll;
UINT8 *RootKey;
UINTN RootKeySize;
UINTN CertCount;

Status = ShellCommandLineParse (mParamList, &ParamPackage, NULL, TRUE);
if (EFI_ERROR (Status)) {
Expand Down Expand Up @@ -522,6 +523,19 @@ MainEntryPoint (
RootCert,
RootCertSize
);
} else if (TestConfig == TEST_CONFIG_MAX_ROOT_CERT_SUPPORT_IN_DB) {
// The total number of RootCert in database exceed the LIBSPDM_MAX_ROOT_CERT_SUPPORT.
CertCount = LIBSPDM_MAX_ROOT_CERT_SUPPORT + 1;
SignatureHeaderSize = 0;
DbSize = sizeof (EFI_SIGNATURE_LIST) + SignatureHeaderSize + CertCount * sizeof(EFI_SIGNATURE_DATA);
DbList = AllocateZeroPool (DbSize);
SignatureList = DbList;
SignatureListSize = DbSize;
ASSERT (SignatureList != NULL);
CopyGuid (&SignatureList->SignatureType, &gEfiCertX509Guid);
SignatureList->SignatureListSize = (UINT32)SignatureListSize;
SignatureList->SignatureHeaderSize = (UINT32)SignatureHeaderSize;
SignatureList->SignatureSize = (UINT32)(sizeof(EFI_SIGNATURE_DATA));
} else {
SignatureHeaderSize = 0;
DbSize = sizeof (EFI_SIGNATURE_LIST) + SignatureHeaderSize + sizeof (EFI_GUID) + RootCertSize;
Expand Down

0 comments on commit 584e0cf

Please sign in to comment.