/* Recognize the Hash algorithm in PE/COFF Authenticode and calculate hash of Pe/Coff image based on the authenticated image hashing in PE/COFF Specification 8.0 Appendix A */
EFI_STATUS HashPeImageByType(VOID)
/* Recognize the Hash algorithm in PE/COFF Authenticode and calculate hash of Pe/Coff image based on the authenticated image hashing in PE/COFF Specification 8.0 Appendix A */
EFI_STATUS HashPeImageByType(VOID)
{
  UINT8                     Index;
  WIN_CERTIFICATE_EFI_PKCS  *PkcsCertData;
  PkcsCertData = (WIN_CERTIFICATE_EFI_PKCS *)(mImageBase + mSecDataDir->Offset);
  for (Index = 0; Index < HASHALG_MAX; Index++) {
    if ((*(PkcsCertData->CertData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) {
      continue;
    }
    if (CompareMem (PkcsCertData->CertData + 32, mHash[Index].OidValue, mHash[Index].OidLength) == 0) {
      break;
    }
  }
  if (Index == HASHALG_MAX) {
    return EFI_UNSUPPORTED;
  }
  if (!HashPeImage (Index)) {
    return EFI_UNSUPPORTED;
  }
  return EFI_SUCCESS;
}