diff options
author | jospaeth <spaethj@in.tum.de> | 2020-07-15 16:28:26 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-07-15 16:28:26 +0200 |
commit | 3192c1c84a8cf6aa81e55ac647adf125cbd88904 (patch) | |
tree | cf8c0505b36ac3a5c7d86d6a683b6651c1917dce /src | |
parent | 122f2979146c6068cbaf189560f196e4a3323801 (diff) | |
download | gnunet-3192c1c84a8cf6aa81e55ac647adf125cbd88904.tar.gz gnunet-3192c1c84a8cf6aa81e55ac647adf125cbd88904.zip |
changes to the escrow api [not compiling]
Diffstat (limited to 'src')
-rw-r--r-- | src/escrow/.gitignore | 1 | ||||
-rw-r--r-- | src/escrow/Makefile.am | 12 | ||||
-rw-r--r-- | src/escrow/escrow_api.c | 103 | ||||
-rw-r--r-- | src/escrow/escrow_plugin_helper.c | 169 | ||||
-rw-r--r-- | src/escrow/escrow_plugin_helper.h | 81 | ||||
-rwxr-xr-x | src/escrow/gnunet-escrow | 210 | ||||
-rw-r--r-- | src/escrow/gnunet-escrow.c | 21 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_anastasis.c | 61 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_gns.c | 61 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_plaintext.c | 66 | ||||
-rw-r--r-- | src/include/gnunet_escrow_lib.h | 57 | ||||
-rw-r--r-- | src/include/gnunet_escrow_plugin.h | 91 |
12 files changed, 697 insertions, 236 deletions
diff --git a/src/escrow/.gitignore b/src/escrow/.gitignore new file mode 100644 index 000000000..116fabf88 --- /dev/null +++ b/src/escrow/.gitignore | |||
@@ -0,0 +1 @@ | |||
gnunet-escrow \ No newline at end of file | |||
diff --git a/src/escrow/Makefile.am b/src/escrow/Makefile.am index c69210b8d..78acfbb16 100644 --- a/src/escrow/Makefile.am +++ b/src/escrow/Makefile.am | |||
@@ -42,7 +42,9 @@ libgnunetescrow_la_LDFLAGS = \ | |||
42 | 42 | ||
43 | 43 | ||
44 | libgnunet_plugin_escrow_plaintext_la_SOURCES = \ | 44 | libgnunet_plugin_escrow_plaintext_la_SOURCES = \ |
45 | plugin_escrow_plaintext.c | 45 | plugin_escrow_plaintext.c \ |
46 | escrow_plugin_helper.c \ | ||
47 | escrow_plugin_helper.h | ||
46 | libgnunet_plugin_escrow_plaintext_la_LIBADD = \ | 48 | libgnunet_plugin_escrow_plaintext_la_LIBADD = \ |
47 | $(top_builddir)/src/util/libgnunetutil.la \ | 49 | $(top_builddir)/src/util/libgnunetutil.la \ |
48 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 50 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
@@ -51,7 +53,9 @@ libgnunet_plugin_escrow_plaintext_la_LDFLAGS = \ | |||
51 | $(GN_PLUGIN_LDFLAGS) | 53 | $(GN_PLUGIN_LDFLAGS) |
52 | 54 | ||
53 | libgnunet_plugin_escrow_gns_la_SOURCES = \ | 55 | libgnunet_plugin_escrow_gns_la_SOURCES = \ |
54 | plugin_escrow_gns.c | 56 | plugin_escrow_gns.c \ |
57 | escrow_plugin_helper.c \ | ||
58 | escrow_plugin_helper.h | ||
55 | libgnunet_plugin_escrow_gns_la_LIBADD = \ | 59 | libgnunet_plugin_escrow_gns_la_LIBADD = \ |
56 | $(top_builddir)/src/util/libgnunetutil.la \ | 60 | $(top_builddir)/src/util/libgnunetutil.la \ |
57 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 61 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
@@ -61,7 +65,9 @@ libgnunet_plugin_escrow_gns_la_LDFLAGS = \ | |||
61 | $(GN_PLUGIN_LDFLAGS) | 65 | $(GN_PLUGIN_LDFLAGS) |
62 | 66 | ||
63 | libgnunet_plugin_escrow_anastasis_la_SOURCES = \ | 67 | libgnunet_plugin_escrow_anastasis_la_SOURCES = \ |
64 | plugin_escrow_anastasis.c | 68 | plugin_escrow_anastasis.c \ |
69 | escrow_plugin_helper.c \ | ||
70 | escrow_plugin_helper.h | ||
65 | libgnunet_plugin_escrow_anastasis_la_LIBADD = \ | 71 | libgnunet_plugin_escrow_anastasis_la_LIBADD = \ |
66 | $(top_builddir)/src/util/libgnunetutil.la \ | 72 | $(top_builddir)/src/util/libgnunetutil.la \ |
67 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 73 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c index b293c05a5..6d4d6531b 100644 --- a/src/escrow/escrow_api.c +++ b/src/escrow/escrow_api.c | |||
@@ -25,12 +25,37 @@ | |||
25 | * @brief api to interact with the escrow component | 25 | * @brief api to interact with the escrow component |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_escrow_lib.h" | 30 | #include "gnunet_escrow_lib.h" |
30 | #include "gnunet_escrow_plugin.h" | 31 | #include "gnunet_escrow_plugin.h" |
31 | 32 | ||
32 | 33 | ||
33 | /** | 34 | /** |
35 | * Handle for the escrow component. | ||
36 | */ | ||
37 | struct GNUNET_ESCROW_Handle | ||
38 | { | ||
39 | /** | ||
40 | * Configuration to use. | ||
41 | */ | ||
42 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
43 | }; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Handle for an operation with the escrow component. | ||
48 | */ | ||
49 | struct GNUNET_ESCROW_Operation | ||
50 | { | ||
51 | /** | ||
52 | * Main escrow handle. | ||
53 | */ | ||
54 | struct GNUNET_ESCROW_Handle *h; | ||
55 | }; | ||
56 | |||
57 | |||
58 | /** | ||
34 | * Init canary for the plaintext plugin | 59 | * Init canary for the plaintext plugin |
35 | */ | 60 | */ |
36 | static int plaintext_initialized; | 61 | static int plaintext_initialized; |
@@ -74,7 +99,8 @@ static struct GNUNET_ESCROW_KeyPluginFunctions *anastasis_api; | |||
74 | * @return pointer to the escrow plugin API | 99 | * @return pointer to the escrow plugin API |
75 | */ | 100 | */ |
76 | struct GNUNET_ESCROW_KeyPluginFunctions * | 101 | struct GNUNET_ESCROW_KeyPluginFunctions * |
77 | init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method) | 102 | init_plugin (struct GNUNET_ESCROW_Handle *h, |
103 | enum GNUNET_ESCROW_Key_Escrow_Method method) | ||
78 | { | 104 | { |
79 | switch (method) | 105 | switch (method) |
80 | { | 106 | { |
@@ -85,7 +111,7 @@ init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method) | |||
85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 111 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Loading PLAINTEXT escrow plugin\n"); | 112 | "Loading PLAINTEXT escrow plugin\n"); |
87 | plaintext_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_plaintext", | 113 | plaintext_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_plaintext", |
88 | NULL); | 114 | (void *)h->cfg); |
89 | return plaintext_api; | 115 | return plaintext_api; |
90 | case GNUNET_ESCROW_KEY_GNS: | 116 | case GNUNET_ESCROW_KEY_GNS: |
91 | if (GNUNET_YES == gns_initialized) | 117 | if (GNUNET_YES == gns_initialized) |
@@ -94,7 +120,7 @@ init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method) | |||
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
95 | "Loading GNS escrow plugin\n"); | 121 | "Loading GNS escrow plugin\n"); |
96 | gns_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_gns", | 122 | gns_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_gns", |
97 | NULL); | 123 | (void *)h->cfg); |
98 | return gns_api; | 124 | return gns_api; |
99 | case GNUNET_ESCROW_KEY_ANASTASIS: | 125 | case GNUNET_ESCROW_KEY_ANASTASIS: |
100 | if (GNUNET_YES == anastasis_initialized) | 126 | if (GNUNET_YES == anastasis_initialized) |
@@ -103,7 +129,7 @@ init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method) | |||
103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
104 | "Loading ANASTASIS escrow plugin\n"); | 130 | "Loading ANASTASIS escrow plugin\n"); |
105 | anastasis_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_anastasis", | 131 | anastasis_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_anastasis", |
106 | NULL); | 132 | (void *)h->cfg); |
107 | return anastasis_api; | 133 | return anastasis_api; |
108 | } | 134 | } |
109 | // should never be reached | 135 | // should never be reached |
@@ -112,11 +138,32 @@ init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method) | |||
112 | 138 | ||
113 | 139 | ||
114 | /** | 140 | /** |
141 | * Initialize the escrow component. | ||
142 | * | ||
143 | * @param cfg the configuration to use | ||
144 | * | ||
145 | * @return handle to use | ||
146 | */ | ||
147 | struct GNUNET_ESCROW_Handle * | ||
148 | GNUNET_ESCROW_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
149 | { | ||
150 | struct GNUNET_ESCROW_Handle *h; | ||
151 | |||
152 | h = GNUNET_new (struct GNUNET_ESCROW_Handle); | ||
153 | h->cfg = cfg; | ||
154 | return h; | ||
155 | } | ||
156 | |||
157 | |||
158 | /** | ||
115 | * Unload all loaded plugins on destruction. | 159 | * Unload all loaded plugins on destruction. |
160 | * | ||
161 | * @param h the escrow handle | ||
116 | */ | 162 | */ |
117 | void __attribute__ ((destructor)) | 163 | void |
118 | GNUNET_ESCROW_fini_plugins () | 164 | GNUNET_ESCROW_fini (struct GNUNET_ESCROW_Handle *h) |
119 | { | 165 | { |
166 | /* unload all loaded plugins */ | ||
120 | if (GNUNET_YES == plaintext_initialized) | 167 | if (GNUNET_YES == plaintext_initialized) |
121 | { | 168 | { |
122 | plaintext_initialized = GNUNET_NO; | 169 | plaintext_initialized = GNUNET_NO; |
@@ -143,6 +190,9 @@ GNUNET_ESCROW_fini_plugins () | |||
143 | anastasis_api)); | 190 | anastasis_api)); |
144 | anastasis_api = NULL; | 191 | anastasis_api = NULL; |
145 | } | 192 | } |
193 | |||
194 | /* freee the escrow handle */ | ||
195 | GNUNET_free (h); | ||
146 | } | 196 | } |
147 | 197 | ||
148 | 198 | ||
@@ -155,12 +205,13 @@ GNUNET_ESCROW_fini_plugins () | |||
155 | * @return the escrow anchor needed to get the data back | 205 | * @return the escrow anchor needed to get the data back |
156 | */ | 206 | */ |
157 | void * | 207 | void * |
158 | GNUNET_ESCROW_put (const struct GNUNET_IDENTITY_Ego *ego, | 208 | GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h, |
209 | const struct GNUNET_IDENTITY_Ego *ego, | ||
159 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 210 | enum GNUNET_ESCROW_Key_Escrow_Method method) |
160 | { | 211 | { |
161 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 212 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
162 | 213 | ||
163 | api = init_plugin (method); | 214 | api = init_plugin (h, method); |
164 | return api->start_key_escrow (ego); | 215 | return api->start_key_escrow (ego); |
165 | } | 216 | } |
166 | 217 | ||
@@ -174,12 +225,13 @@ GNUNET_ESCROW_put (const struct GNUNET_IDENTITY_Ego *ego, | |||
174 | * @return the escrow anchor needed to get the data back | 225 | * @return the escrow anchor needed to get the data back |
175 | */ | 226 | */ |
176 | void * | 227 | void * |
177 | GNUNET_ESCROW_renew (void *escrowAnchor, | 228 | GNUNET_ESCROW_renew (struct GNUNET_ESCROW_Handle *h, |
229 | void *escrowAnchor, | ||
178 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 230 | enum GNUNET_ESCROW_Key_Escrow_Method method) |
179 | { | 231 | { |
180 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 232 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
181 | 233 | ||
182 | api = init_plugin (method); | 234 | api = init_plugin (h, method); |
183 | return api->renew_key_escrow (escrowAnchor); | 235 | return api->renew_key_escrow (escrowAnchor); |
184 | } | 236 | } |
185 | 237 | ||
@@ -194,13 +246,14 @@ GNUNET_ESCROW_renew (void *escrowAnchor, | |||
194 | * @return a new identity ego restored from the escrow | 246 | * @return a new identity ego restored from the escrow |
195 | */ | 247 | */ |
196 | const struct GNUNET_IDENTITY_Ego * | 248 | const struct GNUNET_IDENTITY_Ego * |
197 | GNUNET_ESCROW_get (void *escrowAnchor, | 249 | GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h, |
250 | void *escrowAnchor, | ||
198 | char *egoName, | 251 | char *egoName, |
199 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 252 | enum GNUNET_ESCROW_Key_Escrow_Method method) |
200 | { | 253 | { |
201 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 254 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
202 | 255 | ||
203 | api = init_plugin (method); | 256 | api = init_plugin (h, method); |
204 | return api->restore_key (escrowAnchor, egoName); | 257 | return api->restore_key (escrowAnchor, egoName); |
205 | } | 258 | } |
206 | 259 | ||
@@ -217,12 +270,34 @@ GNUNET_ESCROW_get (void *escrowAnchor, | |||
217 | * GNUNET_ESCROW_INVALID otherwise | 270 | * GNUNET_ESCROW_INVALID otherwise |
218 | */ | 271 | */ |
219 | int | 272 | int |
220 | GNUNET_ESCROW_verify (const struct GNUNET_IDENTITY_Ego *ego, | 273 | GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h, |
274 | const struct GNUNET_IDENTITY_Ego *ego, | ||
221 | void *escrowAnchor, | 275 | void *escrowAnchor, |
222 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 276 | enum GNUNET_ESCROW_Key_Escrow_Method method) |
223 | { | 277 | { |
224 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 278 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
225 | 279 | ||
226 | api = init_plugin (method); | 280 | api = init_plugin (h, method); |
227 | return api->verify_key_escrow (ego, escrowAnchor); | 281 | return api->verify_key_escrow (ego, escrowAnchor); |
228 | } | 282 | } |
283 | |||
284 | |||
285 | /** | ||
286 | * Deserialize an escrow anchor string (e.g. from command line) into a | ||
287 | * GNUNET_ESCROW_Anchor struct | ||
288 | * | ||
289 | * @param anchorString the encoded escrow anchor string | ||
290 | * @param method the escrow method to use | ||
291 | * | ||
292 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
293 | */ | ||
294 | const struct GNUNET_ESCROW_Anchor * | ||
295 | GNUNET_ESCROW_anchor_string_to_data (struct GNUNET_ESCROW_Handle *h, | ||
296 | char *anchorString, | ||
297 | enum GNUNET_ESCROW_Key_Escrow_Method method) | ||
298 | { | ||
299 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | ||
300 | |||
301 | api = init_plugin (h, method); | ||
302 | return api->anchor_string_to_data (anchorString); | ||
303 | } | ||
diff --git a/src/escrow/escrow_plugin_helper.c b/src/escrow/escrow_plugin_helper.c new file mode 100644 index 000000000..15260f639 --- /dev/null +++ b/src/escrow/escrow_plugin_helper.c | |||
@@ -0,0 +1,169 @@ | |||
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.c | ||
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 | |||
33 | |||
34 | /** | ||
35 | * Maintains the ego list for an escrow plugin. | ||
36 | * This function is an implementation of GNUNET_IDENTITY_Callback. | ||
37 | * | ||
38 | * It is initially called for all egos and then again | ||
39 | * whenever a ego's identifier changes or if it is deleted. At the | ||
40 | * end of the initial pass over all egos, the function is once called | ||
41 | * with 'NULL' for 'ego'. That does NOT mean that the callback won't | ||
42 | * be invoked in the future or that there was an error. | ||
43 | * | ||
44 | * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', | ||
45 | * this function is only called ONCE, and 'NULL' being passed in | ||
46 | * 'ego' does indicate an error (i.e. name is taken or no default | ||
47 | * value is known). If 'ego' is non-NULL and if '*ctx' | ||
48 | * is set in those callbacks, the value WILL be passed to a subsequent | ||
49 | * call to the identity callback of 'GNUNET_IDENTITY_connect' (if | ||
50 | * that one was not NULL). | ||
51 | * | ||
52 | * When an identity is renamed, this function is called with the | ||
53 | * (known) ego but the NEW identifier. | ||
54 | * | ||
55 | * When an identity is deleted, this function is called with the | ||
56 | * (known) ego and "NULL" for the 'identifier'. In this case, | ||
57 | * the 'ego' is henceforth invalid (and the 'ctx' should also be | ||
58 | * cleaned up). | ||
59 | * | ||
60 | * @param cls plugin handle | ||
61 | * @param ego ego handle | ||
62 | * @param ctx context for application to store data for this ego | ||
63 | * (during the lifetime of this process, initially NULL) | ||
64 | * @param identifier identifier assigned by the user for this ego, | ||
65 | * NULL if the user just deleted the ego and it | ||
66 | * must thus no longer be used | ||
67 | */ | ||
68 | static void | ||
69 | GNUNET_ESCROW_list_ego (void *cls, | ||
70 | struct GNUNET_IDENTITY_Ego *ego, | ||
71 | void **ctx, | ||
72 | const char *identifier) | ||
73 | { | ||
74 | struct EgoEntry *ego_entry; | ||
75 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | ||
76 | struct EscrowPluginHandle *ph = cls; | ||
77 | |||
78 | if ((NULL == ego) && (ESCROW_PLUGIN_STATE_INIT == ph->state)) | ||
79 | { | ||
80 | ph->state = ESCROW_PLUGIN_STATE_POST_INIT; | ||
81 | /* call ContinueIdentityInitFunction */ | ||
82 | ph->cont (); | ||
83 | return; | ||
84 | } | ||
85 | GNUNET_assert (NULL != ego); | ||
86 | |||
87 | if (ESCROW_PLUGIN_STATE_INIT == ph->state) | ||
88 | { | ||
89 | ego_entry = GNUNET_new (struct EgoEntry); | ||
90 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
91 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
92 | ego_entry->ego = ego; | ||
93 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
94 | GNUNET_CONTAINER_DLL_insert_tail (ph->ego_head, | ||
95 | ph->ego_tail, | ||
96 | ego_entry); | ||
97 | return; | ||
98 | } | ||
99 | /* Ego renamed or added */ | ||
100 | if (identifier != NULL) | ||
101 | { | ||
102 | for (ego_entry = ph->ego_head; NULL != ego_entry; | ||
103 | ego_entry = ego_entry->next) | ||
104 | { | ||
105 | if (ego_entry->ego == ego) | ||
106 | { | ||
107 | /* Rename */ | ||
108 | GNUNET_free (ego_entry->identifier); | ||
109 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
110 | break; | ||
111 | } | ||
112 | } | ||
113 | if (NULL == ego_entry) | ||
114 | { | ||
115 | /* Add */ | ||
116 | ego_entry = GNUNET_new (struct EgoEntry); | ||
117 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
118 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
119 | ego_entry->ego = ego; | ||
120 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
121 | GNUNET_CONTAINER_DLL_insert_tail (ph->ego_head, | ||
122 | ph->ego_tail, | ||
123 | ego_entry); | ||
124 | } | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | /* Delete */ | ||
129 | for (ego_entry = ph->ego_head; NULL != ego_entry; | ||
130 | ego_entry = ego_entry->next) | ||
131 | { | ||
132 | if (ego_entry->ego == ego) | ||
133 | break; | ||
134 | } | ||
135 | if (NULL == ego_entry) | ||
136 | return; /* Not found */ | ||
137 | |||
138 | GNUNET_CONTAINER_DLL_remove (ph->ego_head, | ||
139 | ph->ego_tail, | ||
140 | ego_entry); | ||
141 | GNUNET_free (ego_entry->identifier); | ||
142 | GNUNET_free (ego_entry->keystring); | ||
143 | GNUNET_free (ego_entry); | ||
144 | return; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | |||
149 | /** | ||
150 | * Cleanup the ego list of an escrow plugin. | ||
151 | * | ||
152 | * @param ph handle for the plugin | ||
153 | */ | ||
154 | static void | ||
155 | GNUNET_ESCROW_cleanup_ego_list (struct EscrowPluginHandle *ph) | ||
156 | { | ||
157 | struct EgoEntry *ego_entry; | ||
158 | |||
159 | while (NULL != (ego_entry = ph->ego_head)) | ||
160 | { | ||
161 | GNUNET_CONTAINER_DLL_remove (ph->ego_head, ph->ego_tail, ego_entry); | ||
162 | GNUNET_free (ego_entry->identifier); | ||
163 | GNUNET_free (ego_entry->keystring); | ||
164 | GNUNET_free (ego_entry); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | |||
169 | /* end of escrow_plugin.c */ | ||
diff --git a/src/escrow/escrow_plugin_helper.h b/src/escrow/escrow_plugin_helper.h new file mode 100644 index 000000000..08f024b05 --- /dev/null +++ b/src/escrow/escrow_plugin_helper.h | |||
@@ -0,0 +1,81 @@ | |||
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 | |||
33 | |||
34 | /** | ||
35 | * Maintains the ego list for an escrow plugin. | ||
36 | * This function is an implementation of GNUNET_IDENTITY_Callback. | ||
37 | * | ||
38 | * It is initially called for all egos and then again | ||
39 | * whenever a ego's identifier changes or if it is deleted. At the | ||
40 | * end of the initial pass over all egos, the function is once called | ||
41 | * with 'NULL' for 'ego'. That does NOT mean that the callback won't | ||
42 | * be invoked in the future or that there was an error. | ||
43 | * | ||
44 | * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', | ||
45 | * this function is only called ONCE, and 'NULL' being passed in | ||
46 | * 'ego' does indicate an error (i.e. name is taken or no default | ||
47 | * value is known). If 'ego' is non-NULL and if '*ctx' | ||
48 | * is set in those callbacks, the value WILL be passed to a subsequent | ||
49 | * call to the identity callback of 'GNUNET_IDENTITY_connect' (if | ||
50 | * that one was not NULL). | ||
51 | * | ||
52 | * When an identity is renamed, this function is called with the | ||
53 | * (known) ego but the NEW identifier. | ||
54 | * | ||
55 | * When an identity is deleted, this function is called with the | ||
56 | * (known) ego and "NULL" for the 'identifier'. In this case, | ||
57 | * the 'ego' is henceforth invalid (and the 'ctx' should also be | ||
58 | * cleaned up). | ||
59 | * | ||
60 | * @param cls plugin handle | ||
61 | * @param ego ego handle | ||
62 | * @param ctx context for application to store data for this ego | ||
63 | * (during the lifetime of this process, initially NULL) | ||
64 | * @param identifier identifier assigned by the user for this ego, | ||
65 | * NULL if the user just deleted the ego and it | ||
66 | * must thus no longer be used | ||
67 | */ | ||
68 | static void | ||
69 | GNUNET_ESCROW_list_ego (void *cls, | ||
70 | struct GNUNET_IDENTITY_Ego *ego, | ||
71 | void **ctx, | ||
72 | const char *identifier); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Cleanup the ego list of an escrow plugin. | ||
77 | * | ||
78 | * @param ph handle for the plugin | ||
79 | */ | ||
80 | static void | ||
81 | GNUNET_ESCROW_cleanup_ego_list (struct EscrowPluginHandle *ph); | ||
diff --git a/src/escrow/gnunet-escrow b/src/escrow/gnunet-escrow deleted file mode 100755 index 86d5227a8..000000000 --- a/src/escrow/gnunet-escrow +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | # gnunet-escrow - temporary wrapper script for .libs/gnunet-escrow | ||
4 | # Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-14 | ||
5 | # | ||
6 | # The gnunet-escrow program cannot be directly executed until all the libtool | ||
7 | # libraries that it depends on are installed. | ||
8 | # | ||
9 | # This wrapper script should never be moved out of the build directory. | ||
10 | # If it is, it will not operate correctly. | ||
11 | |||
12 | # Sed substitution that helps us do robust quoting. It backslashifies | ||
13 | # metacharacters that are still active within double-quoted strings. | ||
14 | sed_quote_subst='s|\([`"$\\]\)|\\\1|g' | ||
15 | |||
16 | # Be Bourne compatible | ||
17 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then | ||
18 | emulate sh | ||
19 | NULLCMD=: | ||
20 | # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which | ||
21 | # is contrary to our usage. Disable this feature. | ||
22 | alias -g '${1+"$@"}'='"$@"' | ||
23 | setopt NO_GLOB_SUBST | ||
24 | else | ||
25 | case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac | ||
26 | fi | ||
27 | BIN_SH=xpg4; export BIN_SH # for Tru64 | ||
28 | DUALCASE=1; export DUALCASE # for MKS sh | ||
29 | |||
30 | # The HP-UX ksh and POSIX shell print the target directory to stdout | ||
31 | # if CDPATH is set. | ||
32 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | ||
33 | |||
34 | relink_command="" | ||
35 | |||
36 | # This environment variable determines our operation mode. | ||
37 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then | ||
38 | # install mode needs the following variables: | ||
39 | generated_by_libtool_version='2.4.6' | ||
40 | notinst_deplibs=' ../../src/util/libgnunetutil.la ../../src/namestore/libgnunetnamestore.la libgnunetescrow.la ../../src/identity/libgnunetidentity.la' | ||
41 | else | ||
42 | # When we are sourced in execute mode, $file and $ECHO are already set. | ||
43 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then | ||
44 | file="$0" | ||
45 | |||
46 | # A function that is used when there is no print builtin or printf. | ||
47 | func_fallback_echo () | ||
48 | { | ||
49 | eval 'cat <<_LTECHO_EOF | ||
50 | $1 | ||
51 | _LTECHO_EOF' | ||
52 | } | ||
53 | ECHO="printf %s\\n" | ||
54 | fi | ||
55 | |||
56 | # Very basic option parsing. These options are (a) specific to | ||
57 | # the libtool wrapper, (b) are identical between the wrapper | ||
58 | # /script/ and the wrapper /executable/ that is used only on | ||
59 | # windows platforms, and (c) all begin with the string --lt- | ||
60 | # (application programs are unlikely to have options that match | ||
61 | # this pattern). | ||
62 | # | ||
63 | # There are only two supported options: --lt-debug and | ||
64 | # --lt-dump-script. There is, deliberately, no --lt-help. | ||
65 | # | ||
66 | # The first argument to this parsing function should be the | ||
67 | # script's ../../libtool value, followed by no. | ||
68 | lt_option_debug= | ||
69 | func_parse_lt_options () | ||
70 | { | ||
71 | lt_script_arg0=$0 | ||
72 | shift | ||
73 | for lt_opt | ||
74 | do | ||
75 | case "$lt_opt" in | ||
76 | --lt-debug) lt_option_debug=1 ;; | ||
77 | --lt-dump-script) | ||
78 | lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` | ||
79 | test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. | ||
80 | lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'` | ||
81 | cat "$lt_dump_D/$lt_dump_F" | ||
82 | exit 0 | ||
83 | ;; | ||
84 | --lt-*) | ||
85 | $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 | ||
86 | exit 1 | ||
87 | ;; | ||
88 | esac | ||
89 | done | ||
90 | |||
91 | # Print the debug banner immediately: | ||
92 | if test -n "$lt_option_debug"; then | ||
93 | echo "gnunet-escrow:gnunet-escrow:$LINENO: libtool wrapper (GNU libtool) 2.4.6 Debian-2.4.6-14" 1>&2 | ||
94 | fi | ||
95 | } | ||
96 | |||
97 | # Used when --lt-debug. Prints its arguments to stdout | ||
98 | # (redirection is the responsibility of the caller) | ||
99 | func_lt_dump_args () | ||
100 | { | ||
101 | lt_dump_args_N=1; | ||
102 | for lt_arg | ||
103 | do | ||
104 | $ECHO "gnunet-escrow:gnunet-escrow:$LINENO: newargv[$lt_dump_args_N]: $lt_arg" | ||
105 | lt_dump_args_N=`expr $lt_dump_args_N + 1` | ||
106 | done | ||
107 | } | ||
108 | |||
109 | # Core function for launching the target application | ||
110 | func_exec_program_core () | ||
111 | { | ||
112 | |||
113 | if test -n "$lt_option_debug"; then | ||
114 | $ECHO "gnunet-escrow:gnunet-escrow:$LINENO: newargv[0]: $progdir/$program" 1>&2 | ||
115 | func_lt_dump_args ${1+"$@"} 1>&2 | ||
116 | fi | ||
117 | exec "$progdir/$program" ${1+"$@"} | ||
118 | |||
119 | $ECHO "$0: cannot exec $program $*" 1>&2 | ||
120 | exit 1 | ||
121 | } | ||
122 | |||
123 | # A function to encapsulate launching the target application | ||
124 | # Strips options in the --lt-* namespace from $@ and | ||
125 | # launches target application with the remaining arguments. | ||
126 | func_exec_program () | ||
127 | { | ||
128 | case " $* " in | ||
129 | *\ --lt-*) | ||
130 | for lt_wr_arg | ||
131 | do | ||
132 | case $lt_wr_arg in | ||
133 | --lt-*) ;; | ||
134 | *) set x "$@" "$lt_wr_arg"; shift;; | ||
135 | esac | ||
136 | shift | ||
137 | done ;; | ||
138 | esac | ||
139 | func_exec_program_core ${1+"$@"} | ||
140 | } | ||
141 | |||
142 | # Parse options | ||
143 | func_parse_lt_options "$0" ${1+"$@"} | ||
144 | |||
145 | # Find the directory that this script lives in. | ||
146 | thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'` | ||
147 | test "x$thisdir" = "x$file" && thisdir=. | ||
148 | |||
149 | # Follow symbolic links until we get to the real thisdir. | ||
150 | file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'` | ||
151 | while test -n "$file"; do | ||
152 | destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'` | ||
153 | |||
154 | # If there was a directory component, then change thisdir. | ||
155 | if test "x$destdir" != "x$file"; then | ||
156 | case "$destdir" in | ||
157 | [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; | ||
158 | *) thisdir="$thisdir/$destdir" ;; | ||
159 | esac | ||
160 | fi | ||
161 | |||
162 | file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'` | ||
163 | file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'` | ||
164 | done | ||
165 | |||
166 | # Usually 'no', except on cygwin/mingw when embedded into | ||
167 | # the cwrapper. | ||
168 | WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no | ||
169 | if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then | ||
170 | # special case for '.' | ||
171 | if test "$thisdir" = "."; then | ||
172 | thisdir=`pwd` | ||
173 | fi | ||
174 | # remove .libs from thisdir | ||
175 | case "$thisdir" in | ||
176 | *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;; | ||
177 | .libs ) thisdir=. ;; | ||
178 | esac | ||
179 | fi | ||
180 | |||
181 | # Try to get the absolute directory name. | ||
182 | absdir=`cd "$thisdir" && pwd` | ||
183 | test -n "$absdir" && thisdir="$absdir" | ||
184 | |||
185 | program='gnunet-escrow' | ||
186 | progdir="$thisdir/.libs" | ||
187 | |||
188 | |||
189 | if test -f "$progdir/$program"; then | ||
190 | # Add our own library path to LD_LIBRARY_PATH | ||
191 | LD_LIBRARY_PATH="/home/jo/Schreibtisch/gnunet-build/gnunet/src/util/.libs:/home/jo/Schreibtisch/gnunet-build/gnunet/src/namestore/.libs:/home/jo/Schreibtisch/gnunet-build/gnunet/src/escrow/.libs:/home/jo/Schreibtisch/gnunet-build/gnunet/src/identity/.libs:$LD_LIBRARY_PATH" | ||
192 | |||
193 | # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH | ||
194 | # The second colon is a workaround for a bug in BeOS R4 sed | ||
195 | LD_LIBRARY_PATH=`$ECHO "$LD_LIBRARY_PATH" | /usr/bin/sed 's/::*$//'` | ||
196 | |||
197 | export LD_LIBRARY_PATH | ||
198 | |||
199 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then | ||
200 | # Run the actual program with our arguments. | ||
201 | func_exec_program ${1+"$@"} | ||
202 | fi | ||
203 | else | ||
204 | # The program doesn't exist. | ||
205 | $ECHO "$0: error: '$progdir/$program' does not exist" 1>&2 | ||
206 | $ECHO "This script is just a wrapper for $program." 1>&2 | ||
207 | $ECHO "See the libtool documentation for more information." 1>&2 | ||
208 | exit 1 | ||
209 | fi | ||
210 | fi | ||
diff --git a/src/escrow/gnunet-escrow.c b/src/escrow/gnunet-escrow.c index b84182966..67f613cf6 100644 --- a/src/escrow/gnunet-escrow.c +++ b/src/escrow/gnunet-escrow.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | 28 | ||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_escrow_lib.h" | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * return value | 33 | * return value |
@@ -43,6 +44,22 @@ static char *ego_name; | |||
43 | */ | 44 | */ |
44 | static char *plugin_name; | 45 | static char *plugin_name; |
45 | 46 | ||
47 | /** | ||
48 | * Handle to the escrow component | ||
49 | */ | ||
50 | static struct GNUNET_ESCROW_Handle *escrow_handle; | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Called to clean up the escrow component | ||
55 | */ | ||
56 | static void | ||
57 | do_cleanup (void *cls) | ||
58 | { | ||
59 | GNUNET_ESCROW_fini (escrow_handle); | ||
60 | } | ||
61 | |||
62 | |||
46 | static void | 63 | static void |
47 | run (void *cls, | 64 | run (void *cls, |
48 | char *const *args, | 65 | char *const *args, |
@@ -66,6 +83,10 @@ run (void *cls, | |||
66 | 83 | ||
67 | // TODO: where to decide what to call from api? | 84 | // TODO: where to decide what to call from api? |
68 | 85 | ||
86 | escrow_handle = GNUNET_ESCROW_init (c); | ||
87 | // GNUNET_IDENTITY_connect (..., &ego_cb, ...); | ||
88 | // Ego-API... | ||
89 | |||
69 | } | 90 | } |
70 | 91 | ||
71 | 92 | ||
diff --git a/src/escrow/plugin_escrow_anastasis.c b/src/escrow/plugin_escrow_anastasis.c index 4525bf11b..8c4ff5134 100644 --- a/src/escrow/plugin_escrow_anastasis.c +++ b/src/escrow/plugin_escrow_anastasis.c | |||
@@ -27,10 +27,22 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_escrow_plugin.h" | 29 | #include "gnunet_escrow_plugin.h" |
30 | #include "escrow_plugin_helper.h" | ||
30 | #include <inttypes.h> | 31 | #include <inttypes.h> |
31 | 32 | ||
32 | 33 | ||
33 | /** | 34 | /** |
35 | * Identity handle | ||
36 | */ | ||
37 | static struct GNUNET_IDENTITY_Handle *identity_handle; | ||
38 | |||
39 | /** | ||
40 | * Handle for the plugin instance | ||
41 | */ | ||
42 | struct EscrowPluginHandle ph; | ||
43 | |||
44 | |||
45 | /** | ||
34 | * Start the Anastasis escrow of the key | 46 | * Start the Anastasis escrow of the key |
35 | * | 47 | * |
36 | * @param ego the identity ego containing the private key | 48 | * @param ego the identity ego containing the private key |
@@ -51,7 +63,7 @@ start_anastasis_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | |||
51 | * @return the escrow anchor needed to restore the key | 63 | * @return the escrow anchor needed to restore the key |
52 | */ | 64 | */ |
53 | void * | 65 | void * |
54 | renew_anastasis_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | 66 | renew_anastasis_key_escrow (void *escrowAnchor) |
55 | { | 67 | { |
56 | // TODO: implement | 68 | // TODO: implement |
57 | return NULL; | 69 | return NULL; |
@@ -93,21 +105,63 @@ restore_anastasis_key_escrow (void *escrowAnchor, | |||
93 | 105 | ||
94 | 106 | ||
95 | /** | 107 | /** |
108 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
109 | * | ||
110 | * @param anchorString the encoded escrow anchor string | ||
111 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
112 | */ | ||
113 | const struct GNUNET_ESCROW_Anchor * | ||
114 | anastasis_anchor_string_to_data (char *anchorString) | ||
115 | { | ||
116 | struct GNUNET_ESCROW_Anchor *anchor; | ||
117 | uint32_t data_size; | ||
118 | |||
119 | data_size = strlen (anchorString) + 1; | ||
120 | |||
121 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + data_size); | ||
122 | anchor->size = data_size; | ||
123 | // TODO: deserialize? | ||
124 | GNUNET_memcpy (&anchor[1], anchorString, data_size); | ||
125 | |||
126 | return anchor; | ||
127 | } | ||
128 | |||
129 | |||
130 | /** | ||
131 | * ContinueIdentityInitFunction for the Anastasis plugin | ||
132 | */ | ||
133 | void | ||
134 | anastasis_cont_init () | ||
135 | { | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | |||
140 | /** | ||
96 | * Entry point for the plugin. | 141 | * Entry point for the plugin. |
97 | * | 142 | * |
98 | * @param cls NULL | 143 | * @param cls Config info |
99 | * @return the exported block API | 144 | * @return the exported block API |
100 | */ | 145 | */ |
101 | void * | 146 | void * |
102 | libgnunet_plugin_escrow_anastasis_init (void *cls) | 147 | libgnunet_plugin_escrow_anastasis_init (void *cls) |
103 | { | 148 | { |
104 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 149 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
150 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
105 | 151 | ||
106 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); | 152 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); |
107 | api->start_key_escrow = &start_anastasis_key_escrow; | 153 | api->start_key_escrow = &start_anastasis_key_escrow; |
108 | api->renew_key_escrow = &renew_anastasis_key_escrow; | 154 | api->renew_key_escrow = &renew_anastasis_key_escrow; |
109 | api->verify_key_escrow = &verify_anastasis_key_escrow; | 155 | api->verify_key_escrow = &verify_anastasis_key_escrow; |
110 | api->restore_key = &restore_anastasis_key_escrow; | 156 | api->restore_key = &restore_anastasis_key_escrow; |
157 | api->anchor_string_to_data = &anastasis_anchor_string_to_data; | ||
158 | |||
159 | ph.cont = &anastasis_cont_init; | ||
160 | |||
161 | identity_handle = GNUNET_IDENTITY_connect (cfg, | ||
162 | &GNUNET_ESCROW_list_ego, | ||
163 | &ph); | ||
164 | |||
111 | return api; | 165 | return api; |
112 | } | 166 | } |
113 | 167 | ||
@@ -124,6 +178,9 @@ libgnunet_plugin_escrow_anastasis_done (void *cls) | |||
124 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; | 178 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; |
125 | 179 | ||
126 | GNUNET_free (api); | 180 | GNUNET_free (api); |
181 | GNUNET_IDENTITY_disconnect (identity_handle); | ||
182 | GNUNET_ESCROW_cleanup_ego_list (&ph); | ||
183 | |||
127 | return NULL; | 184 | return NULL; |
128 | } | 185 | } |
129 | 186 | ||
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index 85cbf4347..04a6984e2 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_escrow_plugin.h" | 30 | #include "gnunet_escrow_plugin.h" |
31 | #include "escrow_plugin_helper.h" | ||
31 | #include <sss.h> | 32 | #include <sss.h> |
32 | #include <inttypes.h> | 33 | #include <inttypes.h> |
33 | 34 | ||
@@ -36,6 +37,17 @@ | |||
36 | 37 | ||
37 | 38 | ||
38 | /** | 39 | /** |
40 | * Identity handle | ||
41 | */ | ||
42 | static struct GNUNET_IDENTITY_Handle *identity_handle; | ||
43 | |||
44 | /** | ||
45 | * Handle for the plugin instance | ||
46 | */ | ||
47 | struct EscrowPluginHandle ph; | ||
48 | |||
49 | |||
50 | /** | ||
39 | * Start the GNS escrow of the key | 51 | * Start the GNS escrow of the key |
40 | * | 52 | * |
41 | * @param ego the identity ego containing the private key | 53 | * @param ego the identity ego containing the private key |
@@ -77,7 +89,7 @@ start_gns_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | |||
77 | * @return the escrow anchor needed to restore the key | 89 | * @return the escrow anchor needed to restore the key |
78 | */ | 90 | */ |
79 | void * | 91 | void * |
80 | renew_gns_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | 92 | renew_gns_key_escrow (void *escrowAnchor) |
81 | { | 93 | { |
82 | // TODO: implement | 94 | // TODO: implement |
83 | return NULL; | 95 | return NULL; |
@@ -119,21 +131,63 @@ restore_gns_key_escrow (void *escrowAnchor, | |||
119 | 131 | ||
120 | 132 | ||
121 | /** | 133 | /** |
134 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
135 | * | ||
136 | * @param anchorString the encoded escrow anchor string | ||
137 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
138 | */ | ||
139 | const struct GNUNET_ESCROW_Anchor * | ||
140 | gns_anchor_string_to_data (char *anchorString) | ||
141 | { | ||
142 | struct GNUNET_ESCROW_Anchor *anchor; | ||
143 | uint32_t data_size; | ||
144 | |||
145 | data_size = strlen (anchorString) + 1; | ||
146 | |||
147 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + data_size); | ||
148 | anchor->size = data_size; | ||
149 | // TODO: deserialize? | ||
150 | GNUNET_memcpy (&anchor[1], anchorString, data_size); | ||
151 | |||
152 | return anchor; | ||
153 | } | ||
154 | |||
155 | |||
156 | /** | ||
157 | * ContinueIdentityInitFunction for the GNS plugin | ||
158 | */ | ||
159 | void | ||
160 | gns_cont_init () | ||
161 | { | ||
162 | return; | ||
163 | } | ||
164 | |||
165 | |||
166 | /** | ||
122 | * Entry point for the plugin. | 167 | * Entry point for the plugin. |
123 | * | 168 | * |
124 | * @param cls NULL | 169 | * @param cls Config info |
125 | * @return the exported block API | 170 | * @return the exported block API |
126 | */ | 171 | */ |
127 | void * | 172 | void * |
128 | libgnunet_plugin_escrow_gns_init (void *cls) | 173 | libgnunet_plugin_escrow_gns_init (void *cls) |
129 | { | 174 | { |
130 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 175 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
176 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
131 | 177 | ||
132 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); | 178 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); |
133 | api->start_key_escrow = &start_gns_key_escrow; | 179 | api->start_key_escrow = &start_gns_key_escrow; |
134 | api->renew_key_escrow = &renew_gns_key_escrow; | 180 | api->renew_key_escrow = &renew_gns_key_escrow; |
135 | api->verify_key_escrow = &verify_gns_key_escrow; | 181 | api->verify_key_escrow = &verify_gns_key_escrow; |
136 | api->restore_key = &restore_gns_key_escrow; | 182 | api->restore_key = &restore_gns_key_escrow; |
183 | api->anchor_string_to_data = &gns_anchor_string_to_data; | ||
184 | |||
185 | ph.cont = &gns_cont_init; | ||
186 | |||
187 | identity_handle = GNUNET_IDENTITY_connect (cfg, | ||
188 | &GNUNET_ESCROW_list_ego, | ||
189 | &ph); | ||
190 | |||
137 | return api; | 191 | return api; |
138 | } | 192 | } |
139 | 193 | ||
@@ -150,6 +204,9 @@ libgnunet_plugin_escrow_gns_done (void *cls) | |||
150 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; | 204 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; |
151 | 205 | ||
152 | GNUNET_free (api); | 206 | GNUNET_free (api); |
207 | GNUNET_IDENTITY_disconnect (identity_handle); | ||
208 | GNUNET_ESCROW_cleanup_ego_list (&ph); | ||
209 | |||
153 | return NULL; | 210 | return NULL; |
154 | } | 211 | } |
155 | 212 | ||
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c index 347ab56e5..2213b334c 100644 --- a/src/escrow/plugin_escrow_plaintext.c +++ b/src/escrow/plugin_escrow_plaintext.c | |||
@@ -27,11 +27,23 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_escrow_plugin.h" | 29 | #include "gnunet_escrow_plugin.h" |
30 | #include "escrow_plugin_helper.h" | ||
30 | #include "gnunet_identity_service.h" | 31 | #include "gnunet_identity_service.h" |
31 | #include <inttypes.h> | 32 | #include <inttypes.h> |
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
36 | * Identity handle | ||
37 | */ | ||
38 | static struct GNUNET_IDENTITY_Handle *identity_handle; | ||
39 | |||
40 | /** | ||
41 | * Handle for the plugin instance | ||
42 | */ | ||
43 | struct EscrowPluginHandle ph; | ||
44 | |||
45 | |||
46 | /** | ||
35 | * Start the plaintext escrow of the key, i.e. simply hand out the key | 47 | * Start the plaintext escrow of the key, i.e. simply hand out the key |
36 | * | 48 | * |
37 | * @param ego the identity ego containing the private key | 49 | * @param ego the identity ego containing the private key |
@@ -58,9 +70,9 @@ start_plaintext_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | |||
58 | * @return the escrow anchor needed to restore the key | 70 | * @return the escrow anchor needed to restore the key |
59 | */ | 71 | */ |
60 | void * | 72 | void * |
61 | renew_plaintext_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | 73 | renew_plaintext_key_escrow (void *escrowAnchor) |
62 | { | 74 | { |
63 | return start_plaintext_key_escrow (ego); | 75 | return escrowAnchor; |
64 | } | 76 | } |
65 | 77 | ||
66 | 78 | ||
@@ -102,14 +114,13 @@ const struct GNUNET_IDENTITY_Ego * | |||
102 | restore_plaintext_key_escrow (void *escrowAnchor, | 114 | restore_plaintext_key_escrow (void *escrowAnchor, |
103 | char *egoName) | 115 | char *egoName) |
104 | { | 116 | { |
105 | const struct GNUNET_CRYPTO_EcdsaPrivateKey pk; | 117 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; |
106 | struct GNUNET_IDENTITY_Operation *op; | 118 | struct GNUNET_IDENTITY_Operation *op; |
107 | 119 | ||
108 | if (NULL == escrowAnchor) | 120 | if (NULL == escrowAnchor) |
109 | { | 121 | { |
110 | return NULL; | 122 | return NULL; |
111 | } | 123 | } |
112 | // TODO: ecdsa method for string -> privkey | ||
113 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)escrowAnchor, | 124 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)escrowAnchor, |
114 | strlen ((char *)escrowAnchor), | 125 | strlen ((char *)escrowAnchor), |
115 | &pk)) | 126 | &pk)) |
@@ -128,21 +139,63 @@ restore_plaintext_key_escrow (void *escrowAnchor, | |||
128 | 139 | ||
129 | 140 | ||
130 | /** | 141 | /** |
142 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
143 | * | ||
144 | * @param anchorString the encoded escrow anchor string | ||
145 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
146 | */ | ||
147 | const struct GNUNET_ESCROW_Anchor * | ||
148 | plaintext_anchor_string_to_data (char *anchorString) | ||
149 | { | ||
150 | struct GNUNET_ESCROW_Anchor *anchor; | ||
151 | uint32_t data_size; | ||
152 | |||
153 | data_size = strlen (anchorString) + 1; | ||
154 | |||
155 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + data_size); | ||
156 | anchor->size = data_size; | ||
157 | // TODO: deserialize? | ||
158 | GNUNET_memcpy (&anchor[1], anchorString, data_size); | ||
159 | |||
160 | return anchor; | ||
161 | } | ||
162 | |||
163 | |||
164 | /** | ||
165 | * ContinueIdentityInitFunction for the plaintext plugin | ||
166 | */ | ||
167 | void | ||
168 | plaintext_cont_init () | ||
169 | { | ||
170 | return; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
131 | * Entry point for the plugin. | 175 | * Entry point for the plugin. |
132 | * | 176 | * |
133 | * @param cls NULL | 177 | * @param cls Config info |
134 | * @return the exported block API | 178 | * @return the exported block API |
135 | */ | 179 | */ |
136 | void * | 180 | void * |
137 | libgnunet_plugin_escrow_plaintext_init (void *cls) | 181 | libgnunet_plugin_escrow_plaintext_init (void *cls) |
138 | { | 182 | { |
139 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 183 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
184 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
140 | 185 | ||
141 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); | 186 | api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); |
142 | api->start_key_escrow = &start_plaintext_key_escrow; | 187 | api->start_key_escrow = &start_plaintext_key_escrow; |
143 | api->renew_key_escrow = &renew_plaintext_key_escrow; | 188 | api->renew_key_escrow = &renew_plaintext_key_escrow; |
144 | api->verify_key_escrow = &verify_plaintext_key_escrow; | 189 | api->verify_key_escrow = &verify_plaintext_key_escrow; |
145 | api->restore_key = &restore_plaintext_key_escrow; | 190 | api->restore_key = &restore_plaintext_key_escrow; |
191 | api->anchor_string_to_data = &plaintext_anchor_string_to_data; | ||
192 | |||
193 | ph.cont = &plaintext_cont_init; | ||
194 | |||
195 | identity_handle = GNUNET_IDENTITY_connect (cfg, | ||
196 | &GNUNET_ESCROW_list_ego, | ||
197 | &ph); | ||
198 | |||
146 | return api; | 199 | return api; |
147 | } | 200 | } |
148 | 201 | ||
@@ -159,6 +212,9 @@ libgnunet_plugin_escrow_plaintext_done (void *cls) | |||
159 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; | 212 | struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; |
160 | 213 | ||
161 | GNUNET_free (api); | 214 | GNUNET_free (api); |
215 | GNUNET_IDENTITY_disconnect (identity_handle); | ||
216 | GNUNET_ESCROW_cleanup_ego_list (&ph); | ||
217 | |||
162 | return NULL; | 218 | return NULL; |
163 | } | 219 | } |
164 | 220 | ||
diff --git a/src/include/gnunet_escrow_lib.h b/src/include/gnunet_escrow_lib.h index 2ac3c7761..297926581 100644 --- a/src/include/gnunet_escrow_lib.h +++ b/src/include/gnunet_escrow_lib.h | |||
@@ -38,6 +38,7 @@ extern "C" { | |||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_identity_service.h" | ||
41 | 42 | ||
42 | 43 | ||
43 | /** | 44 | /** |
@@ -61,8 +62,40 @@ enum GNUNET_ESCROW_Verification_Result { | |||
61 | 62 | ||
62 | 63 | ||
63 | /** | 64 | /** |
65 | * Struct for the escrow anchor | ||
66 | */ | ||
67 | struct GNUNET_ESCROW_Anchor { | ||
68 | enum GNUNET_ESCROW_Key_Escrow_Method method; | ||
69 | uint32_t size; | ||
70 | }; | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Initialize the escrow component. | ||
75 | * | ||
76 | * @param cfg the configuration to use | ||
77 | * | ||
78 | * @return handle to use | ||
79 | */ | ||
80 | struct GNUNET_ESCROW_Handle * | ||
81 | GNUNET_ESCROW_init ( | ||
82 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Unload all loaded plugins on destruction. | ||
87 | * | ||
88 | * @param h the escrow handle | ||
89 | */ | ||
90 | void | ||
91 | GNUNET_ESCROW_fini ( | ||
92 | struct GNUNET_ESCROW_Handle *h); | ||
93 | |||
94 | |||
95 | /** | ||
64 | * Put some data in escrow using the specified escrow method | 96 | * Put some data in escrow using the specified escrow method |
65 | * | 97 | * |
98 | * @param h the handle for the escrow component | ||
66 | * @param ego the identity ego to put in escrow | 99 | * @param ego the identity ego to put in escrow |
67 | * @param method the escrow method to use | 100 | * @param method the escrow method to use |
68 | * | 101 | * |
@@ -70,6 +103,7 @@ enum GNUNET_ESCROW_Verification_Result { | |||
70 | */ | 103 | */ |
71 | void * | 104 | void * |
72 | GNUNET_ESCROW_put ( | 105 | GNUNET_ESCROW_put ( |
106 | struct GNUNET_ESCROW_Handle *h, | ||
73 | const struct GNUNET_IDENTITY_Ego *ego, | 107 | const struct GNUNET_IDENTITY_Ego *ego, |
74 | enum GNUNET_ESCROW_Key_Escrow_Method method); | 108 | enum GNUNET_ESCROW_Key_Escrow_Method method); |
75 | 109 | ||
@@ -77,6 +111,7 @@ GNUNET_ESCROW_put ( | |||
77 | /** | 111 | /** |
78 | * Renew the escrow of the data related to the given escrow anchor | 112 | * Renew the escrow of the data related to the given escrow anchor |
79 | * | 113 | * |
114 | * @param h the handle for the escrow component | ||
80 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 115 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
81 | * @param method the escrow method to use | 116 | * @param method the escrow method to use |
82 | * | 117 | * |
@@ -84,6 +119,7 @@ GNUNET_ESCROW_put ( | |||
84 | */ | 119 | */ |
85 | void * | 120 | void * |
86 | GNUNET_ESCROW_renew ( | 121 | GNUNET_ESCROW_renew ( |
122 | struct GNUNET_ESCROW_Handle *h, | ||
87 | void *escrowAnchor, | 123 | void *escrowAnchor, |
88 | enum GNUNET_ESCROW_Key_Escrow_Method method); | 124 | enum GNUNET_ESCROW_Key_Escrow_Method method); |
89 | 125 | ||
@@ -91,6 +127,7 @@ GNUNET_ESCROW_renew ( | |||
91 | /** | 127 | /** |
92 | * Get the escrowed data back | 128 | * Get the escrowed data back |
93 | * | 129 | * |
130 | * @param h the handle for the escrow component | ||
94 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 131 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
95 | * @param egoName the name of the ego to get back | 132 | * @param egoName the name of the ego to get back |
96 | * @param method the escrow method to use | 133 | * @param method the escrow method to use |
@@ -99,6 +136,7 @@ GNUNET_ESCROW_renew ( | |||
99 | */ | 136 | */ |
100 | const struct GNUNET_IDENTITY_Ego * | 137 | const struct GNUNET_IDENTITY_Ego * |
101 | GNUNET_ESCROW_get ( | 138 | GNUNET_ESCROW_get ( |
139 | struct GNUNET_ESCROW_Handle *h, | ||
102 | void *escrowAnchor, | 140 | void *escrowAnchor, |
103 | char *egoName, | 141 | char *egoName, |
104 | enum GNUNET_ESCROW_Key_Escrow_Method method); | 142 | enum GNUNET_ESCROW_Key_Escrow_Method method); |
@@ -107,6 +145,7 @@ GNUNET_ESCROW_get ( | |||
107 | /** | 145 | /** |
108 | * Verify the escrowed data | 146 | * Verify the escrowed data |
109 | * | 147 | * |
148 | * @param h the handle for the escrow component | ||
110 | * @param ego the identity ego that was put into escrow | 149 | * @param ego the identity ego that was put into escrow |
111 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 150 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
112 | * @param method the escrow method to use | 151 | * @param method the escrow method to use |
@@ -117,11 +156,29 @@ GNUNET_ESCROW_get ( | |||
117 | */ | 156 | */ |
118 | int | 157 | int |
119 | GNUNET_ESCROW_verify ( | 158 | GNUNET_ESCROW_verify ( |
159 | struct GNUNET_ESCROW_Handle *h, | ||
120 | const struct GNUNET_IDENTITY_Ego *ego, | 160 | const struct GNUNET_IDENTITY_Ego *ego, |
121 | void *escrowAnchor, | 161 | void *escrowAnchor, |
122 | enum GNUNET_ESCROW_Key_Escrow_Method method); | 162 | enum GNUNET_ESCROW_Key_Escrow_Method method); |
123 | 163 | ||
124 | 164 | ||
165 | /** | ||
166 | * Deserialize an escrow anchor string (e.g. from command line) into a | ||
167 | * GNUNET_ESCROW_Anchor struct | ||
168 | * | ||
169 | * @param h the handle for the escrow component | ||
170 | * @param anchorString the encoded escrow anchor string | ||
171 | * @param method the escrow method to use | ||
172 | * | ||
173 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
174 | */ | ||
175 | const struct GNUNET_ESCROW_Anchor * | ||
176 | GNUNET_ESCROW_anchor_string_to_data ( | ||
177 | struct GNUNET_ESCROW_Handle *h, | ||
178 | char *anchorString, | ||
179 | enum GNUNET_ESCROW_Key_Escrow_Method method); | ||
180 | |||
181 | |||
125 | #if 0 /* keep Emacsens' auto-indent happy */ | 182 | #if 0 /* keep Emacsens' auto-indent happy */ |
126 | { | 183 | { |
127 | #endif | 184 | #endif |
diff --git a/src/include/gnunet_escrow_plugin.h b/src/include/gnunet_escrow_plugin.h index 3b55551ba..a9be01a35 100644 --- a/src/include/gnunet_escrow_plugin.h +++ b/src/include/gnunet_escrow_plugin.h | |||
@@ -41,6 +41,81 @@ extern "C" { | |||
41 | #endif | 41 | #endif |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /** | ||
45 | * State while collecting all egos | ||
46 | */ | ||
47 | #define ESCROW_PLUGIN_STATE_INIT 0 | ||
48 | |||
49 | /** | ||
50 | * Done collecting egos | ||
51 | */ | ||
52 | #define ESCROW_PLUGIN_STATE_POST_INIT 1 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * The ego list | ||
57 | */ | ||
58 | struct EgoEntry | ||
59 | { | ||
60 | /** | ||
61 | * DLL | ||
62 | */ | ||
63 | struct EgoEntry *next; | ||
64 | |||
65 | /** | ||
66 | * DLL | ||
67 | */ | ||
68 | struct EgoEntry *prev; | ||
69 | |||
70 | /** | ||
71 | * Ego Identifier | ||
72 | */ | ||
73 | char *identifier; | ||
74 | |||
75 | /** | ||
76 | * Public key string | ||
77 | */ | ||
78 | char *keystring; | ||
79 | |||
80 | /** | ||
81 | * The Ego | ||
82 | */ | ||
83 | struct GNUNET_IDENTITY_Ego *ego; | ||
84 | }; | ||
85 | |||
86 | /** | ||
87 | * Function called after the initialization of the identity service. | ||
88 | * Passed via cls to the callback of GNUNET_IDENTITY_connect | ||
89 | */ | ||
90 | typedef void (*GNUNET_ESCROW_ContinueIdentityInitFunction) ( | ||
91 | ); | ||
92 | |||
93 | /** | ||
94 | * Handle for a plugin instance | ||
95 | */ | ||
96 | struct EscrowPluginHandle | ||
97 | { | ||
98 | /** | ||
99 | * The ContinueIdentityInit function. | ||
100 | */ | ||
101 | GNUNET_ESCROW_ContinueIdentityInitFunction cont; | ||
102 | |||
103 | /** | ||
104 | * The state of the plugin (in the initialization phase). | ||
105 | */ | ||
106 | int state; | ||
107 | |||
108 | /** | ||
109 | * The head of the ego list. | ||
110 | */ | ||
111 | struct EgoEntry *ego_head; | ||
112 | |||
113 | /** | ||
114 | * The tail of the ego list | ||
115 | */ | ||
116 | struct EgoEntry *ego_tail; | ||
117 | }; | ||
118 | |||
44 | 119 | ||
45 | /** | 120 | /** |
46 | * Function called to start the escrow of the key | 121 | * Function called to start the escrow of the key |
@@ -86,6 +161,17 @@ typedef const struct GNUNET_IDENTITY_Ego *(*GNUNET_ESCROW_RestoreKeyFunction) ( | |||
86 | 161 | ||
87 | 162 | ||
88 | /** | 163 | /** |
164 | * Function called to deserialize an escrow anchor string into a | ||
165 | * GNUNET_ESCROW_Anchor struct | ||
166 | * | ||
167 | * @param anchorString the encoded escrow anchor string | ||
168 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct | ||
169 | */ | ||
170 | typedef const struct GNUNET_ESCROW_Anchor *(*GNUNET_ESCROW_AnchorStringToDataFunction) ( | ||
171 | char *anchorString); | ||
172 | |||
173 | |||
174 | /** | ||
89 | * Each plugin is required to return a pointer to a struct of this | 175 | * Each plugin is required to return a pointer to a struct of this |
90 | * type as the return value from its entry point. | 176 | * type as the return value from its entry point. |
91 | */ | 177 | */ |
@@ -115,6 +201,11 @@ struct GNUNET_ESCROW_KeyPluginFunctions | |||
115 | * Restore key escrow | 201 | * Restore key escrow |
116 | */ | 202 | */ |
117 | GNUNET_ESCROW_RestoreKeyFunction restore_key; | 203 | GNUNET_ESCROW_RestoreKeyFunction restore_key; |
204 | |||
205 | /** | ||
206 | * Deserialize anchor string to data | ||
207 | */ | ||
208 | GNUNET_ESCROW_AnchorStringToDataFunction anchor_string_to_data; | ||
118 | }; | 209 | }; |
119 | 210 | ||
120 | 211 | ||