/* Check whether the input key option is valid. */
BOOLEAN BmIsKeyOptionValid(IN CONST EFI_BOOT_MANAGER_KEY_OPTION *KeyOption, IN UINTN KeyOptionSize)
/* Check whether the input key option is valid. */
BOOLEAN BmIsKeyOptionValid(IN CONST EFI_BOOT_MANAGER_KEY_OPTION *KeyOption, IN UINTN KeyOptionSize)
{
  UINT16  OptionName[BM_OPTION_NAME_LEN];
  UINT8   *BootOption;
  UINTN   BootOptionSize;
  UINT32  Crc;
  if (BmSizeOfKeyOption (KeyOption) != KeyOptionSize) {
    return FALSE;
  }
  UnicodeSPrint (
    OptionName,
    sizeof (OptionName),
    L"%s%04x",
    mBmLoadOptionName[LoadOptionTypeBoot],
    KeyOption->BootOption
    );
  GetEfiGlobalVariable2 (OptionName, (VOID **)&BootOption, &BootOptionSize);
  if (BootOption == NULL) {
    return FALSE;
  }
  gBS->CalculateCrc32 (BootOption, BootOptionSize, &Crc);
  FreePool (BootOption);
  return (BOOLEAN)(KeyOption->BootOptionCrc == Crc);
}