/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will validate its data structure within this image buffer before use. */
EFI_STATUS HashPeImageByType(IN UINT8 *AuthData, IN UINTN AuthDataSize)
/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will validate its data structure within this image buffer before use. */
EFI_STATUS HashPeImageByType(IN UINT8 *AuthData, IN UINTN AuthDataSize)
{
  UINT8  Index;
  for (Index = 0; Index < HASHALG_MAX; Index++) {
    if ((*(AuthData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) {
      continue;
    }
    if (AuthDataSize < 32 + mHash[Index].OidLength) {
      return EFI_UNSUPPORTED;
    }
    if (CompareMem (AuthData + 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;
}