Skip to content

Commit 4edf114

Browse files
committed
DeviceSecurityPkg: test exceed LIBSPDM_MAX_ROOT_CERT_SUPPORT.
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. Signed-off-by: Zhao, Zhiqiang <[email protected]>
1 parent 8dcc69f commit 4edf114

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

DeviceSecurityPkg/Include/Test/TestConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
#define TEST_CONFIG_MULTIPLE_CERT_IN_DB 21
3333
#define TEST_CONFIG_DIFF_CERT_IN_DIFF_SLOT 22
3434
#define TEST_CONFIG_NO_EFI_CERT_X509_GUID_IN_DB 23
35+
#define TEST_CONFIG_MAX_ROOT_CERT_SUPPORT_IN_DB 24
3536

3637
#endif

DeviceSecurityPkg/Test/DeployCert/DeployCert.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ MainEntryPoint (
346346
ShaHashAllFunc ShaHashAll;
347347
UINT8 *RootKey;
348348
UINTN RootKeySize;
349+
UINTN CertCount;
349350

350351
Status = ShellCommandLineParse (mParamList, &ParamPackage, NULL, TRUE);
351352
if (EFI_ERROR (Status)) {
@@ -524,6 +525,19 @@ MainEntryPoint (
524525
RootCert,
525526
RootCertSize
526527
);
528+
} else if (TestConfig == TEST_CONFIG_MAX_ROOT_CERT_SUPPORT_IN_DB) {
529+
// The total number of RootCert in database exceed the LIBSPDM_MAX_ROOT_CERT_SUPPORT.
530+
CertCount = LIBSPDM_MAX_ROOT_CERT_SUPPORT + 1;
531+
SignatureHeaderSize = 0;
532+
DbSize = sizeof (EFI_SIGNATURE_LIST) + SignatureHeaderSize + CertCount * sizeof(EFI_SIGNATURE_DATA);
533+
DbList = AllocateZeroPool (DbSize);
534+
SignatureList = DbList;
535+
SignatureListSize = DbSize;
536+
ASSERT (SignatureList != NULL);
537+
CopyGuid (&SignatureList->SignatureType, &gEfiCertX509Guid);
538+
SignatureList->SignatureListSize = (UINT32)SignatureListSize;
539+
SignatureList->SignatureHeaderSize = (UINT32)SignatureHeaderSize;
540+
SignatureList->SignatureSize = (UINT32)(sizeof(EFI_SIGNATURE_DATA));
527541
} else {
528542
SignatureHeaderSize = 0;
529543
DbSize = sizeof (EFI_SIGNATURE_LIST) + SignatureHeaderSize + sizeof (EFI_GUID) + RootCertSize;

0 commit comments

Comments
 (0)