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 int list_credentials;
49 
53 static char *credential_id;
54 
59 
63 static char *credential_name;
64 
68 static char *credential_type;
69 
73 static int credential_exists;
74 
78 static char *rp;
79 
83 static char *attr_name;
84 
88 static char *attr_value;
89 
93 static char *issue_attrs;
94 
98 static char *consume_ticket;
99 
103 static char *type_str;
104 
108 static char *revoke_ticket;
109 
113 static int list_tickets;
114 
118 static char *ego_name;
119 
124 
129 
134 
139 
144 
145 
150 
151 
155 static const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey;
156 
161 
166 
171 
176 
181 
186 
191 
195 static char *attr_delete;
196 
201 
202 static void
203 do_cleanup (void *cls)
204 {
205  cleanup_task = NULL;
206  if (NULL != timeout)
207  GNUNET_SCHEDULER_cancel (timeout);
208  if (NULL != reclaim_op)
209  GNUNET_RECLAIM_cancel (reclaim_op);
210  if (NULL != attr_iterator)
211  GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
212  if (NULL != cred_iterator)
213  GNUNET_RECLAIM_get_credentials_stop (cred_iterator);
214  if (NULL != ticket_iterator)
215  GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
216  if (NULL != reclaim_handle)
217  GNUNET_RECLAIM_disconnect (reclaim_handle);
218  if (NULL != identity_handle)
219  GNUNET_IDENTITY_disconnect (identity_handle);
220  if (NULL != attr_list)
221  GNUNET_free (attr_list);
222  if (NULL != attr_to_delete)
223  GNUNET_free (attr_to_delete);
224  if (NULL == credential_type)
226 }
227 
228 
229 static void
230 ticket_issue_cb (void *cls,
231  const struct GNUNET_RECLAIM_Ticket *ticket,
232  const struct GNUNET_RECLAIM_PresentationList *presentations)
233 {
234  char *ticket_str;
235 
236  reclaim_op = NULL;
237  if (NULL != ticket)
238  {
239  ticket_str =
241  sizeof(
242  struct GNUNET_RECLAIM_Ticket));
243  printf ("%s\n", ticket_str);
244  GNUNET_free (ticket_str);
245  }
246  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
247 }
248 
249 
250 static void
251 store_cont (void *cls, int32_t success, const char *emsg)
252 {
253  reclaim_op = NULL;
254  if (GNUNET_SYSERR == success)
255  {
256  fprintf (stderr, "%s\n", emsg);
257  }
258  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
259 }
260 
261 
262 static void
263 process_attrs (void *cls,
265  const struct GNUNET_RECLAIM_Attribute *attr,
266  const struct GNUNET_RECLAIM_Presentation *presentation)
267 {
268  char *value_str;
269  char *id;
270  const char *attr_type;
271 
272  if (NULL == identity)
273  {
274  reclaim_op = NULL;
275  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
276  return;
277  }
278  if (NULL == attr)
279  {
280  ret = 1;
281  return;
282  }
284  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
285  value_str = NULL;
286  if (NULL == presentation)
287  {
289  attr->data,
290  attr->data_size);
291  }
292  else
293  {
297 
298  for (ale = al->list_head; NULL != ale; ale = ale->next)
299  {
300  if (0 != strncmp (attr->data, ale->attribute->name, attr->data_size))
301  continue;
302  value_str
304  ale->attribute->data,
305  ale->attribute->data_size);
306  break;
307  }
308  }
309  fprintf (stdout,
310  "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
311  attr->name,
312  (NULL != value_str) ? value_str : "???",
313  attr_type,
314  attr->flag,
315  id,
316  (NULL == presentation) ? "" : "(ATTESTED)");
317  GNUNET_free (value_str);
318  GNUNET_free (id);
319 }
320 
321 
322 static void
323 ticket_iter_err (void *cls)
324 {
325  ticket_iterator = NULL;
326  fprintf (stderr, "Failed to iterate over tickets\n");
327  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
328 }
329 
330 
331 static void
332 ticket_iter_fin (void *cls)
333 {
334  ticket_iterator = NULL;
335  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
336 }
337 
338 
339 static void
340 ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
341 {
342  char *aud;
343  char *ref;
344  char *tkt;
345 
346  aud =
348  sizeof(struct
350  ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
351  tkt =
353  sizeof(struct GNUNET_RECLAIM_Ticket));
354  fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud);
355  GNUNET_free (aud);
356  GNUNET_free (ref);
357  GNUNET_free (tkt);
358  GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
359 }
360 
361 
362 static void
363 iter_error (void *cls)
364 {
365  attr_iterator = NULL;
366  cred_iterator = NULL;
367  fprintf (stderr, "Failed\n");
368 
369  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
370 }
371 
372 
373 static void
374 timeout_task (void *cls)
375 {
376  timeout = NULL;
377  ret = 1;
378  fprintf (stderr, "Timeout\n");
379  if (NULL == cleanup_task)
380  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
381 }
382 
383 
384 static void
385 process_rvk (void *cls, int success, const char *msg)
386 {
387  reclaim_op = NULL;
388  if (GNUNET_OK != success)
389  {
390  fprintf (stderr, "Revocation failed.\n");
391  ret = 1;
392  }
393  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
394 }
395 
396 
397 static void
398 process_delete (void *cls, int success, const char *msg)
399 {
400  reclaim_op = NULL;
401  if (GNUNET_OK != success)
402  {
403  fprintf (stderr, "Deletion failed.\n");
404  ret = 1;
405  }
406  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
407 }
408 
409 
410 static void
411 iter_finished (void *cls)
412 {
413  char *data;
414  size_t data_size;
415  int type;
416 
417  attr_iterator = NULL;
418  if (list)
419  {
420  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
421  return;
422  }
423 
424  if (issue_attrs)
425  {
426  reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
427  pkey,
428  &rp_key,
429  attr_list,
431  NULL);
432  return;
433  }
434  if (consume_ticket)
435  {
436  reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
437  pkey,
438  &ticket,
439  &process_attrs,
440  NULL);
441  timeout = GNUNET_SCHEDULER_add_delayed (
443  &timeout_task,
444  NULL);
445  return;
446  }
447  if (revoke_ticket)
448  {
449  reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle,
450  pkey,
451  &ticket,
452  &process_rvk,
453  NULL);
454  return;
455  }
456  if (attr_delete)
457  {
458  if (NULL == attr_to_delete)
459  {
460  fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
462  return;
463  }
464  reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
465  pkey,
466  attr_to_delete,
468  NULL);
469  return;
470  }
471  if (attr_name)
472  {
473  if (NULL == type_str)
475  else
477 
480  attr_value,
481  (void **) &data,
482  &data_size));
483  if (NULL != claim)
484  {
485  claim->type = type;
486  claim->data = data;
487  claim->data_size = data_size;
488  }
489  else
490  {
491  claim =
492  GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
493  }
494  if (NULL != credential_id)
495  {
496  claim->credential = credential;
497  }
498  reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
499  pkey,
500  claim,
501  &exp_interval,
502  &store_cont,
503  NULL);
504  GNUNET_free (data);
505  GNUNET_free (claim);
506  return;
507  }
508  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
509 }
510 
511 
512 static void
513 iter_cb (void *cls,
515  const struct GNUNET_RECLAIM_Attribute *attr)
516 {
518  char *attrs_tmp;
519  char *attr_str;
520  char *label;
521  char *id;
522  const char *attr_type;
523 
524  if ((NULL != attr_name) && (NULL != claim))
525  {
526  if (0 == strcasecmp (attr_name, attr->name))
527  {
528  claim = GNUNET_RECLAIM_attribute_new (attr->name,
529  &attr->credential,
530  attr->type,
531  attr->data,
532  attr->data_size);
533  }
534  }
535  else if (issue_attrs)
536  {
537  attrs_tmp = GNUNET_strdup (issue_attrs);
538  attr_str = strtok (attrs_tmp, ",");
539  while (NULL != attr_str)
540  {
541  if (0 != strcasecmp (attr_str, attr->name))
542  {
543  attr_str = strtok (NULL, ",");
544  continue;
545  }
548  &attr->credential,
549  attr->type,
550  attr->data,
551  attr->data_size);
552  le->attribute->flag = attr->flag;
553  le->attribute->id = attr->id;
555  attr_list->list_tail,
556  le);
557  break;
558  }
559  GNUNET_free (attrs_tmp);
560  }
561  else if (attr_delete && (NULL == attr_to_delete))
562  {
563  label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
564  if (0 == strcasecmp (attr_delete, label))
565  {
566  attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
567  &attr->credential,
568  attr->type,
569  attr->data,
570  attr->data_size);
571  attr_to_delete->id = attr->id;
572  }
573  GNUNET_free (label);
574  }
575  else if (list)
576  {
578  attr->data,
579  attr->data_size);
581  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
583  {
584  fprintf (stdout,
585  "%s: ``%s'' (%s); ID: %s\n",
586  attr->name,
587  attr_str,
588  attr_type,
589  id);
590  }
591  else
592  {
593  char *cred_id =
595  sizeof(attr->credential));
596  fprintf (stdout,
597  "%s: ``%s'' in credential presentation `%s' (%s); ID: %s\n",
598  attr->name,
599  attr_str,
600  cred_id,
601  attr_type,
602  id);
603  GNUNET_free (cred_id);
604 
605  }
606  GNUNET_free (id);
607  }
608  GNUNET_RECLAIM_get_attributes_next (attr_iterator);
609 }
610 
611 
612 static void
614 {
615  cred_iterator = NULL;
616 
617  // Add new credential
618  if ((NULL != credential_name) &&
619  (NULL != attr_value))
620  {
621  enum GNUNET_RECLAIM_CredentialType ctype =
625  ctype,
626  attr_value,
627  strlen (attr_value));
628  reclaim_op = GNUNET_RECLAIM_credential_store (reclaim_handle,
629  pkey,
630  credential,
631  &exp_interval,
632  store_cont,
633  NULL);
634  return;
635 
636  }
637  if (list_credentials)
638  {
639  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
640  return;
641  }
642  attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
643  pkey,
644  &iter_error,
645  NULL,
646  &iter_cb,
647  NULL,
648  &iter_finished,
649  NULL);
650 
651 }
652 
653 
654 static void
655 cred_iter_cb (void *cls,
657  const struct GNUNET_RECLAIM_Credential *cred)
658 {
659  char *cred_str;
660  char *attr_str;
661  char *id;
662  const char *cred_type;
664 
666  &cred->id))
668  if (list_credentials)
669  {
671  cred->data,
672  cred->data_size);
674  id = GNUNET_STRINGS_data_to_string_alloc (&cred->id, sizeof(cred->id));
675  fprintf (stdout,
676  "%s: ``%s'' (%s); ID: %s\n",
677  cred->name,
678  cred_str,
679  cred_type,
680  id);
681  struct GNUNET_RECLAIM_AttributeList *attrs =
683  if (NULL != attrs)
684  {
685  fprintf (stdout,
686  "\t Attributes:\n");
687  for (ale = attrs->list_head; NULL != ale; ale = ale->next)
688  {
690  ale->attribute->type,
691  ale->attribute->data,
692  ale->attribute->data_size);
693  fprintf (stdout,
694  "\t %s: %s\n", ale->attribute->name, attr_str);
695  GNUNET_free (attr_str);
696  }
698  }
699  GNUNET_free (id);
700  }
701  GNUNET_RECLAIM_get_credentials_next (cred_iterator);
702 }
703 
704 
705 static void
707 {
708  if (NULL == pkey)
709  {
710  fprintf (stderr, "Ego %s not found\n", ego_name);
711  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
712  return;
713  }
714  if (NULL == credential_type)
715  credential_type = GNUNET_strdup ("JWT");
717  if (NULL != credential_id)
719  strlen (credential_id),
720  &credential, sizeof(credential));
722  if (list_tickets)
723  {
724  ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
725  pkey,
727  NULL,
728  &ticket_iter,
729  NULL,
731  NULL);
732  return;
733  }
734 
735  if ((NULL != rp) &&
736  (GNUNET_OK !=
738  {
739  fprintf (stderr, "%s is not a public key!\n", rp);
740  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
741  return;
742  }
743  if (NULL != consume_ticket)
745  strlen (consume_ticket),
746  &ticket,
747  sizeof(struct GNUNET_RECLAIM_Ticket));
748  if (NULL != revoke_ticket)
750  strlen (revoke_ticket),
751  &ticket,
752  sizeof(struct GNUNET_RECLAIM_Ticket));
753 
754  attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
755  claim = NULL;
756  cred_iterator = GNUNET_RECLAIM_get_credentials_start (reclaim_handle,
757  pkey,
758  &iter_error,
759  NULL,
760  &cred_iter_cb,
761  NULL,
763  NULL);
764 
765 }
766 
767 
768 static int init = GNUNET_YES;
769 
770 static void
771 ego_cb (void *cls,
772  struct GNUNET_IDENTITY_Ego *ego,
773  void **ctx,
774  const char *name)
775 {
776  if (NULL == name)
777  {
778  if (GNUNET_YES == init)
779  {
780  init = GNUNET_NO;
781  start_process ();
782  }
783  return;
784  }
785  if (0 != strcmp (name, ego_name))
786  return;
788 }
789 
790 
791 static void
792 run (void *cls,
793  char *const *args,
794  const char *cfgfile,
795  const struct GNUNET_CONFIGURATION_Handle *c)
796 {
797  ret = 0;
798  if (NULL == ego_name)
799  {
800  ret = 1;
801  fprintf (stderr, _ ("Ego is required\n"));
802  return;
803  }
804 
805  if ((NULL == attr_value) && (NULL != attr_name))
806  {
807  ret = 1;
808  fprintf (stderr, _ ("Attribute value missing!\n"));
809  return;
810  }
811 
812  if ((NULL == rp) && (NULL != issue_attrs))
813  {
814  ret = 1;
815  fprintf (stderr, _ ("Requesting party key is required!\n"));
816  return;
817  }
818 
819  reclaim_handle = GNUNET_RECLAIM_connect (c);
820  // Get Ego
821  identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL);
822 }
823 
824 
825 int
826 main (int argc, char *const argv[])
827 {
829  struct GNUNET_GETOPT_CommandLineOption options[] = {
831  "add",
832  "NAME",
833  gettext_noop ("Add an attribute NAME"),
834  &attr_name),
836  "delete",
837  "ID",
838  gettext_noop ("Delete the attribute with ID"),
839  &attr_delete),
841  "value",
842  "VALUE",
843  gettext_noop ("The attribute VALUE"),
844  &attr_value),
846  "ego",
847  "EGO",
848  gettext_noop ("The EGO to use"),
849  &ego_name),
851  "rp",
852  "RP",
853  gettext_noop (
854  "Specify the relying party for issue"),
855  &rp),
857  "dump",
858  gettext_noop ("List attributes for EGO"),
859  &list),
861  "credentials",
862  gettext_noop ("List credentials for EGO"),
865  "credential-id",
866  "CREDENTIAL_ID",
867  gettext_noop (
868  "Credential to use for attribute"),
869  &credential_id),
871  "credential-name",
872  "NAME",
873  gettext_noop ("Credential name"),
874  &credential_name),
876  "issue",
877  "A1,A2,...",
878  gettext_noop (
879  "Issue a ticket for a set of attributes separated by comma"),
880  &issue_attrs),
882  "consume",
883  "TICKET",
884  gettext_noop ("Consume a ticket"),
885  &consume_ticket),
887  "revoke",
888  "TICKET",
889  gettext_noop ("Revoke a ticket"),
890  &revoke_ticket),
892  "type",
893  "TYPE",
894  gettext_noop ("Type of attribute"),
895  &type_str),
897  "credential-type",
898  "TYPE",
899  gettext_noop ("Type of credential"),
900  &credential_type),
902  "tickets",
903  gettext_noop ("List tickets of ego"),
904  &list_tickets),
906  "expiration",
907  "INTERVAL",
908  gettext_noop (
909  "Expiration interval of the attribute"),
910  &exp_interval),
911 
913  };
914  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
915  argv,
916  "gnunet-reclaim",
917  _ ("re:claimID command line tool"),
918  options,
919  &run,
920  NULL))
921  return 1;
922  else
923  return ret;
924 }
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:566
static char * credential_type
Credential type.
static char * consume_ticket
Ticket to consume.
void GNUNET_RECLAIM_get_credentials_next(struct GNUNET_RECLAIM_CredentialIterator *ait)
Calls the record processor specified in GNUNET_RECLAIM_get_credentials_start for the next record...
Definition: reclaim_api.c:1487
Handle to the service.
Definition: reclaim_api.c:317
The authorization ticket.
uint32_t GNUNET_RECLAIM_credential_typename_to_number(const char *typename)
Convert an credential type name to the corresponding number.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
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:1331
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
static int init
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_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1591
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void do_cleanup(void *cls)
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1509
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:1637
static int list_tickets
Ticket listing.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
static void iter_finished(void *cls)
static int credential_exists
Credential exists.
static void store_cont(void *cls, int32_t success, const char *emsg)
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1182
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
const char * name
The name of the attribute.
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
size_t data_size
Number of bytes in data.
#define GNUNET_TIME_UNIT_SECONDS
One second.
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:595
static char * credential_id
Credential ID string.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1104
static int list_credentials
List credentials flag.
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:1089
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:1681
A list of GNUNET_RECLAIM_Attribute structures.
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:1701
const void * data
Binary value stored as credential value.
static void start_process()
static void iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
#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:1377
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.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_CredentialResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all credentials for a local identity.
Definition: reclaim_api.c:1440
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void cred_iter_finished(void *cls)
static struct GNUNET_RECLAIM_TicketIterator * ticket_iterator
Ticket iterator.
static void ticket_issue_cb(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_PresentationList *presentations)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
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:184
static void process_attrs(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
static char * ego_name
Ego name.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static struct GNUNET_RECLAIM_AttributeList * attr_list
Attribute list.
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:1269
Handle for an ego.
Definition: identity.h:245
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:1732
Handle for a attribute iterator operation.
Definition: reclaim_api.c:182
static char * attr_value
Attribute value.
static char * attr_name
The attribute.
Handle for the service.
Definition: identity_api.c:95
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_presentation_get_attributes(const struct GNUNET_RECLAIM_Presentation *cred)
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:1296
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
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_AttributeList *attrs, GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls)
Issues a ticket to a relying party.
Definition: reclaim_api.c:1542
static struct GNUNET_SCHEDULER_Task * timeout
Timeout task.
static struct GNUNET_IDENTITY_Handle * identity_handle
Identity handle.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
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:884
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
static char * issue_attrs
Attributes to issue.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:1135
static struct GNUNET_RECLAIM_Attribute * attr_to_delete
Claim object to delete.
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.
static char * credential_name
Credential name.
static struct GNUNET_CRYPTO_EcdsaPublicKey rp_key
rp public key
A reclaim identifier FIXME maybe put this in a different namespace.
static void iter_error(void *cls)
static struct GNUNET_RECLAIM_CredentialIterator * cred_iterator
Credential iterator.
A credential presentation.
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.
const char * name
The name of the credential.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
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 const struct GNUNET_CRYPTO_EcdsaPrivateKey * pkey
ego private key
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
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:366
static struct GNUNET_RECLAIM_Operation * reclaim_op
reclaim operation
static void cred_iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Credential *cred)
A list of GNUNET_RECLAIM_Presentation structures.
configuration data
Definition: configuration.c:84
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:1398
static void ego_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
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)
#define GNUNET_RECLAIM_id_is_equal(a, b)
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.
Handle for a ticket iterator operation.
Definition: reclaim_api.c:119
Entry in list of pending tasks.
Definition: scheduler.c:134
GNUNET_RECLAIM_CredentialType
const void * data
Binary value stored as attribute value.
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.
static char * rp
Relying party.
uint32_t type
Type of Claim.
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)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_new(const char *name, uint32_t type, const void *data, size_t data_size)
Create a new credential.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *credential, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store a credential.
Definition: reclaim_api.c:1227
char * GNUNET_RECLAIM_credential_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an credential to a string.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:936
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:1064
uint32_t data
The data value.
Handle for a credential iterator operation.
Definition: reclaim_api.c:249
static void timeout_task(void *cls)
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
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:971
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
#define GNUNET_RECLAIM_id_is_zero(a)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_credential_get_attributes(const struct GNUNET_RECLAIM_Credential *cred)
Convert an credential type name to the corresponding number.