GNUnet  0.11.x
gnunet-service-reclaim_tickets.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  */
20 
27 #include <inttypes.h>
29 
30 
35 #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS
36 
41 struct ParallelLookup;
42 
43 
48 {
53 
58 
63 
68 };
69 
70 
75 {
79  struct GNUNET_RECLAIM_Ticket ticket;
80 
85 
90 
94  struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
95 
100 
105 
110 
115 
119  struct GNUNET_TIME_Absolute lookup_start_time;
120 
125 
129  void *cb_cls;
130 };
131 
132 
137 {
138  /* DLL */
140 
141  /* DLL */
143 
144  /* The GNS request */
146 
147  /* The handle the return to */
149 
153  struct GNUNET_TIME_Absolute lookup_start_time;
154 
155  /* The label to look up */
156  char *label;
157 };
158 
159 
164 {
169 
174 
178  struct GNUNET_RECLAIM_Ticket ticket;
179 
184 
189 
194 
198  void *cb_cls;
199 };
200 
201 
206 {
211 
216 
220  void *cb_cls;
221 };
222 
223 
225 {
230 
235 
239  uint64_t old_id;
240 
244  uint64_t new_id;
245 };
246 
247 
252 {
257 
262 
266  void *cb_cls;
267 
271  struct GNUNET_RECLAIM_Ticket ticket;
272 
277 
282 
287 
292 
297 
301  unsigned int ticket_attrs;
302 
307 
312 };
313 
314 
319 
320 
321 /* Namestore handle */
323 
324 
325 /* GNS handle */
326 static struct GNUNET_GNS_Handle *gns;
327 
328 
329 /* Handle to the statistics service */
331 
332 
338 static void
340 {
341  struct RevokedAttributeEntry *ae;
342  struct TicketRecordsEntry *le;
343 
344  if (NULL != rh->ns_qe)
346  if (NULL != rh->ns_it)
348  while (NULL != (ae = rh->attrs_head))
349  {
351  GNUNET_free (ae);
352  }
353  while (NULL != (le = rh->tickets_to_update_head))
354  {
357  le);
358  if (NULL != le->data)
359  GNUNET_free (le->data);
360  if (NULL != le->label)
361  GNUNET_free (le->label);
362  GNUNET_free (le);
363  }
364  GNUNET_free (rh);
365 }
366 
367 
374 static void
375 process_tickets (void *cls);
376 
377 
386 static void
387 ticket_processed (void *cls, int32_t success, const char *emsg)
388 {
389  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
390 
391  rvk->ns_qe = NULL;
393 }
394 
395 
401 static void
402 process_tickets (void *cls)
403 {
404  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
405  struct TicketRecordsEntry *le;
406  struct RevokedAttributeEntry *ae;
407 
408  if (NULL == rvk->tickets_to_update_head)
409  {
411  "Finished updatding tickets, success\n");
412  rvk->cb (rvk->cb_cls, GNUNET_OK);
413  cleanup_rvk (rvk);
414  return;
415  }
416  le = rvk->tickets_to_update_head;
419  le);
420  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
422  le->data,
423  le->rd_count,
424  rd))
425  {
427  "Unable to deserialize ticket record(s)\n");
428  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
429  cleanup_rvk (rvk);
430  return;
431  }
432  for (int i = 0; i < le->rd_count; i++)
433  {
435  continue;
436  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
437  {
438  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
439  continue;
440  rd[i].data = &ae->new_id;
441  }
442  }
444  &rvk->identity,
445  le->label,
446  le->rd_count,
447  rd,
449  rvk);
450  GNUNET_free (le->label);
451  GNUNET_free (le->data);
452  GNUNET_free (le);
453 }
454 
455 
461 static void
463 {
464  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
465 
466  rvk->ns_it = NULL;
468 }
469 
470 
481 static void
482 rvk_ticket_update (void *cls,
483  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
484  const char *label,
485  unsigned int rd_count,
486  const struct GNUNET_GNSRECORD_Data *rd)
487 {
488  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
489  struct TicketRecordsEntry *le;
490  struct RevokedAttributeEntry *ae;
491  int has_changed = GNUNET_NO;
492 
494  for (int i = 0; i < rd_count; i++)
495  {
496  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
497  continue;
498  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
499  {
500  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
501  continue;
502  has_changed = GNUNET_YES;
503  break;
504  }
505  if (GNUNET_YES == has_changed)
506  break;
507  }
508  if (GNUNET_YES == has_changed)
509  {
510  le = GNUNET_new (struct TicketRecordsEntry);
511  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
512  le->data = GNUNET_malloc (le->data_size);
513  le->rd_count = rd_count;
514  le->label = GNUNET_strdup (label);
515  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
518  le);
519  }
521 }
522 
523 
529 static void
530 rvk_ns_iter_err (void *cls)
531 {
532  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
533 
534  rvk->ns_it = NULL;
536  "Namestore error on revocation (id=%" PRIu64 "\n",
537  rvk->move_attr->old_id);
538  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
539  cleanup_rvk (rvk);
540 }
541 
542 
548 static void
549 rvk_ns_err (void *cls)
550 {
551  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
552 
553  rvk->ns_qe = NULL;
555  "Namestore error on revocation (id=%" PRIu64 "\n",
556  rvk->move_attr->old_id);
557  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
558  cleanup_rvk (rvk);
559 }
560 
561 
571 static void
573 
574 
580 static void
581 move_attrs_cont (void *cls)
582 {
583  move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
584 }
585 
586 
595 static void
596 del_attr_finished (void *cls, int32_t success, const char *emsg)
597 {
598  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
599 
600  rvk->ns_qe = NULL;
601  if (GNUNET_SYSERR == success)
602  {
604  "Error removing attribute: %s\n",
605  emsg);
606  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
607  cleanup_rvk (rvk);
608  return;
609  }
610  rvk->move_attr = rvk->move_attr->next;
612 }
613 
614 
624 static void
625 move_attr_finished (void *cls, int32_t success, const char *emsg)
626 {
627  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
628  char *label;
629 
630  rvk->ns_qe = NULL;
631  if (GNUNET_SYSERR == success)
632  {
633  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
634  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
635  cleanup_rvk (rvk);
636  return;
637  }
639  sizeof(uint64_t));
640  GNUNET_assert (NULL != label);
641  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
643  &rvk->identity,
644  label,
645  0,
646  NULL,
648  rvk);
649  GNUNET_free (label);
650 }
651 
652 
662 static void
663 rvk_move_attr_cb (void *cls,
664  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
665  const char *label,
666  unsigned int rd_count,
667  const struct GNUNET_GNSRECORD_Data *rd)
668 {
669  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
670  struct GNUNET_GNSRECORD_Data new_rd[rd_count];
671  struct RevokedAttributeEntry *le;
672  char *new_label;
673  char *attr_data;
674 
675  rvk->ns_qe = NULL;
676  if (0 == rd_count)
677  {
679  "The claim %s no longer exists!\n",
680  label);
681  le = rvk->move_attr;
682  rvk->move_attr = le->next;
684  GNUNET_free (le);
686  return;
687  }
689  new_label=NULL;
690  attr_data=NULL;
691  //new_rd = *rd;
692  for (int i = 0; i < rd_count; i++)
693  {
694  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
695  {
698  claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size);
700  "Attribute to update: Name=%s, ID=%" PRIu64 "\n",
701  claim->name,
702  claim->id);
703  claim->id = rvk->move_attr->new_id;
705  attr_data = GNUNET_malloc (rd[i].data_size);
706  new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data);
707  new_rd[i].data = attr_data;
708  new_rd[i].record_type = rd[i].record_type;
709  new_rd[i].flags = rd[i].flags;
710  new_rd[i].expiration_time = rd[i].expiration_time;
712  sizeof(uint64_t));
713  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
714  GNUNET_free (claim);
715  } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
716  {
717  struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
720  "Attestation to update: Name=%s, ID=%" PRIu64 "\n",
721  attest->name,
722  attest->id);
723  attest->id = rvk->move_attr->new_id;
725  attr_data = GNUNET_malloc (rd[i].data_size);
726  new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, attr_data);
727  new_rd[i].data = attr_data;
728  new_rd[i].record_type = rd[i].record_type;
729  new_rd[i].flags = rd[i].flags;
730  new_rd[i].expiration_time = rd[i].expiration_time;
731  new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t));
732  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", new_label);
733  GNUNET_free (attest);
734  } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
735  {
736  struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
739  "Reference to update: Name=%s, ID=%" PRIu64 "\n",
740  reference->name,
741  reference->id);
742  reference->id = rvk->move_attr->new_id;
743  reference->id_attest = rvk->move_attr->new_id;
745  attr_data = GNUNET_malloc (rd[i].data_size);
746  new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference, attr_data);
747  new_rd[i].data = attr_data;
748  new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t));
749  new_rd[i].record_type = rd[i].record_type;
750  new_rd[i].flags = rd[i].flags;
751  new_rd[i].expiration_time = rd[i].expiration_time;
752  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference %s\n", new_label);
753  GNUNET_free (reference);
754  }
755  }
757  &rvk->identity,
758  new_label,
759  rd_count,
760  new_rd,
762  rvk);
763  GNUNET_free (new_label);
764  GNUNET_free (attr_data);
765 }
766 
767 
776 static void
778 {
779  char *label;
780 
781  if (NULL == rvk->move_attr)
782  {
783  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
784  rvk->ns_it =
786  &rvk->identity,
788  rvk,
790  rvk,
792  rvk);
793  return;
794  }
796  sizeof(uint64_t));
797  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
798 
800  &rvk->identity,
801  label,
802  &rvk_ns_err,
803  rvk,
805  rvk);
806  GNUNET_free (label);
807 }
808 
809 
821 static void
822 remove_ticket_cont (void *cls, int32_t success, const char *emsg)
823 {
824  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
825 
826  rvk->ns_qe = NULL;
827  if (GNUNET_SYSERR == success)
828  {
829  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
830  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
831  cleanup_rvk (rvk);
832  return;
833  }
834  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
835  if (0 == rvk->ticket_attrs)
836  {
838  "No attributes to move... strange\n");
839  rvk->cb (rvk->cb_cls, GNUNET_OK);
840  cleanup_rvk (rvk);
841  return;
842  }
843  rvk->move_attr = rvk->attrs_head;
844  move_attrs (rvk);
845 }
846 
847 
858 static void
859 revoke_attrs_cb (void *cls,
860  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
861  const char *label,
862  unsigned int rd_count,
863  const struct GNUNET_GNSRECORD_Data *rd)
864 
865 {
866  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
867  struct RevokedAttributeEntry *le;
868 
869  rvk->ns_qe = NULL;
874  for (int i = 0; i < rd_count; i++)
875  {
876  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
877  continue;
878  le = GNUNET_new (struct RevokedAttributeEntry);
879  le->old_id = *((uint64_t *) rd[i].data);
881  rvk->ticket_attrs++;
882  }
883 
886  &rvk->identity,
887  label,
888  0,
889  NULL,
891  rvk);
892 }
893 
894 
900 static void
901 rvk_attrs_err_cb (void *cls)
902 {
903  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
904 
905  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
906  cleanup_rvk (rvk);
907 }
908 
909 
925  void *cb_cls)
926 {
927  struct RECLAIM_TICKETS_RevokeHandle *rvk;
928  char *label;
929 
931  rvk->cb = cb;
932  rvk->cb_cls = cb_cls;
933  rvk->identity = *identity;
934  rvk->ticket = *ticket;
937  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
938  GNUNET_assert (NULL != label);
940  identity,
941  label,
943  rvk,
945  rvk);
946  GNUNET_free (label);
947  return rvk;
948 }
949 
950 
956 void
958 {
959  GNUNET_assert (NULL != rh);
960  cleanup_rvk (rh);
961 }
962 
963 
964 /*******************************
965 * Ticket consume
966 *******************************/
967 
973 static void
975 {
976  struct ParallelLookup *lu;
977 
978  if (NULL != cth->lookup_request)
980  if (NULL != cth->kill_task)
982  while (NULL != (lu = cth->parallel_lookups_head))
983  {
984  if (NULL != lu->lookup_request)
989  lu);
990  GNUNET_free (lu);
991  }
992 
993  if (NULL != cth->attrs)
995  GNUNET_free (cth);
996 }
997 
998 
1006 static void
1008  uint32_t rd_count,
1009  const struct GNUNET_GNSRECORD_Data *rd)
1010 {
1011  struct ParallelLookup *parallel_lookup = cls;
1012  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1014 
1016  "Parallel lookup finished (count=%u)\n",
1017  rd_count);
1018 
1020  cth->parallel_lookups_tail,
1021  parallel_lookup);
1022  GNUNET_free (parallel_lookup->label);
1023 
1024  GNUNET_STATISTICS_update (stats,
1025  "attribute_lookup_time_total",
1027  parallel_lookup->lookup_start_time)
1028  .rel_value_us,
1029  GNUNET_YES);
1030  GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
1031 
1032 
1033  GNUNET_free (parallel_lookup);
1034  if (0 == rd_count)
1035  GNUNET_break (0);
1036  // REMARK: It is possible now to find rd_count > 1
1037  for (int i = 0; i < rd_count; i++)
1038  {
1039  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
1040  {
1042  attr_le->claim =
1045  cth->attrs->list_tail,
1046  attr_le);
1047  attr_le->reference = NULL;
1048  attr_le->attest = NULL;
1049  }
1050  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
1051  {
1060  continue;
1061  }
1062  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
1063  {
1064  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le2;
1067  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[0].record_type)
1068  {
1070  rd[0].
1071  data_size);
1072  attr_le2->reference =
1074  rd[i].data_size);
1075  attr_le->claim = NULL;
1076  attr_le->reference = NULL;
1077  attr_le2->claim = NULL;
1078  attr_le2->attest = NULL;
1080  cth->attrs->list_tail,
1081  attr_le);
1083  cth->attrs->list_tail,
1084  attr_le2);
1085  }
1086  else
1087  {
1089  "Parallel Lookup of Reference without Attestation");
1090  continue;
1091  }
1092 
1093 
1094  }
1095  }
1096  if (NULL != cth->parallel_lookups_head)
1097  return; // Wait for more
1098  /* Else we are done */
1099  cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
1100  cleanup_cth (cth);
1101 }
1102 
1103 
1109 static void
1111 {
1112  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1113  struct ParallelLookup *lu;
1114  struct ParallelLookup *tmp;
1115 
1116  cth->kill_task = NULL;
1117  for (lu = cth->parallel_lookups_head; NULL != lu;)
1118  {
1120  GNUNET_free (lu->label);
1121  tmp = lu->next;
1123  cth->parallel_lookups_tail,
1124  lu);
1125  GNUNET_free (lu);
1126  lu = tmp;
1127  }
1128  cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted");
1129 }
1130 
1131 
1141 static void
1142 lookup_authz_cb (void *cls,
1143  uint32_t rd_count,
1144  const struct GNUNET_GNSRECORD_Data *rd)
1145 {
1146  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1147  struct ParallelLookup *parallel_lookup;
1148  char *lbl;
1149 
1150  cth->lookup_request = NULL;
1151 
1152  GNUNET_STATISTICS_update (stats,
1153  "reclaim_authz_lookup_time_total",
1155  cth->lookup_start_time)
1156  .rel_value_us,
1157  GNUNET_YES);
1158  GNUNET_STATISTICS_update (stats,
1159  "reclaim_authz_lookups_count",
1160  1,
1161  GNUNET_YES);
1162 
1163  for (int i = 0; i < rd_count; i++)
1164  {
1165  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1166  continue;
1167  lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1168  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
1169  parallel_lookup = GNUNET_new (struct ParallelLookup);
1170  parallel_lookup->handle = cth;
1171  parallel_lookup->label = lbl;
1172  parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1173  parallel_lookup->lookup_request =
1174  GNUNET_GNS_lookup (gns,
1175  lbl,
1176  &cth->ticket.identity,
1180  parallel_lookup);
1182  cth->parallel_lookups_tail,
1183  parallel_lookup);
1184  }
1189  if (NULL != cth->parallel_lookups_head)
1190  {
1194  cth);
1195  return;
1196  }
1200  cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
1201  cleanup_cth (cth);
1202 }
1203 
1204 
1218  const struct GNUNET_RECLAIM_Ticket *ticket,
1220  void *cb_cls)
1221 {
1222  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1223  char *label;
1224 
1226 
1227  cth->identity = *id;
1230  cth->ticket = *ticket;
1231  cth->cb = cb;
1232  cth->cb_cls = cb_cls;
1233  label =
1234  GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t));
1236  "Looking for AuthZ info under %s\n",
1237  label);
1239  cth->lookup_request =
1240  GNUNET_GNS_lookup (gns,
1241  label,
1242  &cth->ticket.identity,
1245  &lookup_authz_cb,
1246  cth);
1247  GNUNET_free (label);
1248  return cth;
1249 }
1250 
1251 
1257 void
1259 {
1260  cleanup_cth (cth);
1261  return;
1262 }
1263 
1264 
1265 /*******************************
1266 * Ticket issue
1267 *******************************/
1268 
1273 static void
1275 {
1276  if (NULL != handle->ns_qe)
1277  GNUNET_NAMESTORE_cancel (handle->ns_qe);
1278  GNUNET_free (handle);
1279 }
1280 
1281 
1290 static void
1291 store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1292 {
1293  struct TicketIssueHandle *handle = cls;
1294 
1295  handle->ns_qe = NULL;
1296  if (GNUNET_SYSERR == success)
1297  {
1298  handle->cb (handle->cb_cls,
1299  &handle->ticket,
1300  GNUNET_SYSERR,
1301  "Error storing AuthZ ticket in GNS");
1302  return;
1303  }
1304  handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
1305  cleanup_issue_handle (handle);
1306 }
1307 
1308 
1316 static void
1318 {
1320  struct GNUNET_GNSRECORD_Data *attrs_record;
1321  char *label;
1322  size_t list_len = 1;
1323  int i;
1324  char *attest_string;
1325 
1326  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1327  list_len++;
1328 
1329  attrs_record =
1330  GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1331  i = 0;
1332  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1333  {
1334  if (NULL != le->claim)
1335  {
1336  attrs_record[i].data = &le->claim->id;
1337  attrs_record[i].data_size = sizeof(le->claim->id);
1338  }
1339  else if (NULL != le->attest)
1340  {
1341  // REMARK: Since we only store IDs, the references are irrelevant
1342  int j = 0;
1343  GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1344  while (j<i)
1345  {
1346  if (0 == strcmp (attest_string,GNUNET_STRINGS_data_to_string_alloc (
1347  attrs_record[j].data, attrs_record[j].data_size)))
1348  break;
1349  j++;
1350  }
1351  if (j < i)
1352  {
1353  list_len--;
1354  continue;
1355  }
1356  attrs_record[i].data = &le->attest->id;
1357  attrs_record[i].data_size = sizeof(le->attest->id);
1358  }
1359  else if (NULL != le->reference)
1360  {
1361  list_len--;
1362  continue;
1363  /*
1364  int j = 0;
1365  GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1366  while (j<i)
1367  {
1368  if (strcmp(attest_string, GNUNET_STRINGS_data_to_string_alloc (
1369  attrs_record[j].data, attrs_record[j].data_size)))
1370  break;
1371  j++;
1372  }
1373  if (j < i)
1374  continue;
1375  attrs_record[i].data = &le->reference->id;
1376  attrs_record[i].data_size = sizeof(le->reference->id);
1377  */
1378  }
1386  i++;
1387  }
1388  attrs_record[i].data = &ih->ticket;
1389  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1392  attrs_record[i].flags =
1394 
1395  label =
1396  GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t));
1397  // Publish record
1399  &ih->identity,
1400  label,
1401  list_len,
1402  attrs_record,
1404  ih);
1405  GNUNET_free (attrs_record);
1406  GNUNET_free (label);
1407 }
1408 
1409 
1410 /*************************************************
1411 * Ticket iteration (finding a specific ticket)
1412 *************************************************/
1413 
1414 
1420 static void
1422 {
1423  struct TicketIssueHandle *tih = cls;
1424 
1425  tih->ns_it = NULL;
1426  tih->cb (tih->cb_cls,
1427  &tih->ticket,
1428  GNUNET_SYSERR,
1429  "Error storing AuthZ ticket in GNS");
1430  cleanup_issue_handle (tih);
1431 }
1432 
1433 
1446 static void
1448  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1449  const char *label,
1450  unsigned int rd_count,
1451  const struct GNUNET_GNSRECORD_Data *rd)
1452 {
1453  struct TicketIssueHandle *tih = cls;
1454  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1455 
1456  // figure out the number of requested attributes
1458  unsigned int attr_cnt = 0;
1459 
1460  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1461  attr_cnt++;
1462 
1463  // ticket search
1464  unsigned int found_attrs_cnt = 0;
1465 
1466  for (int i = 0; i < rd_count; i++)
1467  {
1468  // found ticket
1469  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1470  {
1471  ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1472  // cmp audience
1473  if (0 == memcmp (&tih->ticket.audience,
1474  &ticket->audience,
1475  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1476  {
1477  tih->ticket = *ticket;
1478  continue;
1479  }
1480  ticket = NULL;
1481  }
1482 
1483  // cmp requested attributes with ticket attributes
1484  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1485  continue;
1486  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1487  {
1488  // cmp attr_ref id with requested attr id
1489  if (NULL !=le->claim)
1490  {
1492  " %" PRIu64 "\n %" PRIu64 "\n",
1493  *((uint64_t *) rd[i].data),
1494  le->claim->id);
1495  if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t)))
1496  found_attrs_cnt++;
1497  }
1498  else if (NULL !=le->attest)
1499  {
1501  " %" PRIu64 "\n %" PRIu64 "\n",
1502  *((uint64_t *) rd[i].data),
1503  le->attest->id);
1504  if (0 == memcmp (rd[i].data, &le->attest->id, sizeof(uint64_t)))
1505  found_attrs_cnt++;
1506  }
1507  else if (NULL != le->reference)
1508  {
1510  " %" PRIu64 "\n %" PRIu64 "\n",
1511  *((uint64_t *) rd[i].data),
1512  le->reference->id);
1513  if (0 == memcmp (rd[i].data, &le->reference->id, sizeof(uint64_t)))
1514  found_attrs_cnt++;
1515  }
1516 
1517  }
1518  }
1519 
1524  if ((attr_cnt == found_attrs_cnt) && (NULL != ticket))
1525  {
1527  tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
1528  cleanup_issue_handle (tih);
1529  return;
1530  }
1531 
1532  // ticket not found in current record, checking next record set
1534 }
1535 
1536 
1544 static void
1546 {
1547  struct TicketIssueHandle *tih = cls;
1548 
1550  tih->ticket.rnd =
1552  issue_ticket (tih);
1553 }
1554 
1555 
1567 void
1570  const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
1572  void *cb_cls)
1573 {
1574  struct TicketIssueHandle *tih;
1575 
1576  tih = GNUNET_new (struct TicketIssueHandle);
1577  tih->cb = cb;
1578  tih->cb_cls = cb_cls;
1580  tih->identity = *identity;
1581  tih->ticket.audience = *audience;
1582 
1583  // First check whether the ticket has already been issued
1584  tih->ns_it =
1586  &tih->identity,
1588  tih,
1590  tih,
1592  tih);
1593 }
1594 
1595 
1596 /************************************
1597 * Ticket iteration
1598 ************************************/
1599 
1605 static void
1607 {
1608  if (NULL != iter->ns_it)
1610  GNUNET_free (iter);
1611 }
1612 
1613 
1625 static void
1627  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1628  const char *label,
1629  unsigned int rd_count,
1630  const struct GNUNET_GNSRECORD_Data *rd)
1631 {
1632  struct RECLAIM_TICKETS_Iterator *iter = cls;
1633 
1634  for (int i = 0; i < rd_count; i++)
1635  {
1636  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1637  continue;
1638  iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1639  return;
1640  }
1642 }
1643 
1644 
1650 static void
1652 {
1653  struct RECLAIM_TICKETS_Iterator *iter = cls;
1654 
1655  iter->ns_it = NULL;
1656  iter->cb (iter->cb_cls, NULL);
1657  cleanup_iter (iter);
1658 }
1659 
1660 
1666 static void
1668 {
1669  struct RECLAIM_TICKETS_Iterator *iter = cls;
1670 
1671  iter->ns_it = NULL;
1672  iter->cb (iter->cb_cls, NULL);
1673  cleanup_iter (iter);
1674 }
1675 
1676 
1682 void
1684 {
1686 }
1687 
1688 
1694 void
1696 {
1698  cleanup_iter (iter);
1699 }
1700 
1701 
1710 struct RECLAIM_TICKETS_Iterator *
1714  void *cb_cls)
1715 {
1716  struct RECLAIM_TICKETS_Iterator *iter;
1717 
1718  iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1719  iter->cb = cb;
1720  iter->cb_cls = cb_cls;
1721  iter->ns_it =
1723  identity,
1725  iter,
1727  iter,
1729  iter);
1730  return iter;
1731 }
1732 
1733 
1740 int
1742 {
1743  // Get ticket expiration time (relative) from config
1744  if (GNUNET_OK ==
1746  "reclaim",
1747  "TICKET_REFRESH_INTERVAL",
1749  {
1751  "Configured refresh interval for tickets: %s\n",
1753  GNUNET_YES));
1754  }
1755  else
1756  {
1758  }
1759  // Connect to identity and namestore services
1760  nsh = GNUNET_NAMESTORE_connect (c);
1761  if (NULL == nsh)
1762  {
1764  "error connecting to namestore");
1765  return GNUNET_SYSERR;
1766  }
1767  gns = GNUNET_GNS_connect (c);
1768  if (NULL == gns)
1769  {
1770  GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1771  return GNUNET_SYSERR;
1772  }
1773  stats = GNUNET_STATISTICS_create ("reclaim", c);
1774  return GNUNET_OK;
1775 }
1776 
1777 
1782 void
1784 {
1785  if (NULL != nsh)
1787  nsh = NULL;
1788  if (NULL != gns)
1789  GNUNET_GNS_disconnect (gns);
1790  gns = NULL;
1791  if (NULL != stats)
1792  {
1794  stats = NULL;
1795  }
1796 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
Connection to the GNS service.
Definition: gns_api.h:35
static void rvk_move_attr_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got the referenced attribute.
static void filter_tickets_finished_cb(void *cls)
Done iterating over tickets and we apparently did not find an existing, matching ticket.
static void cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
Cleanup ticket iterator.
The authorization ticket.
static void abort_parallel_lookups(void *cls)
Cancel the lookups for attribute records.
struct TicketReference * prev
DLL.
struct GNUNET_RECLAIM_Ticket ticket
Tickets.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
uint64_t rel_value_us
The actual value.
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
Get required size for serialization buffer FIXME:
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
static void issue_ticket(struct TicketIssueHandle *ih)
Issue a new ticket.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
static void move_attr_finished(void *cls, int32_t success, const char *emsg)
Updated an attribute ID.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
static void ticket_processed(void *cls, int32_t success, const char *emsg)
Finished storing updated attribute references.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static void process_parallel_lookup_result(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found an attribute record.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static struct GNUNET_TIME_Relative ticket_refresh_interval
Ticket expiration interval.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
uint64_t new_id
New ID of the attribute.
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static void move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh)
We change every attribute ID of the ticket attributes we want to revoke.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void store_ticket_issue_cont(void *cls, int32_t success, const char *emsg)
Store finished, abort on error.
Handle to a lookup request.
Definition: gns_api.c:48
struct ParallelLookup * prev
static void rvk_ns_iter_err(void *cls)
Error iterating namestore.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Audience Key.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_NO
Definition: gnunet_common.h:86
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
size_t data_size
Number of bytes in data.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RECLAIM_TICKETS_ConsumeHandle * handle
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
Private ECC key encoded for transmission.
void(* RECLAIM_TICKETS_TicketIter)(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Continuation called with ticket.
struct RevokedAttributeEntry * next
DLL.
struct TicketReference * next
DLL.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
uint64_t id_attest
Referenced ID of Attestation.
struct GNUNET_GNS_LookupRequest * lookup_request
static void filter_tickets_error_cb(void *cls)
Namestore error on issue.
static void collect_tickets_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Return each record of type to the caller and proceed with the iteration.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
Handle for the service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, char *result)
Serialize a reference.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void revoke_attrs_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found the attribute references.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void del_attr_finished(void *cls, int32_t success, const char *emsg)
Done deleting the old record.
static char * zone
Name of the zone we manage.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE
Record type for reclaim identity references.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
Handle for a zone iterator operation.
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
const void * data
Binary value stored in the DNS record.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
Connection to the NAMESTORE service.
uint64_t expiration_time
Expiration time for the DNS record.
static void rvk_ticket_update_finished(void *cls)
Done collecting tickets.
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
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR
Record type for reclaim identity attestation.
unsigned int rd_count
Record count.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:290
static void move_attrs_cont(void *cls)
Delayed continuation for move_attrs.
Handle to a consume operation.
static void collect_tickets_error_cb(void *cls)
Cancel ticket iteration on namestore error.
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
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(* RECLAIM_TICKETS_ConsumeCallback)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l, int32_t success, const char *emsg)
Consume callback.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:268
This is a private record of this peer and it should thus not be handed out to other peers...
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void rvk_attrs_err_cb(void *cls)
Failed to query namestore.
#define DEFAULT_TICKET_REFRESH_INTERVAL
FIXME: the defaul ticket iteration interval should probably be the minimim attribute expiration...
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
size_t GNUNET_RECLAIM_ATTESTATION_serialize(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, char *result)
Serialize an attestation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
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:84
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:172
struct ParallelLookup * next
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
uint64_t rnd
The ticket random (NBO)
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes to issue.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
void(* RECLAIM_TICKETS_TicketResult)(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, const char *emsg)
Continuation called with ticket.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
struct RevokedAttributeEntry * prev
DLL.
static void process_tickets(void *cls)
For each ticket, store new, updated attribute references (Implementation further below) ...
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
uint32_t record_type
Type of the GNS/DNS record.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
const char * name
The name of the attribute.
configuration data
Definition: configuration.c:84
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
const char * name
The name of the attribute/attestation reference value.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
static void remove_ticket_cont(void *cls, int32_t success, const char *emsg)
Finished deleting ticket and attribute references.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c:314
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
Ticket issue request handle.
A reference to a ticket stored in GNS.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
Time for absolute times used by GNUnet, in microseconds.
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
Get required size for serialization buffer.
RECLAIM_TICKETS_TicketResult cb
Callback.
#define GNUNET_YES
Definition: gnunet_common.h:85
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
Claim to store.
Defaults, look in cache, then in DHT.
uint64_t old_id
Old ID of the attribute.
static void collect_tickets_finished_cb(void *cls)
Signal ticket iteration has finished.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
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
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
static void filter_tickets_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Iterator over records.
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
Definition: gns_api.c:412
uint32_t data
The data value.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_dup(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Make a (deep) copy of a claim list.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
static void rvk_ticket_update(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We need to update all other tickets with the new attribute IDs.
void(* RECLAIM_TICKETS_RevokeCallback)(void *cls, int32_t success)
Revocation callback.
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
static void lookup_authz_cb(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
GNS result with attribute references.
unsigned int ticket_attrs
Number of attributes in ticket.
static struct GNUNET_STATISTICS_Handle * stats
static struct GNUNET_GNS_Handle * gns
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
static void rvk_ns_err(void *cls)
Error storing new attribute in namestore.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Handle for a parallel GNS lookup job.
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub
Audience Key.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
High-quality operations are desired.