lib/sign: initial implementation
Added the initial version of signing interface allowing to allowing to sign and verify commits. Implemented initial signing modules: - dummy -- simple module allowing to sign/verify with ASCII string - ed25519 -- module allowing to sign/verify commit with ed25519 (EdDSA) signature scheme provided by libsodium library. Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
This commit is contained in:
1 parent
84c8164610
commit
edbbe1c4f2
11 files changed
+1224
-5
No files matched your search
@@ -0,0 +1,156 @@
|
||||
/* vim:set et sw=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e2s: */
|
||||
|
||||
/*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Authors:
|
||||
* - Denis Pynkin (d4s) <denis.pynkin@collabora.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "ostree-ref.h"
|
||||
#include "ostree-remote.h"
|
||||
#include "ostree-types.h"
|
||||
|
||||
/* Special remote */
|
||||
#define OSTREE_SIGN_ALL_REMOTES "__OSTREE_ALL_REMOTES__"
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define OSTREE_TYPE_SIGN (ostree_sign_get_type ())
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
G_DECLARE_INTERFACE (OstreeSign, ostree_sign, OSTREE, SIGN, GObject)
|
||||
|
||||
struct _OstreeSignInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
gchar *(* get_name) (OstreeSign *self);
|
||||
gboolean (* data) (OstreeSign *self,
|
||||
GBytes *data,
|
||||
GBytes **signature,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gchar *(* metadata_key) (OstreeSign *self);
|
||||
gchar *(* metadata_format) (OstreeSign *self);
|
||||
gboolean (* metadata_verify) (OstreeSign *self,
|
||||
GBytes *data,
|
||||
GVariant *metadata,
|
||||
GError **error);
|
||||
|
||||
gboolean (* set_sk) (OstreeSign *self,
|
||||
GVariant *secret_key,
|
||||
GError **error);
|
||||
|
||||
gboolean (* set_pk) (OstreeSign *self,
|
||||
GVariant *public_key,
|
||||
GError **error);
|
||||
|
||||
gboolean (* load_pk) (OstreeSign *self,
|
||||
gchar *remote_name,
|
||||
GError **error);
|
||||
|
||||
};
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
const gchar * ostree_sign_get_name (OstreeSign *self);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_data (OstreeSign *self,
|
||||
GBytes *data,
|
||||
GBytes **signature,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gchar * ostree_sign_metadata_key (OstreeSign *self);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gchar * ostree_sign_metadata_format (OstreeSign *self);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
GVariant * ostree_sign_detached_metadata_append (OstreeSign *self,
|
||||
GVariant *existing_metadata,
|
||||
GBytes *signature_bytes);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_commit (OstreeSign *self,
|
||||
OstreeRepo *repo,
|
||||
const gchar *commit_checksum,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_metadata_verify (OstreeSign *self,
|
||||
GBytes *data,
|
||||
GVariant *signatures,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_commit_verify (OstreeSign *self,
|
||||
OstreeRepo *repo,
|
||||
const gchar *commit_checksum,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_set_sk (OstreeSign *self,
|
||||
GVariant *secret_key,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_set_pk (OstreeSign *self,
|
||||
GVariant *public_key,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_sign_load_pk (OstreeSign *self,
|
||||
gchar *remote_name,
|
||||
GError **error);
|
||||
|
||||
|
||||
/**
|
||||
* ostree_sign_list_names:
|
||||
*
|
||||
* Return the array with all available sign modules names.
|
||||
*
|
||||
* Returns: (transfer full): an array of strings, free when you used it
|
||||
*/
|
||||
_OSTREE_PUBLIC
|
||||
GStrv ostree_sign_list_names(void);
|
||||
|
||||
/**
|
||||
* ostree_sign_get_by_name:
|
||||
*
|
||||
* Tries to find and return proper signing engine by it's name.
|
||||
*
|
||||
* Returns: (transfer full): a constant, free when you used it
|
||||
*/
|
||||
_OSTREE_PUBLIC
|
||||
OstreeSign * ostree_sign_get_by_name (const gchar *name, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
Reference in new issue
Block a user