/* Finalizes a hash operation in progress and returns calculation result. The output is final with any necessary padding added by the function. The hash may not be further updated or extended after HashFinal(). */
EFI_STATUS EFIAPI BaseCrypto2HashFinal(IN CONST EFI_HASH2_PROTOCOL *This, IN OUT EFI_HASH2_OUTPUT *Hash)
/* Finalizes a hash operation in progress and returns calculation result. The output is final with any necessary padding added by the function. The hash may not be further updated or extended after HashFinal(). */
EFI_STATUS EFIAPI BaseCrypto2HashFinal(IN CONST EFI_HASH2_PROTOCOL *This, IN OUT EFI_HASH2_OUTPUT *Hash)
{
  EFI_HASH_INFO        *HashInfo;
  VOID                 *HashCtx;
  BOOLEAN              Ret;
  HASH2_INSTANCE_DATA  *Instance;
  if ((This == NULL) || (Hash == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Instance = HASH2_INSTANCE_DATA_FROM_THIS (This);
  if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL) ||
      (!Instance->Updated))
  {
    return EFI_NOT_READY;
  }
  HashInfo = Instance->HashInfoContext;
  HashCtx  = Instance->HashContext;
  Ret = HashInfo->Final (HashCtx, (UINT8 *)Hash->Sha1Hash);
  FreePool (HashCtx);
  Instance->HashInfoContext = NULL;
  Instance->HashContext     = NULL;
  Instance->Updated         = FALSE;
  if (!Ret) {
    return EFI_OUT_OF_RESOURCES;
  }
  return EFI_SUCCESS;
}