GNUnet  0.19.4
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 "platform.h"
28 #include <inttypes.h>
30 
31 
36 #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS
37 
42 struct ParallelLookup;
43 
44 
49 {
54 
59 
64 
69 };
70 
71 
76 {
81 
86 
91 
96 
101 
106 
111 
116 
121 
126 
131 
135  void *cb_cls;
136 };
137 
138 
143 {
144  /* DLL */
146 
147  /* DLL */
149 
150  /* The GNS request */
152 
153  /* The handle the return to */
155 
160 
161  /* The label to look up */
162  char *label;
163 };
164 
165 
170 {
175 
180 
185 
190 
195 
200 
205 
209  void *cb_cls;
210 };
211 
212 
217 {
222 
227 
231  void *cb_cls;
232 };
233 
234 
236 {
241 
246 
251 
256 };
257 
258 
263 {
268 
273 
277  void *cb_cls;
278 
283 
288 
293 
298 
303 
308 
312  unsigned int ticket_attrs;
313 
318 
323 };
324 
325 
330 
331 
332 /* Namestore handle */
334 
335 
336 /* GNS handle */
337 static struct GNUNET_GNS_Handle *gns;
338 
339 
340 /* Handle to the statistics service */
342 
343 
349 static void
351 {
352  struct RevokedAttributeEntry *ae;
353  struct TicketRecordsEntry *le;
354 
355  if (NULL != rh->ns_qe)
357  if (NULL != rh->ns_it)
359  while (NULL != (ae = rh->attrs_head))
360  {
362  GNUNET_free (ae);
363  }
364  while (NULL != (le = rh->tickets_to_update_head))
365  {
368  le);
369  if (NULL != le->data)
370  GNUNET_free (le->data);
371  if (NULL != le->label)
372  GNUNET_free (le->label);
373  GNUNET_free (le);
374  }
375  GNUNET_free (rh);
376 }
377 
378 
385 static void
386 process_tickets (void *cls);
387 
388 
397 static void
398 ticket_processed (void *cls, enum GNUNET_ErrorCode ec)
399 {
400  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
401 
402  rvk->ns_qe = NULL;
404 }
405 
406 
412 static void
413 process_tickets (void *cls)
414 {
415  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
416  struct TicketRecordsEntry *le;
417  struct RevokedAttributeEntry *ae;
418 
419  if (NULL == rvk->tickets_to_update_head)
420  {
422  "Finished updatding tickets, success\n");
423  rvk->cb (rvk->cb_cls, GNUNET_OK);
424  cleanup_rvk (rvk);
425  return;
426  }
427  le = rvk->tickets_to_update_head;
430  le);
431  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
433  le->data,
434  le->rd_count,
435  rd))
436  {
438  "Unable to deserialize ticket record(s)\n");
439  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
440  cleanup_rvk (rvk);
441  return;
442  }
443  for (int i = 0; i < le->rd_count; i++)
444  {
446  continue;
447  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
448  {
449  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
450  continue;
451  rd[i].data = &ae->new_id;
452  }
453  }
455  &rvk->identity,
456  le->label,
457  le->rd_count,
458  rd,
460  rvk);
461  GNUNET_free (le->label);
462  GNUNET_free (le->data);
463  GNUNET_free (le);
464 }
465 
466 
472 static void
474 {
475  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
476 
477  rvk->ns_it = NULL;
479 }
480 
481 
492 static void
493 rvk_ticket_update (void *cls,
494  const struct GNUNET_IDENTITY_PrivateKey *zone,
495  const char *label,
496  unsigned int rd_count,
497  const struct GNUNET_GNSRECORD_Data *rd)
498 {
499  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
500  struct TicketRecordsEntry *le;
501  struct RevokedAttributeEntry *ae;
502  int has_changed = GNUNET_NO;
503 
505  for (int i = 0; i < rd_count; i++)
506  {
507  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
508  continue;
509  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
510  {
511  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
512  continue;
513  has_changed = GNUNET_YES;
514  break;
515  }
516  if (GNUNET_YES == has_changed)
517  break;
518  }
519  if (GNUNET_YES == has_changed)
520  {
521  le = GNUNET_new (struct TicketRecordsEntry);
523  le->data = GNUNET_malloc (le->data_size);
524  le->rd_count = rd_count;
525  le->label = GNUNET_strdup (label);
529  le);
530  }
532 }
533 
534 
540 static void
541 rvk_ns_iter_err (void *cls)
542 {
543  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
544 
545  rvk->ns_it = NULL;
546  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
547  cleanup_rvk (rvk);
548 }
549 
550 
556 static void
557 rvk_ns_err (void *cls)
558 {
559  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
560 
561  rvk->ns_qe = NULL;
562  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
563  cleanup_rvk (rvk);
564 }
565 
566 
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
601 {
602  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
603 
604  rvk->ns_qe = NULL;
605  if (GNUNET_EC_NONE != ec)
606  {
608  "Error removing attribute: %s\n",
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
630 {
631  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
632  char *label;
633 
634  rvk->ns_qe = NULL;
635  if (GNUNET_EC_NONE != ec)
636  {
638  "Error moving attribute: %s\n",
640  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
641  cleanup_rvk (rvk);
642  return;
643  }
645  sizeof(rvk->move_attr->old_id));
646  GNUNET_assert (NULL != label);
647  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
649  &rvk->identity,
650  label,
651  0,
652  NULL,
654  rvk);
655  GNUNET_free (label);
656 }
657 
658 
668 static void
669 rvk_move_attr_cb (void *cls,
670  const struct GNUNET_IDENTITY_PrivateKey *zone,
671  const char *label,
672  unsigned int rd_count,
673  const struct GNUNET_GNSRECORD_Data *rd)
674 {
675  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
676  struct GNUNET_GNSRECORD_Data new_rd[rd_count];
677  struct RevokedAttributeEntry *le;
678  char *new_label;
679  char *attr_data;
680 
681  rvk->ns_qe = NULL;
682  if (0 == rd_count)
683  {
685  "The claim %s no longer exists!\n",
686  label);
687  le = rvk->move_attr;
688  rvk->move_attr = le->next;
690  GNUNET_free (le);
692  return;
693  }
695  new_label =
697  sizeof (rvk->move_attr->new_id));
698 
699  attr_data = NULL;
700  // new_rd = *rd;
701  for (int i = 0; i < rd_count; i++)
702  {
703  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
704  {
708  rd[i].data_size,
709  &claim);
711  "Attribute to update: Name=%s\n",
712  claim->name);
713  claim->id = rvk->move_attr->new_id;
715  attr_data = GNUNET_malloc (rd[i].data_size);
717  attr_data);
718  new_rd[i].data = attr_data;
719  new_rd[i].record_type = rd[i].record_type;
720  new_rd[i].flags = rd[i].flags;
721  new_rd[i].expiration_time = rd[i].expiration_time;
722  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
723  GNUNET_free (claim);
724  }
725  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
726  {
729  rd[i].data_size);
731  "Credential to update: Name=%s\n",
732  credential->name);
733  credential->id = rvk->move_attr->new_id;
734  new_rd[i].data_size =
736  attr_data = GNUNET_malloc (rd[i].data_size);
738  attr_data);
739  new_rd[i].data = attr_data;
740  new_rd[i].record_type = rd[i].record_type;
741  new_rd[i].flags = rd[i].flags;
742  new_rd[i].expiration_time = rd[i].expiration_time;
743  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n",
744  new_label);
746  }
747  else {
748  memcpy (&new_rd[i], &rd[i], sizeof (struct GNUNET_GNSRECORD_Data));
749  }
750  }
752  &rvk->identity,
753  new_label,
754  rd_count,
755  new_rd,
757  rvk);
758  GNUNET_free (new_label);
759  GNUNET_free (attr_data);
760 }
761 
762 
763 static void
765 {
766  char *label;
767 
768  if (NULL == rvk->move_attr)
769  {
770  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
771  rvk->ns_it =
773  &rvk->identity,
775  rvk,
777  rvk,
779  rvk);
780  return;
781  }
783  sizeof (rvk->move_attr->old_id));
784  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
785 
787  &rvk->identity,
788  label,
789  &rvk_ns_err,
790  rvk,
792  rvk);
793  GNUNET_free (label);
794 }
795 
796 
808 static void
810 {
811  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
812 
813  rvk->ns_qe = NULL;
814  if (GNUNET_EC_NONE != ec)
815  {
818  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
819  cleanup_rvk (rvk);
820  return;
821  }
822  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
823  if (0 == rvk->ticket_attrs)
824  {
826  "No attributes to move... strange\n");
827  rvk->cb (rvk->cb_cls, GNUNET_OK);
828  cleanup_rvk (rvk);
829  return;
830  }
831  rvk->move_attr = rvk->attrs_head;
832  move_attrs (rvk);
833 }
834 
835 
846 static void
847 revoke_attrs_cb (void *cls,
848  const struct GNUNET_IDENTITY_PrivateKey *zone,
849  const char *label,
850  unsigned int rd_count,
851  const struct GNUNET_GNSRECORD_Data *rd)
852 
853 {
854  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
855  struct RevokedAttributeEntry *le;
856 
857  rvk->ns_qe = NULL;
862  for (int i = 0; i < rd_count; i++)
863  {
864  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
865  continue;
866  le = GNUNET_new (struct RevokedAttributeEntry);
867  le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
869  rvk->ticket_attrs++;
870  }
871 
874  &rvk->identity,
875  label,
876  0,
877  NULL,
879  rvk);
880 }
881 
882 
888 static void
889 rvk_attrs_err_cb (void *cls)
890 {
891  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
892 
893  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
894  cleanup_rvk (rvk);
895 }
896 
897 
911  const struct GNUNET_IDENTITY_PrivateKey *identity,
913  void *cb_cls)
914 {
915  struct RECLAIM_TICKETS_RevokeHandle *rvk;
916  char *label;
917 
919  rvk->cb = cb;
920  rvk->cb_cls = cb_cls;
921  rvk->identity = *identity;
922  rvk->ticket = *ticket;
926  sizeof(ticket->rnd));
927  GNUNET_assert (NULL != label);
929  identity,
930  label,
932  rvk,
934  rvk);
935  GNUNET_free (label);
936  return rvk;
937 }
938 
939 
945 void
947 {
948  GNUNET_assert (NULL != rh);
949  cleanup_rvk (rh);
950 }
951 
952 
953 /*******************************
954 * Ticket consume
955 *******************************/
956 
962 static void
964 {
965  struct ParallelLookup *lu;
966 
967  if (NULL != cth->lookup_request)
969  if (NULL != cth->kill_task)
971  while (NULL != (lu = cth->parallel_lookups_head))
972  {
973  if (NULL != lu->lookup_request)
975  GNUNET_free (lu->label);
978  lu);
979  GNUNET_free (lu);
980  }
981 
982  if (NULL != cth->attrs)
984  if (NULL != cth->presentations)
986  GNUNET_free (cth);
987 }
988 
989 
997 static void
999  uint32_t rd_count,
1000  const struct GNUNET_GNSRECORD_Data *rd)
1001 {
1002  struct ParallelLookup *parallel_lookup = cls;
1003  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1004  struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1005 
1007  "Parallel lookup finished (count=%u)\n",
1008  rd_count);
1009 
1011  cth->parallel_lookups_tail,
1012  parallel_lookup);
1013  GNUNET_free (parallel_lookup->label);
1014 
1016  "attribute_lookup_time_total",
1018  parallel_lookup->lookup_start_time)
1019  .rel_value_us,
1020  GNUNET_YES);
1021  GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
1022 
1023 
1024  GNUNET_free (parallel_lookup);
1025  if (0 == rd_count)
1026  GNUNET_break (0);
1027  // REMARK: It is possible now to find rd_count > 1
1028  for (int i = 0; i < rd_count; i++)
1029  {
1030  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
1031  continue;
1032  attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1034  &attr_le->attribute);
1036  cth->attrs->list_tail,
1037  attr_le);
1038  }
1039  if (NULL != cth->parallel_lookups_head)
1040  return; // Wait for more
1041  /* Else we are done */
1042  cth->cb (cth->cb_cls, &cth->ticket.identity,
1043  cth->attrs, cth->presentations, GNUNET_OK, NULL);
1044  cleanup_cth (cth);
1045 }
1046 
1047 
1053 static void
1055 {
1056  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1057  struct ParallelLookup *lu;
1058  struct ParallelLookup *tmp;
1059 
1060  cth->kill_task = NULL;
1061  for (lu = cth->parallel_lookups_head; NULL != lu;)
1062  {
1064  GNUNET_free (lu->label);
1065  tmp = lu->next;
1067  cth->parallel_lookups_tail,
1068  lu);
1069  GNUNET_free (lu);
1070  lu = tmp;
1071  }
1072  cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1073 }
1074 
1075 
1085 static void
1086 lookup_authz_cb (void *cls,
1087  uint32_t rd_count,
1088  const struct GNUNET_GNSRECORD_Data *rd)
1089 {
1090  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1091  struct ParallelLookup *parallel_lookup;
1092  char *lbl;
1094 
1095  cth->lookup_request = NULL;
1096 
1098  "reclaim_authz_lookup_time_total",
1100  cth->lookup_start_time)
1101  .rel_value_us,
1102  GNUNET_YES);
1104  "reclaim_authz_lookups_count",
1105  1,
1106  GNUNET_YES);
1107 
1108  for (int i = 0; i < rd_count; i++)
1109  {
1114  switch (rd[i].record_type)
1115  {
1118  ale->presentation =
1120  rd[i].data_size);
1122  cth->presentations->list_tail,
1123  ale);
1124  break;
1127  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1128  parallel_lookup = GNUNET_new (struct ParallelLookup);
1129  parallel_lookup->handle = cth;
1130  parallel_lookup->label = lbl;
1131  parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1132  parallel_lookup->lookup_request =
1134  lbl,
1135  &cth->ticket.identity,
1139  parallel_lookup);
1141  cth->parallel_lookups_tail,
1142  parallel_lookup);
1143  break;
1144  default:
1146  "Ignoring unknown record type %d", rd[i].record_type);
1147  }
1148  }
1153  if (NULL != cth->parallel_lookups_head)
1154  {
1158  cth);
1159  return;
1160  }
1164  cth->cb (cth->cb_cls, &cth->ticket.identity,
1165  cth->attrs, NULL, GNUNET_OK, NULL);
1166  cleanup_cth (cth);
1167 }
1168 
1169 
1183  const struct GNUNET_RECLAIM_Ticket *ticket,
1185  void *cb_cls)
1186 {
1187  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1188  char *label;
1189 
1191 
1192  cth->identity = *id;
1196  cth->ticket = *ticket;
1197  cth->cb = cb;
1198  cth->cb_cls = cb_cls;
1199  label =
1201  sizeof(cth->ticket.rnd));
1204  "Looking for AuthZ info under %s in %s\n",
1205  label, str);
1206  GNUNET_free (str);
1208  cth->lookup_request =
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)
1247  GNUNET_free (handle);
1248 }
1249 
1250 
1259 static void
1261 {
1262  struct TicketIssueHandle *handle = cls;
1263 
1264  handle->ns_qe = NULL;
1265  if (GNUNET_EC_NONE != ec)
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);
1279 }
1280 
1281 
1289 static void
1291 {
1294  struct GNUNET_GNSRECORD_Data *attrs_record;
1295  char *label;
1296  char *tkt_data;
1297  int i;
1298  int j;
1299  int attrs_count = 0;
1300 
1301  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1302  attrs_count++;
1303 
1304  // Worst case we have one presentation per attribute
1305  attrs_record =
1306  GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1307  i = 0;
1308  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1309  {
1311  "Adding list entry: %s\n", le->attribute->name);
1312 
1313  attrs_record[i].data = &le->attribute->id;
1314  attrs_record[i].data_size = sizeof(le->attribute->id);
1318  i++;
1320  {
1322  "Attribute is backed by credential. Adding...\n");
1323  struct GNUNET_RECLAIM_Presentation *presentation = NULL;
1324  for (j = 0; j < i; j++)
1325  {
1326  if (attrs_record[j].record_type
1328  continue;
1330  attrs_record[j].data,
1331  attrs_record[j].
1332  data_size);
1333  if (NULL == presentation)
1334  {
1336  "Failed to deserialize presentation\n");
1337  continue;
1338  }
1339  if (0 == memcmp (&presentation->credential_id,
1340  &le->attribute->credential,
1341  sizeof (le->attribute->credential)))
1342  break;
1343  GNUNET_free (presentation);
1344  presentation = NULL;
1345  }
1346  if (NULL != presentation)
1347  {
1348  GNUNET_free (presentation);
1349  continue; // Skip as we have already added this credential presentation.
1350  }
1351  for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next)
1352  {
1354  "Checking presentation....\n");
1355 
1356  if (0 != memcmp (&le->attribute->credential,
1357  &ple->presentation->credential_id,
1358  sizeof (le->attribute->credential)))
1359  {
1361  "Presentation does not match credential ID.\n");
1362  continue;
1363  }
1364  char *pres_buf;
1365  size_t pres_size;
1366 
1367  pres_size =
1369  pres_buf = GNUNET_malloc (pres_size);
1371  pres_buf);
1372  attrs_record[i].data = pres_buf;
1373  attrs_record[i].data_size = pres_size;
1374  attrs_record[i].expiration_time =
1376  attrs_record[i].record_type =
1379  i++;
1380  break;
1381  }
1382  }
1383  }
1384  attrs_record[i].data_size =
1386  tkt_data = GNUNET_malloc (attrs_record[i].data_size);
1388  tkt_data,
1389  attrs_record[i].data_size);
1390  attrs_record[i].data = tkt_data;
1393  attrs_record[i].flags =
1395  i++;
1396 
1397  label =
1399  sizeof(ih->ticket.rnd));
1402  &pub);
1405  "Storing AuthZ information under %s in %s\n", label, str);
1406  GNUNET_free (str);
1407  // Publish record
1409  &ih->identity,
1410  label,
1411  i,
1412  attrs_record,
1414  ih);
1415  for (j = 0; j < i; j++)
1416  {
1417  if (attrs_record[j].record_type
1419  continue;
1420  // Yes, we are allowed to do this because we allocated it above
1421  char *ptr = (char*) attrs_record[j].data;
1422  GNUNET_free (ptr);
1423  }
1424  GNUNET_free (tkt_data);
1425  GNUNET_free (attrs_record);
1426  GNUNET_free (label);
1427 }
1428 
1429 
1430 /*************************************************
1431  * Ticket iteration (finding a specific ticket)
1432  *************************************************/
1433 
1434 
1440 static void
1442 {
1443  struct TicketIssueHandle *tih = cls;
1444 
1445  tih->ns_it = NULL;
1446  tih->cb (tih->cb_cls,
1447  &tih->ticket,
1448  NULL,
1449  GNUNET_SYSERR,
1450  "Error storing AuthZ ticket in GNS");
1451  cleanup_issue_handle (tih);
1452 }
1453 
1454 
1467 static void
1469  const struct GNUNET_IDENTITY_PrivateKey *zone,
1470  const char *label,
1471  unsigned int rd_count,
1472  const struct GNUNET_GNSRECORD_Data *rd)
1473 {
1474  struct TicketIssueHandle *tih = cls;
1476  struct GNUNET_RECLAIM_Presentation *presentation;
1477  struct GNUNET_RECLAIM_PresentationList *ticket_presentations;
1478  struct GNUNET_RECLAIM_Credential *cred;
1481  unsigned int attr_cnt = 0;
1482  unsigned int pres_cnt = 0;
1483  int ticket_found = GNUNET_NO;
1484 
1485  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1486  {
1487  attr_cnt++;
1489  pres_cnt++;
1490  }
1491 
1492  // ticket search
1493  unsigned int found_attrs_cnt = 0;
1494  unsigned int found_pres_cnt = 0;
1495  size_t read;
1496  ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1497 
1498  for (int i = 0; i < rd_count; i++)
1499  {
1500  // found ticket
1501  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1502  {
1503  if ((GNUNET_SYSERR ==
1505  rd[i].data_size,
1506  &ticket,
1507  &read)) ||
1508  (read != rd[i].data_size))
1509  {
1511  "Failed to deserialize ticket from record\n");
1512  continue;
1513  }
1514  // cmp audience
1515  // FIXME this is ugly, GNUNET_IDENTITY_PublicKey cannot be compared
1516  // like this
1517  if (0 == memcmp (&tih->ticket.audience,
1518  &ticket.audience,
1519  sizeof(struct GNUNET_IDENTITY_PublicKey)))
1520  {
1521  tih->ticket = ticket;
1522  ticket_found = GNUNET_YES;
1523  continue;
1524  }
1525  }
1526 
1527  // cmp requested attributes with ticket attributes
1528  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1529  {
1530  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1531  {
1533  &le->attribute->id))
1534  found_attrs_cnt++;
1535  }
1536  }
1537  if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
1538  {
1540  "Found credential...\n");
1541 
1542  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1543  {
1545  rd[i].data_size);
1546  if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id,
1547  &le->attribute->credential))
1548  {
1550  "No match.\n");
1551  GNUNET_free (cred);
1552  continue;
1553  }
1555  "Match, creating presentation...\n");
1557  cred,
1558  tih->attrs,
1559  &presentation))
1560  {
1562  "Unable to retrieve presentation from credential\n");
1563  GNUNET_free (cred);
1564  continue;
1565  }
1567  ple->presentation = presentation;
1569  tih->presentations->list_tail,
1570  ple);
1571  GNUNET_free (cred);
1572  break;
1573  }
1574  }
1575  if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type)
1576  {
1577  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1578  {
1579  presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1580  rd[i].data_size);
1581  if (NULL == presentation)
1582  {
1584  "Failed to deserialize presentation\n");
1585  continue;
1586  }
1588  &presentation->credential_id,
1589  &le->attribute->credential))
1590  {
1591  found_pres_cnt++;
1593  ple->presentation = presentation;
1594  GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head,
1595  ticket_presentations->list_tail,
1596  ple);
1597  }
1598  }
1599  }
1600  }
1601 
1606  if ((attr_cnt == found_attrs_cnt) &&
1607  (pres_cnt == found_pres_cnt) &&
1608  (GNUNET_YES == ticket_found))
1609  {
1611  tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL);
1612  GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1613  cleanup_issue_handle (tih);
1614  return;
1615  }
1616  GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1617  // ticket not found in current record, checking next record set
1619 }
1620 
1621 
1629 static void
1631 {
1632  struct TicketIssueHandle *tih = cls;
1633 
1636  issue_ticket (tih);
1637 }
1638 
1639 
1651 void
1653  const struct GNUNET_RECLAIM_AttributeList *attrs,
1654  const struct GNUNET_IDENTITY_PublicKey *audience,
1656  void *cb_cls)
1657 {
1658  struct TicketIssueHandle *tih;
1659 
1660  tih = GNUNET_new (struct TicketIssueHandle);
1661  tih->cb = cb;
1662  tih->cb_cls = cb_cls;
1665  tih->identity = *identity;
1666  tih->ticket.audience = *audience;
1667 
1668  // First check whether the ticket has already been issued
1669  tih->ns_it =
1671  &tih->identity,
1673  tih,
1675  tih,
1677  tih);
1678 }
1679 
1680 
1681 /************************************
1682  * Ticket iteration
1683  ************************************/
1684 
1690 static void
1692 {
1693  if (NULL != iter->ns_it)
1695  GNUNET_free (iter);
1696 }
1697 
1698 
1710 static void
1712  const struct GNUNET_IDENTITY_PrivateKey *zone,
1713  const char *label,
1714  unsigned int rd_count,
1715  const struct GNUNET_GNSRECORD_Data *rd)
1716 {
1717  struct RECLAIM_TICKETS_Iterator *iter = cls;
1719  size_t read;
1720 
1721  for (int i = 0; i < rd_count; i++)
1722  {
1723  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1724  continue;
1725  if ((GNUNET_SYSERR ==
1727  rd[i].data_size,
1728  &ticket,
1729  &read)) ||
1730  (read != rd[i].data_size))
1731  {
1733  "Failed to deserialize ticket from record\n");
1734  continue;
1735  }
1736  iter->cb (iter->cb_cls, &ticket);
1737  return;
1738  }
1740 }
1741 
1742 
1748 static void
1750 {
1751  struct RECLAIM_TICKETS_Iterator *iter = cls;
1752 
1753  iter->ns_it = NULL;
1754  iter->cb (iter->cb_cls, NULL);
1755  cleanup_iter (iter);
1756 }
1757 
1758 
1764 static void
1766 {
1767  struct RECLAIM_TICKETS_Iterator *iter = cls;
1768 
1769  iter->ns_it = NULL;
1770  iter->cb (iter->cb_cls, NULL);
1771  cleanup_iter (iter);
1772 }
1773 
1774 
1780 void
1782 {
1784 }
1785 
1786 
1792 void
1794 {
1796  cleanup_iter (iter);
1797 }
1798 
1799 
1808 struct RECLAIM_TICKETS_Iterator *
1810  const struct GNUNET_IDENTITY_PrivateKey *identity,
1812  void *cb_cls)
1813 {
1814  struct RECLAIM_TICKETS_Iterator *iter;
1815 
1816  iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1817  iter->cb = cb;
1818  iter->cb_cls = cb_cls;
1819  iter->ns_it =
1821  identity,
1823  iter,
1825  iter,
1827  iter);
1828  return iter;
1829 }
1830 
1831 
1838 int
1840 {
1841  // Get ticket expiration time (relative) from config
1842  if (GNUNET_OK ==
1844  "reclaim",
1845  "TICKET_REFRESH_INTERVAL",
1847  {
1849  "Configured refresh interval for tickets: %s\n",
1851  GNUNET_YES));
1852  }
1853  else
1854  {
1856  }
1857  // Connect to identity and namestore services
1859  if (NULL == nsh)
1860  {
1862  "error connecting to namestore");
1863  return GNUNET_SYSERR;
1864  }
1865  gns = GNUNET_GNS_connect (c);
1866  if (NULL == gns)
1867  {
1868  GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1869  return GNUNET_SYSERR;
1870  }
1871  stats = GNUNET_STATISTICS_create ("reclaim", c);
1872  return GNUNET_OK;
1873 }
1874 
1875 
1880 void
1882 {
1883  if (NULL != nsh)
1885  nsh = NULL;
1886  if (NULL != gns)
1888  gns = NULL;
1889  if (NULL != stats)
1890  {
1892  stats = NULL;
1893  }
1894 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
identity attribute
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
for reclaim records
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation (e.g.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
local ticket reference
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
uint32_t data
The data value.
static char * zone
Name of the zone being managed.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
static struct GNUNET_GNS_Handle * gns
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
static void filter_tickets_finished_cb(void *cls)
Done iterating over tickets and we apparently did not find an existing, matching ticket.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
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 collect_tickets_finished_cb(void *cls)
Signal ticket iteration has finished.
static void lookup_authz_cb(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
GNS result with attribute references.
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.
static void move_attrs_cont(void *cls)
Delayed continuation for move_attrs.
static void abort_parallel_lookups(void *cls)
Cancel the lookups for attribute records.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
static void rvk_ticket_update_finished(void *cls)
Done collecting tickets.
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.
static struct GNUNET_STATISTICS_Handle * stats
#define DEFAULT_TICKET_REFRESH_INTERVAL
FIXME: the default ticket iteration interval should probably be the minimim attribute expiration.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
static void cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
Cleanup ticket iterator.
static struct GNUNET_TIME_Relative ticket_refresh_interval
Ticket expiration interval.
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
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 GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET to the caller and proceed with the it...
static void collect_tickets_error_cb(void *cls)
Cancel ticket iteration on namestore error.
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.
static void move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh)
We change every attribute ID of the ticket attributes we want to revoke.
static void remove_ticket_cont(void *cls, enum GNUNET_ErrorCode ec)
Finished deleting ticket and attribute references.
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
static void store_ticket_issue_cont(void *cls, enum GNUNET_ErrorCode ec)
Store finished, abort on error.
static void del_attr_finished(void *cls, enum GNUNET_ErrorCode ec)
Done deleting the old record.
static void process_tickets(void *cls)
For each ticket, store new, updated attribute references (Implementation further below)
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...
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
static void move_attr_finished(void *cls, enum GNUNET_ErrorCode ec)
Updated an attribute ID.
static void issue_ticket(struct TicketIssueHandle *ih)
Issue a new ticket.
static void filter_tickets_error_cb(void *cls)
Namestore error on issue.
static struct GNUNET_NAMESTORE_Handle * nsh
static void rvk_ns_err(void *cls)
Error storing new attribute in namestore.
static void rvk_ns_iter_err(void *cls)
Error iterating namestore.
static void ticket_processed(void *cls, enum GNUNET_ErrorCode ec)
Finished storing updated attribute references.
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.
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.
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.
static void rvk_attrs_err_cb(void *cls)
Failed to query namestore.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
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_TicketIter)(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Continuation called with ticket.
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.
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.
void(* RECLAIM_TICKETS_RevokeCallback)(void *cls, int32_t success)
Revocation callback.
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.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:422
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:290
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c:314
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
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
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.
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.
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.
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
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:179
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
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)
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 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 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_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.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
#define GNUNET_RECLAIM_id_is_equal(a, b)
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
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.
#define GNUNET_RECLAIM_id_is_zero(a)
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize a presentation.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
#define GNUNET_RECLAIM_id_generate(id)
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_dup(const struct GNUNET_RECLAIM_AttributeList *attrs)
Make a (deep) copy of a claim list.
enum GNUNET_GenericReturnValue GNUNET_RECLAIM_read_ticket_from_buffer(const void *buffer, size_t len, struct GNUNET_RECLAIM_Ticket *tkt, size_t *tb_read)
Deserializes a ticket.
Definition: reclaim_api.c:1750
ssize_t GNUNET_RECLAIM_write_ticket_to_buffer(const struct GNUNET_RECLAIM_Ticket *tkt, void *buffer, size_t len)
Serializes a ticket.
Definition: reclaim_api.c:1783
size_t GNUNET_RECLAIM_ticket_serialize_get_size(const struct GNUNET_RECLAIM_Ticket *tkt)
Get serialized ticket size.
Definition: reclaim_api.c:1740
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:1299
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
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:1272
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:763
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:436
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
#define GNUNET_TIME_UNIT_MINUTES
One minute.
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:484
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:569
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Connection to the GNS service.
Definition: gns_api.h:36
Handle to a lookup request.
Definition: gns_api.c:49
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:53
Handle for a zone iterator operation.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_Identifier id
ID.
struct GNUNET_RECLAIM_Identifier id
ID.
A reclaim identifier FIXME maybe put this in a different namespace.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
A list of GNUNET_RECLAIM_Presentation structures.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
A credential presentation.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
The authorization ticket.
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
struct GNUNET_IDENTITY_PublicKey audience
The ticket audience (= relying party)
struct GNUNET_IDENTITY_PublicKey identity
The ticket issuer (= the user)
Entry in list of pending tasks.
Definition: scheduler.c:136
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle for a parallel GNS lookup job.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct RECLAIM_TICKETS_ConsumeHandle * handle
struct ParallelLookup * prev
struct ParallelLookup * next
struct GNUNET_GNS_LookupRequest * lookup_request
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
struct GNUNET_IDENTITY_PublicKey identity_pub
Audience Key.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations.
struct GNUNET_IDENTITY_PrivateKey identity
Audience Key.
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
Ticket revocation request handle.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_IDENTITY_PrivateKey identity
Issuer Key.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
unsigned int ticket_attrs
Number of attributes in ticket.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
struct RevokedAttributeEntry * next
DLL.
struct RevokedAttributeEntry * prev
DLL.
struct GNUNET_RECLAIM_Identifier new_id
New ID of the attribute.
Ticket issue request handle.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes to issue.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
RECLAIM_TICKETS_TicketResult cb
Callback.
struct GNUNET_IDENTITY_PrivateKey identity
Issuer Key.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
unsigned int rd_count
Record count.
A reference to a ticket stored in GNS.
struct TicketReference * prev
DLL.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_Ticket ticket
Tickets.
struct TicketReference * next
DLL.