aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/escrow_plugin_helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/escrow/escrow_plugin_helper.h')
-rw-r--r--src/escrow/escrow_plugin_helper.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/escrow/escrow_plugin_helper.h b/src/escrow/escrow_plugin_helper.h
new file mode 100644
index 000000000..d911800e6
--- /dev/null
+++ b/src/escrow/escrow_plugin_helper.h
@@ -0,0 +1,142 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @author Johannes Späth
23 * @file escrow/escrow_plugin.h
24 *
25 * @brief helper functions for escrow plugins
26 */
27
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_identity_service.h"
31#include "gnunet_escrow_plugin.h"
32#include "escrow.h"
33
34
35/**
36 * Maintains the ego list for an escrow plugin.
37 * This function is an implementation of GNUNET_IDENTITY_Callback.
38 *
39 * It is initially called for all egos and then again
40 * whenever a ego's identifier changes or if it is deleted. At the
41 * end of the initial pass over all egos, the function is once called
42 * with 'NULL' for 'ego'. That does NOT mean that the callback won't
43 * be invoked in the future or that there was an error.
44 *
45 * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get',
46 * this function is only called ONCE, and 'NULL' being passed in
47 * 'ego' does indicate an error (i.e. name is taken or no default
48 * value is known). If 'ego' is non-NULL and if '*ctx'
49 * is set in those callbacks, the value WILL be passed to a subsequent
50 * call to the identity callback of 'GNUNET_IDENTITY_connect' (if
51 * that one was not NULL).
52 *
53 * When an identity is renamed, this function is called with the
54 * (known) ego but the NEW identifier.
55 *
56 * When an identity is deleted, this function is called with the
57 * (known) ego and "NULL" for the 'identifier'. In this case,
58 * the 'ego' is henceforth invalid (and the 'ctx' should also be
59 * cleaned up).
60 *
61 * @param cls plugin handle
62 * @param ego ego handle
63 * @param ctx context for application to store data for this ego
64 * (during the lifetime of this process, initially NULL)
65 * @param identifier identifier assigned by the user for this ego,
66 * NULL if the user just deleted the ego and it
67 * must thus no longer be used
68 */
69void
70ESCROW_list_ego (void *cls,
71 struct GNUNET_IDENTITY_Ego *ego,
72 void **ctx,
73 const char *identifier);
74
75
76/**
77 * Cleanup the ego list of an escrow plugin.
78 *
79 * @param ph handle for the plugin
80 */
81void
82ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph);
83
84
85/**
86 * Build an anchor struct.
87 *
88 * @param method escrow method
89 * @param egoName name of the ego
90 * @param data anchor data
91 * @param data_size size of the anchor data
92 *
93 * @return a new anchor struct
94 */
95struct GNUNET_ESCROW_Anchor *
96ESCROW_build_anchor (enum GNUNET_ESCROW_Key_Escrow_Method method,
97 const char *egoName,
98 void *data,
99 uint32_t data_size);
100
101
102/**
103 * Update the status of an escrow in the configuration after a VERIFY operation.
104 *
105 * @param h handle for the escrow component
106 * @param ego the ego of which the escrow status is updated
107 * @param plugin_name the name of the used plugin
108 *
109 * @return GNUNET_OK on success
110 */
111int
112ESCROW_update_escrow_status_verify (struct GNUNET_ESCROW_Handle *h,
113 struct GNUNET_IDENTITY_Ego *ego,
114 const char *plugin_name);
115
116
117/**
118 * Update the status of an escrow in the configuration after a PUT operation.
119 *
120 * @param h handle for the escrow component
121 * @param ego the ego of which the escrow status is updated
122 * @param plugin_name the name of the used plugin
123 *
124 * @return GNUNET_OK on success
125 */
126int
127ESCROW_update_escrow_status_put (struct GNUNET_ESCROW_Handle *h,
128 struct GNUNET_IDENTITY_Ego *ego,
129 const char *plugin_name);
130
131
132/**
133 * Get the status of an escrow from the configuration.
134 *
135 * @param h handle for the escrow component
136 * @param ego the ego of which the escrow status has to be obtained
137 *
138 * @return the status of the escrow, packed into a GNUNET_ESCROW_Status struct
139 */
140struct GNUNET_ESCROW_Status *
141ESCROW_get_escrow_status (struct GNUNET_ESCROW_Handle *h,
142 struct GNUNET_IDENTITY_Ego *ego);