repo: Add ostree_repo_verify_summary()
authorMatthew Barnes <mbarnes@redhat.com>
Wed, 16 Dec 2015 23:53:57 +0000 (18:53 -0500)
committerMatthew Barnes <mbarnes@redhat.com>
Thu, 17 Dec 2015 20:49:44 +0000 (15:49 -0500)
Verifies signatures on a summary -- both taken as GBytes inputs -- and
returns an OstreeGpgVerifyResult.

doc/ostree-sections.txt
src/libostree/ostree-repo.c
src/libostree/ostree-repo.h

index aecaa5665545940550b913cd0741d60af0f240e2..5e9dfb9b88ff231b0a62aab4dbfc241e9a1fa453 100644 (file)
@@ -313,6 +313,7 @@ ostree_repo_sign_commit
 ostree_repo_append_gpg_signature
 ostree_repo_verify_commit
 ostree_repo_verify_commit_ext
+ostree_repo_verify_summary
 ostree_repo_regenerate_summary
 <SUBSECTION Standard>
 OSTREE_REPO
index cc3bd6f7d199d83b86c4282550de9232820a0a56..f9cd5cc4195f54300c5d81e00b474a536fcfb39b 100644 (file)
@@ -1879,17 +1879,13 @@ ostree_repo_remote_fetch_summary (OstreeRepo    *self,
   if (gpg_verify_summary && summary != NULL && signatures != NULL)
     {
       glnx_unref_object OstreeGpgVerifyResult *result = NULL;
-      g_autoptr(GVariant) signatures_variant = NULL;
-
-      signatures_variant = g_variant_new_from_bytes (OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
-                                                     signatures, FALSE);
-      result = _ostree_repo_gpg_verify_with_metadata (self,
-                                                      summary,
-                                                      signatures_variant,
-                                                      name,
-                                                      NULL, NULL,
-                                                      cancellable,
-                                                      error);
+
+      result = ostree_repo_verify_summary (self,
+                                           name,
+                                           summary,
+                                           signatures,
+                                           cancellable,
+                                           error);
       if (result == NULL)
         goto out;
 
@@ -4489,6 +4485,47 @@ ostree_repo_verify_commit_ext (OstreeRepo    *self,
                                               error);
 }
 
+/**
+ * ostree_repo_verify_summary:
+ * @self: Repo
+ * @remote_name: Name of remote
+ * @summary: Summary data as a #GBytes
+ * @signatures: Summary signatures as a #GBytes
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Verify @signatures for @summary data using GPG keys in the keyring for
+ * @remote_name, and return an #OstreeGpgVerifyResult.
+ *
+ * Returns: (transfer full): an #OstreeGpgVerifyResult, or %NULL on error
+ */
+OstreeGpgVerifyResult *
+ostree_repo_verify_summary (OstreeRepo    *self,
+                            const char    *remote_name,
+                            GBytes        *summary,
+                            GBytes        *signatures,
+                            GCancellable  *cancellable,
+                            GError       **error)
+{
+  g_autoptr(GVariant) signatures_variant = NULL;
+
+  g_return_val_if_fail (OSTREE_IS_REPO (self), NULL);
+  g_return_val_if_fail (remote_name != NULL, NULL);
+  g_return_val_if_fail (summary != NULL, NULL);
+  g_return_val_if_fail (signatures != NULL, NULL);
+
+  signatures_variant = g_variant_new_from_bytes (OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
+                                                 signatures, FALSE);
+
+  return _ostree_repo_gpg_verify_with_metadata (self,
+                                                summary,
+                                                signatures_variant,
+                                                remote_name,
+                                                NULL, NULL,
+                                                cancellable,
+                                                error);
+}
+
 /**
  * ostree_repo_regenerate_summary:
  * @self: Repo
index 69720a2e295cd020f9eed1b7d195c304a4742418..51a407517fc19a7ed50d9e87147c90edf0b150f1 100644 (file)
@@ -782,6 +782,13 @@ OstreeGpgVerifyResult * ostree_repo_verify_commit_ext (OstreeRepo    *self,
                                                        GCancellable  *cancellable,
                                                        GError       **error);
 
+OstreeGpgVerifyResult * ostree_repo_verify_summary (OstreeRepo    *self,
+                                                    const char    *remote_name,
+                                                    GBytes        *summary,
+                                                    GBytes        *signatures,
+                                                    GCancellable  *cancellable,
+                                                    GError       **error);
+
 gboolean ostree_repo_regenerate_summary (OstreeRepo     *self,
                                          GVariant       *additional_metadata,
                                          GCancellable   *cancellable,