summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-sign.h
blob: 3a9bcc6a7ba087f3c39df33576f72a39465e11e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* 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, see <https://www.gnu.org/licenses/>.
 *
 * 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"

G_BEGIN_DECLS

#define OSTREE_TYPE_SIGN (ostree_sign_get_type ())

_OSTREE_PUBLIC
GType ostree_sign_get_type (void);

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeSign OstreeSign;
typedef struct _OstreeSignInterface OstreeSignInterface;

static inline OstreeSign *OSTREE_SIGN (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_sign_get_type (), OstreeSign); }
static inline gboolean OSTREE_IS_SIGN (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_sign_get_type ()); }
static inline OstreeSignInterface *OSTREE_SIGN_GET_IFACE (gpointer ptr) { return G_TYPE_INSTANCE_GET_INTERFACE (ptr, ostree_sign_get_type (), OstreeSignInterface); }
G_GNUC_END_IGNORE_DEPRECATIONS

/**
 * OSTREE_SIGN_NAME_ED25519:
 * The name of the default ed25519 signing type.
 *
 * Since: 2020.4
 */
#define OSTREE_SIGN_NAME_ED25519 "ed25519"

/* Have to use glib-2.44 for this
_OSTREE_PUBLIC
G_DECLARE_INTERFACE (OstreeSign, ostree_sign, OSTREE, SIGN, GObject)
*/

struct _OstreeSignInterface
{
  GTypeInterface g_iface;
  const gchar *(* get_name) (OstreeSign *self);
  gboolean (* data)   (OstreeSign *self,
                       GBytes *data,
                       GBytes **signature,
                       GCancellable *cancellable,
                       GError **error);
  gboolean (* data_verify) (OstreeSign *self,
                            GBytes *data,
                            GVariant   *signatures,
                            char      **out_success_message,
                            GError **error);
  const gchar *(* metadata_key) (OstreeSign *self);
  const gchar *(* metadata_format) (OstreeSign *self);
  gboolean (* clear_keys) (OstreeSign *self,
                           GError **error);
  gboolean (* set_sk) (OstreeSign *self,
                       GVariant *secret_key,
                       GError **error);
  gboolean (* set_pk) (OstreeSign *self,
                       GVariant *public_key,
                       GError **error);
  gboolean (* add_pk) (OstreeSign *self,
                       GVariant *public_key,
                       GError **error);
  gboolean (* load_pk) (OstreeSign *self,
                        GVariant *options,
                        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
gboolean ostree_sign_data_verify (OstreeSign *self,
                                  GBytes     *data,
                                  GVariant   *signatures,
                                  char      **out_success_message,
                                  GError     **error);

_OSTREE_PUBLIC
const gchar * ostree_sign_metadata_key (OstreeSign *self);

_OSTREE_PUBLIC
const gchar * ostree_sign_metadata_format (OstreeSign *self);

_OSTREE_PUBLIC
gboolean ostree_sign_commit (OstreeSign     *self,
                             OstreeRepo     *repo,
                             const gchar    *commit_checksum,
                             GCancellable   *cancellable,
                             GError         **error);

_OSTREE_PUBLIC
gboolean ostree_sign_commit_verify (OstreeSign *self,
                                    OstreeRepo     *repo,
                                    const gchar    *commit_checksum,
                                    char          **out_success_message,
                                    GCancellable   *cancellable,
                                    GError         **error);

_OSTREE_PUBLIC
gboolean ostree_sign_clear_keys (OstreeSign *self,
                                 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_add_pk (OstreeSign *self,
                             GVariant *public_key,
                             GError **error);

_OSTREE_PUBLIC
gboolean ostree_sign_load_pk (OstreeSign *self,
                              GVariant *options,
                              GError **error);


_OSTREE_PUBLIC
GPtrArray * ostree_sign_get_all(void);

_OSTREE_PUBLIC
OstreeSign * ostree_sign_get_by_name (const gchar *name, GError **error);

_OSTREE_PUBLIC
gboolean ostree_sign_summary (OstreeSign    *self,
                              OstreeRepo    *repo,
                              GVariant      *keys,
                              GCancellable  *cancellable,
                              GError       **error);
G_END_DECLS