Skip to content

Commit

Permalink
SecurityPkg/DeviceSecurity: add check for slot_mask in get_digest
Browse files Browse the repository at this point in the history
1. Ensure the slot_id 0 is valid;
2. Only get cert from valid slot_mask;

Signed-off-by: Wenxing Hou <[email protected]>
  • Loading branch information
Wenxing-hou authored and jyao1 committed Aug 15, 2023
1 parent c1dbca7 commit b822626
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ DoDeviceAuthentication (
if ((CapabilityFlags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP) != 0) {
ZeroMem (TotalDigestBuffer, sizeof (TotalDigestBuffer));
SpdmReturn = SpdmGetDigest (SpdmContext, NULL, &SlotMask, TotalDigestBuffer);
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
if ((LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) || ((SlotMask & 0x01) == 0)) {
SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
return EFI_DEVICE_ERROR;
}
Expand All @@ -552,6 +552,10 @@ DoDeviceAuthentication (
*ValidSlotId = SPDM_MAX_SLOT_COUNT;

for (SlotId = 0; SlotId < SPDM_MAX_SLOT_COUNT; SlotId++) {
if (((SlotMask >> SlotId) & 0x01) == 0) {
continue;
}

CertChainSize = sizeof (CertChain);
ZeroMem (CertChain, sizeof (CertChain));
SpdmReturn = SpdmGetCertificateEx (SpdmContext, NULL, SlotId, &CertChainSize, CertChain, (CONST VOID **)&TrustAnchor, &TrustAnchorSize);
Expand Down

0 comments on commit b822626

Please sign in to comment.