/* It searches the signature list for the certificate hash by CertType. If the signature list is found, get the offset of Database for the next hash of a certificate. */
BOOLEAN GetSignaturelistOffset(IN EFI_SIGNATURE_LIST *Database, IN UINTN DatabaseSize, IN EFI_GUID *SignatureType, OUT UINTN *Offset)
/* It searches the signature list for the certificate hash by CertType. If the signature list is found, get the offset of Database for the next hash of a certificate. */
BOOLEAN GetSignaturelistOffset(IN EFI_SIGNATURE_LIST *Database, IN UINTN DatabaseSize, IN EFI_GUID *SignatureType, OUT UINTN *Offset)
{
  EFI_SIGNATURE_LIST  *SigList;
  UINTN               SiglistSize;
  if ((Database == NULL) || (DatabaseSize == 0)) {
    *Offset = 0;
    return FALSE;
  }
  SigList     = Database;
  SiglistSize = DatabaseSize;
  while ((SiglistSize > 0) && (SiglistSize >= SigList->SignatureListSize)) {
    if (CompareGuid (&SigList->SignatureType, SignatureType)) {
      *Offset = DatabaseSize - SiglistSize;
      return TRUE;
    }
    SiglistSize -= SigList->SignatureListSize;
    SigList      = (EFI_SIGNATURE_LIST *)((UINT8 *)SigList + SigList->SignatureListSize);
  }
  *Offset = 0;
  return FALSE;
}