GNUnet  0.11.x
gnunet-reclaim.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012-2015 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  */
26 #include "platform.h"
27 #include <inttypes.h>
28 
29 #include "gnunet_util_lib.h"
30 
33 #include "gnunet_reclaim_service.h"
34 #include "gnunet_signatures.h"
38 static int ret;
39 
43 static int list;
44 
48 static char *rp;
49 
53 static char *attr_name;
54 
58 static char *attr_value;
59 
63 static char *issue_attrs;
64 
68 static char *consume_ticket;
69 
73 static char *type_str;
74 
78 static char *revoke_ticket;
79 
83 static int list_tickets;
84 
88 static char *ego_name;
89 
94 
99 
104 
109 
114 
119 
123 static const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey;
124 
129 
134 
139 
144 
149 
154 
159 
163 static char *attr_delete;
164 
169 
170 static void
171 do_cleanup (void *cls)
172 {
173  cleanup_task = NULL;
174  if (NULL != timeout)
175  GNUNET_SCHEDULER_cancel (timeout);
176  if (NULL != reclaim_op)
177  GNUNET_RECLAIM_cancel (reclaim_op);
178  if (NULL != attr_iterator)
179  GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
180  if (NULL != ticket_iterator)
181  GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
182  if (NULL != reclaim_handle)
183  GNUNET_RECLAIM_disconnect (reclaim_handle);
184  if (NULL != identity_handle)
185  GNUNET_IDENTITY_disconnect (identity_handle);
186  if (NULL != abe_key)
187  GNUNET_free (abe_key);
188  if (NULL != attr_list)
189  GNUNET_free (attr_list);
190  if (NULL != attr_to_delete)
191  GNUNET_free (attr_to_delete);
192 }
193 
194 
195 static void
196 ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
197 {
198  char *ticket_str;
199 
200  reclaim_op = NULL;
201  if (NULL != ticket)
202  {
203  ticket_str =
205  sizeof(
206  struct GNUNET_RECLAIM_Ticket));
207  printf ("%s\n", ticket_str);
208  GNUNET_free (ticket_str);
209  }
210  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
211 }
212 
213 
214 static void
215 store_attr_cont (void *cls, int32_t success, const char *emsg)
216 {
217  reclaim_op = NULL;
218  if (GNUNET_SYSERR == success)
219  {
220  fprintf (stderr, "%s\n", emsg);
221  }
222  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
223 }
224 
225 
226 static void
227 process_attrs (void *cls,
229  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
230 {
231  char *value_str;
232  char *id;
233  const char *attr_type;
234 
235  if (NULL == identity)
236  {
237  reclaim_op = NULL;
238  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
239  return;
240  }
241  if (NULL == attr)
242  {
243  ret = 1;
244  return;
245  }
247  attr->data,
248  attr->data_size);
250  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
251  fprintf (stdout,
252  "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
253  attr->name,
254  value_str,
255  attr_type,
256  attr->version,
257  id);
258  GNUNET_free (id);
259 }
260 
261 
262 static void
263 ticket_iter_err (void *cls)
264 {
265  ticket_iterator = NULL;
266  fprintf (stderr, "Failed to iterate over tickets\n");
267  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
268 }
269 
270 
271 static void
272 ticket_iter_fin (void *cls)
273 {
274  ticket_iterator = NULL;
275  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
276 }
277 
278 
279 static void
280 ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
281 {
282  char *aud;
283  char *ref;
284  char *tkt;
285 
286  aud =
288  sizeof(struct
290  ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
291  tkt =
293  sizeof(struct GNUNET_RECLAIM_Ticket));
294  fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud);
295  GNUNET_free (aud);
296  GNUNET_free (ref);
297  GNUNET_free (tkt);
298  GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
299 }
300 
301 
302 static void
303 iter_error (void *cls)
304 {
305  attr_iterator = NULL;
306  fprintf (stderr, "Failed to iterate over attributes\n");
307  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
308 }
309 
310 
311 static void
312 timeout_task (void *cls)
313 {
314  timeout = NULL;
315  ret = 1;
316  fprintf (stderr, "Timeout\n");
317  if (NULL == cleanup_task)
318  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
319 }
320 
321 
322 static void
323 process_rvk (void *cls, int success, const char *msg)
324 {
325  reclaim_op = NULL;
326  if (GNUNET_OK != success)
327  {
328  fprintf (stderr, "Revocation failed.\n");
329  ret = 1;
330  }
331  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
332 }
333 
334 
335 static void
336 process_delete (void *cls, int success, const char *msg)
337 {
338  reclaim_op = NULL;
339  if (GNUNET_OK != success)
340  {
341  fprintf (stderr, "Deletion failed.\n");
342  ret = 1;
343  }
344  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
345 }
346 
347 
348 static void
349 iter_finished (void *cls)
350 {
351  char *data;
352  size_t data_size;
353  int type;
354 
355  attr_iterator = NULL;
356  if (list)
357  {
358  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
359  return;
360  }
361 
362  if (issue_attrs)
363  {
364  reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
365  pkey,
366  &rp_key,
367  attr_list,
369  NULL);
370  return;
371  }
372  if (consume_ticket)
373  {
374  reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
375  pkey,
376  &ticket,
377  &process_attrs,
378  NULL);
379  timeout = GNUNET_SCHEDULER_add_delayed (
381  &timeout_task,
382  NULL);
383  return;
384  }
385  if (revoke_ticket)
386  {
387  reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle,
388  pkey,
389  &ticket,
390  &process_rvk,
391  NULL);
392  return;
393  }
394  if (attr_delete)
395  {
396  if (NULL == attr_to_delete)
397  {
398  fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
399  return;
400  }
401  reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
402  pkey,
403  attr_to_delete,
405  NULL);
406  return;
407  }
408  if (attr_name)
409  {
410  if (NULL == type_str)
412  else
414 
417  attr_value,
418  (void **) &data,
419  &data_size));
420  if (NULL != claim)
421  {
422  claim->type = type;
423  claim->data = data;
424  claim->data_size = data_size;
425  }
426  else
427  {
428  claim =
429  GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
430  }
431  reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
432  pkey,
433  claim,
434  &exp_interval,
436  NULL);
437  GNUNET_free (data);
438  GNUNET_free (claim);
439  return;
440  }
441  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
442 }
443 
444 
445 static void
446 iter_cb (void *cls,
448  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
449 {
451  char *attrs_tmp;
452  char *attr_str;
453  char *label;
454  char *id;
455  const char *attr_type;
456 
457  if ((NULL != attr_name) && (NULL != claim))
458  {
459  if (0 == strcasecmp (attr_name, attr->name))
460  {
462  attr->type,
463  attr->data,
464  attr->data_size);
465  }
466  }
467  else if (issue_attrs)
468  {
469  attrs_tmp = GNUNET_strdup (issue_attrs);
470  attr_str = strtok (attrs_tmp, ",");
471  while (NULL != attr_str)
472  {
473  if (0 != strcasecmp (attr_str, attr->name))
474  {
475  attr_str = strtok (NULL, ",");
476  continue;
477  }
480  attr->type,
481  attr->data,
482  attr->data_size);
483  le->claim->version = attr->version;
484  le->claim->id = attr->id;
486  attr_list->list_tail,
487  le);
488  break;
489  }
490  GNUNET_free (attrs_tmp);
491  }
492  else if (attr_delete && (NULL == attr_to_delete))
493  {
494  label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
495  if (0 == strcasecmp (attr_delete, label))
496  {
497  attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
498  attr->type,
499  attr->data,
500  attr->data_size);
501  attr_to_delete->id = attr->id;
502  }
503  GNUNET_free (label);
504  }
505  else if (list)
506  {
508  attr->data,
509  attr->data_size);
511  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
512  fprintf (stdout,
513  "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
514  attr->name,
515  attr_str,
516  attr_type,
517  attr->version,
518  id);
519  GNUNET_free (id);
520  }
521  GNUNET_RECLAIM_get_attributes_next (attr_iterator);
522 }
523 
524 
525 static void
527 {
528  if (NULL == pkey)
529  {
530  fprintf (stderr, "Ego %s not found\n", ego_name);
531  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
532  return;
533  }
534 
535  if (list_tickets)
536  {
537  ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
538  pkey,
540  NULL,
541  &ticket_iter,
542  NULL,
544  NULL);
545  return;
546  }
547 
548  if ((NULL != rp) &&
549  (GNUNET_OK !=
551  {
552  fprintf (stderr, "%s is not a public key!\n", rp);
553  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
554  return;
555  }
556  if (NULL != consume_ticket)
558  strlen (consume_ticket),
559  &ticket,
560  sizeof(struct GNUNET_RECLAIM_Ticket));
561  if (NULL != revoke_ticket)
563  strlen (revoke_ticket),
564  &ticket,
565  sizeof(struct GNUNET_RECLAIM_Ticket));
566 
567  attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
568  claim = NULL;
569  attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
570  pkey,
571  &iter_error,
572  NULL,
573  &iter_cb,
574  NULL,
575  &iter_finished,
576  NULL);
577 }
578 
579 
580 static int init = GNUNET_YES;
581 
582 static void
583 ego_cb (void *cls,
584  struct GNUNET_IDENTITY_Ego *ego,
585  void **ctx,
586  const char *name)
587 {
588  if (NULL == name)
589  {
590  if (GNUNET_YES == init)
591  {
592  init = GNUNET_NO;
593  start_process ();
594  }
595  return;
596  }
597  if (0 != strcmp (name, ego_name))
598  return;
600 }
601 
602 
603 static void
604 run (void *cls,
605  char *const *args,
606  const char *cfgfile,
607  const struct GNUNET_CONFIGURATION_Handle *c)
608 {
609  ret = 0;
610  if (NULL == ego_name)
611  {
612  ret = 1;
613  fprintf (stderr, _ ("Ego is required\n"));
614  return;
615  }
616 
617  if ((NULL == attr_value) && (NULL != attr_name))
618  {
619  ret = 1;
620  fprintf (stderr, _ ("Attribute value missing!\n"));
621  return;
622  }
623 
624  if ((NULL == rp) && (NULL != issue_attrs))
625  {
626  ret = 1;
627  fprintf (stderr, _ ("Requesting party key is required!\n"));
628  return;
629  }
630 
631  reclaim_handle = GNUNET_RECLAIM_connect (c);
632  // Get Ego
633  identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL);
634 }
635 
636 
637 int
638 main (int argc, char *const argv[])
639 {
641  struct GNUNET_GETOPT_CommandLineOption options[] = {
643  "add",
644  "NAME",
645  gettext_noop ("Add an attribute NAME"),
646  &attr_name),
648  "delete",
649  "ID",
650  gettext_noop ("Delete the attribute with ID"),
651  &attr_delete),
653  "value",
654  "VALUE",
655  gettext_noop ("The attribute VALUE"),
656  &attr_value),
658  "ego",
659  "EGO",
660  gettext_noop ("The EGO to use"),
661  &ego_name),
663  "rp",
664  "RP",
665  gettext_noop (
666  "Specify the relying party for issue"),
667  &rp),
669  "dump",
670  gettext_noop ("List attributes for EGO"),
671  &list),
673  'i',
674  "issue",
675  "A1,A2,...",
676  gettext_noop (
677  "Issue a ticket for a set of attributes separated by comma"),
678  &issue_attrs),
680  "consume",
681  "TICKET",
682  gettext_noop ("Consume a ticket"),
683  &consume_ticket),
685  "revoke",
686  "TICKET",
687  gettext_noop ("Revoke a ticket"),
688  &revoke_ticket),
690  "type",
691  "TYPE",
692  gettext_noop ("Type of attribute"),
693  &type_str),
695  "tickets",
696  gettext_noop ("List tickets of ego"),
697  &list_tickets),
699  "expiration",
700  "INTERVAL",
701  gettext_noop (
702  "Expiration interval of the attribute"),
703  &exp_interval),
704 
706  };
707  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
708  argv,
709  "gnunet-reclaim",
710  _ ("re:claimID command line tool"),
711  options,
712  &run,
713  NULL))
714  return 1;
715  else
716  return ret;
717 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:527
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
static char * consume_ticket
Ticket to consume.
char * GNUNET_RECLAIM_ATTRIBUTE_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
Handle to the service.
Definition: reclaim_api.c:235
The authorization ticket.
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:954
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_TIME_UNIT_HOURS
One hour.
static int init
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void do_cleanup(void *cls)
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:850
static void ticket_iter_fin(void *cls)
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Lists all tickets that have been issued to remote identites (relying parties)
Definition: reclaim_api.c:1145
static int list_tickets
Ticket listing.
size_t data_size
Number of bytes in data.
static void iter_finished(void *cls)
static void process_attrs(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
static char * attr_delete
Claim to delete.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attr_list
Attribute list.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
uint32_t GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:819
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:804
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record...
Definition: reclaim_api.c:1189
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1209
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void start_process()
int GNUNET_RECLAIM_ATTRIBUTE_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;claim&#39; of an attribute to the binary representation.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
Private ECC key encoded for transmission.
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record...
Definition: reclaim_api.c:1000
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
static struct GNUNET_RECLAIM_Handle * reclaim_handle
reclaim handle
Handle for an operation with the service.
Definition: reclaim_api.c:41
static struct GNUNET_RECLAIM_AttributeIterator * attr_iterator
Attribute iterator.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_RECLAIM_TicketIterator * ticket_iterator
Ticket iterator.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
const void * data
Binary value stored as attribute value.
static char * ego_name
Ego name.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
Handle for an ego.
Definition: identity.h:245
static void ticket_issue_cb(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1240
Handle for a attribute iterator operation.
Definition: reclaim_api.c:167
static char * attr_value
Attribute value.
const char * GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:897
static char * attr_name
The attribute.
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
Handle for the service.
Definition: identity_api.c:95
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
Issues a ticket to a relying party.
Definition: reclaim_api.c:1052
static struct GNUNET_SCHEDULER_Task * timeout
Timeout task.
static struct GNUNET_IDENTITY_Handle * identity_handle
Identity handle.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:442
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:837
static char * issue_attrs
Attributes to issue.
static struct GNUNET_CRYPTO_EcdsaPublicKey rp_key
rp public key
static void iter_error(void *cls)
static void ticket_iter(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint64_t rnd
The ticket random (NBO)
static char * type_str
Attribute type.
static void ticket_iter_err(void *cls)
static void process_delete(void *cls, int success, const char *msg)
static void iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
static const struct GNUNET_CRYPTO_EcdsaPrivateKey * pkey
ego private key
int GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:466
static struct GNUNET_RECLAIM_Operation * reclaim_op
reclaim operation
configuration data
Definition: configuration.c:85
const char * name
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1021
static void ego_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static void process_rvk(void *cls, int success, const char *msg)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
Handle for a ticket iterator operation.
Definition: reclaim_api.c:104
Entry in list of pending tasks.
Definition: scheduler.c:134
static char * rp
Relying party.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
static struct GNUNET_CRYPTO_AbeMasterKey * abe_key
Master ABE key.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1101
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
Claim to store.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
static int list
List attribute flag.
static char * revoke_ticket
Ticket to revoke.
int main(int argc, char *const argv[])
static int ret
return value
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:779
uint32_t data
The data value.
static struct GNUNET_RECLAIM_ATTRIBUTE_Claim * attr_to_delete
Claim object to delete.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
static void timeout_task(void *cls)
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:952
static void store_attr_cont(void *cls, int32_t success, const char *emsg)
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966