diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-13 11:33:41 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-14 10:01:24 +0200 |
commit | 41d086c02574e08a820612faf2cfb6e68049b316 (patch) | |
tree | 2f80bb52d05d3824451fa02b64b19467324cbdfe /src/reclaim/gnunet-reclaim.c | |
parent | 0a6ac045814213ff33e9317a40daf7250528249a (diff) | |
download | gnunet-41d086c02574e08a820612faf2cfb6e68049b316.tar.gz gnunet-41d086c02574e08a820612faf2cfb6e68049b316.zip |
RECLAIM: less unneccessary crypto; syntax and build fixes
Diffstat (limited to 'src/reclaim/gnunet-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 411 |
1 files changed, 143 insertions, 268 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index c36955a04..790813eec 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -23,14 +23,15 @@ | |||
23 | * @brief Identity Provider utility | 23 | * @brief Identity Provider utility |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | |||
27 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include <inttypes.h> | ||
28 | |||
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | |||
31 | #include "gnunet_identity_service.h" | ||
29 | #include "gnunet_namestore_service.h" | 32 | #include "gnunet_namestore_service.h" |
30 | #include "gnunet_reclaim_service.h" | 33 | #include "gnunet_reclaim_service.h" |
31 | #include "gnunet_identity_service.h" | ||
32 | #include "gnunet_signatures.h" | 34 | #include "gnunet_signatures.h" |
33 | |||
34 | /** | 35 | /** |
35 | * return value | 36 | * return value |
36 | */ | 37 | */ |
@@ -44,37 +45,37 @@ static int list; | |||
44 | /** | 45 | /** |
45 | * Relying party | 46 | * Relying party |
46 | */ | 47 | */ |
47 | static char* rp; | 48 | static char *rp; |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * The attribute | 51 | * The attribute |
51 | */ | 52 | */ |
52 | static char* attr_name; | 53 | static char *attr_name; |
53 | 54 | ||
54 | /** | 55 | /** |
55 | * Attribute value | 56 | * Attribute value |
56 | */ | 57 | */ |
57 | static char* attr_value; | 58 | static char *attr_value; |
58 | 59 | ||
59 | /** | 60 | /** |
60 | * Attributes to issue | 61 | * Attributes to issue |
61 | */ | 62 | */ |
62 | static char* issue_attrs; | 63 | static char *issue_attrs; |
63 | 64 | ||
64 | /** | 65 | /** |
65 | * Ticket to consume | 66 | * Ticket to consume |
66 | */ | 67 | */ |
67 | static char* consume_ticket; | 68 | static char *consume_ticket; |
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Attribute type | 71 | * Attribute type |
71 | */ | 72 | */ |
72 | static char* type_str; | 73 | static char *type_str; |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Ticket to revoke | 76 | * Ticket to revoke |
76 | */ | 77 | */ |
77 | static char* revoke_ticket; | 78 | static char *revoke_ticket; |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * Ticket listing | 81 | * Ticket listing |
@@ -84,7 +85,7 @@ static int list_tickets; | |||
84 | /** | 85 | /** |
85 | * Ego name | 86 | * Ego name |
86 | */ | 87 | */ |
87 | static char* ego_name; | 88 | static char *ego_name; |
88 | 89 | ||
89 | /** | 90 | /** |
90 | * Identity handle | 91 | * Identity handle |
@@ -156,8 +157,7 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task; | |||
156 | */ | 157 | */ |
157 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 158 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
158 | 159 | ||
159 | static void | 160 | static void do_cleanup (void *cls) |
160 | do_cleanup(void *cls) | ||
161 | { | 161 | { |
162 | cleanup_task = NULL; | 162 | cleanup_task = NULL; |
163 | if (NULL != timeout) | 163 | if (NULL != timeout) |
@@ -178,196 +178,146 @@ do_cleanup(void *cls) | |||
178 | GNUNET_free (attr_list); | 178 | GNUNET_free (attr_list); |
179 | } | 179 | } |
180 | 180 | ||
181 | static void | 181 | static void ticket_issue_cb (void *cls, |
182 | ticket_issue_cb (void* cls, | 182 | const struct GNUNET_RECLAIM_Ticket *ticket) |
183 | const struct GNUNET_RECLAIM_Ticket *ticket) | ||
184 | { | 183 | { |
185 | char* ticket_str; | 184 | char *ticket_str; |
186 | reclaim_op = NULL; | 185 | reclaim_op = NULL; |
187 | if (NULL != ticket) { | 186 | if (NULL != ticket) { |
188 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (ticket, | 187 | ticket_str = GNUNET_STRINGS_data_to_string_alloc ( |
189 | sizeof (struct GNUNET_RECLAIM_Ticket)); | 188 | ticket, sizeof (struct GNUNET_RECLAIM_Ticket)); |
190 | printf("%s\n", | 189 | printf ("%s\n", ticket_str); |
191 | ticket_str); | ||
192 | GNUNET_free (ticket_str); | 190 | GNUNET_free (ticket_str); |
193 | } | 191 | } |
194 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 192 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
195 | } | 193 | } |
196 | 194 | ||
197 | static void | 195 | static void store_attr_cont (void *cls, int32_t success, const char *emsg) |
198 | store_attr_cont (void *cls, | ||
199 | int32_t success, | ||
200 | const char*emsg) | ||
201 | { | 196 | { |
202 | reclaim_op = NULL; | 197 | reclaim_op = NULL; |
203 | if (GNUNET_SYSERR == success) { | 198 | if (GNUNET_SYSERR == success) { |
204 | fprintf (stderr, | 199 | fprintf (stderr, "%s\n", emsg); |
205 | "%s\n", emsg); | ||
206 | } | 200 | } |
207 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 201 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
208 | } | 202 | } |
209 | 203 | ||
210 | static void | 204 | static void process_attrs (void *cls, |
211 | process_attrs (void *cls, | 205 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
212 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 206 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
213 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | ||
214 | { | 207 | { |
215 | char *value_str; | 208 | char *value_str; |
216 | const char* attr_type; | 209 | const char *attr_type; |
217 | 210 | ||
218 | if (NULL == identity) | 211 | if (NULL == identity) { |
219 | { | ||
220 | reclaim_op = NULL; | 212 | reclaim_op = NULL; |
221 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 213 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
222 | return; | 214 | return; |
223 | } | 215 | } |
224 | if (NULL == attr) | 216 | if (NULL == attr) { |
225 | { | ||
226 | ret = 1; | 217 | ret = 1; |
227 | return; | 218 | return; |
228 | } | 219 | } |
229 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | 220 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, |
230 | attr->data, | ||
231 | attr->data_size); | 221 | attr->data_size); |
232 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 222 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
233 | fprintf (stdout, | 223 | fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, value_str, |
234 | "%s: %s [%s,v%u,id=%lu]\n", | 224 | attr_type, attr->version, attr->id); |
235 | attr->name, value_str, attr_type, attr->version, attr->id); | ||
236 | } | 225 | } |
237 | 226 | ||
238 | static void | 227 | static void ticket_iter_err (void *cls) |
239 | ticket_iter_err (void *cls) | ||
240 | { | 228 | { |
241 | ticket_iterator = NULL; | 229 | ticket_iterator = NULL; |
242 | fprintf (stderr, | 230 | fprintf (stderr, "Failed to iterate over tickets\n"); |
243 | "Failed to iterate over tickets\n"); | ||
244 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 231 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
245 | } | 232 | } |
246 | 233 | ||
247 | static void | 234 | static void ticket_iter_fin (void *cls) |
248 | ticket_iter_fin (void *cls) | ||
249 | { | 235 | { |
250 | ticket_iterator = NULL; | 236 | ticket_iterator = NULL; |
251 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 237 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
252 | } | 238 | } |
253 | 239 | ||
254 | static void | 240 | static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) |
255 | ticket_iter (void *cls, | ||
256 | const struct GNUNET_RECLAIM_Ticket *ticket) | ||
257 | { | 241 | { |
258 | fprintf (stdout, | 242 | fprintf (stdout, "Found ticket\n"); |
259 | "Found ticket\n"); | ||
260 | GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); | 243 | GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); |
261 | } | 244 | } |
262 | 245 | ||
263 | static void | 246 | static void iter_error (void *cls) |
264 | iter_error (void *cls) | ||
265 | { | 247 | { |
266 | attr_iterator = NULL; | 248 | attr_iterator = NULL; |
267 | fprintf (stderr, | 249 | fprintf (stderr, "Failed to iterate over attributes\n"); |
268 | "Failed to iterate over attributes\n"); | ||
269 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 250 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
270 | } | 251 | } |
271 | 252 | ||
272 | static void | 253 | static void timeout_task (void *cls) |
273 | timeout_task (void *cls) | ||
274 | { | 254 | { |
275 | timeout = NULL; | 255 | timeout = NULL; |
276 | ret = 1; | 256 | ret = 1; |
277 | fprintf (stderr, | 257 | fprintf (stderr, "Timeout\n"); |
278 | "Timeout\n"); | ||
279 | if (NULL == cleanup_task) | 258 | if (NULL == cleanup_task) |
280 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 259 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
281 | } | 260 | } |
282 | 261 | ||
283 | static void | 262 | static void process_rvk (void *cls, int success, const char *msg) |
284 | process_rvk (void *cls, int success, const char* msg) | ||
285 | { | 263 | { |
286 | reclaim_op = NULL; | 264 | reclaim_op = NULL; |
287 | if (GNUNET_OK != success) | 265 | if (GNUNET_OK != success) { |
288 | { | 266 | fprintf (stderr, "Revocation failed.\n"); |
289 | fprintf (stderr, | ||
290 | "Revocation failed.\n"); | ||
291 | ret = 1; | 267 | ret = 1; |
292 | } | 268 | } |
293 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 269 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
294 | } | 270 | } |
295 | 271 | ||
296 | static void | 272 | static void iter_finished (void *cls) |
297 | iter_finished (void *cls) | ||
298 | { | 273 | { |
299 | char *data; | 274 | char *data; |
300 | size_t data_size; | 275 | size_t data_size; |
301 | int type; | 276 | int type; |
302 | 277 | ||
303 | attr_iterator = NULL; | 278 | attr_iterator = NULL; |
304 | if (list) | 279 | if (list) { |
305 | { | ||
306 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 280 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
307 | return; | 281 | return; |
308 | } | 282 | } |
309 | 283 | ||
310 | if (issue_attrs) | 284 | if (issue_attrs) { |
311 | { | 285 | reclaim_op = GNUNET_RECLAIM_ticket_issue ( |
312 | reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle, | 286 | reclaim_handle, pkey, &rp_key, attr_list, &ticket_issue_cb, NULL); |
313 | pkey, | ||
314 | &rp_key, | ||
315 | attr_list, | ||
316 | &ticket_issue_cb, | ||
317 | NULL); | ||
318 | return; | 287 | return; |
319 | } | 288 | } |
320 | if (consume_ticket) | 289 | if (consume_ticket) { |
321 | { | 290 | reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, pkey, &ticket, |
322 | reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, | 291 | &process_attrs, NULL); |
323 | pkey, | 292 | timeout = GNUNET_SCHEDULER_add_delayed ( |
324 | &ticket, | 293 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), |
325 | &process_attrs, | 294 | &timeout_task, NULL); |
326 | NULL); | ||
327 | timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), | ||
328 | &timeout_task, | ||
329 | NULL); | ||
330 | return; | 295 | return; |
331 | } | 296 | } |
332 | if (revoke_ticket) | 297 | if (revoke_ticket) { |
333 | { | 298 | reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle, pkey, &ticket, |
334 | reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle, | 299 | &process_rvk, NULL); |
335 | pkey, | ||
336 | &ticket, | ||
337 | &process_rvk, | ||
338 | NULL); | ||
339 | return; | 300 | return; |
340 | } | 301 | } |
341 | if (attr_name) | 302 | if (attr_name) { |
342 | { | ||
343 | if (NULL == type_str) | 303 | if (NULL == type_str) |
344 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; | 304 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; |
345 | else | 305 | else |
346 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); | 306 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); |
347 | 307 | ||
348 | GNUNET_assert (GNUNET_SYSERR != GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, | 308 | GNUNET_assert (GNUNET_SYSERR != |
349 | attr_value, | 309 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value ( |
350 | (void**)&data, | 310 | type, attr_value, (void **)&data, &data_size)); |
351 | &data_size)); | 311 | if (NULL != claim) { |
352 | if (NULL != claim) | ||
353 | { | ||
354 | claim->type = type; | 312 | claim->type = type; |
355 | claim->data = data; | 313 | claim->data = data; |
356 | claim->data_size = data_size; | 314 | claim->data_size = data_size; |
315 | } else { | ||
316 | claim = | ||
317 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); | ||
357 | } | 318 | } |
358 | else | 319 | reclaim_op = GNUNET_RECLAIM_attribute_store ( |
359 | { | 320 | reclaim_handle, pkey, claim, &exp_interval, &store_attr_cont, NULL); |
360 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, | ||
361 | type, | ||
362 | data, | ||
363 | data_size); | ||
364 | } | ||
365 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, | ||
366 | pkey, | ||
367 | claim, | ||
368 | &exp_interval, | ||
369 | &store_attr_cont, | ||
370 | NULL); | ||
371 | GNUNET_free (data); | 321 | GNUNET_free (data); |
372 | GNUNET_free (claim); | 322 | GNUNET_free (claim); |
373 | return; | 323 | return; |
@@ -375,28 +325,21 @@ iter_finished (void *cls) | |||
375 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 325 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
376 | } | 326 | } |
377 | 327 | ||
378 | static void | 328 | static void iter_cb (void *cls, |
379 | iter_cb (void *cls, | 329 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
380 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 330 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
381 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | ||
382 | { | 331 | { |
383 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 332 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
384 | char *attrs_tmp; | 333 | char *attrs_tmp; |
385 | char *attr_str; | 334 | char *attr_str; |
386 | const char *attr_type; | 335 | const char *attr_type; |
387 | 336 | ||
388 | if ((NULL != attr_name) && (NULL != claim)) | 337 | if ((NULL != attr_name) && (NULL != claim)) { |
389 | { | 338 | if (0 == strcasecmp (attr_name, attr->name)) { |
390 | if (0 == strcasecmp (attr_name, attr->name)) | 339 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, attr->type, |
391 | { | 340 | attr->data, attr->data_size); |
392 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | ||
393 | attr->type, | ||
394 | attr->data, | ||
395 | attr->data_size); | ||
396 | } | 341 | } |
397 | } | 342 | } else if (issue_attrs) { |
398 | else if (issue_attrs) | ||
399 | { | ||
400 | attrs_tmp = GNUNET_strdup (issue_attrs); | 343 | attrs_tmp = GNUNET_strdup (issue_attrs); |
401 | attr_str = strtok (attrs_tmp, ","); | 344 | attr_str = strtok (attrs_tmp, ","); |
402 | while (NULL != attr_str) { | 345 | while (NULL != attr_str) { |
@@ -405,92 +348,62 @@ iter_cb (void *cls, | |||
405 | continue; | 348 | continue; |
406 | } | 349 | } |
407 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 350 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
408 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | 351 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new ( |
409 | attr->type, | 352 | attr->name, attr->type, attr->data, attr->data_size); |
410 | attr->data, | ||
411 | attr->data_size); | ||
412 | le->claim->version = attr->version; | 353 | le->claim->version = attr->version; |
413 | le->claim->id = attr->id; | 354 | le->claim->id = attr->id; |
414 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, | 355 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, attr_list->list_tail, |
415 | attr_list->list_tail, | ||
416 | le); | 356 | le); |
417 | break; | 357 | break; |
418 | } | 358 | } |
419 | GNUNET_free (attrs_tmp); | 359 | GNUNET_free (attrs_tmp); |
420 | } | 360 | } else if (list) { |
421 | else if (list) | 361 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, |
422 | { | ||
423 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | ||
424 | attr->data, | ||
425 | attr->data_size); | 362 | attr->data_size); |
426 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 363 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
427 | fprintf (stdout, | 364 | fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, attr_str, |
428 | "%s: %s [%s,v%u,id=%lu]\n", | 365 | attr_type, attr->version, attr->id); |
429 | attr->name, attr_str, attr_type, attr->version, attr->id); | ||
430 | } | 366 | } |
431 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 367 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
432 | } | 368 | } |
433 | 369 | ||
434 | static void | 370 | static void start_process () |
435 | start_process () | ||
436 | { | 371 | { |
437 | if (NULL == pkey) | 372 | if (NULL == pkey) { |
438 | { | 373 | fprintf (stderr, "Ego %s not found\n", ego_name); |
439 | fprintf (stderr, | ||
440 | "Ego %s not found\n", ego_name); | ||
441 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 374 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
442 | return; | 375 | return; |
443 | } | 376 | } |
444 | 377 | ||
445 | if (list_tickets) | 378 | if (list_tickets) { |
446 | { | 379 | ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start ( |
447 | ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle, | 380 | reclaim_handle, pkey, &ticket_iter_err, NULL, &ticket_iter, NULL, |
448 | pkey, | 381 | &ticket_iter_fin, NULL); |
449 | &ticket_iter_err, | ||
450 | NULL, | ||
451 | &ticket_iter, | ||
452 | NULL, | ||
453 | &ticket_iter_fin, | ||
454 | NULL); | ||
455 | return; | 382 | return; |
456 | } | 383 | } |
457 | 384 | ||
458 | if (NULL != rp) | 385 | if (NULL != rp) |
459 | GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, | 386 | GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, strlen (rp), &rp_key); |
460 | strlen (rp), | ||
461 | &rp_key); | ||
462 | if (NULL != consume_ticket) | 387 | if (NULL != consume_ticket) |
463 | GNUNET_STRINGS_string_to_data (consume_ticket, | 388 | GNUNET_STRINGS_string_to_data (consume_ticket, strlen (consume_ticket), |
464 | strlen (consume_ticket), | ||
465 | &ticket, | 389 | &ticket, |
466 | sizeof (struct GNUNET_RECLAIM_Ticket)); | 390 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
467 | if (NULL != revoke_ticket) | 391 | if (NULL != revoke_ticket) |
468 | GNUNET_STRINGS_string_to_data (revoke_ticket, | 392 | GNUNET_STRINGS_string_to_data (revoke_ticket, strlen (revoke_ticket), |
469 | strlen (revoke_ticket), | ||
470 | &ticket, | 393 | &ticket, |
471 | sizeof (struct GNUNET_RECLAIM_Ticket)); | 394 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
472 | 395 | ||
473 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 396 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
474 | claim = NULL; | 397 | claim = NULL; |
475 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, | 398 | attr_iterator = GNUNET_RECLAIM_get_attributes_start ( |
476 | pkey, | 399 | reclaim_handle, pkey, &iter_error, NULL, &iter_cb, NULL, &iter_finished, |
477 | &iter_error, | 400 | NULL); |
478 | NULL, | ||
479 | &iter_cb, | ||
480 | NULL, | ||
481 | &iter_finished, | ||
482 | NULL); | ||
483 | |||
484 | |||
485 | } | 401 | } |
486 | 402 | ||
487 | static int init = GNUNET_YES; | 403 | static int init = GNUNET_YES; |
488 | 404 | ||
489 | static void | 405 | static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, |
490 | ego_cb (void *cls, | 406 | const char *name) |
491 | struct GNUNET_IDENTITY_Ego *ego, | ||
492 | void **ctx, | ||
493 | const char *name) | ||
494 | { | 407 | { |
495 | if (NULL == name) { | 408 | if (NULL == name) { |
496 | if (GNUNET_YES == init) { | 409 | if (GNUNET_YES == init) { |
@@ -505,113 +418,75 @@ ego_cb (void *cls, | |||
505 | } | 418 | } |
506 | 419 | ||
507 | 420 | ||
508 | static void | 421 | static void run (void *cls, char *const *args, const char *cfgfile, |
509 | run (void *cls, | 422 | const struct GNUNET_CONFIGURATION_Handle *c) |
510 | char *const *args, | ||
511 | const char *cfgfile, | ||
512 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
513 | { | 423 | { |
514 | ret = 0; | 424 | ret = 0; |
515 | if (NULL == ego_name) | 425 | if (NULL == ego_name) { |
516 | { | ||
517 | ret = 1; | 426 | ret = 1; |
518 | fprintf (stderr, | 427 | fprintf (stderr, _ ("Ego is required\n")); |
519 | _("Ego is required\n")); | ||
520 | return; | 428 | return; |
521 | } | 429 | } |
522 | 430 | ||
523 | if ( (NULL == attr_value) && (NULL != attr_name) ) | 431 | if ((NULL == attr_value) && (NULL != attr_name)) { |
524 | { | ||
525 | ret = 1; | 432 | ret = 1; |
526 | fprintf (stderr, | 433 | fprintf (stderr, _ ("Attribute value missing!\n")); |
527 | _("Attribute value missing!\n")); | ||
528 | return; | 434 | return; |
529 | } | 435 | } |
530 | 436 | ||
531 | if ( (NULL == rp) && (NULL != issue_attrs) ) | 437 | if ((NULL == rp) && (NULL != issue_attrs)) { |
532 | { | ||
533 | ret = 1; | 438 | ret = 1; |
534 | fprintf (stderr, | 439 | fprintf (stderr, _ ("Requesting party key is required!\n")); |
535 | _("Requesting party key is required!\n")); | ||
536 | return; | 440 | return; |
537 | } | 441 | } |
538 | 442 | ||
539 | reclaim_handle = GNUNET_RECLAIM_connect (c); | 443 | reclaim_handle = GNUNET_RECLAIM_connect (c); |
540 | //Get Ego | 444 | // Get Ego |
541 | identity_handle = GNUNET_IDENTITY_connect (c, | 445 | identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL); |
542 | &ego_cb, | ||
543 | NULL); | ||
544 | |||
545 | |||
546 | } | 446 | } |
547 | 447 | ||
548 | 448 | ||
549 | int | 449 | int main (int argc, char *const argv[]) |
550 | main(int argc, char *const argv[]) | ||
551 | { | 450 | { |
552 | exp_interval = GNUNET_TIME_UNIT_HOURS; | 451 | exp_interval = GNUNET_TIME_UNIT_HOURS; |
553 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 452 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
554 | 453 | ||
555 | GNUNET_GETOPT_option_string ('a', | 454 | GNUNET_GETOPT_option_string ('a', "add", "NAME", |
556 | "add", | 455 | gettext_noop ("Add an attribute NAME"), |
557 | "NAME", | 456 | &attr_name), |
558 | gettext_noop ("Add an attribute NAME"), | 457 | |
559 | &attr_name), | 458 | GNUNET_GETOPT_option_string ('V', "value", "VALUE", |
560 | 459 | gettext_noop ("The attribute VALUE"), | |
561 | GNUNET_GETOPT_option_string ('V', | 460 | &attr_value), |
562 | "value", | 461 | GNUNET_GETOPT_option_string ('e', "ego", "EGO", |
563 | "VALUE", | 462 | gettext_noop ("The EGO to use"), &ego_name), |
564 | gettext_noop ("The attribute VALUE"), | 463 | GNUNET_GETOPT_option_string ( |
565 | &attr_value), | 464 | 'r', "rp", "RP", gettext_noop ("Specify the relying party for issue"), |
566 | GNUNET_GETOPT_option_string ('e', | 465 | &rp), |
567 | "ego", | 466 | GNUNET_GETOPT_option_flag ( |
568 | "EGO", | 467 | 'D', "dump", gettext_noop ("List attributes for EGO"), &list), |
569 | gettext_noop ("The EGO to use"), | 468 | GNUNET_GETOPT_option_string ( |
570 | &ego_name), | 469 | 'i', "issue", "A1,A2,...", |
571 | GNUNET_GETOPT_option_string ('r', | 470 | gettext_noop ( |
572 | "rp", | 471 | "Issue a ticket for a set of attributes separated by comma"), |
573 | "RP", | 472 | &issue_attrs), |
574 | gettext_noop ("Specify the relying party for issue"), | 473 | GNUNET_GETOPT_option_string ('C', "consume", "TICKET", |
575 | &rp), | 474 | gettext_noop ("Consume a ticket"), |
576 | GNUNET_GETOPT_option_flag ('D', | 475 | &consume_ticket), |
577 | "dump", | 476 | GNUNET_GETOPT_option_string ('R', "revoke", "TICKET", |
578 | gettext_noop ("List attributes for EGO"), | 477 | gettext_noop ("Revoke a ticket"), |
579 | &list), | 478 | &revoke_ticket), |
580 | GNUNET_GETOPT_option_string ('i', | 479 | GNUNET_GETOPT_option_string ( |
581 | "issue", | 480 | 't', "type", "TYPE", gettext_noop ("Type of attribute"), &type_str), |
582 | "A1,A2,...", | 481 | GNUNET_GETOPT_option_flag ( |
583 | gettext_noop ("Issue a ticket for a set of attributes separated by comma"), | 482 | 'T', "tickets", gettext_noop ("List tickets of ego"), &list_tickets), |
584 | &issue_attrs), | 483 | GNUNET_GETOPT_option_relative_time ( |
585 | GNUNET_GETOPT_option_string ('C', | 484 | 'E', "expiration", "INTERVAL", |
586 | "consume", | 485 | gettext_noop ("Expiration interval of the attribute"), &exp_interval), |
587 | "TICKET", | 486 | |
588 | gettext_noop ("Consume a ticket"), | 487 | GNUNET_GETOPT_OPTION_END}; |
589 | &consume_ticket), | 488 | if (GNUNET_OK != |
590 | GNUNET_GETOPT_option_string ('R', | 489 | GNUNET_PROGRAM_run (argc, argv, "ct", "ct", options, &run, NULL)) |
591 | "revoke", | ||
592 | "TICKET", | ||
593 | gettext_noop ("Revoke a ticket"), | ||
594 | &revoke_ticket), | ||
595 | GNUNET_GETOPT_option_string ('t', | ||
596 | "type", | ||
597 | "TYPE", | ||
598 | gettext_noop ("Type of attribute"), | ||
599 | &type_str), | ||
600 | GNUNET_GETOPT_option_flag ('T', | ||
601 | "tickets", | ||
602 | gettext_noop ("List tickets of ego"), | ||
603 | &list_tickets), | ||
604 | GNUNET_GETOPT_option_relative_time ('E', | ||
605 | "expiration", | ||
606 | "INTERVAL", | ||
607 | gettext_noop ("Expiration interval of the attribute"), | ||
608 | &exp_interval), | ||
609 | |||
610 | GNUNET_GETOPT_OPTION_END | ||
611 | }; | ||
612 | if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct", | ||
613 | "ct", options, | ||
614 | &run, NULL)) | ||
615 | return 1; | 490 | return 1; |
616 | else | 491 | else |
617 | return ret; | 492 | return ret; |