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_IDENTITY_PublicKey identity_pub;
95 
100 
105 
110 
115 
120 
124  struct GNUNET_TIME_Absolute lookup_start_time;
125 
130 
134  void *cb_cls;
135 };
136 
137 
142 {
143  /* DLL */
145 
146  /* DLL */
148 
149  /* The GNS request */
151 
152  /* The handle the return to */
154 
158  struct GNUNET_TIME_Absolute lookup_start_time;
159 
160  /* The label to look up */
161  char *label;
162 };
163 
164 
169 {
174 
179 
184 
188  struct GNUNET_RECLAIM_Ticket ticket;
189 
194 
199 
204 
208  void *cb_cls;
209 };
210 
211 
216 {
221 
226 
230  void *cb_cls;
231 };
232 
233 
235 {
240 
245 
250 
255 };
256 
257 
262 {
267 
272 
276  void *cb_cls;
277 
281  struct GNUNET_RECLAIM_Ticket ticket;
282 
287 
292 
297 
302 
307 
311  unsigned int ticket_attrs;
312 
317 
322 };
323 
324 
329 
330 
331 /* Namestore handle */
333 
334 
335 /* GNS handle */
336 static struct GNUNET_GNS_Handle *gns;
337 
338 
339 /* Handle to the statistics service */
341 
342 
348 static void
350 {
351  struct RevokedAttributeEntry *ae;
352  struct TicketRecordsEntry *le;
353 
354  if (NULL != rh->ns_qe)
356  if (NULL != rh->ns_it)
358  while (NULL != (ae = rh->attrs_head))
359  {
361  GNUNET_free (ae);
362  }
363  while (NULL != (le = rh->tickets_to_update_head))
364  {
367  le);
368  if (NULL != le->data)
369  GNUNET_free (le->data);
370  if (NULL != le->label)
371  GNUNET_free (le->label);
372  GNUNET_free (le);
373  }
374  GNUNET_free (rh);
375 }
376 
377 
384 static void
385 process_tickets (void *cls);
386 
387 
396 static void
397 ticket_processed (void *cls, int32_t success, const char *emsg)
398 {
399  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
400 
401  rvk->ns_qe = NULL;
403 }
404 
405 
411 static void
412 process_tickets (void *cls)
413 {
414  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
415  struct TicketRecordsEntry *le;
416  struct RevokedAttributeEntry *ae;
417 
418  if (NULL == rvk->tickets_to_update_head)
419  {
421  "Finished updatding tickets, success\n");
422  rvk->cb (rvk->cb_cls, GNUNET_OK);
423  cleanup_rvk (rvk);
424  return;
425  }
426  le = rvk->tickets_to_update_head;
429  le);
430  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
432  le->data,
433  le->rd_count,
434  rd))
435  {
437  "Unable to deserialize ticket record(s)\n");
438  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
439  cleanup_rvk (rvk);
440  return;
441  }
442  for (int i = 0; i < le->rd_count; i++)
443  {
445  continue;
446  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
447  {
448  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
449  continue;
450  rd[i].data = &ae->new_id;
451  }
452  }
454  &rvk->identity,
455  le->label,
456  le->rd_count,
457  rd,
459  rvk);
460  GNUNET_free (le->label);
461  GNUNET_free (le->data);
462  GNUNET_free (le);
463 }
464 
465 
471 static void
473 {
474  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
475 
476  rvk->ns_it = NULL;
478 }
479 
480 
491 static void
492 rvk_ticket_update (void *cls,
493  const struct GNUNET_IDENTITY_PrivateKey *zone,
494  const char *label,
495  unsigned int rd_count,
496  const struct GNUNET_GNSRECORD_Data *rd)
497 {
498  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
499  struct TicketRecordsEntry *le;
500  struct RevokedAttributeEntry *ae;
501  int has_changed = GNUNET_NO;
502 
504  for (int i = 0; i < rd_count; i++)
505  {
506  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
507  continue;
508  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
509  {
510  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
511  continue;
512  has_changed = GNUNET_YES;
513  break;
514  }
515  if (GNUNET_YES == has_changed)
516  break;
517  }
518  if (GNUNET_YES == has_changed)
519  {
520  le = GNUNET_new (struct TicketRecordsEntry);
521  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
522  le->data = GNUNET_malloc (le->data_size);
523  le->rd_count = rd_count;
524  le->label = GNUNET_strdup (label);
525  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
528  le);
529  }
531 }
532 
533 
539 static void
540 rvk_ns_iter_err (void *cls)
541 {
542  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
543 
544  rvk->ns_it = NULL;
545  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
546  cleanup_rvk (rvk);
547 }
548 
549 
555 static void
556 rvk_ns_err (void *cls)
557 {
558  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
559 
560  rvk->ns_qe = NULL;
561  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
562  cleanup_rvk (rvk);
563 }
564 
565 
575 static void
577 
578 
584 static void
585 move_attrs_cont (void *cls)
586 {
587  move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
588 }
589 
590 
599 static void
600 del_attr_finished (void *cls, int32_t success, const char *emsg)
601 {
602  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
603 
604  rvk->ns_qe = NULL;
605  if (GNUNET_SYSERR == success)
606  {
608  "Error removing attribute: %s\n",
609  emsg);
610  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
611  cleanup_rvk (rvk);
612  return;
613  }
614  rvk->move_attr = rvk->move_attr->next;
616 }
617 
618 
628 static void
629 move_attr_finished (void *cls, int32_t success, const char *emsg)
630 {
631  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
632  char *label;
633 
634  rvk->ns_qe = NULL;
635  if (GNUNET_SYSERR == success)
636  {
637  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
638  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
639  cleanup_rvk (rvk);
640  return;
641  }
643  sizeof(rvk->move_attr->old_id));
644  GNUNET_assert (NULL != label);
645  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
647  &rvk->identity,
648  label,
649  0,
650  NULL,
652  rvk);
653  GNUNET_free (label);
654 }
655 
656 
666 static void
667 rvk_move_attr_cb (void *cls,
668  const struct GNUNET_IDENTITY_PrivateKey *zone,
669  const char *label,
670  unsigned int rd_count,
671  const struct GNUNET_GNSRECORD_Data *rd)
672 {
673  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
674  struct GNUNET_GNSRECORD_Data new_rd[rd_count];
675  struct RevokedAttributeEntry *le;
676  char *new_label;
677  char *attr_data;
678 
679  rvk->ns_qe = NULL;
680  if (0 == rd_count)
681  {
683  "The claim %s no longer exists!\n",
684  label);
685  le = rvk->move_attr;
686  rvk->move_attr = le->next;
688  GNUNET_free (le);
690  return;
691  }
693  new_label =
695  sizeof (rvk->move_attr->new_id));
696 
697  attr_data = NULL;
698  // new_rd = *rd;
699  for (int i = 0; i < rd_count; i++)
700  {
701  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
702  {
706  rd[i].data_size,
707  &claim);
709  "Attribute to update: Name=%s\n",
710  claim->name);
711  claim->id = rvk->move_attr->new_id;
713  attr_data = GNUNET_malloc (rd[i].data_size);
715  attr_data);
716  new_rd[i].data = attr_data;
717  new_rd[i].record_type = rd[i].record_type;
718  new_rd[i].flags = rd[i].flags;
719  new_rd[i].expiration_time = rd[i].expiration_time;
720  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
721  GNUNET_free (claim);
722  }
723  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
724  {
726  credential = GNUNET_RECLAIM_credential_deserialize (rd[i].data,
727  rd[i].data_size);
729  "Credential to update: Name=%s\n",
730  credential->name);
731  credential->id = rvk->move_attr->new_id;
732  new_rd[i].data_size =
734  attr_data = GNUNET_malloc (rd[i].data_size);
735  new_rd[i].data_size = GNUNET_RECLAIM_credential_serialize (credential,
736  attr_data);
737  new_rd[i].data = attr_data;
738  new_rd[i].record_type = rd[i].record_type;
739  new_rd[i].flags = rd[i].flags;
740  new_rd[i].expiration_time = rd[i].expiration_time;
741  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n",
742  new_label);
743  GNUNET_free (credential);
744  }
745  }
747  &rvk->identity,
748  new_label,
749  rd_count,
750  new_rd,
752  rvk);
753  GNUNET_free (new_label);
754  GNUNET_free (attr_data);
755 }
756 
757 
766 static void
768 {
769  char *label;
770 
771  if (NULL == rvk->move_attr)
772  {
773  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
774  rvk->ns_it =
776  &rvk->identity,
778  rvk,
780  rvk,
782  rvk);
783  return;
784  }
786  sizeof (rvk->move_attr->old_id));
787  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
788 
790  &rvk->identity,
791  label,
792  &rvk_ns_err,
793  rvk,
795  rvk);
796  GNUNET_free (label);
797 }
798 
799 
811 static void
812 remove_ticket_cont (void *cls, int32_t success, const char *emsg)
813 {
814  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
815 
816  rvk->ns_qe = NULL;
817  if (GNUNET_SYSERR == success)
818  {
819  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
820  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
821  cleanup_rvk (rvk);
822  return;
823  }
824  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
825  if (0 == rvk->ticket_attrs)
826  {
828  "No attributes to move... strange\n");
829  rvk->cb (rvk->cb_cls, GNUNET_OK);
830  cleanup_rvk (rvk);
831  return;
832  }
833  rvk->move_attr = rvk->attrs_head;
834  move_attrs (rvk);
835 }
836 
837 
848 static void
849 revoke_attrs_cb (void *cls,
850  const struct GNUNET_IDENTITY_PrivateKey *zone,
851  const char *label,
852  unsigned int rd_count,
853  const struct GNUNET_GNSRECORD_Data *rd)
854 
855 {
856  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
857  struct RevokedAttributeEntry *le;
858 
859  rvk->ns_qe = NULL;
864  for (int i = 0; i < rd_count; i++)
865  {
866  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
867  continue;
868  le = GNUNET_new (struct RevokedAttributeEntry);
869  le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
871  rvk->ticket_attrs++;
872  }
873 
876  &rvk->identity,
877  label,
878  0,
879  NULL,
881  rvk);
882 }
883 
884 
890 static void
891 rvk_attrs_err_cb (void *cls)
892 {
893  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
894 
895  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
896  cleanup_rvk (rvk);
897 }
898 
899 
913  const struct GNUNET_IDENTITY_PrivateKey *identity,
915  void *cb_cls)
916 {
917  struct RECLAIM_TICKETS_RevokeHandle *rvk;
918  char *label;
919 
921  rvk->cb = cb;
922  rvk->cb_cls = cb_cls;
923  rvk->identity = *identity;
924  rvk->ticket = *ticket;
927  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd,
928  sizeof(ticket->rnd));
929  GNUNET_assert (NULL != label);
931  identity,
932  label,
934  rvk,
936  rvk);
937  GNUNET_free (label);
938  return rvk;
939 }
940 
941 
947 void
949 {
950  GNUNET_assert (NULL != rh);
951  cleanup_rvk (rh);
952 }
953 
954 
955 /*******************************
956 * Ticket consume
957 *******************************/
958 
964 static void
966 {
967  struct ParallelLookup *lu;
968 
969  if (NULL != cth->lookup_request)
971  if (NULL != cth->kill_task)
973  while (NULL != (lu = cth->parallel_lookups_head))
974  {
975  if (NULL != lu->lookup_request)
977  GNUNET_free (lu->label);
980  lu);
981  GNUNET_free (lu);
982  }
983 
984  if (NULL != cth->attrs)
986  if (NULL != cth->presentations)
988  GNUNET_free (cth);
989 }
990 
991 
999 static void
1001  uint32_t rd_count,
1002  const struct GNUNET_GNSRECORD_Data *rd)
1003 {
1004  struct ParallelLookup *parallel_lookup = cls;
1005  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1006  struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1007 
1009  "Parallel lookup finished (count=%u)\n",
1010  rd_count);
1011 
1013  cth->parallel_lookups_tail,
1014  parallel_lookup);
1015  GNUNET_free (parallel_lookup->label);
1016 
1017  GNUNET_STATISTICS_update (stats,
1018  "attribute_lookup_time_total",
1020  parallel_lookup->lookup_start_time)
1021  .rel_value_us,
1022  GNUNET_YES);
1023  GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
1024 
1025 
1026  GNUNET_free (parallel_lookup);
1027  if (0 == rd_count)
1028  GNUNET_break (0);
1029  // REMARK: It is possible now to find rd_count > 1
1030  for (int i = 0; i < rd_count; i++)
1031  {
1032  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
1033  continue;
1034  attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1036  &attr_le->attribute);
1038  cth->attrs->list_tail,
1039  attr_le);
1040  }
1041  if (NULL != cth->parallel_lookups_head)
1042  return; // Wait for more
1043  /* Else we are done */
1044  cth->cb (cth->cb_cls, &cth->ticket.identity,
1045  cth->attrs, cth->presentations, GNUNET_OK, NULL);
1046  cleanup_cth (cth);
1047 }
1048 
1049 
1055 static void
1057 {
1058  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1059  struct ParallelLookup *lu;
1060  struct ParallelLookup *tmp;
1061 
1062  cth->kill_task = NULL;
1063  for (lu = cth->parallel_lookups_head; NULL != lu;)
1064  {
1066  GNUNET_free (lu->label);
1067  tmp = lu->next;
1069  cth->parallel_lookups_tail,
1070  lu);
1071  GNUNET_free (lu);
1072  lu = tmp;
1073  }
1074  cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1075 }
1076 
1077 
1087 static void
1088 lookup_authz_cb (void *cls,
1089  uint32_t rd_count,
1090  const struct GNUNET_GNSRECORD_Data *rd)
1091 {
1092  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1093  struct ParallelLookup *parallel_lookup;
1094  char *lbl;
1096 
1097  cth->lookup_request = NULL;
1098 
1099  GNUNET_STATISTICS_update (stats,
1100  "reclaim_authz_lookup_time_total",
1102  cth->lookup_start_time)
1103  .rel_value_us,
1104  GNUNET_YES);
1105  GNUNET_STATISTICS_update (stats,
1106  "reclaim_authz_lookups_count",
1107  1,
1108  GNUNET_YES);
1109 
1110  for (int i = 0; i < rd_count; i++)
1111  {
1116  switch (rd[i].record_type)
1117  {
1120  ale->presentation =
1122  rd[i].data_size);
1124  cth->presentations->list_tail,
1125  ale);
1126  break;
1128  lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1129  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1130  parallel_lookup = GNUNET_new (struct ParallelLookup);
1131  parallel_lookup->handle = cth;
1132  parallel_lookup->label = lbl;
1133  parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1134  parallel_lookup->lookup_request =
1135  GNUNET_GNS_lookup (gns,
1136  lbl,
1137  &cth->ticket.identity,
1141  parallel_lookup);
1143  cth->parallel_lookups_tail,
1144  parallel_lookup);
1145  break;
1146  default:
1148  "Ignoring unknown record type %d", rd[i].record_type);
1149  }
1150  }
1155  if (NULL != cth->parallel_lookups_head)
1156  {
1160  cth);
1161  return;
1162  }
1166  cth->cb (cth->cb_cls, &cth->ticket.identity,
1167  cth->attrs, NULL, GNUNET_OK, NULL);
1168  cleanup_cth (cth);
1169 }
1170 
1171 
1185  const struct GNUNET_RECLAIM_Ticket *ticket,
1187  void *cb_cls)
1188 {
1189  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1190  char *label;
1191 
1193 
1194  cth->identity = *id;
1198  cth->ticket = *ticket;
1199  cth->cb = cb;
1200  cth->cb_cls = cb_cls;
1201  label =
1203  sizeof(cth->ticket.rnd));
1205  "Looking for AuthZ info under %s\n",
1206  label);
1208  cth->lookup_request =
1209  GNUNET_GNS_lookup (gns,
1210  label,
1211  &cth->ticket.identity,
1214  &lookup_authz_cb,
1215  cth);
1216  GNUNET_free (label);
1217  return cth;
1218 }
1219 
1220 
1226 void
1228 {
1229  cleanup_cth (cth);
1230  return;
1231 }
1232 
1233 
1234 /*******************************
1235  * Ticket issue
1236  *******************************/
1237 
1242 static void
1244 {
1245  if (NULL != handle->ns_qe)
1246  GNUNET_NAMESTORE_cancel (handle->ns_qe);
1247  GNUNET_free (handle);
1248 }
1249 
1250 
1259 static void
1260 store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1261 {
1262  struct TicketIssueHandle *handle = cls;
1263 
1264  handle->ns_qe = NULL;
1265  if (GNUNET_SYSERR == success)
1266  {
1267  handle->cb (handle->cb_cls,
1268  &handle->ticket,
1269  NULL,
1270  GNUNET_SYSERR,
1271  "Error storing AuthZ ticket in GNS");
1272  return;
1273  }
1274  handle->cb (handle->cb_cls,
1275  &handle->ticket,
1276  handle->presentations,
1277  GNUNET_OK, NULL);
1278  cleanup_issue_handle (handle);
1279 }
1280 
1281 
1289 static void
1291 {
1294  struct GNUNET_GNSRECORD_Data *attrs_record;
1295  char *label;
1296  int i;
1297  int j;
1298  int attrs_count = 0;
1299 
1300  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1301  attrs_count++;
1302 
1303  // Worst case we have one presentation per attribute
1304  attrs_record =
1305  GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1306  i = 0;
1307  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1308  {
1310  "Adding list entry: %s\n", le->attribute->name);
1311 
1312  attrs_record[i].data = &le->attribute->id;
1313  attrs_record[i].data_size = sizeof(le->attribute->id);
1317  i++;
1319  {
1321  "Attribute is backed by credential. Adding...\n");
1322  struct GNUNET_RECLAIM_Presentation *presentation = NULL;
1323  for (j = 0; j < i; j++)
1324  {
1325  if (attrs_record[j].record_type
1327  continue;
1329  attrs_record[j].data,
1330  attrs_record[j].
1331  data_size);
1332  if (NULL == presentation)
1333  {
1335  "Failed to deserialize presentation\n");
1336  continue;
1337  }
1338  if (0 == memcmp (&presentation->credential_id,
1339  &le->attribute->credential,
1340  sizeof (le->attribute->credential)))
1341  break;
1342  GNUNET_free (presentation);
1343  presentation = NULL;
1344  }
1345  if (NULL != presentation)
1346  {
1347  GNUNET_free (presentation);
1348  continue; // Skip as we have already added this credential presentation.
1349  }
1350  for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next)
1351  {
1353  "Checking presentation....\n");
1354 
1355  if (0 != memcmp (&le->attribute->credential,
1356  &ple->presentation->credential_id,
1357  sizeof (le->attribute->credential)))
1358  {
1360  "Presentation does not match credential ID.\n");
1361  continue;
1362  }
1363  char *pres_buf;
1364  size_t pres_size;
1365 
1366  pres_size =
1368  pres_buf = GNUNET_malloc (pres_size);
1370  pres_buf);
1371  attrs_record[i].data = pres_buf;
1372  attrs_record[i].data_size = pres_size;
1373  attrs_record[i].expiration_time =
1375  attrs_record[i].record_type =
1378  i++;
1379  break;
1380  }
1381  }
1382  }
1383  attrs_record[i].data = &ih->ticket;
1384  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1387  attrs_record[i].flags =
1389  i++;
1390 
1391  label =
1393  sizeof(ih->ticket.rnd));
1394  // Publish record
1396  &ih->identity,
1397  label,
1398  i,
1399  attrs_record,
1401  ih);
1402  for (j = 0; j < i; j++)
1403  {
1404  if (attrs_record[j].record_type
1406  continue;
1407  // Yes, we are allowed to do this because we allocated it above
1408  char *ptr = (char*) attrs_record[j].data;
1409  GNUNET_free (ptr);
1410  }
1411  GNUNET_free (attrs_record);
1412  GNUNET_free (label);
1413 }
1414 
1415 
1416 /*************************************************
1417  * Ticket iteration (finding a specific ticket)
1418  *************************************************/
1419 
1420 
1426 static void
1428 {
1429  struct TicketIssueHandle *tih = cls;
1430 
1431  tih->ns_it = NULL;
1432  tih->cb (tih->cb_cls,
1433  &tih->ticket,
1434  NULL,
1435  GNUNET_SYSERR,
1436  "Error storing AuthZ ticket in GNS");
1437  cleanup_issue_handle (tih);
1438 }
1439 
1440 
1453 static void
1455  const struct GNUNET_IDENTITY_PrivateKey *zone,
1456  const char *label,
1457  unsigned int rd_count,
1458  const struct GNUNET_GNSRECORD_Data *rd)
1459 {
1460  struct TicketIssueHandle *tih = cls;
1461  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1462  struct GNUNET_RECLAIM_Presentation *presentation;
1463  struct GNUNET_RECLAIM_PresentationList *ticket_presentations;
1464  struct GNUNET_RECLAIM_Credential *cred;
1467  unsigned int attr_cnt = 0;
1468  unsigned int pres_cnt = 0;
1469 
1470  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1471  {
1472  attr_cnt++;
1474  pres_cnt++;
1475  }
1476 
1477  // ticket search
1478  unsigned int found_attrs_cnt = 0;
1479  unsigned int found_pres_cnt = 0;
1480  ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1481 
1482  for (int i = 0; i < rd_count; i++)
1483  {
1484  // found ticket
1485  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1486  {
1487  ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1488  // cmp audience
1489  if (0 == memcmp (&tih->ticket.audience,
1490  &ticket->audience,
1491  sizeof(struct GNUNET_IDENTITY_PublicKey)))
1492  {
1493  tih->ticket = *ticket;
1494  continue;
1495  }
1496  ticket = NULL;
1497  }
1498 
1499  // cmp requested attributes with ticket attributes
1500  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1501  {
1502  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1503  {
1505  &le->attribute->id))
1506  found_attrs_cnt++;
1507  }
1508  }
1509  if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
1510  {
1512  "Found credential...\n");
1513 
1514  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1515  {
1517  rd[i].data_size);
1518  if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id,
1519  &le->attribute->credential))
1520  {
1522  "No match.\n");
1523  GNUNET_free (cred);
1524  continue;
1525  }
1527  "Match, creating presentation...\n");
1529  cred,
1530  tih->attrs,
1531  &presentation))
1532  {
1534  "Unable to retrieve presentation from credential\n");
1535  GNUNET_free (cred);
1536  continue;
1537  }
1539  ple->presentation = presentation;
1541  tih->presentations->list_tail,
1542  ple);
1543  GNUNET_free (cred);
1544  break;
1545  }
1546  }
1547  if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type)
1548  {
1549  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1550  {
1551  presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1552  rd[i].data_size);
1553  if (NULL == presentation)
1554  {
1556  "Failed to deserialize presentation\n");
1557  continue;
1558  }
1560  &presentation->credential_id,
1561  &le->attribute->credential))
1562  {
1563  found_pres_cnt++;
1565  ple->presentation = presentation;
1566  GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head,
1567  ticket_presentations->list_tail,
1568  ple);
1569  }
1570  }
1571  }
1572  }
1573 
1578  if ((attr_cnt == found_attrs_cnt) &&
1579  (pres_cnt == found_pres_cnt) &&
1580  (NULL != ticket))
1581  {
1583  tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL);
1584  GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1585  cleanup_issue_handle (tih);
1586  return;
1587  }
1588  GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1589  // ticket not found in current record, checking next record set
1591 }
1592 
1593 
1601 static void
1603 {
1604  struct TicketIssueHandle *tih = cls;
1605 
1608  issue_ticket (tih);
1609 }
1610 
1611 
1623 void
1625  const struct GNUNET_RECLAIM_AttributeList *attrs,
1626  const struct GNUNET_IDENTITY_PublicKey *audience,
1628  void *cb_cls)
1629 {
1630  struct TicketIssueHandle *tih;
1631 
1632  tih = GNUNET_new (struct TicketIssueHandle);
1633  tih->cb = cb;
1634  tih->cb_cls = cb_cls;
1637  tih->identity = *identity;
1638  tih->ticket.audience = *audience;
1639 
1640  // First check whether the ticket has already been issued
1641  tih->ns_it =
1643  &tih->identity,
1645  tih,
1647  tih,
1649  tih);
1650 }
1651 
1652 
1653 /************************************
1654  * Ticket iteration
1655  ************************************/
1656 
1662 static void
1664 {
1665  if (NULL != iter->ns_it)
1667  GNUNET_free (iter);
1668 }
1669 
1670 
1682 static void
1684  const struct GNUNET_IDENTITY_PrivateKey *zone,
1685  const char *label,
1686  unsigned int rd_count,
1687  const struct GNUNET_GNSRECORD_Data *rd)
1688 {
1689  struct RECLAIM_TICKETS_Iterator *iter = cls;
1690 
1691  for (int i = 0; i < rd_count; i++)
1692  {
1693  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1694  continue;
1695  iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1696  return;
1697  }
1699 }
1700 
1701 
1707 static void
1709 {
1710  struct RECLAIM_TICKETS_Iterator *iter = cls;
1711 
1712  iter->ns_it = NULL;
1713  iter->cb (iter->cb_cls, NULL);
1714  cleanup_iter (iter);
1715 }
1716 
1717 
1723 static void
1725 {
1726  struct RECLAIM_TICKETS_Iterator *iter = cls;
1727 
1728  iter->ns_it = NULL;
1729  iter->cb (iter->cb_cls, NULL);
1730  cleanup_iter (iter);
1731 }
1732 
1733 
1739 void
1741 {
1743 }
1744 
1745 
1751 void
1753 {
1755  cleanup_iter (iter);
1756 }
1757 
1758 
1767 struct RECLAIM_TICKETS_Iterator *
1769  const struct GNUNET_IDENTITY_PrivateKey *identity,
1771  void *cb_cls)
1772 {
1773  struct RECLAIM_TICKETS_Iterator *iter;
1774 
1775  iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1776  iter->cb = cb;
1777  iter->cb_cls = cb_cls;
1778  iter->ns_it =
1780  identity,
1782  iter,
1784  iter,
1786  iter);
1787  return iter;
1788 }
1789 
1790 
1797 int
1799 {
1800  // Get ticket expiration time (relative) from config
1801  if (GNUNET_OK ==
1803  "reclaim",
1804  "TICKET_REFRESH_INTERVAL",
1806  {
1808  "Configured refresh interval for tickets: %s\n",
1810  GNUNET_YES));
1811  }
1812  else
1813  {
1815  }
1816  // Connect to identity and namestore services
1817  nsh = GNUNET_NAMESTORE_connect (c);
1818  if (NULL == nsh)
1819  {
1821  "error connecting to namestore");
1822  return GNUNET_SYSERR;
1823  }
1824  gns = GNUNET_GNS_connect (c);
1825  if (NULL == gns)
1826  {
1827  GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1828  return GNUNET_SYSERR;
1829  }
1830  stats = GNUNET_STATISTICS_create ("reclaim", c);
1831  return GNUNET_OK;
1832 }
1833 
1834 
1839 void
1841 {
1842  if (NULL != nsh)
1844  nsh = NULL;
1845  if (NULL != gns)
1846  GNUNET_GNS_disconnect (gns);
1847  gns = NULL;
1848  if (NULL != stats)
1849  {
1851  stats = NULL;
1852  }
1853 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Connection to the GNS service.
Definition: gns_api.h:35
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an 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.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_IDENTITY_PublicKey *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
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_IDENTITY_PrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize a presentation.
uint64_t rel_value_us
The actual value.
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
static void collect_tickets_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
for reclaim records
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_dup(const struct GNUNET_RECLAIM_AttributeList *attrs)
Make a (deep) copy of a claim list.
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
static void issue_ticket(struct TicketIssueHandle *ih)
Issue a new ticket.
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.
const char * name
The name of the attribute.
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_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static void rvk_ticket_update(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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.
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.
#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_RECLAIM_PresentationListEntry * next
DLL.
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.
A private key for an identity as per LSD0001.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
A list of GNUNET_RECLAIM_Attribute structures.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
size_t data_size
Number of bytes in data.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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.
#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...
void(* RECLAIM_TICKETS_TicketIter)(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Continuation called with ticket.
struct RevokedAttributeEntry * next
DLL.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
identity attribute
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.
struct GNUNET_GNS_LookupRequest * lookup_request
static void filter_tickets_error_cb(void *cls)
Namestore error on issue.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
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.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
Handle for the service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
struct GNUNET_IDENTITY_PrivateKey identity
Audience Key.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations.
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 being managed.
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...
struct GNUNET_IDENTITY_PrivateKey identity
Issuer Key.
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:1269
int GNUNET_RECLAIM_credential_get_presentation(const struct GNUNET_RECLAIM_Credential *cred, const struct GNUNET_RECLAIM_AttributeList *attrs, struct GNUNET_RECLAIM_Presentation **presentation)
Create a presentation from a credential and a lift of (selected) attributes in the credential...
const void * data
Binary value stored in the DNS record.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
struct GNUNET_IDENTITY_PublicKey identity
The ticket issuer (= the user)
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_IDENTITY_PrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
Connection to the NAMESTORE service.
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
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:1296
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.
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:557
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes to issue.
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
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:311
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
struct GNUNET_RECLAIM_Identifier id
ID.
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.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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)...
static void rvk_attrs_err_cb(void *cls)
Failed to query namestore.
#define DEFAULT_TICKET_REFRESH_INTERVAL
FIXME: the default 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:86
void RECLAIM_TICKETS_issue(const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_IDENTITY_PublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
A reclaim identifier FIXME maybe put this in a different namespace.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
A credential presentation.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
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.
struct ParallelLookup * next
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
const char * name
The name of the credential.
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
local ticket reference
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation (e.g.
struct GNUNET_IDENTITY_PrivateKey identity
Issuer Key.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
struct GNUNET_IDENTITY_PublicKey identity_pub
Audience Key.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
struct GNUNET_RECLAIM_Identifier new_id
New ID of the attribute.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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.
void(* RECLAIM_TICKETS_TicketResult)(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Continuation called with ticket.
struct RevokedAttributeEntry * prev
DLL.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
static void process_tickets(void *cls)
For each ticket, store new, updated attribute references (Implementation further below) ...
An identity key as per LSD0001.
static void rvk_move_attr_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got the referenced attribute.
A list of GNUNET_RECLAIM_Presentation structures.
uint32_t record_type
Type of the GNS/DNS record.
configuration data
enum GNUNET_GenericReturnValue 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.
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:263
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
#define GNUNET_RECLAIM_id_is_equal(a, b)
static void remove_ticket_cont(void *cls, int32_t success, const char *emsg)
Finished deleting ticket and attribute references.
struct GNUNET_IDENTITY_PublicKey audience
The ticket audience (= relying party)
#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
static void revoke_attrs_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found the attribute references.
Ticket issue request handle.
A reference to a ticket stored in GNS.
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
Time for absolute times used by GNUnet, in microseconds.
RECLAIM_TICKETS_TicketResult cb
Callback.
Defaults, look in cache, then in DHT.
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:750
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
#define GNUNET_RECLAIM_id_generate(id)
static void filter_tickets_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Iterator over records.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_IDENTITY_PrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
uint32_t data
The data value.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
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
static void rvk_ns_err(void *cls)
Error storing new attribute in namestore.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_malloc(size)
Wrapper around malloc.
void(* RECLAIM_TICKETS_ConsumeCallback)(void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_AttributeList *attributes, const struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Consume callback.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_RECLAIM_id_is_zero(a)
Handle for a parallel GNS lookup job.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972