gpg: Add OstreeGpgVerifyResult

Wrappers a referenced gpgme_verify_result_t so detailed verify results
can be examined independently of executing a verify operation.

_ostree_gpg_verifier_check_signature() now returns this object instead
of a single valid/invalid boolean, but the idea is for OstreeRepo to also
return this object for commit signature verification so it can be utilized
at the CLI layer (and possibly by other programs).
This commit is contained in:
Matthew Barnes committed 2015-03-18 11:52:22 -04:00
1 parent 553d7840d5
commit 4a2733f9e7
19 files changed
+1679 -105

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include <gio/gio.h>
G_BEGIN_DECLS
#define OSTREE_TYPE_GPG_VERIFY_RESULT \
(ostree_gpg_verify_result_get_type ())
#define OSTREE_GPG_VERIFY_RESULT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_GPG_VERIFY_RESULT, OstreeGpgVerifyResult))
#define OSTREE_IS_GPG_VERIFY_RESULT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSTREE_TYPE_GPG_VERIFY_RESULT))
typedef struct OstreeGpgVerifyResult OstreeGpgVerifyResult;
/**
* OstreeGpgSignatureAttr:
* @OSTREE_GPG_SIGNATURE_ATTR_VALID:
* [#G_VARIANT_TYPE_BOOLEAN] Is the signature valid?
* @OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED:
* [#G_VARIANT_TYPE_BOOLEAN] Has the signature expired?
* @OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED:
* [#G_VARIANT_TYPE_BOOLEAN] Has the signing key expired?
* @OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED:
* [#G_VARIANT_TYPE_BOOLEAN] Has the signing key been revoked?
* @OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING:
* [#G_VARIANT_TYPE_BOOLEAN] Is the signing key missing?
* @OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT:
* [#G_VARIANT_TYPE_STRING] Fingerprint of the signing key
* @OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP:
* [#G_VARIANT_TYPE_INT64] Signature creation Unix timestamp
* @OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP:
* [#G_VARIANT_TYPE_INT64] Signature expiration Unix timestamp (0 if no
* expiration)
* @OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME:
* [#G_VARIANT_TYPE_STRING] Name of the public key algorithm used to create
* the signature
* @OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME:
* [#G_VARIANT_TYPE_STRING] Name of the hash algorithm used to create the
* signature
* @OSTREE_GPG_SIGNATURE_ATTR_USER_NAME:
* [#G_VARIANT_TYPE_STRING] The name of the signing key's primary user
* @OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL:
* [#G_VARIANT_TYPE_STRING] The email address of the signing key's primary
* user
*
* Signature attributes available from an #OstreeGpgVerifyResult.
* The attribute's #GVariantType is shown in brackets.
**/
typedef enum {
OSTREE_GPG_SIGNATURE_ATTR_VALID,
OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED,
OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT,
OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP,
OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP,
OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME,
OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME,
OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL
} OstreeGpgSignatureAttr;
GType ostree_gpg_verify_result_get_type (void);
guint ostree_gpg_verify_result_count_all (OstreeGpgVerifyResult *result);
guint ostree_gpg_verify_result_count_valid (OstreeGpgVerifyResult *result);
gboolean ostree_gpg_verify_result_lookup (OstreeGpgVerifyResult *result,
const gchar *key_id,
guint *out_signature_index);
GVariant * ostree_gpg_verify_result_get (OstreeGpgVerifyResult *result,
guint signature_index,
OstreeGpgSignatureAttr *attrs,
guint n_attrs);
GVariant * ostree_gpg_verify_result_get_all (OstreeGpgVerifyResult *result,
guint signature_index);
G_END_DECLS