fwupd/src/fu-keyring-utils.c
Richard Hughes 5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00

46 lines
1.1 KiB
C

/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#define G_LOG_DOMAIN "FuKeyring"
#include <config.h>
#include <string.h>
#include "fwupd-error.h"
#include "fu-keyring-utils.h"
/**
* fu_keyring_get_release_flags:
* @release: A #XbNode, e.g. %FWUPD_KEYRING_KIND_GPG
* @flags: A #FwupdReleaseFlags, e.g. %FWUPD_RELEASE_FLAG_TRUSTED_PAYLOAD
* @error: A #GError, or %NULL
*
* Uses the correct keyring to get the trust flags for a given release.
*
* Returns: %TRUE if @flags has been set
**/
gboolean
fu_keyring_get_release_flags (XbNode *release,
FwupdReleaseFlags *flags,
GError **error)
{
GBytes *blob;
blob = g_object_get_data (G_OBJECT (release), "fwupd::ReleaseFlags");
if (blob == NULL)
return TRUE;
if (g_bytes_get_size (blob) != sizeof(FwupdReleaseFlags)) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"invalid fwupd::ReleaseFlags set by loader");
return FALSE;
}
memcpy (flags, g_bytes_get_data (blob, NULL), sizeof(FwupdReleaseFlags));
return TRUE;
}