diff options
author | jospaeth <spaethj@in.tum.de> | 2020-07-16 13:41:56 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-07-16 13:41:56 +0200 |
commit | a8b7f94fadb36299b55f15faaa5f4fda143ba9bb (patch) | |
tree | 5641541a01aba222d1131166baca6e33dfd2d4f4 /src/escrow/escrow_api.c | |
parent | f6007d417be9f3030dad817151ed39d896d233ba (diff) | |
download | gnunet-a8b7f94fadb36299b55f15faaa5f4fda143ba9bb.tar.gz gnunet-a8b7f94fadb36299b55f15faaa5f4fda143ba9bb.zip |
change plugin functions to support async code
Diffstat (limited to 'src/escrow/escrow_api.c')
-rw-r--r-- | src/escrow/escrow_api.c | 114 |
1 files changed, 69 insertions, 45 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c index 6d4d6531b..05491497e 100644 --- a/src/escrow/escrow_api.c +++ b/src/escrow/escrow_api.c | |||
@@ -29,30 +29,7 @@ | |||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_escrow_lib.h" | 30 | #include "gnunet_escrow_lib.h" |
31 | #include "gnunet_escrow_plugin.h" | 31 | #include "gnunet_escrow_plugin.h" |
32 | 32 | #include "escrow.h" | |
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 | 33 | ||
57 | 34 | ||
58 | /** | 35 | /** |
@@ -199,86 +176,132 @@ GNUNET_ESCROW_fini (struct GNUNET_ESCROW_Handle *h) | |||
199 | /** | 176 | /** |
200 | * Put some data in escrow using the specified escrow method | 177 | * Put some data in escrow using the specified escrow method |
201 | * | 178 | * |
179 | * @param h the handle for the escrow component | ||
202 | * @param ego the identity ego to put in escrow | 180 | * @param ego the identity ego to put in escrow |
203 | * @param method the escrow method to use | 181 | * @param method the escrow method to use |
182 | * @param cb function to call with the escrow anchor on completion | ||
183 | * @param cb_cls closure for @a cb | ||
204 | * | 184 | * |
205 | * @return the escrow anchor needed to get the data back | 185 | * @return handle to abort the operation |
206 | */ | 186 | */ |
207 | void * | 187 | struct GNUNET_ESCROW_Operation * |
208 | GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h, | 188 | GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h, |
209 | const struct GNUNET_IDENTITY_Ego *ego, | 189 | const struct GNUNET_IDENTITY_Ego *ego, |
210 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 190 | enum GNUNET_ESCROW_Key_Escrow_Method method, |
191 | GNUNET_ESCROW_AnchorContinuation cb, | ||
192 | void *cb_cls) | ||
211 | { | 193 | { |
194 | struct GNUNET_ESCROW_Operation *op; | ||
212 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 195 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
213 | 196 | ||
197 | op = GNUNET_new (struct GNUNET_ESCROW_Operation); | ||
198 | op->h = h; | ||
199 | op->cb_put = cb; | ||
200 | |||
214 | api = init_plugin (h, method); | 201 | api = init_plugin (h, method); |
215 | return api->start_key_escrow (ego); | 202 | api->start_key_escrow (h, ego, cb, cb_cls); |
203 | |||
204 | return op; | ||
216 | } | 205 | } |
217 | 206 | ||
218 | 207 | ||
219 | /** | 208 | /** |
220 | * Renew the escrow of the data related to the given escrow anchor | 209 | * Renew the escrow of the data related to the given escrow anchor |
221 | * | 210 | * |
211 | * @param h the handle for the escrow component | ||
222 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 212 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
223 | * @param method the escrow method to use | 213 | * @param method the escrow method to use |
214 | * @param cb function to call with the escrow anchor on completion | ||
215 | * @param cb_cls closure for @a cb | ||
224 | * | 216 | * |
225 | * @return the escrow anchor needed to get the data back | 217 | * @return handle to abort the operation |
226 | */ | 218 | */ |
227 | void * | 219 | struct GNUNET_ESCROW_Operation * |
228 | GNUNET_ESCROW_renew (struct GNUNET_ESCROW_Handle *h, | 220 | GNUNET_ESCROW_renew (struct GNUNET_ESCROW_Handle *h, |
229 | void *escrowAnchor, | 221 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
230 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 222 | enum GNUNET_ESCROW_Key_Escrow_Method method, |
223 | GNUNET_ESCROW_AnchorContinuation cb, | ||
224 | void *cb_cls) | ||
231 | { | 225 | { |
226 | struct GNUNET_ESCROW_Operation *op; | ||
232 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 227 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
233 | 228 | ||
229 | op = GNUNET_new (struct GNUNET_ESCROW_Operation); | ||
230 | op->h = h; | ||
231 | op->cb_renew = cb; | ||
232 | |||
234 | api = init_plugin (h, method); | 233 | api = init_plugin (h, method); |
235 | return api->renew_key_escrow (escrowAnchor); | 234 | api->renew_key_escrow (h, escrowAnchor, cb, cb_cls); |
235 | |||
236 | return op; | ||
236 | } | 237 | } |
237 | 238 | ||
238 | 239 | ||
239 | /** | 240 | /** |
240 | * Get the escrowed data back | 241 | * Get the escrowed data back |
241 | * | 242 | * |
243 | * @param h the handle for the escrow component | ||
242 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 244 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
243 | * @param egoName the name of the ego to get back | 245 | * @param egoName the name of the ego to get back |
244 | * @param method the escrow method to use | 246 | * @param method the escrow method to use |
247 | * @param cb function to call with the restored ego on completion | ||
248 | * @param cb_cls closure for @a cb | ||
245 | * | 249 | * |
246 | * @return a new identity ego restored from the escrow | 250 | * @return handle to abort the operation |
247 | */ | 251 | */ |
248 | const struct GNUNET_IDENTITY_Ego * | 252 | struct GNUNET_ESCROW_Operation * |
249 | GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h, | 253 | GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h, |
250 | void *escrowAnchor, | 254 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
251 | char *egoName, | 255 | char *egoName, |
252 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 256 | enum GNUNET_ESCROW_Key_Escrow_Method method, |
257 | GNUNET_ESCROW_EgoContinuation cb, | ||
258 | void *cb_cls) | ||
253 | { | 259 | { |
260 | struct GNUNET_ESCROW_Operation *op; | ||
254 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 261 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
255 | 262 | ||
263 | op = GNUNET_new (struct GNUNET_ESCROW_Operation); | ||
264 | op->h = h; | ||
265 | op->cb_get = cb; | ||
266 | |||
256 | api = init_plugin (h, method); | 267 | api = init_plugin (h, method); |
257 | return api->restore_key (escrowAnchor, egoName); | 268 | api->restore_key (h, escrowAnchor, egoName, cb, cb_cls); |
269 | |||
270 | return op; | ||
258 | } | 271 | } |
259 | 272 | ||
260 | 273 | ||
261 | /** | 274 | /** |
262 | * Verify the escrowed data | 275 | * Verify the escrowed data |
263 | * | 276 | * |
277 | * @param h the handle for the escrow component | ||
264 | * @param ego the identity ego that was put into escrow | 278 | * @param ego the identity ego that was put into escrow |
265 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method | 279 | * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method |
266 | * @param method the escrow method to use | 280 | * @param method the escrow method to use |
281 | * @param cb function to call with the verification result on completion | ||
282 | * @param cb_cls closure for @a cb | ||
267 | * | 283 | * |
268 | * @return GNUNET_ESCROW_VALID if the escrow could successfully by restored, | 284 | * @return handle to abort the operation |
269 | * GNUNET_ESCROW_RENEW_NEEDED if the escrow needs to be renewed, | ||
270 | * GNUNET_ESCROW_INVALID otherwise | ||
271 | */ | 285 | */ |
272 | int | 286 | struct GNUNET_ESCROW_Operation * |
273 | GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h, | 287 | GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h, |
274 | const struct GNUNET_IDENTITY_Ego *ego, | 288 | const struct GNUNET_IDENTITY_Ego *ego, |
275 | void *escrowAnchor, | 289 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
276 | enum GNUNET_ESCROW_Key_Escrow_Method method) | 290 | enum GNUNET_ESCROW_Key_Escrow_Method method, |
291 | GNUNET_ESCROW_VerifyContinuation cb, | ||
292 | void *cb_cls) | ||
277 | { | 293 | { |
294 | struct GNUNET_ESCROW_Operation *op; | ||
278 | struct GNUNET_ESCROW_KeyPluginFunctions *api; | 295 | struct GNUNET_ESCROW_KeyPluginFunctions *api; |
279 | 296 | ||
297 | op = GNUNET_new (struct GNUNET_ESCROW_Operation); | ||
298 | op->h = h; | ||
299 | op->cb_verify = cb; | ||
300 | |||
280 | api = init_plugin (h, method); | 301 | api = init_plugin (h, method); |
281 | return api->verify_key_escrow (ego, escrowAnchor); | 302 | api->verify_key_escrow (h, ego, escrowAnchor, cb, cb_cls); |
303 | |||
304 | return op; | ||
282 | } | 305 | } |
283 | 306 | ||
284 | 307 | ||
@@ -286,6 +309,7 @@ GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h, | |||
286 | * Deserialize an escrow anchor string (e.g. from command line) into a | 309 | * Deserialize an escrow anchor string (e.g. from command line) into a |
287 | * GNUNET_ESCROW_Anchor struct | 310 | * GNUNET_ESCROW_Anchor struct |
288 | * | 311 | * |
312 | * @param h the handle for the escrow component | ||
289 | * @param anchorString the encoded escrow anchor string | 313 | * @param anchorString the encoded escrow anchor string |
290 | * @param method the escrow method to use | 314 | * @param method the escrow method to use |
291 | * | 315 | * |