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_attestations;
49 
53 static char *attestation_id;
54 
59 
63 static char *attestation_name;
64 
68 static int attestation_exists;
69 
73 static char *rp;
74 
78 static char *attr_name;
79 
83 static char *attr_value;
84 
88 static char *issue_attrs;
89 
93 static char *consume_ticket;
94 
98 static char *type_str;
99 
103 static char *revoke_ticket;
104 
108 static int list_tickets;
109 
113 static char *ego_name;
114 
119 
124 
129 
134 
139 
140 
145 
150 
154 static const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey;
155 
160 
165 
170 
175 
180 
185 
190 
194 static char *attr_delete;
195 
200 
201 static void
202 do_cleanup (void *cls)
203 {
204  cleanup_task = NULL;
205  if (NULL != timeout)
206  GNUNET_SCHEDULER_cancel (timeout);
207  if (NULL != reclaim_op)
208  GNUNET_RECLAIM_cancel (reclaim_op);
209  if (NULL != attr_iterator)
210  GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
211  if (NULL != attest_iterator)
212  GNUNET_RECLAIM_get_attestations_stop (attest_iterator);
213  if (NULL != ticket_iterator)
214  GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
215  if (NULL != reclaim_handle)
216  GNUNET_RECLAIM_disconnect (reclaim_handle);
217  if (NULL != identity_handle)
218  GNUNET_IDENTITY_disconnect (identity_handle);
219  if (NULL != abe_key)
220  GNUNET_free (abe_key);
221  if (NULL != attr_list)
222  GNUNET_free (attr_list);
223  if (NULL != attr_to_delete)
224  GNUNET_free (attr_to_delete);
225 }
226 
227 
228 static void
229 ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
230 {
231  char *ticket_str;
232 
233  reclaim_op = NULL;
234  if (NULL != ticket)
235  {
236  ticket_str =
238  sizeof(
239  struct GNUNET_RECLAIM_Ticket));
240  printf ("%s\n", ticket_str);
241  GNUNET_free (ticket_str);
242  }
243  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
244 }
245 
246 
247 static void
248 store_cont (void *cls, int32_t success, const char *emsg)
249 {
250  reclaim_op = NULL;
251  if (GNUNET_SYSERR == success)
252  {
253  fprintf (stderr, "%s\n", emsg);
254  }
255  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
256 }
257 
258 
259 static void
260 process_attrs (void *cls,
262  const struct GNUNET_RECLAIM_Attribute *attr,
263  const struct GNUNET_RECLAIM_Attestation *attest)
264 {
265  char *value_str;
266  char *id;
267  const char *attr_type;
268 
269  if (NULL == identity)
270  {
271  reclaim_op = NULL;
272  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
273  return;
274  }
275  if (NULL == attr)
276  {
277  ret = 1;
278  return;
279  }
281  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
282  value_str = NULL;
283  if (NULL == attest)
284  {
286  attr->data,
287  attr->data_size);
288  }
289  else
290  {
294 
295  for (ale = al->list_head; NULL != ale; ale = ale->next)
296  {
297  if (0 != strncmp (attr->data, ale->attribute->name, attr->data_size))
298  continue;
299  value_str
301  ale->attribute->
302  data,
303  ale->attribute->
304  data_size);
305  break;
306  }
307  }
308  fprintf (stdout,
309  "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
310  attr->name,
311  (NULL != value_str) ? value_str : "???",
312  attr_type,
313  attr->flag,
314  id,
315  (NULL == attest) ? "" : "(ATTESTED)");
316  GNUNET_free (value_str);
317  GNUNET_free (id);
318 }
319 
320 
321 static void
322 ticket_iter_err (void *cls)
323 {
324  ticket_iterator = NULL;
325  fprintf (stderr, "Failed to iterate over tickets\n");
326  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
327 }
328 
329 
330 static void
331 ticket_iter_fin (void *cls)
332 {
333  ticket_iterator = NULL;
334  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
335 }
336 
337 
338 static void
339 ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
340 {
341  char *aud;
342  char *ref;
343  char *tkt;
344 
345  aud =
347  sizeof(struct
349  ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
350  tkt =
352  sizeof(struct GNUNET_RECLAIM_Ticket));
353  fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud);
354  GNUNET_free (aud);
355  GNUNET_free (ref);
356  GNUNET_free (tkt);
357  GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
358 }
359 
360 
361 static void
362 iter_error (void *cls)
363 {
364  attr_iterator = NULL;
365  attest_iterator = NULL;
366  fprintf (stderr, "Failed\n");
367 
368  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
369 }
370 
371 
372 static void
373 timeout_task (void *cls)
374 {
375  timeout = NULL;
376  ret = 1;
377  fprintf (stderr, "Timeout\n");
378  if (NULL == cleanup_task)
379  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
380 }
381 
382 
383 static void
384 process_rvk (void *cls, int success, const char *msg)
385 {
386  reclaim_op = NULL;
387  if (GNUNET_OK != success)
388  {
389  fprintf (stderr, "Revocation failed.\n");
390  ret = 1;
391  }
392  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
393 }
394 
395 
396 static void
397 process_delete (void *cls, int success, const char *msg)
398 {
399  reclaim_op = NULL;
400  if (GNUNET_OK != success)
401  {
402  fprintf (stderr, "Deletion failed.\n");
403  ret = 1;
404  }
405  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
406 }
407 
408 
409 static void
410 iter_finished (void *cls)
411 {
412  char *data;
413  size_t data_size;
414  int type;
415 
416  attr_iterator = NULL;
417  if (list)
418  {
419  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
420  return;
421  }
422 
423  if (issue_attrs)
424  {
425  reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
426  pkey,
427  &rp_key,
428  attr_list,
430  NULL);
431  return;
432  }
433  if (consume_ticket)
434  {
435  reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
436  pkey,
437  &ticket,
438  &process_attrs,
439  NULL);
440  timeout = GNUNET_SCHEDULER_add_delayed (
442  &timeout_task,
443  NULL);
444  return;
445  }
446  if (revoke_ticket)
447  {
448  reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle,
449  pkey,
450  &ticket,
451  &process_rvk,
452  NULL);
453  return;
454  }
455  if (attr_delete)
456  {
457  if (NULL == attr_to_delete)
458  {
459  fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
460  return;
461  }
462  reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
463  pkey,
464  attr_to_delete,
466  NULL);
467  return;
468  }
469  if (attr_name)
470  {
471  if (NULL == type_str)
473  else
475 
478  attr_value,
479  (void **) &data,
480  &data_size));
481  if (NULL != claim)
482  {
483  claim->type = type;
484  claim->data = data;
485  claim->data_size = data_size;
486  }
487  else
488  {
489  claim =
490  GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
491  }
492  if (NULL != attestation_id)
493  {
494  claim->attestation = attestation;
495  }
496  reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
497  pkey,
498  claim,
499  &exp_interval,
500  &store_cont,
501  NULL);
502  GNUNET_free (data);
503  GNUNET_free (claim);
504  return;
505  }
506  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
507 }
508 
509 
510 static void
511 iter_cb (void *cls,
513  const struct GNUNET_RECLAIM_Attribute *attr)
514 {
516  char *attrs_tmp;
517  char *attr_str;
518  char *label;
519  char *id;
520  const char *attr_type;
521 
522  if ((NULL != attr_name) && (NULL != claim))
523  {
524  if (0 == strcasecmp (attr_name, attr->name))
525  {
526  claim = GNUNET_RECLAIM_attribute_new (attr->name,
527  &attr->attestation,
528  attr->type,
529  attr->data,
530  attr->data_size);
531  }
532  }
533  else if (issue_attrs)
534  {
535  attrs_tmp = GNUNET_strdup (issue_attrs);
536  attr_str = strtok (attrs_tmp, ",");
537  while (NULL != attr_str)
538  {
539  if (0 != strcasecmp (attr_str, attr->name))
540  {
541  attr_str = strtok (NULL, ",");
542  continue;
543  }
546  &attr->attestation,
547  attr->type,
548  attr->data,
549  attr->data_size);
550  le->attribute->flag = attr->flag;
551  le->attribute->id = attr->id;
553  attr_list->list_tail,
554  le);
555  break;
556  }
557  GNUNET_free (attrs_tmp);
558  }
559  else if (attr_delete && (NULL == attr_to_delete))
560  {
561  label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
562  if (0 == strcasecmp (attr_delete, label))
563  {
564  attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
565  &attr->attestation,
566  attr->type,
567  attr->data,
568  attr->data_size);
569  attr_to_delete->id = attr->id;
570  }
571  GNUNET_free (label);
572  }
573  else if (list)
574  {
576  attr->data,
577  attr->data_size);
579  id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
581  {
582  fprintf (stdout,
583  "%s: ``%s'' (%s); ID: %s\n",
584  attr->name,
585  attr_str,
586  attr_type,
587  id);
588  }
589  else
590  {
591  char *attest_id =
593  sizeof(attr->attestation));
594  fprintf (stdout,
595  "%s: <``%s'' in attestation %s> (%s); ID: %s\n",
596  attr->name,
597  attr_str,
598  attest_id,
599  attr_type,
600  id);
601  GNUNET_free (attest_id);
602 
603  }
604  GNUNET_free (id);
605  }
606  GNUNET_RECLAIM_get_attributes_next (attr_iterator);
607 }
608 
609 
610 static void
612 {
613  attest_iterator = NULL;
614 
615  // Add new attestation
616  if ((NULL != attestation_name) &&
617  (NULL != attr_value))
618  {
621  GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, // FIXME hardcoded
622  attr_value,
623  strlen (attr_value));
624  reclaim_op = GNUNET_RECLAIM_attestation_store (reclaim_handle,
625  pkey,
626  attestation,
627  &exp_interval,
628  store_cont,
629  NULL);
630  return;
631 
632  }
633  if (list_attestations)
634  {
635  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
636  return;
637  }
638  attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
639  pkey,
640  &iter_error,
641  NULL,
642  &iter_cb,
643  NULL,
644  &iter_finished,
645  NULL);
646 
647 }
648 
649 
650 static void
651 attest_iter_cb (void *cls,
653  const struct GNUNET_RECLAIM_Attestation *attest)
654 {
655  char *attest_str;
656  char *attr_str;
657  char *id;
658  const char *attest_type;
660 
662  &attest->id))
664  if (list_attestations)
665  {
666  attest_str = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
667  attest->data,
668  attest->data_size);
669  attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
670  id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
671  fprintf (stdout,
672  "%s: ``%s'' (%s); ID: %s\n",
673  attest->name,
674  attest_str,
675  attest_type,
676  id);
677  struct GNUNET_RECLAIM_AttributeList *attrs =
679  if (NULL != attrs)
680  {
681  fprintf (stdout,
682  "\t Attributes:\n");
683  for (ale = attrs->list_head; NULL != ale; ale = ale->next)
684  {
686  ale->attribute->type,
687  ale->attribute->
688  data,
689  ale->attribute->
690  data_size);
691 
692  fprintf (stdout,
693  "\t %s: %s\n", ale->attribute->name, attr_str);
694  GNUNET_free (attr_str);
695  }
697  }
698  GNUNET_free (id);
699  }
700  GNUNET_RECLAIM_get_attestations_next (attest_iterator);
701 }
702 
703 
704 static void
706 {
707  if (NULL == pkey)
708  {
709  fprintf (stderr, "Ego %s not found\n", ego_name);
710  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
711  return;
712  }
714  if (NULL != attestation_id)
716  strlen (attestation_id),
717  &attestation, sizeof(attestation));
719  if (list_tickets)
720  {
721  ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
722  pkey,
724  NULL,
725  &ticket_iter,
726  NULL,
728  NULL);
729  return;
730  }
731 
732  if ((NULL != rp) &&
733  (GNUNET_OK !=
735  {
736  fprintf (stderr, "%s is not a public key!\n", rp);
737  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
738  return;
739  }
740  if (NULL != consume_ticket)
742  strlen (consume_ticket),
743  &ticket,
744  sizeof(struct GNUNET_RECLAIM_Ticket));
745  if (NULL != revoke_ticket)
747  strlen (revoke_ticket),
748  &ticket,
749  sizeof(struct GNUNET_RECLAIM_Ticket));
750 
751  attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
752  claim = NULL;
753  attest_iterator = GNUNET_RECLAIM_get_attestations_start (reclaim_handle,
754  pkey,
755  &iter_error,
756  NULL,
758  NULL,
759  &
761  NULL);
762 
763 }
764 
765 
766 static int init = GNUNET_YES;
767 
768 static void
769 ego_cb (void *cls,
770  struct GNUNET_IDENTITY_Ego *ego,
771  void **ctx,
772  const char *name)
773 {
774  if (NULL == name)
775  {
776  if (GNUNET_YES == init)
777  {
778  init = GNUNET_NO;
779  start_process ();
780  }
781  return;
782  }
783  if (0 != strcmp (name, ego_name))
784  return;
786 }
787 
788 
789 static void
790 run (void *cls,
791  char *const *args,
792  const char *cfgfile,
793  const struct GNUNET_CONFIGURATION_Handle *c)
794 {
795  ret = 0;
796  if (NULL == ego_name)
797  {
798  ret = 1;
799  fprintf (stderr, _ ("Ego is required\n"));
800  return;
801  }
802 
803  if ((NULL == attr_value) && (NULL != attr_name))
804  {
805  ret = 1;
806  fprintf (stderr, _ ("Attribute value missing!\n"));
807  return;
808  }
809 
810  if ((NULL == rp) && (NULL != issue_attrs))
811  {
812  ret = 1;
813  fprintf (stderr, _ ("Requesting party key is required!\n"));
814  return;
815  }
816 
817  reclaim_handle = GNUNET_RECLAIM_connect (c);
818  // Get Ego
819  identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL);
820 }
821 
822 
823 int
824 main (int argc, char *const argv[])
825 {
827  struct GNUNET_GETOPT_CommandLineOption options[] = {
829  "add",
830  "NAME",
831  gettext_noop ("Add an attribute NAME"),
832  &attr_name),
834  "delete",
835  "ID",
836  gettext_noop ("Delete the attribute with ID"),
837  &attr_delete),
839  "value",
840  "VALUE",
841  gettext_noop ("The attribute VALUE"),
842  &attr_value),
844  "ego",
845  "EGO",
846  gettext_noop ("The EGO to use"),
847  &ego_name),
849  "rp",
850  "RP",
851  gettext_noop (
852  "Specify the relying party for issue"),
853  &rp),
855  "dump",
856  gettext_noop ("List attributes for EGO"),
857  &list),
859  "attestations",
860  gettext_noop ("List attestations for EGO"),
863  "Attestation ID",
864  "ATTESTATION_ID",
865  gettext_noop (
866  "Attestation to use for attribute"),
867  &attestation_id),
869  "attestation-name",
870  "NAME",
871  gettext_noop ("Attestation name"),
874  "issue",
875  "A1,A2,...",
876  gettext_noop (
877  "Issue a ticket for a set of attributes separated by comma"),
878  &issue_attrs),
880  "consume",
881  "TICKET",
882  gettext_noop ("Consume a ticket"),
883  &consume_ticket),
885  "revoke",
886  "TICKET",
887  gettext_noop ("Revoke a ticket"),
888  &revoke_ticket),
890  "type",
891  "TYPE",
892  gettext_noop ("Type of attribute"),
893  &type_str),
895  "tickets",
896  gettext_noop ("List tickets of ego"),
897  &list_tickets),
899  "expiration",
900  "INTERVAL",
901  gettext_noop (
902  "Expiration interval of the attribute"),
903  &exp_interval),
904 
906  };
907  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
908  argv,
909  "gnunet-reclaim",
910  _ ("re:claimID command line tool"),
911  options,
912  &run,
913  NULL))
914  return 1;
915  else
916  return ret;
917 }
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 * consume_ticket
Ticket to consume.
Handle to the service.
Definition: reclaim_api.c:312
The authorization ticket.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attestation_get_attributes(const struct GNUNET_RECLAIM_Attestation *attest)
Convert an attestation type name to the corresponding number.
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:1293
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_TIME_UNIT_HOURS
One hour.
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:1553
struct GNUNET_RECLAIM_AttestationIterator * GNUNET_RECLAIM_get_attestations_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttestationResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attestations for a local identity.
Definition: reclaim_api.c:1402
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void do_cleanup(void *cls)
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:1597
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 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:1144
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.
#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
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1066
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:1051
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:1641
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:1661
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.
static struct GNUNET_RECLAIM_AttestationIterator * attest_iterator
Attestation iterator.
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:1339
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.
void GNUNET_RECLAIM_get_attestations_next(struct GNUNET_RECLAIM_AttestationIterator *ait)
Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start for the next record...
Definition: reclaim_api.c:1449
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static void attest_iter_finished(void *cls)
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
char * GNUNET_RECLAIM_attestation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
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
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:1692
Handle for a attribute iterator operation.
Definition: reclaim_api.c:177
static char * attr_value
Attribute value.
static char * attr_name
The attribute.
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
static char * attestation_name
Attestation name.
Handle for the service.
Definition: identity_api.c:95
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
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
const char * GNUNET_RECLAIM_attestation_number_to_typename(uint32_t type)
Convert an attestation type number to the corresponding attestation type string.
static struct GNUNET_SCHEDULER_Task * timeout
Timeout task.
static void attest_iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attestation *attest)
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:1097
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_new(const char *name, uint32_t type, const void *data, size_t data_size)
Create a new attestation.
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.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attestation *attestation, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation.
Definition: reclaim_api.c:1189
struct GNUNET_RECLAIM_Identifier id
ID.
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)
uint32_t type
Type/Format of Claim.
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT
A JSON Web Token attestation.
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.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
static char * type_str
Attribute type.
static void ticket_iter_err(void *cls)
static void process_delete(void *cls, int success, const char *msg)
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
const void * data
Binary value stored as attribute value.
static const struct GNUNET_CRYPTO_EcdsaPrivateKey * pkey
ego private key
static struct GNUNET_RECLAIM_Identifier attestation
Attestation ID.
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 int list_attestations
List attestations flag.
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:1360
Handle for a attestation iterator operation.
Definition: reclaim_api.c:244
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:114
Entry in list of pending tasks.
Definition: scheduler.c:134
const void * data
Binary value stored as attribute value.
static char * attestation_id
Attestation ID string.
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)
static struct GNUNET_CRYPTO_AbeMasterKey * abe_key
Master ABE key.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static int attestation_exists
Attestation exists.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:935
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:1026
uint32_t data
The data value.
static void process_attrs(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Attestation *attest)
void GNUNET_RECLAIM_get_attestations_stop(struct GNUNET_RECLAIM_AttestationIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1471
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:970
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_TicketCallback cb, void *cb_cls)
Issues a ticket to a relying party.
Definition: reclaim_api.c:1504
#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