GNUnet  last
gnunet-service-reclaim.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012-2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "gnunet_util_lib.h"
28 #include "gnunet_gnsrecord_lib.h"
29 #include "gnunet_protocols.h"
30 #include "gnunet_reclaim_lib.h"
31 #include "gnunet_reclaim_service.h"
32 #include "reclaim.h"
33 
34 
39 
44 
48 static const struct GNUNET_CONFIGURATION_Handle *cfg;
49 
53 struct IdpClient;
54 
59 {
64 
69 
73  struct IdpClient *client;
74 
78  uint32_t r_id;
79 
84 };
85 
86 
90 struct Iterator
91 {
95  struct Iterator *next;
96 
100  struct Iterator *prev;
101 
105  struct IdpClient *client;
106 
111 
116 
120  uint32_t request_id;
121 
125  void *ctx;
126 };
127 
128 
132 struct IdpClient
133 {
137  struct IdpClient *prev;
138 
142  struct IdpClient *next;
143 
148 
153 
160 
167 
174 
181 
186 
191 
196 
201 
206 
211 
216 
221 
226 
235 
240 };
241 
242 
247 {
252 
257 
261  struct IdpClient *client;
262 
267 
268 
273 
278 
283 
288 
293 
298 
303 
308 
312  char *label;
313 
317  uint32_t r_id;
318 };
319 
320 
325 {
330 
335 
339  struct IdpClient *client;
340 
345 
350 
355 
360 
365 
369  struct GNUNET_TIME_Relative exp;
370 
374  uint32_t r_id;
375 };
376 
377 
382 {
387 
392 
396  struct IdpClient *client;
397 
401  uint32_t r_id;
402 
407 };
408 
409 
414 {
419 
424 
428  struct IdpClient *client;
429 
434 
438  uint32_t r_id;
439 };
440 
441 
446 {
451 
456 
460  struct IdpClient *client;
461 
465  uint32_t r_id;
466 };
467 
468 
472 static struct IdpClient *client_list_head = NULL;
473 
477 static struct IdpClient *client_list_tail = NULL;
478 
479 
485 static void
487 {
488  struct TicketRecordsEntry *le;
489 
490  if (NULL != adh->ns_it)
492  if (NULL != adh->ns_qe)
494  if (NULL != adh->label)
495  GNUNET_free (adh->label);
496  if (NULL != adh->claim)
497  GNUNET_free (adh->claim);
498  if (NULL != adh->credential)
499  GNUNET_free (adh->credential);
500  if (NULL != adh->existing_credentials)
502  if (NULL != adh->existing_attributes)
504  while (NULL != (le = adh->tickets_to_update_head))
505  {
508  le);
509  if (NULL != le->label)
510  GNUNET_free (le->label);
511  if (NULL != le->data)
512  GNUNET_free (le->data);
513  GNUNET_free (le);
514  }
515  GNUNET_free (adh);
516 }
517 
518 
524 static void
526 {
527  if (NULL != ash->ns_qe)
529  if (NULL != ash->claim)
530  GNUNET_free (ash->claim);
531  if (NULL != ash->credential)
532  GNUNET_free (ash->credential);
533  GNUNET_free (ash);
534 }
535 
536 
542 static void
544 {
545  struct Iterator *ai;
546  struct TicketIteration *ti;
547  struct TicketRevocationOperation *rop;
548  struct TicketIssueOperation *iss;
549  struct ConsumeTicketOperation *ct;
550  struct AttributeStoreHandle *as;
551  struct AttributeDeleteHandle *adh;
552 
553  while (NULL != (iss = idp->issue_op_head))
554  {
555  GNUNET_CONTAINER_DLL_remove (idp->issue_op_head, idp->issue_op_tail, iss);
556  GNUNET_free (iss);
557  }
558  while (NULL != (ct = idp->consume_op_head))
559  {
560  GNUNET_CONTAINER_DLL_remove (idp->consume_op_head,
561  idp->consume_op_tail,
562  ct);
563  if (NULL != ct->ch)
565  GNUNET_free (ct);
566  }
567  while (NULL != (as = idp->store_op_head))
568  {
569  GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as);
570  cleanup_as_handle (as);
571  }
572  while (NULL != (adh = idp->delete_op_head))
573  {
574  GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh);
575  cleanup_adh (adh);
576  }
577 
578  while (NULL != (ai = idp->attr_iter_head))
579  {
580  GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
581  GNUNET_free (ai);
582  }
583  while (NULL != (ai = idp->cred_iter_head))
584  {
585  GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
586  ai);
587  GNUNET_free (ai);
588  }
589 
590  while (NULL != (rop = idp->revoke_op_head))
591  {
592  GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop);
593  if (NULL != rop->rh)
595  GNUNET_free (rop);
596  }
597  while (NULL != (ti = idp->ticket_iter_head))
598  {
599  GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head,
600  idp->ticket_iter_tail,
601  ti);
602  if (NULL != ti->iter)
604  GNUNET_free (ti);
605  }
606  GNUNET_free (idp);
607 }
608 
609 
613 static void
615 {
616  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
617 
619  if (NULL != timeout_task)
621  if (NULL != nsh)
623 }
624 
625 
631 static void
632 do_shutdown (void *cls)
633 {
634  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
635  cleanup ();
636 }
637 
638 
647 static void
649  uint32_t r_id,
650  const struct GNUNET_RECLAIM_Ticket *ticket,
651  const struct GNUNET_RECLAIM_PresentationList *presentations,
652  uint32_t success)
653 {
654  struct TicketResultMessage *irm;
655  struct GNUNET_MQ_Envelope *env;
656  size_t pres_len = 0;
657  size_t tkt_len = 0;
658  ssize_t written;
659  char *buf;
660 
661  if (NULL != presentations)
662  {
663  pres_len =
665  }
666  if (NULL != ticket)
668  env = GNUNET_MQ_msg_extra (irm,
669  pres_len + tkt_len,
671  buf = (char*) &irm[1];
672  if (NULL != ticket)
673  {
674  irm->tkt_len = htons (tkt_len);
675  written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len);
676  GNUNET_assert (0 <= written);
677  buf += written;
678  }
679  // TODO add success member
680  irm->id = htonl (r_id);
681  irm->presentations_len = htons (pres_len);
682  if (NULL != presentations)
683  {
685  buf);
686  }
687  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
688  GNUNET_MQ_send (client->mq, env);
689 }
690 
691 
701 static void
704  struct GNUNET_RECLAIM_PresentationList *presentations,
705  int32_t success,
706  const char *emsg)
707 {
708  struct TicketIssueOperation *tio = cls;
709 
710  if (GNUNET_OK != success)
711  {
712  send_ticket_result (tio->client, tio->r_id, NULL, NULL, GNUNET_SYSERR);
713  GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
714  tio->client->issue_op_tail,
715  tio);
716  GNUNET_free (tio);
717  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
718  return;
719  }
720  send_ticket_result (tio->client, tio->r_id,
721  ticket, presentations, GNUNET_SYSERR);
722  GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
723  tio->client->issue_op_tail,
724  tio);
725  GNUNET_free (tio);
726 }
727 
728 
736 static int
737 check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
738 {
739  uint16_t size;
740  size_t attrs_len;
741  size_t key_len;
742  size_t pkey_len;
743 
744  size = ntohs (im->header.size);
745  attrs_len = ntohs (im->attr_len);
746  key_len = ntohs (im->key_len);
747  pkey_len = ntohs (im->pkey_len);
748  if (size != attrs_len + key_len + pkey_len + sizeof(struct
750  {
751  GNUNET_break (0);
752  return GNUNET_SYSERR;
753  }
754  return GNUNET_OK;
755 }
756 
757 
764 static void
765 handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
766 {
767  struct TicketIssueOperation *tio;
768  struct IdpClient *idp = cls;
769  struct GNUNET_RECLAIM_AttributeList *attrs;
773  size_t attrs_len;
774  size_t key_len;
775  size_t pkey_len;
776  size_t read;
777  char *buf;
778 
779  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
780  key_len = ntohs (im->key_len);
781  buf = (char *) &im[1];
782  if ((GNUNET_SYSERR ==
784  &identity, &read)) ||
785  (read != key_len))
786  {
788  "Failed to read private key\n");
790  return;
791  }
792  buf += read;
793  pkey_len = ntohs (im->pkey_len);
794  if ((GNUNET_SYSERR ==
796  &rp, &read)) ||
797  (read != pkey_len))
798  {
800  "Failed to read public key\n");
802  return;
803  }
804  buf += read;
806  attrs_len = ntohs (im->attr_len);
808  attrs_len);
809  for (le = attrs->list_head; NULL != le; le = le->next)
811  "List entry: %s\n", le->attribute->name);
812 
813  tio->r_id = ntohl (im->id);
814  tio->client = idp;
815  GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
817  attrs,
818  &rp,
820  tio);
823 }
824 
825 
826 /**********************************************************
827 * Revocation
828 **********************************************************/
829 
836 static void
837 revoke_result_cb (void *cls, int32_t success)
838 {
839  struct TicketRevocationOperation *rop = cls;
840  struct GNUNET_MQ_Envelope *env;
841  struct RevokeTicketResultMessage *trm;
842 
844  "Sending REVOKE_TICKET_RESULT message\n");
845  rop->rh = NULL;
847  trm->id = htonl (rop->r_id);
848  trm->success = htonl (success);
849  GNUNET_MQ_send (rop->client->mq, env);
851  rop->client->revoke_op_tail,
852  rop);
853  GNUNET_free (rop);
854 }
855 
856 
864 static int
866 {
867  uint16_t size;
868 
869  size = ntohs (im->header.size);
870  if (size != sizeof(struct RevokeTicketMessage))
871  {
872  GNUNET_break (0);
873  return GNUNET_SYSERR;
874  }
875  return GNUNET_OK;
876 }
877 
878 
885 static void
887 {
888  struct TicketRevocationOperation *rop;
889  struct IdpClient *idp = cls;
892  size_t key_len;
893  size_t tkt_len;
894  size_t read;
895  char *buf;
896 
897  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
898  key_len = ntohs (rm->key_len);
899  buf = (char *) &rm[1];
900  if ((GNUNET_SYSERR ==
902  &identity, &read)) ||
903  (read != key_len))
904  {
906  "Failed to read private key\n");
908  return;
909  }
910  buf += read;
911  tkt_len = ntohs (rm->tkt_len);
912  if ((GNUNET_SYSERR ==
914  &ticket, &read)) ||
915  (read != tkt_len))
916  {
918  "Failed to read ticket\n");
920  return;
921  }
922  rop = GNUNET_new (struct TicketRevocationOperation);
923  rop->r_id = ntohl (rm->id);
924  rop->client = idp;
925  GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
926  rop->rh
929 }
930 
931 
941 static void
942 consume_result_cb (void *cls,
943  const struct GNUNET_CRYPTO_PublicKey *identity,
944  const struct GNUNET_RECLAIM_AttributeList *attrs,
945  const struct GNUNET_RECLAIM_PresentationList *presentations,
946  int32_t success,
947  const char *emsg)
948 {
949  struct ConsumeTicketOperation *cop = cls;
950  struct ConsumeTicketResultMessage *crm;
951  struct GNUNET_MQ_Envelope *env;
952  char *data_tmp;
953  size_t attrs_len = 0;
954  size_t pres_len = 0;
955  size_t key_len;
956  ssize_t written;
957 
958  if (GNUNET_OK != success)
959  {
960  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
961  }
964  presentations);
967  "Sending CONSUME_TICKET_RESULT message\n");
968  env = GNUNET_MQ_msg_extra (crm,
969  attrs_len + pres_len + key_len,
971  crm->id = htonl (cop->r_id);
972  crm->attrs_len = htons (attrs_len);
973  crm->presentations_len = htons (pres_len);
974  crm->key_len = htons (key_len);
975  crm->result = htons (success);
976  data_tmp = (char *) &crm[1];
978  data_tmp,
979  key_len);
980  GNUNET_assert (0 <= written);
981  data_tmp += written;
982  GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
983  data_tmp += attrs_len;
984  GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
985  GNUNET_MQ_send (cop->client->mq, env);
987  cop->client->consume_op_tail,
988  cop);
989  GNUNET_free (cop);
990 }
991 
992 
999 static int
1001 {
1002  uint16_t size;
1003 
1004  size = ntohs (cm->header.size);
1005  if (size <= sizeof(struct ConsumeTicketMessage))
1006  {
1007  GNUNET_break (0);
1008  return GNUNET_SYSERR;
1009  }
1010  return GNUNET_OK;
1011 }
1012 
1013 
1020 static void
1022 {
1023  struct ConsumeTicketOperation *cop;
1024  struct IdpClient *idp = cls;
1027  size_t key_len;
1028  size_t tkt_len;
1029  size_t read;
1030  char *buf;
1031 
1032  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1033  key_len = ntohs (cm->key_len);
1034  buf = (char *) &cm[1];
1035  if ((GNUNET_SYSERR ==
1037  &identity, &read)) ||
1038  (read != key_len))
1039  {
1041  "Failed to read private key\n");
1043  return;
1044  }
1045  buf += read;
1046  tkt_len = ntohs (cm->tkt_len);
1047  if ((GNUNET_SYSERR ==
1049  &ticket, &read)) ||
1050  (read != tkt_len))
1051  {
1053  "Failed to read ticket\n");
1055  return;
1056  }
1057  cop = GNUNET_new (struct ConsumeTicketOperation);
1058  cop->r_id = ntohl (cm->id);
1059  cop->client = idp;
1060  cop->ch
1062  cop);
1063  GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
1065 }
1066 
1067 
1068 /*****************************************
1069 * Attribute store
1070 *****************************************/
1071 
1072 
1080 static void
1081 attr_store_cont (void *cls, enum GNUNET_ErrorCode ec)
1082 {
1083  struct AttributeStoreHandle *ash = cls;
1084  struct GNUNET_MQ_Envelope *env;
1085  struct SuccessResultMessage *acr_msg;
1086 
1087  ash->ns_qe = NULL;
1089  ash->client->store_op_tail,
1090  ash);
1091 
1092  if (GNUNET_EC_NONE != ec)
1093  {
1095  "Failed to store attribute %s\n",
1097  cleanup_as_handle (ash);
1099  return;
1100  }
1101 
1102  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1104  acr_msg->id = htonl (ash->r_id);
1105  acr_msg->op_result = htonl (GNUNET_OK);
1106  GNUNET_MQ_send (ash->client->mq, env);
1107  cleanup_as_handle (ash);
1108 }
1109 
1110 
1116 static void
1117 attr_store_task (void *cls)
1118 {
1119  struct AttributeStoreHandle *ash = cls;
1120  struct GNUNET_GNSRECORD_Data rd[1];
1121  char *buf;
1122  char *label;
1123  size_t buf_size;
1124 
1125  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
1127  buf = GNUNET_malloc (buf_size);
1128  // Give the ash a new id if unset
1129  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id))
1132  label
1134  sizeof (ash->claim->id));
1135  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1136 
1137  rd[0].data_size = buf_size;
1138  rd[0].data = buf;
1141  rd[0].expiration_time = ash->exp.rel_value_us;
1143  &ash->identity,
1144  label,
1145  1,
1146  rd,
1147  &attr_store_cont,
1148  ash);
1149  GNUNET_free (buf);
1150  GNUNET_free (label);
1151 }
1152 
1153 
1160 static int
1162  const struct AttributeStoreMessage *sam)
1163 {
1164  uint16_t size;
1165 
1166  size = ntohs (sam->header.size);
1167  if (size <= sizeof(struct AttributeStoreMessage))
1168  {
1169  GNUNET_break (0);
1170  return GNUNET_SYSERR;
1171  }
1172  return GNUNET_OK;
1173 }
1174 
1175 
1182 static void
1184  const struct AttributeStoreMessage *sam)
1185 {
1186  struct AttributeStoreHandle *ash;
1187  struct IdpClient *idp = cls;
1189  size_t data_len;
1190  size_t key_len;
1191  size_t read;
1192  char *buf;
1193 
1194  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1195 
1196  data_len = ntohs (sam->attr_len);
1197  key_len = ntohs (sam->key_len);
1198  buf = (char *) &sam[1];
1199  if ((GNUNET_SYSERR ==
1201  &identity, &read)) ||
1202  (read != key_len))
1203  {
1205  "Failed to read private key\n");
1207  return;
1208  }
1209  buf += read;
1210  ash = GNUNET_new (struct AttributeStoreHandle);
1212  data_len,
1213  &ash->claim);
1214 
1215  ash->r_id = ntohl (sam->id);
1216  ash->identity = identity;
1217  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1219 
1221  ash->client = idp;
1222  GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1224 }
1225 
1226 
1234 static void
1235 cred_store_cont (void *cls, enum GNUNET_ErrorCode ec)
1236 {
1237  struct AttributeStoreHandle *ash = cls;
1238  struct GNUNET_MQ_Envelope *env;
1239  struct SuccessResultMessage *acr_msg;
1240 
1241  ash->ns_qe = NULL;
1243  ash->client->store_op_tail,
1244  ash);
1245 
1246  if (GNUNET_EC_NONE != ec)
1247  {
1249  "Failed to store credential: %s\n",
1251  cleanup_as_handle (ash);
1253  return;
1254  }
1255 
1256  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1258  acr_msg->id = htonl (ash->r_id);
1259  acr_msg->op_result = htonl (GNUNET_OK);
1260  GNUNET_MQ_send (ash->client->mq, env);
1261  cleanup_as_handle (ash);
1262 }
1263 
1264 
1270 static void
1271 cred_error (void *cls)
1272 {
1273  struct AttributeStoreHandle *ash = cls;
1275  "Failed to check for existing credential.\n");
1276  cleanup_as_handle (ash);
1278  return;
1279 }
1280 
1281 
1291 static void
1292 cred_add_cb (void *cls,
1293  const struct GNUNET_CRYPTO_PrivateKey *zone,
1294  const char *label,
1295  unsigned int rd_count,
1296  const struct GNUNET_GNSRECORD_Data *rd)
1297 {
1298  struct AttributeStoreHandle *ash = cls;
1299  struct GNUNET_GNSRECORD_Data rd_new[1];
1300  char *buf;
1301  size_t buf_size;
1302 
1304  buf = GNUNET_malloc (buf_size);
1307  "Storing new credential under `%s'.\n",
1308  label);
1309  rd_new[0].data_size = buf_size;
1310  rd_new[0].data = buf;
1313  rd_new[0].expiration_time = ash->exp.rel_value_us;
1315  &ash->identity,
1316  label,
1317  1,
1318  rd_new,
1319  &cred_store_cont,
1320  ash);
1321  GNUNET_free (buf);
1322  return;
1323 }
1324 
1325 
1331 static void
1332 cred_store_task (void *cls)
1333 {
1334  struct AttributeStoreHandle *ash = cls;
1335  char *label;
1336 
1337  // Give the ash a new id if unset
1341  sizeof (ash->credential->id));
1343  "Looking up existing data under label `%s'\n", label);
1345  &ash->identity,
1346  label,
1347  &cred_error,
1348  ash,
1349  &cred_add_cb,
1350  ash);
1351  GNUNET_free (label);
1352 }
1353 
1354 
1361 static int
1363  const struct AttributeStoreMessage *sam)
1364 {
1365  uint16_t size;
1366 
1367  size = ntohs (sam->header.size);
1368  if (size <= sizeof(struct AttributeStoreMessage))
1369  {
1370  GNUNET_break (0);
1371  return GNUNET_SYSERR;
1372  }
1373  return GNUNET_OK;
1374 }
1375 
1376 
1383 static void
1385  const struct AttributeStoreMessage *sam)
1386 {
1387  struct AttributeStoreHandle *ash;
1388  struct IdpClient *idp = cls;
1390  size_t data_len;
1391  size_t key_len;
1392  size_t read;
1393  char *buf;
1394 
1395  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1396 
1397  data_len = ntohs (sam->attr_len);
1398  key_len = ntohs (sam->key_len);
1399  buf = (char *) &sam[1];
1400  if ((GNUNET_SYSERR ==
1402  &identity, &read)) ||
1403  (read != key_len))
1404  {
1406  "Failed to read private key\n");
1408  return;
1409  }
1410  buf += read;
1411  ash = GNUNET_new (struct AttributeStoreHandle);
1413  data_len);
1414 
1415  ash->r_id = ntohl (sam->id);
1416  ash->identity = identity;
1417  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1419 
1421  ash->client = idp;
1422  GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1424 }
1425 
1426 
1433 static void
1434 send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
1435 {
1436  struct GNUNET_MQ_Envelope *env;
1437  struct SuccessResultMessage *acr_msg;
1438 
1440  adh->client->delete_op_tail,
1441  adh);
1442 
1443  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1445  acr_msg->id = htonl (adh->r_id);
1446  acr_msg->op_result = htonl (success);
1447  GNUNET_MQ_send (adh->client->mq, env);
1448 }
1449 
1450 
1461 static void
1462 consistency_iter (void *cls,
1463  const struct GNUNET_CRYPTO_PrivateKey *zone,
1464  const char *label,
1465  unsigned int rd_count,
1466  const struct GNUNET_GNSRECORD_Data *rd)
1467 {
1468  struct AttributeDeleteHandle *adh = cls;
1469  struct TicketRecordsEntry *le;
1472  int is_ticket = GNUNET_NO;
1473  for (int i = 0; i < rd_count; i++)
1474  {
1475  switch (rd[i].record_type)
1476  {
1480  rd[i].data_size,
1481  &ale->attribute);
1484  ale);
1485  break;
1489  rd[i].data_size);
1492  cle);
1493  break;
1496  "Ticket to delete found (%s)\n",
1497  label);
1498  is_ticket = GNUNET_YES;
1499  break;
1500  default:
1501  break;
1502  }
1503  if (GNUNET_YES == is_ticket)
1504  break;
1505  }
1506  if (GNUNET_YES == is_ticket)
1507  {
1508  le = GNUNET_new (struct TicketRecordsEntry);
1510  le->data = GNUNET_malloc (le->data_size);
1511  le->rd_count = rd_count;
1512  le->label = GNUNET_strdup (label);
1516  le);
1517  }
1519 }
1520 
1521 
1526 static void
1527 update_tickets (void *cls);
1528 
1529 
1537 static void
1538 ticket_updated (void *cls, enum GNUNET_ErrorCode ec)
1539 {
1540  struct AttributeDeleteHandle *adh = cls;
1541 
1542  adh->ns_qe = NULL;
1544 }
1545 
1546 
1554 static void
1555 update_tickets (void *cls)
1556 {
1557  struct AttributeDeleteHandle *adh = cls;
1558  struct TicketRecordsEntry *le;
1559 
1560  if (NULL == adh->tickets_to_update_head)
1561  {
1563  "Finished updating tickets, success\n");
1565  cleanup_adh (adh);
1566  return;
1567  }
1568  le = adh->tickets_to_update_head;
1571  le);
1572  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1573  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1575  le->data,
1576  le->rd_count,
1577  rd))
1578  {
1580  "Unable to deserialize record data!\n");
1582  cleanup_adh (adh);
1583  return;
1584  }
1585  int j = 0;
1586  int i = 0;
1589  struct GNUNET_RECLAIM_Presentation *presentation;
1590  for (i = 0; i < le->rd_count; i++)
1591  {
1592  switch (rd[i].record_type)
1593  {
1595  for (ale = adh->existing_attributes->list_head; NULL != ale; ale =
1596  ale->next)
1597  {
1599  &ale->attribute->id))
1600  {
1602  "Found attribute %s, readding...\n",
1603  ale->attribute->name);
1604  rd_new[j] = rd[i];
1605  j++;
1606  break; // Found and added
1607  }
1608  }
1609  break;
1611  presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1612  rd[i].data_size);
1613  for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1614  cle->next)
1615  {
1617  &presentation->credential_id,
1618  &cle->credential->id))
1619  {
1621  "Found presentation for credential %s, readding...\n",
1622  cle->credential->name);
1623  rd_new[j] = rd[i];
1624  j++;
1625  break; // Found and added
1626  }
1627  }
1628  GNUNET_free (presentation);
1629  break;
1631  rd_new[j] = rd[i];
1632  j++;
1633  break; // Found and added
1634  default:
1635  GNUNET_break (0);
1636  }
1637  }
1639  "Updating ticket with %d entries (%d before)...\n",
1640  j, i);
1642  &adh->identity,
1643  le->label,
1644  j,
1645  rd_new,
1646  &ticket_updated,
1647  adh);
1648  GNUNET_free (le->label);
1649  GNUNET_free (le->data);
1650  GNUNET_free (le);
1651 }
1652 
1653 
1658 static void
1659 purge_attributes (void *cls);;
1660 
1661 static void
1663 {
1664  struct AttributeDeleteHandle *adh = cls;
1665 
1666  adh->ns_qe = NULL;
1667  if (GNUNET_EC_NONE != ec)
1668  {
1670  "Error deleting attribute %s\n",
1671  adh->label);
1673  cleanup_adh (adh);
1674  return;
1675  }
1676  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1678 }
1679 
1680 
1685 static void
1686 purge_attributes (void *cls)
1687 {
1688  struct AttributeDeleteHandle *adh = cls;
1691 
1692  for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1693  {
1694  if (GNUNET_YES ==
1696  continue;
1697 
1698  for (cle = adh->existing_credentials->list_head;
1699  NULL != cle; cle = cle->next)
1700  {
1701  if (GNUNET_YES !=
1703  &ale->attribute->credential))
1704  continue;
1705  break;
1706  }
1707  if (NULL == cle)
1708  {
1710  "Found attribute with missing credential\n");
1711  break;
1712  }
1713  }
1714  if (NULL == ale)
1715  {
1717  "Attributes consistent, updating tickets.\n");
1719  return;
1720  }
1722  "Attributes inconsistent, deleting offending attribute.\n");
1723  char *label
1725  sizeof(ale->attribute->id));
1726 
1728  &adh->identity,
1729  label,
1730  0,
1731  NULL,
1733  adh);
1736  ale);
1737  GNUNET_free (ale);
1738  GNUNET_free (label);
1739 }
1740 
1741 
1747 static void
1749 {
1750  struct AttributeDeleteHandle *adh = cls;
1751  adh->ns_it = NULL;
1753 }
1754 
1755 
1761 static void
1763 {
1764  struct AttributeDeleteHandle *adh = cls;
1765 
1766  adh->ns_it = NULL;
1768  "Namestore error on consistency check\n");
1770  cleanup_adh (adh);
1771 }
1772 
1773 
1780 static void
1782 {
1783  struct AttributeDeleteHandle *adh = cls;
1784 
1787 
1789  &adh->identity,
1791  adh,
1793  adh,
1795  adh);
1796 }
1797 
1798 
1806 static void
1808 {
1809  struct AttributeDeleteHandle *adh = cls;
1810 
1811  adh->ns_qe = NULL;
1812  if (GNUNET_EC_NONE != ec)
1813  {
1815  "Error deleting attribute %s\n",
1816  adh->label);
1818  cleanup_adh (adh);
1819  return;
1820  }
1821  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1823 }
1824 
1825 
1832 static int
1834  const struct AttributeDeleteMessage *dam)
1835 {
1836  uint16_t size;
1837 
1838  size = ntohs (dam->header.size);
1839  if (size <= sizeof(struct AttributeDeleteMessage))
1840  {
1841  GNUNET_break (0);
1842  return GNUNET_SYSERR;
1843  }
1844  return GNUNET_OK;
1845 }
1846 
1847 
1854 static void
1856  const struct AttributeDeleteMessage *dam)
1857 {
1858  struct AttributeDeleteHandle *adh;
1859  struct IdpClient *idp = cls;
1861  size_t data_len;
1862  size_t key_len;
1863  size_t read;
1864  char *buf;
1865 
1866  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1867 
1868  data_len = ntohs (dam->attr_len);
1869  key_len = ntohs (dam->key_len);
1870  buf = (char *) &dam[1];
1871  if ((GNUNET_SYSERR ==
1873  &identity, &read)) ||
1874  (read != key_len))
1875  {
1877  "Failed to read private key\n");
1879  return;
1880  }
1881  buf += read;
1882  adh = GNUNET_new (struct AttributeDeleteHandle);
1884  data_len,
1885  &adh->claim);
1886  adh->credential = NULL;
1887 
1888  adh->r_id = ntohl (dam->id);
1889  adh->identity = identity;
1890  adh->label
1892  sizeof(adh->claim->id));
1894  adh->client = idp;
1895  GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1897  &adh->identity,
1898  adh->label,
1899  0,
1900  NULL,
1902  adh);
1903 }
1904 
1905 
1913 static void
1915 {
1916  struct AttributeDeleteHandle *adh = cls;
1917 
1918  adh->ns_qe = NULL;
1919  if (GNUNET_EC_NONE != ec)
1920  {
1922  "Error deleting credential `%s'\n",
1923  adh->label);
1925  cleanup_adh (adh);
1926  return;
1927  }
1928  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1930 }
1931 
1932 
1939 static int
1941  const struct AttributeDeleteMessage *dam)
1942 {
1943  uint16_t size;
1944 
1945  size = ntohs (dam->header.size);
1946  if (size <= sizeof(struct AttributeDeleteMessage))
1947  {
1948  GNUNET_break (0);
1949  return GNUNET_SYSERR;
1950  }
1951  return GNUNET_OK;
1952 }
1953 
1954 
1961 static void
1963  const struct AttributeDeleteMessage *dam)
1964 {
1965  struct AttributeDeleteHandle *adh;
1966  struct IdpClient *idp = cls;
1968  size_t data_len;
1969  size_t key_len;
1970  size_t read;
1971  char *buf;
1972 
1973  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1974 
1975  data_len = ntohs (dam->attr_len);
1976  key_len = ntohs (dam->key_len);
1977  buf = (char *) &dam[1];
1978  if ((GNUNET_SYSERR ==
1980  &identity, &read)) ||
1981  (read != key_len))
1982  {
1984  "Failed to read private key\n");
1986  return;
1987  }
1988  buf += read;
1989  adh = GNUNET_new (struct AttributeDeleteHandle);
1991  data_len);
1992  adh->claim = NULL;
1993 
1994  adh->r_id = ntohl (dam->id);
1995  adh->identity = identity;
1996  adh->label
1998  sizeof(adh->credential->id));
2000  adh->client = idp;
2001  GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
2003  &adh->identity,
2004  adh->label,
2005  0,
2006  NULL,
2008  adh);
2009 }
2010 
2011 
2012 /*************************************************
2013  * Attribute iteration
2014  *************************************************/
2015 
2016 
2022 static void
2024 {
2025  struct Iterator *ai = cls;
2026  struct GNUNET_MQ_Envelope *env;
2027  struct AttributeResultMessage *arm;
2028 
2029  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
2031  arm->id = htonl (ai->request_id);
2032  arm->attr_len = htons (0);
2033  arm->pkey_len = htons (0);
2034  GNUNET_MQ_send (ai->client->mq, env);
2035  GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2036  ai->client->attr_iter_tail,
2037  ai);
2038  GNUNET_free (ai);
2039 }
2040 
2041 
2047 static void
2048 attr_iter_error (void *cls)
2049 {
2050  struct Iterator *ai = cls;
2051 
2052  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2054 }
2055 
2056 
2066 static void
2067 attr_iter_cb (void *cls,
2068  const struct GNUNET_CRYPTO_PrivateKey *zone,
2069  const char *label,
2070  unsigned int rd_count,
2071  const struct GNUNET_GNSRECORD_Data *rd)
2072 {
2073  struct Iterator *ai = cls;
2074  struct GNUNET_MQ_Envelope *env;
2076  char *data_tmp;
2077  size_t key_len;
2078  ssize_t written;
2079 
2080  if ((rd_count != 1) ||
2082  {
2084  return;
2085  }
2086  struct AttributeResultMessage *arm;
2087  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2088  label);
2090  "Sending ATTRIBUTE_RESULT message\n");
2093  env = GNUNET_MQ_msg_extra (arm,
2094  rd->data_size + key_len,
2096  arm->id = htonl (ai->request_id);
2097  arm->attr_len = htons (rd->data_size);
2098  data_tmp = (char *) &arm[1];
2099  arm->pkey_len = htons (key_len);
2101  data_tmp,
2102  key_len);
2103  GNUNET_assert (0 <= written);
2104  data_tmp += written;
2105  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2106  GNUNET_MQ_send (ai->client->mq, env);
2107 }
2108 
2109 
2110 static enum GNUNET_GenericReturnValue
2112  void *cls,
2113  const struct AttributeIterationStartMessage *ais_msg)
2114 {
2115  uint16_t size;
2116  size_t key_len;
2117 
2118  size = ntohs (ais_msg->header.size);
2119  key_len = ntohs (ais_msg->key_len);
2120 
2121  if (size < key_len + sizeof(*ais_msg))
2122  {
2123  GNUNET_break (0);
2124  return GNUNET_SYSERR;
2125  }
2126  return GNUNET_OK;
2127 }
2128 
2129 
2136 static void
2138  const struct AttributeIterationStartMessage *ais_msg)
2139 {
2140  struct IdpClient *idp = cls;
2141  struct Iterator *ai;
2143  size_t key_len;
2144  size_t read;
2145 
2147  "Received ATTRIBUTE_ITERATION_START message\n");
2148  key_len = ntohs (ais_msg->key_len);
2149  if ((GNUNET_SYSERR ==
2151  key_len,
2152  &identity,
2153  &read)) ||
2154  (read != key_len))
2155  {
2157  "Failed to read private key.\n");
2159  return;
2160  }
2161  ai = GNUNET_new (struct Iterator);
2162  ai->request_id = ntohl (ais_msg->id);
2163  ai->client = idp;
2164  ai->identity = identity;
2165 
2166  GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
2168  &ai->identity,
2169  &attr_iter_error,
2170  ai,
2171  &attr_iter_cb,
2172  ai,
2174  ai);
2176 }
2177 
2178 
2185 static void
2187  const struct AttributeIterationStopMessage *ais_msg)
2188 {
2189  struct IdpClient *idp = cls;
2190  struct Iterator *ai;
2191  uint32_t rid;
2192 
2194  "Received `%s' message\n",
2195  "ATTRIBUTE_ITERATION_STOP");
2196  rid = ntohl (ais_msg->id);
2197  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2198  if (ai->request_id == rid)
2199  break;
2200  if (NULL == ai)
2201  {
2202  GNUNET_break (0);
2204  return;
2205  }
2206  GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
2207  GNUNET_free (ai);
2209 }
2210 
2211 
2218 static void
2220  const struct AttributeIterationNextMessage *ais_msg)
2221 {
2222  struct IdpClient *idp = cls;
2223  struct Iterator *ai;
2224  uint32_t rid;
2225 
2227  "Received ATTRIBUTE_ITERATION_NEXT message\n");
2228  rid = ntohl (ais_msg->id);
2229  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2230  if (ai->request_id == rid)
2231  break;
2232  if (NULL == ai)
2233  {
2234  GNUNET_break (0);
2236  return;
2237  }
2240 }
2241 
2242 
2243 /*************************************************
2244  * Credential iteration
2245  *************************************************/
2246 
2247 
2253 static void
2255 {
2256  struct Iterator *ai = cls;
2257  struct GNUNET_MQ_Envelope *env;
2258  struct CredentialResultMessage *arm;
2259 
2260  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2262  arm->id = htonl (ai->request_id);
2263  arm->credential_len = htons (0);
2264  arm->key_len = htons (0);
2265  GNUNET_MQ_send (ai->client->mq, env);
2266  GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2267  ai->client->cred_iter_tail,
2268  ai);
2269  GNUNET_free (ai);
2270 }
2271 
2272 
2278 static void
2279 cred_iter_error (void *cls)
2280 {
2281  struct Iterator *ai = cls;
2282 
2283  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2285 }
2286 
2287 
2297 static void
2298 cred_iter_cb (void *cls,
2299  const struct GNUNET_CRYPTO_PrivateKey *zone,
2300  const char *label,
2301  unsigned int rd_count,
2302  const struct GNUNET_GNSRECORD_Data *rd)
2303 {
2304  struct Iterator *ai = cls;
2305  struct GNUNET_MQ_Envelope *env;
2306  struct CredentialResultMessage *arm;
2308  char *data_tmp;
2309  size_t key_len;
2310  ssize_t written;
2311 
2312  if ((rd_count != 1) ||
2314  {
2316  return;
2317  }
2318  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2319  label);
2321  "Sending CREDENTIAL_RESULT message\n");
2324  env = GNUNET_MQ_msg_extra (arm,
2325  rd->data_size + key_len,
2327  arm->id = htonl (ai->request_id);
2328  arm->credential_len = htons (rd->data_size);
2329  arm->key_len = htons (key_len);
2330  data_tmp = (char *) &arm[1];
2332  data_tmp,
2333  key_len);
2334  GNUNET_assert (written >= 0);
2335  data_tmp += written;
2336  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2337  GNUNET_MQ_send (ai->client->mq, env);
2338 }
2339 
2340 
2341 static enum GNUNET_GenericReturnValue
2343  void *cls,
2344  const struct CredentialIterationStartMessage *cis_msg)
2345 {
2346  uint16_t size;
2347  size_t key_len;
2348 
2349  size = ntohs (cis_msg->header.size);
2350  key_len = ntohs (cis_msg->key_len);
2351 
2352  if (size < key_len + sizeof(*cis_msg))
2353  {
2354  GNUNET_break (0);
2355  return GNUNET_SYSERR;
2356  }
2357  return GNUNET_OK;
2358 }
2359 
2360 
2367 static void
2369  const struct
2371 {
2372  struct IdpClient *idp = cls;
2373  struct Iterator *ai;
2375  size_t key_len;
2376  size_t read;
2377 
2379  "Received CREDENTIAL_ITERATION_START message\n");
2380  key_len = ntohs (ais_msg->key_len);
2381  if ((GNUNET_SYSERR ==
2383  key_len,
2384  &identity,
2385  &read)) ||
2386  (read != key_len))
2387  {
2389  "Failed to read private key.\n");
2391  return;
2392  }
2393  ai = GNUNET_new (struct Iterator);
2394  ai->request_id = ntohl (ais_msg->id);
2395  ai->client = idp;
2396  ai->identity = identity;
2397 
2398  GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2399  ai);
2401  &ai->identity,
2402  &cred_iter_error,
2403  ai,
2404  &cred_iter_cb,
2405  ai,
2407  ai);
2409 }
2410 
2411 
2418 static void
2420  const struct
2422 {
2423  struct IdpClient *idp = cls;
2424  struct Iterator *ai;
2425  uint32_t rid;
2426 
2428  "Received `%s' message\n",
2429  "CREDENTIAL_ITERATION_STOP");
2430  rid = ntohl (ais_msg->id);
2431  for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2432  if (ai->request_id == rid)
2433  break;
2434  if (NULL == ai)
2435  {
2436  GNUNET_break (0);
2438  return;
2439  }
2440  GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2441  ai);
2442  GNUNET_free (ai);
2444 }
2445 
2446 
2453 static void
2455  const struct
2457 {
2458  struct IdpClient *idp = cls;
2459  struct Iterator *ai;
2460  uint32_t rid;
2461 
2463  "Received CREDENTIAL_ITERATION_NEXT message\n");
2464  rid = ntohl (ais_msg->id);
2465  for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2466  if (ai->request_id == rid)
2467  break;
2468  if (NULL == ai)
2469  {
2470  GNUNET_break (0);
2472  return;
2473  }
2476 }
2477 
2478 
2479 /******************************************************
2480  * Ticket iteration
2481  ******************************************************/
2482 
2489 static void
2491 {
2492  struct TicketIteration *ti = cls;
2493  struct GNUNET_MQ_Envelope *env;
2494  struct TicketResultMessage *trm;
2495  size_t tkt_len;
2496 
2497  if (NULL == ticket)
2498  tkt_len = 0;
2499  else
2501 
2502  env = GNUNET_MQ_msg_extra (trm,
2503  tkt_len,
2505  if (NULL == ticket)
2506  {
2507  /* send empty response to indicate end of list */
2509  ti->client->ticket_iter_tail,
2510  ti);
2511  }
2512  else
2513  {
2515  &trm[1],
2516  tkt_len);
2517  }
2518  trm->tkt_len = htons (tkt_len);
2519  trm->id = htonl (ti->r_id);
2520  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2521  GNUNET_MQ_send (ti->client->mq, env);
2522  if (NULL == ticket)
2523  GNUNET_free (ti);
2524 }
2525 
2526 
2527 static enum GNUNET_GenericReturnValue
2529  void *cls,
2530  const struct TicketIterationStartMessage *tis_msg)
2531 {
2532  uint16_t size;
2533  size_t key_len;
2534 
2535  size = ntohs (tis_msg->header.size);
2536  key_len = ntohs (tis_msg->key_len);
2537 
2538  if (size < key_len + sizeof(*tis_msg))
2539  {
2540  GNUNET_break (0);
2541  return GNUNET_SYSERR;
2542  }
2543  return GNUNET_OK;
2544 }
2545 
2546 
2553 static void
2555  void *cls,
2556  const struct TicketIterationStartMessage *tis_msg)
2557 {
2559  struct IdpClient *client = cls;
2560  struct TicketIteration *ti;
2561  size_t key_len;
2562  size_t read;
2563 
2565  "Received TICKET_ITERATION_START message\n");
2566  key_len = ntohs (tis_msg->key_len);
2567  if ((GNUNET_SYSERR ==
2569  key_len,
2570  &identity,
2571  &read)) ||
2572  (read != key_len))
2573  {
2575  "Failed to read private key\n");
2577  return;
2578  }
2579  ti = GNUNET_new (struct TicketIteration);
2580  ti->r_id = ntohl (tis_msg->id);
2581  ti->client = client;
2584  ti);
2585  ti->iter
2588 }
2589 
2590 
2597 static void
2599  const struct TicketIterationStopMessage *tis_msg)
2600 {
2601  struct IdpClient *client = cls;
2602  struct TicketIteration *ti;
2603  uint32_t rid;
2604 
2606  "Received `%s' message\n",
2607  "TICKET_ITERATION_STOP");
2608  rid = ntohl (tis_msg->id);
2609  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2610  if (ti->r_id == rid)
2611  break;
2612  if (NULL == ti)
2613  {
2614  GNUNET_break (0);
2616  return;
2617  }
2621  ti);
2622  GNUNET_free (ti);
2624 }
2625 
2626 
2633 static void
2635  const struct TicketIterationNextMessage *tis_msg)
2636 {
2637  struct IdpClient *client = cls;
2638  struct TicketIteration *ti;
2639  uint32_t rid;
2640 
2642  "Received TICKET_ITERATION_NEXT message\n");
2643  rid = ntohl (tis_msg->id);
2644  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2645  if (ti->r_id == rid)
2646  break;
2647  if (NULL == ti)
2648  {
2649  GNUNET_break (0);
2651  return;
2652  }
2655 }
2656 
2657 
2665 static void
2666 run (void *cls,
2667  const struct GNUNET_CONFIGURATION_Handle *c,
2668  struct GNUNET_SERVICE_Handle *server)
2669 {
2670  cfg = c;
2671 
2673  {
2675  "Unable to initialize TICKETS subsystem.\n");
2677  return;
2678  }
2679  // Connect to identity and namestore services
2681  if (NULL == nsh)
2682  {
2684  "error connecting to namestore");
2685  }
2686 
2688 }
2689 
2690 
2698 static void
2700  struct GNUNET_SERVICE_Client *client,
2701  void *app_ctx)
2702 {
2703  struct IdpClient *idp = app_ctx;
2704 
2705  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2708  idp);
2709  cleanup_client (idp);
2710 }
2711 
2712 
2721 static void *
2723  struct GNUNET_SERVICE_Client *client,
2724  struct GNUNET_MQ_Handle *mq)
2725 {
2726  struct IdpClient *idp;
2727 
2728  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2729  idp = GNUNET_new (struct IdpClient);
2730  idp->client = client;
2731  idp->mq = mq;
2734  idp);
2735  return idp;
2736 }
2737 
2738 
2743  "reclaim",
2745  &run,
2748  NULL,
2749  GNUNET_MQ_hd_var_size (attribute_store_message,
2751  struct AttributeStoreMessage,
2752  NULL),
2753  GNUNET_MQ_hd_var_size (credential_store_message,
2755  struct AttributeStoreMessage,
2756  NULL),
2757  GNUNET_MQ_hd_var_size (attribute_delete_message,
2759  struct AttributeDeleteMessage,
2760  NULL),
2761  GNUNET_MQ_hd_var_size (credential_delete_message,
2763  struct AttributeDeleteMessage,
2764  NULL),
2765  GNUNET_MQ_hd_var_size (iteration_start,
2768  NULL),
2769  GNUNET_MQ_hd_fixed_size (iteration_next,
2772  NULL),
2773  GNUNET_MQ_hd_fixed_size (iteration_stop,
2776  NULL),
2777  GNUNET_MQ_hd_var_size (credential_iteration_start,
2780  NULL),
2781  GNUNET_MQ_hd_fixed_size (credential_iteration_next,
2784  NULL),
2785  GNUNET_MQ_hd_fixed_size (credential_iteration_stop,
2788  NULL),
2789 
2790  GNUNET_MQ_hd_var_size (issue_ticket_message,
2792  struct IssueTicketMessage,
2793  NULL),
2794  GNUNET_MQ_hd_var_size (consume_ticket_message,
2796  struct ConsumeTicketMessage,
2797  NULL),
2798  GNUNET_MQ_hd_var_size (ticket_iteration_start,
2801  NULL),
2802  GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
2805  NULL),
2806  GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
2809  NULL),
2810  GNUNET_MQ_hd_var_size (revoke_ticket_message,
2812  struct RevokeTicketMessage,
2813  NULL),
2815 /* end of gnunet-service-reclaim.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#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 struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static char * data
The data to insert into the dht.
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 size_t data_size
Number of bytes in data.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static char * rp
Relying party.
static void handle_ticket_iteration_next(void *cls, const struct TicketIterationNextMessage *tis_msg)
Client requests next result.
static void cred_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
Credential deleted callback.
static void attr_store_cont(void *cls, enum GNUNET_ErrorCode ec)
Attribute store result handler.
static int check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
Check a consume ticket message.
static int check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
Check issue ticket message.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
static void handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
Handle ticket issue message.
static void update_tickets(void *cls)
Recursion prototype for function.
static void consume_result_cb(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Handle a ticket consume result.
static void cred_store_task(void *cls)
Add a new credential.
static void attr_iter_finished(void *cls)
Done iterating over attributes.
static void handle_iteration_start(void *cls, const struct AttributeIterationStartMessage *ais_msg)
Iterate over zone to get attributes.
static int check_credential_store_message(void *cls, const struct AttributeStoreMessage *sam)
Check an credential store message.
static int check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im)
Check revocation message format.
static void revoke_result_cb(void *cls, int32_t success)
Handles revocation result.
static void handle_credential_iteration_start(void *cls, const struct CredentialIterationStartMessage *ais_msg)
Iterate over zone to get attributes.
static int check_attribute_store_message(void *cls, const struct AttributeStoreMessage *sam)
Check an attribute store message.
static void cred_iter_error(void *cls)
Error iterating over credentials.
static struct IdpClient * client_list_tail
Client list.
static void cred_iter_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static void consistency_iter(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
static void handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm)
Handle a revocation message to a ticket.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void cleanup()
Cleanup task.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
static void offending_attr_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
static void cred_store_cont(void *cls, enum GNUNET_ErrorCode ec)
Credential store result handler.
static void consistency_iter_err(void *cls)
Error collecting affected tickets.
static void cred_error(void *cls)
Error looking up potential credential.
static void handle_attribute_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Handle attribute deletion.
static void purge_attributes(void *cls)
Delete all attributes which reference credentials that no longer exist.
static void handle_credential_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Handle credential deletion.
static void handle_credential_iteration_next(void *cls, const struct CredentialIterationNextMessage *ais_msg)
Client requests next credential from iterator.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *server)
Main function that will be run.
static void handle_ticket_iteration_start(void *cls, const struct TicketIterationStartMessage *tis_msg)
Client requests a ticket iteration.
static void do_shutdown(void *cls)
Shutdown task.
static void start_consistency_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.
static void consistency_iter_fin(void *cls)
Done collecting affected tickets, start updating.
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Got a ticket.
static void ticket_updated(void *cls, enum GNUNET_ErrorCode ec)
Callback called when a ticket was updated.
static void attr_iter_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static void handle_credential_store_message(void *cls, const struct AttributeStoreMessage *sam)
Handle a credential store message.
static void attr_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
Attribute deleted callback.
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Issue ticket result.
static void handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
Handle a consume ticket message.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
static int check_credential_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Check credential delete message format.
static void handle_attribute_store_message(void *cls, const struct AttributeStoreMessage *sam)
Handle an attribute store message.
static void cred_iter_finished(void *cls)
Done iterating over credentials.
static void cred_add_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check for existing record before storing credential.
static struct IdpClient * client_list_head
Client list.
static struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
static void attr_iter_error(void *cls)
Error iterating over attributes.
static void send_ticket_result(const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_PresentationList *presentations, uint32_t success)
Sends a ticket result message to the client.
static int check_attribute_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Check attribute delete message format.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Add a client to our list of active clients.
static void handle_iteration_stop(void *cls, const struct AttributeIterationStopMessage *ais_msg)
Handle iteration stop message from client.
static void attr_store_task(void *cls)
Add a new attribute.
GNUNET_SERVICE_MAIN("reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(credential_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(credential_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(credential_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, struct CredentialIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, struct CredentialIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, struct CredentialIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL), GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL), GNUNET_MQ_hd_var_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static enum GNUNET_GenericReturnValue check_iteration_start(void *cls, const struct AttributeIterationStartMessage *ais_msg)
static void handle_credential_iteration_stop(void *cls, const struct CredentialIterationStopMessage *ais_msg)
Handle iteration stop message from client.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
static enum GNUNET_GenericReturnValue check_credential_iteration_start(void *cls, const struct CredentialIterationStartMessage *cis_msg)
static void handle_iteration_next(void *cls, const struct AttributeIterationNextMessage *ais_msg)
Client requests next attribute from iterator.
static void handle_ticket_iteration_stop(void *cls, const struct TicketIterationStopMessage *tis_msg)
Client has had enough tickets.
static enum GNUNET_GenericReturnValue check_ticket_iteration_start(void *cls, const struct TicketIterationStartMessage *tis_msg)
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_PrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_PrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_CRYPTO_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...
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_PrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
API that can be used to manipulate GNS record data.
Constants for network protocols.
Identity attribute definitions.
reclaim service; implements identity and personal data sharing for GNUnet
#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.
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.
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.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:68
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
Definition: crypto_pkey.c:128
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:598
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:146
@ 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
@ GNUNET_ERROR_TYPE_INFO
#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_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
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_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
#define GNUNET_RECLAIM_id_is_equal(a, b)
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy credential list.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an 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.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute 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.
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
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_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize a presentation list.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size(const struct GNUNET_RECLAIM_PresentationList *presentations)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
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.
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
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
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
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2489
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2408
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static unsigned int size
Size of the "table".
Definition: peer.c:68
Common type definitions for the identity provider service and API.
Handle for attribute deletion request.
struct GNUNET_RECLAIM_CredentialList * existing_credentials
Existing credentials.
struct GNUNET_CRYPTO_PrivateKey identity
Identity.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_RECLAIM_Attribute * claim
The attribute to delete.
struct AttributeDeleteHandle * next
DLL.
struct IdpClient * client
Client connection.
char * label
Attribute label.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct GNUNET_RECLAIM_AttributeList * existing_attributes
Existing attributes.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct AttributeDeleteHandle * prev
DLL.
struct GNUNET_RECLAIM_Credential * credential
The credential to delete.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
Use to delete an identity attribute.
Definition: reclaim.h:77
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:81
uint16_t key_len
The length of the private key.
Definition: reclaim.h:96
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:91
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:86
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:233
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:242
Start a attribute iteration for the given identity.
Definition: reclaim.h:202
uint16_t key_len
The length of the private key.
Definition: reclaim.h:221
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:211
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:206
Stop attribute iteration for the given operation.
Definition: reclaim.h:315
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:324
Attribute is returned from the idp.
Definition: reclaim.h:127
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:146
uint16_t pkey_len
The length of the public key.
Definition: reclaim.h:156
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:136
Handle for attribute store request.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct IdpClient * client
Client connection.
struct GNUNET_CRYPTO_PrivateKey identity
Identity.
struct GNUNET_RECLAIM_Credential * credential
The credential to store.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_CRYPTO_PublicKey identity_pkey
Identity pubkey.
struct AttributeStoreHandle * prev
DLL.
struct AttributeStoreHandle * next
DLL.
struct GNUNET_RECLAIM_Attribute * claim
The attribute to store.
Use to store an identity attribute.
Definition: reclaim.h:41
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:50
uint16_t key_len
The length of the private key.
Definition: reclaim.h:65
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:60
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:55
Ticket consume message.
Definition: reclaim.h:523
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:532
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:527
uint16_t key_len
The length of the private key.
Definition: reclaim.h:537
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:542
Handle for ticket consume request.
struct ConsumeTicketOperation * next
DLL.
struct IdpClient * client
Client connection.
struct ConsumeTicketOperation * prev
DLL.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
Attribute list is returned from the idp.
Definition: reclaim.h:554
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:578
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:583
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:563
uint16_t key_len
The length of the private key.
Definition: reclaim.h:588
uint32_t result
Result.
Definition: reclaim.h:568
Ask for next result of credential iteration for the given operation.
Definition: reclaim.h:281
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:290
Start a credential iteration for the given identity.
Definition: reclaim.h:250
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:259
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:254
uint16_t key_len
The length of the private key.
Definition: reclaim.h:269
Stop credential iteration for the given operation.
Definition: reclaim.h:298
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:307
Credential is returned from the idp.
Definition: reclaim.h:169
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:183
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:178
uint16_t key_len
The length of the public key.
Definition: reclaim.h:188
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
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.
Handle to a message queue.
Definition: mq.c:87
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:49
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_CredentialListEntry * next
DLL.
struct GNUNET_RECLAIM_Credential * credential
The credential.
A list of GNUNET_RECLAIM_Credential structures.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
const char * name
The name of the credential.
struct GNUNET_RECLAIM_Identifier id
ID.
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:326
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:391
A list of GNUNET_RECLAIM_Presentation structures.
A credential presentation.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
The authorization ticket.
Entry in list of pending tasks.
Definition: scheduler.c:136
Handle to a client that is connected to a service.
Definition: service.c:252
Handle to a service.
Definition: service.c:118
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.
An idp client.
struct IdpClient * next
DLL.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
struct GNUNET_SERVICE_Client * client
The client.
struct Iterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
struct IdpClient * prev
DLL.
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
struct Iterator * cred_iter_tail
Tail of the DLL of Credential iteration operations in progress initiated by this client.
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct Iterator * cred_iter_head
Head of the DLL of Credential iteration operations in progress initiated by this client.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
struct Iterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
Ticket issue message.
Definition: reclaim.h:396
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:405
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:400
uint16_t pkey_len
The length of the relying party public key.
Definition: reclaim.h:425
uint16_t key_len
The length of the identity private key.
Definition: reclaim.h:420
uint16_t attr_len
length of serialized attribute list
Definition: reclaim.h:415
An attribute iteration operation.
struct Iterator * prev
Previous element in the DLL.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
struct IdpClient * client
IDP client which intiated this zone iteration.
struct GNUNET_CRYPTO_PrivateKey identity
Key of the zone we are iterating over.
void * ctx
Context.
struct Iterator * next
Next element in the DLL.
uint32_t request_id
The operation id for the zone iteration in the response for the client.
Ticket revocation request handle.
Ticket revoke message.
Definition: reclaim.h:438
uint16_t key_len
The length of the private key.
Definition: reclaim.h:452
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:447
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:457
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:442
Ticket revoke message.
Definition: reclaim.h:470
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:479
uint32_t success
Revocation result.
Definition: reclaim.h:484
Attribute store/delete response message.
Definition: reclaim.h:106
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:115
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:120
Ticket issue operation handle.
struct TicketIssueOperation * next
DLL.
struct IdpClient * client
Client connection.
struct TicketIssueOperation * prev
DLL.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:362
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:371
Start a ticket iteration for the given identity.
Definition: reclaim.h:331
uint16_t key_len
The length of the private key.
Definition: reclaim.h:350
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:340
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:335
Stop ticket iteration for the given operation.
Definition: reclaim.h:379
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
A ticket iteration operation.
struct TicketIteration * next
DLL.
struct IdpClient * client
Client which intiated this zone iteration.
uint32_t r_id
The operation id for the iteration in the response for the client.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
struct TicketIteration * prev
DLL.
unsigned int rd_count
Record count.
Ticket result message.
Definition: reclaim.h:492
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:501
uint16_t presentations_len
Length of new presentations created.
Definition: reclaim.h:511
uint16_t tkt_len
Ticket length.
Definition: reclaim.h:506
Ticket revocation request handle.
struct TicketRevocationOperation * next
DLL.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct TicketRevocationOperation * prev
DLL.
struct IdpClient * client
Client connection.