GNUnet 0.22.2
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 */
25#include "gnunet_util_lib.h"
28#include "gnunet_protocols.h"
29#include "gnunet_reclaim_lib.h"
31#include "reclaim.h"
32
33
38
43
47static const struct GNUNET_CONFIGURATION_Handle *cfg;
48
52struct IdpClient;
53
58{
63
68
73
77 uint32_t r_id;
78
83};
84
85
90{
94 struct Iterator *next;
95
99 struct Iterator *prev;
100
105
110
115
119 uint32_t request_id;
120
124 void *ctx;
125};
126
127
132{
137
142
147
152
159
166
173
180
185
190
195
200
205
210
215
220
225
234
239};
240
241
246{
251
256
261
266
267
272
277
282
287
292
297
302
307
311 char *label;
312
316 uint32_t r_id;
317};
318
319
324{
329
334
339
344
349
354
359
364
369
373 uint32_t r_id;
374};
375
376
381{
386
391
396
400 uint32_t r_id;
401
406};
407
408
413{
418
423
428
433
437 uint32_t r_id;
438};
439
440
445{
450
455
460
464 uint32_t r_id;
465};
466
467
471static struct IdpClient *client_list_head = NULL;
472
476static struct IdpClient *client_list_tail = NULL;
477
478
484static void
486{
487 struct TicketRecordsEntry *le;
488
489 if (NULL != adh->ns_it)
491 if (NULL != adh->ns_qe)
493 if (NULL != adh->label)
494 GNUNET_free (adh->label);
495 if (NULL != adh->claim)
496 GNUNET_free (adh->claim);
497 if (NULL != adh->credential)
498 GNUNET_free (adh->credential);
499 if (NULL != adh->existing_credentials)
501 if (NULL != adh->existing_attributes)
503 while (NULL != (le = adh->tickets_to_update_head))
504 {
507 le);
508 if (NULL != le->label)
509 GNUNET_free (le->label);
510 if (NULL != le->data)
511 GNUNET_free (le->data);
512 GNUNET_free (le);
513 }
514 GNUNET_free (adh);
515}
516
517
523static void
525{
526 if (NULL != ash->ns_qe)
528 if (NULL != ash->claim)
529 GNUNET_free (ash->claim);
530 if (NULL != ash->credential)
531 GNUNET_free (ash->credential);
532 GNUNET_free (ash);
533}
534
535
541static void
543{
544 struct Iterator *ai;
545 struct TicketIteration *ti;
546 struct TicketRevocationOperation *rop;
547 struct TicketIssueOperation *iss;
548 struct ConsumeTicketOperation *ct;
549 struct AttributeStoreHandle *as;
550 struct AttributeDeleteHandle *adh;
551
552 while (NULL != (iss = idp->issue_op_head))
553 {
554 GNUNET_CONTAINER_DLL_remove (idp->issue_op_head, idp->issue_op_tail, iss);
555 GNUNET_free (iss);
556 }
557 while (NULL != (ct = idp->consume_op_head))
558 {
559 GNUNET_CONTAINER_DLL_remove (idp->consume_op_head,
560 idp->consume_op_tail,
561 ct);
562 if (NULL != ct->ch)
564 GNUNET_free (ct);
565 }
566 while (NULL != (as = idp->store_op_head))
567 {
568 GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as);
570 }
571 while (NULL != (adh = idp->delete_op_head))
572 {
573 GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh);
574 cleanup_adh (adh);
575 }
576
577 while (NULL != (ai = idp->attr_iter_head))
578 {
579 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
580 GNUNET_free (ai);
581 }
582 while (NULL != (ai = idp->cred_iter_head))
583 {
584 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
585 ai);
586 GNUNET_free (ai);
587 }
588
589 while (NULL != (rop = idp->revoke_op_head))
590 {
591 GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop);
592 if (NULL != rop->rh)
594 GNUNET_free (rop);
595 }
596 while (NULL != (ti = idp->ticket_iter_head))
597 {
598 GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head,
599 idp->ticket_iter_tail,
600 ti);
601 if (NULL != ti->iter)
603 GNUNET_free (ti);
604 }
606}
607
608
612static void
614{
615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
616
618 if (NULL != timeout_task)
620 if (NULL != nsh)
622}
623
624
630static void
631do_shutdown (void *cls)
632{
633 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
634 cleanup ();
635}
636
637
646static void
648 uint32_t r_id,
649 const struct GNUNET_RECLAIM_Ticket *ticket,
650 const struct GNUNET_RECLAIM_PresentationList *presentations,
651 uint32_t success)
652{
653 struct TicketResultMessage *irm;
654 struct GNUNET_MQ_Envelope *env;
655 size_t pres_len = 0;
656 size_t tkt_len = 0;
657 char *buf;
658
659 if (NULL != presentations)
660 {
661 pres_len =
663 }
664 if (NULL != ticket)
665 tkt_len = strlen (ticket->gns_name) + 1;
667 pres_len + tkt_len,
669 buf = (char*) &irm[1];
670 if (NULL != ticket)
671 {
672 memcpy (buf, ticket, tkt_len);
673 buf += tkt_len;
674 }
675 // TODO add success member
676 irm->id = htonl (r_id);
677 irm->tkt_len = htons (tkt_len);
678 irm->rp_uri_len = htons (0);
679 irm->presentations_len = htons (pres_len);
680 if (NULL != presentations)
681 {
683 buf);
684 }
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
686 GNUNET_MQ_send (client->mq, env);
687}
688
689
699static void
702 struct GNUNET_RECLAIM_PresentationList *presentations,
703 int32_t success,
704 const char *emsg)
705{
706 struct TicketIssueOperation *tio = cls;
707
708 if (GNUNET_OK != success)
709 {
710 send_ticket_result (tio->client, tio->r_id, NULL, NULL, GNUNET_SYSERR);
711 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
712 tio->client->issue_op_tail,
713 tio);
715 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
716 return;
717 }
718 send_ticket_result (tio->client, tio->r_id,
719 ticket, presentations, GNUNET_SYSERR);
720 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
721 tio->client->issue_op_tail,
722 tio);
724}
725
726
734static int
736{
737 uint16_t size;
738 size_t attrs_len;
739 size_t key_len;
740 size_t rp_len;
741
742 size = ntohs (im->header.size);
743 attrs_len = ntohs (im->attr_len);
744 key_len = ntohs (im->key_len);
745 rp_len = ntohs (im->rp_uri_len);
746 if (size != attrs_len + key_len + rp_len + sizeof(struct
748 {
749 GNUNET_break (0);
750 return GNUNET_SYSERR;
751 }
752 return GNUNET_OK;
753}
754
755
762static void
764{
766 struct IdpClient *idp = cls;
767 struct GNUNET_RECLAIM_AttributeList *attrs;
770 const char *rp;
771 size_t attrs_len;
772 size_t key_len;
773 size_t rp_len;
774 size_t read;
775 char *buf;
776
777 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
778 key_len = ntohs (im->key_len);
779 buf = (char *) &im[1];
780 if ((GNUNET_SYSERR ==
782 &identity, &read)) ||
783 (read != key_len))
784 {
786 "Failed to read private key\n");
788 return;
789 }
790 buf += read;
791 rp_len = ntohs (im->rp_uri_len);
792 rp = buf;
793 buf += rp_len;
795 attrs_len = ntohs (im->attr_len);
797 attrs_len);
798 for (le = attrs->list_head; NULL != le; le = le->next)
800 "List entry: %s\n", le->attribute->name);
801
802 tio->r_id = ntohl (im->id);
803 tio->client = idp;
804 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
806 attrs,
807 rp,
809 tio);
812}
813
814
815/**********************************************************
816* Revocation
817**********************************************************/
818
825static void
826revoke_result_cb (void *cls, int32_t success)
827{
828 struct TicketRevocationOperation *rop = cls;
829 struct GNUNET_MQ_Envelope *env;
830 struct RevokeTicketResultMessage *trm;
831
833 "Sending REVOKE_TICKET_RESULT message\n");
834 rop->rh = NULL;
836 trm->id = htonl (rop->r_id);
837 trm->success = htonl (success);
838 GNUNET_MQ_send (rop->client->mq, env);
841 rop);
842 GNUNET_free (rop);
843}
844
845
853static int
855{
856 uint16_t size;
857 size_t key_len;
858 size_t tkt_len;
859
860 size = ntohs (rm->header.size);
861 key_len = ntohs (rm->key_len);
862 tkt_len = ntohs (rm->tkt_len);
863
864 if (size != sizeof(struct RevokeTicketMessage) + key_len + tkt_len)
865 {
866 GNUNET_break (0);
867 return GNUNET_SYSERR;
868 }
869 return GNUNET_OK;
870}
871
872
879static void
881{
882 struct TicketRevocationOperation *rop;
883 struct IdpClient *idp = cls;
886 size_t key_len;
887 size_t read;
888 char *buf;
889
890 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
891 key_len = ntohs (rm->key_len);
892 buf = (char *) &rm[1];
893 if ((GNUNET_SYSERR ==
895 &identity, &read)) ||
896 (read != key_len))
897 {
899 "Failed to read private key\n");
901 return;
902 }
903 buf += read;
904 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
906 rop->r_id = ntohl (rm->id);
907 rop->client = idp;
908 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
909 rop->rh
912}
913
914
924static void
926 const struct GNUNET_CRYPTO_PublicKey *identity,
927 const struct GNUNET_RECLAIM_AttributeList *attrs,
928 const struct GNUNET_RECLAIM_PresentationList *presentations,
929 int32_t success,
930 const char *emsg)
931{
932 struct ConsumeTicketOperation *cop = cls;
933 struct ConsumeTicketResultMessage *crm;
934 struct GNUNET_MQ_Envelope *env;
935 char *data_tmp;
936 size_t attrs_len = 0;
937 size_t pres_len = 0;
938 size_t key_len;
939 ssize_t written;
940
941 if (GNUNET_OK != success)
942 {
943 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
944 }
947 presentations);
950 "Sending CONSUME_TICKET_RESULT message\n");
952 attrs_len + pres_len + key_len,
954 crm->id = htonl (cop->r_id);
955 crm->attrs_len = htons (attrs_len);
956 crm->presentations_len = htons (pres_len);
957 crm->key_len = htons (key_len);
958 crm->result = htons (success);
959 data_tmp = (char *) &crm[1];
961 data_tmp,
962 key_len);
963 GNUNET_assert (0 <= written);
964 data_tmp += written;
966 data_tmp += attrs_len;
967 GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
968 GNUNET_MQ_send (cop->client->mq, env);
971 cop);
972 GNUNET_free (cop);
973}
974
975
982static int
984{
985 uint16_t size;
986 uint16_t tkt_size;
987 uint16_t rp_uri_size;
988
989 size = ntohs (cm->header.size);
990 tkt_size = ntohs (cm->tkt_len);
991 rp_uri_size = ntohs (cm->rp_uri_len);
992 if (size < sizeof(struct ConsumeTicketMessage) + tkt_size + rp_uri_size)
993 {
994 GNUNET_break (0);
995 return GNUNET_SYSERR;
996 }
997 return GNUNET_OK;
998}
999
1000
1007static void
1009{
1010 struct ConsumeTicketOperation *cop;
1011 struct IdpClient *idp = cls;
1013 char *buf;
1014 const char *rp_uri;
1015
1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1017 buf = (char*) &cm[1];
1018 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
1019 rp_uri = buf + ntohs (cm->tkt_len);
1020 cop = GNUNET_new (struct ConsumeTicketOperation);
1021 cop->r_id = ntohl (cm->id);
1022 cop->client = idp;
1023 cop->ch
1025 rp_uri,
1027 cop);
1028 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
1030}
1031
1032
1033/*****************************************
1034* Attribute store
1035*****************************************/
1036
1037
1045static void
1047{
1048 struct AttributeStoreHandle *ash = cls;
1049 struct GNUNET_MQ_Envelope *env;
1050 struct SuccessResultMessage *acr_msg;
1051
1052 ash->ns_qe = NULL;
1054 ash->client->store_op_tail,
1055 ash);
1056
1057 if (GNUNET_EC_NONE != ec)
1058 {
1060 "Failed to store attribute %s\n",
1062 cleanup_as_handle (ash);
1064 return;
1065 }
1066
1067 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1069 acr_msg->id = htonl (ash->r_id);
1070 acr_msg->op_result = htonl (GNUNET_OK);
1071 GNUNET_MQ_send (ash->client->mq, env);
1072 cleanup_as_handle (ash);
1073}
1074
1075
1081static void
1083{
1084 struct AttributeStoreHandle *ash = cls;
1085 struct GNUNET_GNSRECORD_Data rd[1];
1086 char *buf;
1087 char *label;
1088 size_t buf_size;
1089
1090 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
1092 buf = GNUNET_malloc (buf_size);
1093 // Give the ash a new id if unset
1097 label
1099 sizeof (ash->claim->id));
1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1101
1102 rd[0].data_size = buf_size;
1103 rd[0].data = buf;
1108 &ash->identity,
1109 label,
1110 1,
1111 rd,
1113 ash);
1114 GNUNET_free (buf);
1115 GNUNET_free (label);
1116}
1117
1118
1125static int
1127 const struct AttributeStoreMessage *sam)
1128{
1129 uint16_t size;
1130
1131 size = ntohs (sam->header.size);
1132 if (size <= sizeof(struct AttributeStoreMessage))
1133 {
1134 GNUNET_break (0);
1135 return GNUNET_SYSERR;
1136 }
1137 return GNUNET_OK;
1138}
1139
1140
1147static void
1149 const struct AttributeStoreMessage *sam)
1150{
1151 struct AttributeStoreHandle *ash;
1152 struct IdpClient *idp = cls;
1154 size_t data_len;
1155 size_t key_len;
1156 size_t read;
1157 char *buf;
1158
1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1160
1161 data_len = ntohs (sam->attr_len);
1162 key_len = ntohs (sam->key_len);
1163 buf = (char *) &sam[1];
1164 if ((GNUNET_SYSERR ==
1166 &identity, &read)) ||
1167 (read != key_len))
1168 {
1170 "Failed to read private key\n");
1172 return;
1173 }
1174 buf += read;
1175 ash = GNUNET_new (struct AttributeStoreHandle);
1177 data_len,
1178 &ash->claim);
1179
1180 ash->r_id = ntohl (sam->id);
1181 ash->identity = identity;
1182 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1184
1186 ash->client = idp;
1187 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1189}
1190
1191
1199static void
1201{
1202 struct AttributeStoreHandle *ash = cls;
1203 struct GNUNET_MQ_Envelope *env;
1204 struct SuccessResultMessage *acr_msg;
1205
1206 ash->ns_qe = NULL;
1208 ash->client->store_op_tail,
1209 ash);
1210
1211 if (GNUNET_EC_NONE != ec)
1212 {
1214 "Failed to store credential: %s\n",
1216 cleanup_as_handle (ash);
1218 return;
1219 }
1220
1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1223 acr_msg->id = htonl (ash->r_id);
1224 acr_msg->op_result = htonl (GNUNET_OK);
1225 GNUNET_MQ_send (ash->client->mq, env);
1226 cleanup_as_handle (ash);
1227}
1228
1229
1235static void
1236cred_error (void *cls)
1237{
1238 struct AttributeStoreHandle *ash = cls;
1240 "Failed to check for existing credential.\n");
1241 cleanup_as_handle (ash);
1243 return;
1244}
1245
1246
1256static void
1257cred_add_cb (void *cls,
1258 const struct GNUNET_CRYPTO_PrivateKey *zone,
1259 const char *label,
1260 unsigned int rd_count,
1261 const struct GNUNET_GNSRECORD_Data *rd)
1262{
1263 struct AttributeStoreHandle *ash = cls;
1264 struct GNUNET_GNSRECORD_Data rd_new[1];
1265 char *buf;
1266 size_t buf_size;
1267
1269 buf = GNUNET_malloc (buf_size);
1272 "Storing new credential under `%s'.\n",
1273 label);
1274 rd_new[0].data_size = buf_size;
1275 rd_new[0].data = buf;
1278 rd_new[0].expiration_time = ash->exp.rel_value_us;
1280 &ash->identity,
1281 label,
1282 1,
1283 rd_new,
1285 ash);
1286 GNUNET_free (buf);
1287 return;
1288}
1289
1290
1296static void
1298{
1299 struct AttributeStoreHandle *ash = cls;
1300 char *label;
1301
1302 // Give the ash a new id if unset
1306 sizeof (ash->credential->id));
1308 "Looking up existing data under label `%s'\n", label);
1310 &ash->identity,
1311 label,
1312 &cred_error,
1313 ash,
1314 &cred_add_cb,
1315 ash);
1316 GNUNET_free (label);
1317}
1318
1319
1326static int
1328 const struct AttributeStoreMessage *sam)
1329{
1330 uint16_t size;
1331
1332 size = ntohs (sam->header.size);
1333 if (size <= sizeof(struct AttributeStoreMessage))
1334 {
1335 GNUNET_break (0);
1336 return GNUNET_SYSERR;
1337 }
1338 return GNUNET_OK;
1339}
1340
1341
1348static void
1350 const struct AttributeStoreMessage *sam)
1351{
1352 struct AttributeStoreHandle *ash;
1353 struct IdpClient *idp = cls;
1355 size_t data_len;
1356 size_t key_len;
1357 size_t read;
1358 char *buf;
1359
1360 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1361
1362 data_len = ntohs (sam->attr_len);
1363 key_len = ntohs (sam->key_len);
1364 buf = (char *) &sam[1];
1365 if ((GNUNET_SYSERR ==
1367 &identity, &read)) ||
1368 (read != key_len))
1369 {
1371 "Failed to read private key\n");
1373 return;
1374 }
1375 buf += read;
1376 ash = GNUNET_new (struct AttributeStoreHandle);
1378 data_len);
1379
1380 ash->r_id = ntohl (sam->id);
1381 ash->identity = identity;
1382 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1384
1386 ash->client = idp;
1387 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1389}
1390
1391
1398static void
1399send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
1400{
1401 struct GNUNET_MQ_Envelope *env;
1402 struct SuccessResultMessage *acr_msg;
1403
1405 adh->client->delete_op_tail,
1406 adh);
1407
1408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1410 acr_msg->id = htonl (adh->r_id);
1411 acr_msg->op_result = htonl (success);
1412 GNUNET_MQ_send (adh->client->mq, env);
1413}
1414
1415
1426static void
1428 const struct GNUNET_CRYPTO_PrivateKey *zone,
1429 const char *label,
1430 unsigned int rd_count,
1431 const struct GNUNET_GNSRECORD_Data *rd)
1432{
1433 struct AttributeDeleteHandle *adh = cls;
1434 struct TicketRecordsEntry *le;
1437 int is_ticket = GNUNET_NO;
1438 for (int i = 0; i < rd_count; i++)
1439 {
1440 switch (rd[i].record_type)
1441 {
1445 rd[i].data_size,
1446 &ale->attribute);
1449 ale);
1450 break;
1454 rd[i].data_size);
1457 cle);
1458 break;
1461 "Ticket to delete found (%s)\n",
1462 label);
1463 is_ticket = GNUNET_YES;
1464 break;
1465 default:
1466 break;
1467 }
1468 if (GNUNET_YES == is_ticket)
1469 break;
1470 }
1471 if (GNUNET_YES == is_ticket)
1472 {
1473 le = GNUNET_new (struct TicketRecordsEntry);
1475 le->data = GNUNET_malloc (le->data_size);
1476 le->rd_count = rd_count;
1477 le->label = GNUNET_strdup (label);
1481 le);
1482 }
1484}
1485
1486
1491static void
1492update_tickets (void *cls);
1493
1494
1502static void
1504{
1505 struct AttributeDeleteHandle *adh = cls;
1506
1507 adh->ns_qe = NULL;
1509}
1510
1511
1519static void
1521{
1522 struct AttributeDeleteHandle *adh = cls;
1523 struct TicketRecordsEntry *le;
1524 int j = 0;
1525 int i = 0;
1528 struct GNUNET_RECLAIM_Presentation *presentation;
1529
1530 if (NULL == adh->tickets_to_update_head)
1531 {
1533 "Finished updating tickets, success\n");
1535 cleanup_adh (adh);
1536 return;
1537 }
1538 le = adh->tickets_to_update_head;
1541 le);
1542 {
1543 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1544 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1546 le->data,
1547 le->rd_count,
1548 rd))
1549 {
1551 "Unable to deserialize record data!\n");
1553 cleanup_adh (adh);
1554 return;
1555 }
1556 for (i = 0; i < le->rd_count; i++)
1557 {
1558 switch (rd[i].record_type)
1559 {
1561 for (ale = adh->existing_attributes->list_head; NULL != ale; ale =
1562 ale->next)
1563 {
1565 &ale->attribute->id))
1566 {
1568 "Found attribute %s, re-adding...\n",
1569 ale->attribute->name);
1570 rd_new[j] = rd[i];
1571 j++;
1572 break; // Found and added
1573 }
1574 }
1575 break;
1578 rd[i].data_size)
1579 ;
1580 for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1581 cle->next)
1582 {
1584 &presentation->credential_id,
1585 &cle->credential->id))
1586 {
1588 "Found presentation for credential %s, re-adding...\n",
1589 cle->credential->name);
1590 rd_new[j] = rd[i];
1591 j++;
1592 break; // Found and added
1593 }
1594 }
1595 GNUNET_free (presentation);
1596 break;
1598 rd_new[j] = rd[i];
1599 j++;
1600 break; // Found and added
1601 default:
1602 GNUNET_break (0);
1603 }
1604 }
1605
1607 "Updating ticket with %d entries (%d before)...\n",
1608 j, i);
1610 &adh->identity,
1611 le->label,
1612 j,
1613 rd_new,
1615 adh);
1616 GNUNET_free (le->label);
1617 GNUNET_free (le->data);
1618 GNUNET_free (le);
1619 }
1620}
1621
1622
1627static void
1628purge_attributes (void *cls);;
1629
1630static void
1632{
1633 struct AttributeDeleteHandle *adh = cls;
1634
1635 adh->ns_qe = NULL;
1636 if (GNUNET_EC_NONE != ec)
1637 {
1639 "Error deleting attribute %s\n",
1640 adh->label);
1642 cleanup_adh (adh);
1643 return;
1644 }
1645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1647}
1648
1649
1654static void
1656{
1657 struct AttributeDeleteHandle *adh = cls;
1660 char *label;
1661
1662 for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1663 {
1664 if (GNUNET_YES ==
1666 continue;
1667
1668 for (cle = adh->existing_credentials->list_head;
1669 NULL != cle; cle = cle->next)
1670 {
1671 if (GNUNET_YES !=
1673 &ale->attribute->credential))
1674 continue;
1675 break;
1676 }
1677 if (NULL == cle)
1678 {
1680 "Found attribute with missing credential\n");
1681 break;
1682 }
1683 }
1684 if (NULL == ale)
1685 {
1687 "Attributes consistent, updating tickets.\n");
1689 return;
1690 }
1692 "Attributes inconsistent, deleting offending attribute.\n");
1694 sizeof(ale->attribute->id));
1695
1697 &adh->identity,
1698 label,
1699 0,
1700 NULL,
1702 adh);
1705 ale);
1706 GNUNET_free (ale);
1707 GNUNET_free (label);
1708}
1709
1710
1716static void
1718{
1719 struct AttributeDeleteHandle *adh = cls;
1720 adh->ns_it = NULL;
1722}
1723
1724
1730static void
1732{
1733 struct AttributeDeleteHandle *adh = cls;
1734
1735 adh->ns_it = NULL;
1737 "Namestore error on consistency check\n");
1739 cleanup_adh (adh);
1740}
1741
1742
1749static void
1751{
1752 struct AttributeDeleteHandle *adh = cls;
1753
1756
1758 &adh->identity,
1760 adh,
1762 adh,
1764 adh);
1765}
1766
1767
1775static void
1777{
1778 struct AttributeDeleteHandle *adh = cls;
1779
1780 adh->ns_qe = NULL;
1781 if (GNUNET_EC_NONE != ec)
1782 {
1784 "Error deleting attribute %s\n",
1785 adh->label);
1787 cleanup_adh (adh);
1788 return;
1789 }
1790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1792}
1793
1794
1801static int
1803 const struct AttributeDeleteMessage *dam)
1804{
1805 uint16_t size;
1806
1807 size = ntohs (dam->header.size);
1808 if (size <= sizeof(struct AttributeDeleteMessage))
1809 {
1810 GNUNET_break (0);
1811 return GNUNET_SYSERR;
1812 }
1813 return GNUNET_OK;
1814}
1815
1816
1823static void
1825 const struct AttributeDeleteMessage *dam)
1826{
1827 struct AttributeDeleteHandle *adh;
1828 struct IdpClient *idp = cls;
1830 size_t data_len;
1831 size_t key_len;
1832 size_t read;
1833 char *buf;
1834
1835 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1836
1837 data_len = ntohs (dam->attr_len);
1838 key_len = ntohs (dam->key_len);
1839 buf = (char *) &dam[1];
1840 if ((GNUNET_SYSERR ==
1842 &identity, &read)) ||
1843 (read != key_len))
1844 {
1846 "Failed to read private key\n");
1848 return;
1849 }
1850 buf += read;
1851 adh = GNUNET_new (struct AttributeDeleteHandle);
1853 data_len,
1854 &adh->claim);
1855 adh->credential = NULL;
1856
1857 adh->r_id = ntohl (dam->id);
1858 adh->identity = identity;
1859 adh->label
1861 sizeof(adh->claim->id));
1863 adh->client = idp;
1864 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1866 &adh->identity,
1867 adh->label,
1868 0,
1869 NULL,
1871 adh);
1872}
1873
1874
1882static void
1884{
1885 struct AttributeDeleteHandle *adh = cls;
1886
1887 adh->ns_qe = NULL;
1888 if (GNUNET_EC_NONE != ec)
1889 {
1891 "Error deleting credential `%s'\n",
1892 adh->label);
1894 cleanup_adh (adh);
1895 return;
1896 }
1897 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1899}
1900
1901
1908static int
1910 const struct AttributeDeleteMessage *dam)
1911{
1912 uint16_t size;
1913
1914 size = ntohs (dam->header.size);
1915 if (size <= sizeof(struct AttributeDeleteMessage))
1916 {
1917 GNUNET_break (0);
1918 return GNUNET_SYSERR;
1919 }
1920 return GNUNET_OK;
1921}
1922
1923
1930static void
1932 const struct AttributeDeleteMessage *dam)
1933{
1934 struct AttributeDeleteHandle *adh;
1935 struct IdpClient *idp = cls;
1937 size_t data_len;
1938 size_t key_len;
1939 size_t read;
1940 char *buf;
1941
1942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1943
1944 data_len = ntohs (dam->attr_len);
1945 key_len = ntohs (dam->key_len);
1946 buf = (char *) &dam[1];
1947 if ((GNUNET_SYSERR ==
1949 &identity, &read)) ||
1950 (read != key_len))
1951 {
1953 "Failed to read private key\n");
1955 return;
1956 }
1957 buf += read;
1958 adh = GNUNET_new (struct AttributeDeleteHandle);
1960 data_len);
1961 adh->claim = NULL;
1962
1963 adh->r_id = ntohl (dam->id);
1964 adh->identity = identity;
1965 adh->label
1967 sizeof(adh->credential->id));
1969 adh->client = idp;
1970 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1972 &adh->identity,
1973 adh->label,
1974 0,
1975 NULL,
1977 adh);
1978}
1979
1980
1981/*************************************************
1982 * Attribute iteration
1983 *************************************************/
1984
1985
1991static void
1993{
1994 struct Iterator *ai = cls;
1995 struct GNUNET_MQ_Envelope *env;
1996 struct AttributeResultMessage *arm;
1997
1998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
2000 arm->id = htonl (ai->request_id);
2001 arm->attr_len = htons (0);
2002 arm->pkey_len = htons (0);
2003 GNUNET_MQ_send (ai->client->mq, env);
2004 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2005 ai->client->attr_iter_tail,
2006 ai);
2007 GNUNET_free (ai);
2008}
2009
2010
2016static void
2018{
2019 struct Iterator *ai = cls;
2020
2021 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2023}
2024
2025
2035static void
2036attr_iter_cb (void *cls,
2037 const struct GNUNET_CRYPTO_PrivateKey *zone,
2038 const char *label,
2039 unsigned int rd_count,
2040 const struct GNUNET_GNSRECORD_Data *rd)
2041{
2042 struct Iterator *ai = cls;
2043 struct GNUNET_MQ_Envelope *env;
2045 struct AttributeResultMessage *arm;
2046 char *data_tmp;
2047 size_t key_len;
2048 ssize_t written;
2049
2050 if ((rd_count != 1) ||
2052 {
2054 return;
2055 }
2056 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2057 label);
2059 "Sending ATTRIBUTE_RESULT message\n");
2062 env = GNUNET_MQ_msg_extra (arm,
2063 rd->data_size + key_len,
2065 arm->id = htonl (ai->request_id);
2066 arm->attr_len = htons (rd->data_size);
2067 data_tmp = (char *) &arm[1];
2068 arm->pkey_len = htons (key_len);
2070 data_tmp,
2071 key_len);
2072 GNUNET_assert (0 <= written);
2073 data_tmp += written;
2074 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2075 GNUNET_MQ_send (ai->client->mq, env);
2076}
2077
2078
2079static enum GNUNET_GenericReturnValue
2081 void *cls,
2082 const struct AttributeIterationStartMessage *ais_msg)
2083{
2084 uint16_t size;
2085 size_t key_len;
2086
2087 size = ntohs (ais_msg->header.size);
2088 key_len = ntohs (ais_msg->key_len);
2089
2090 if (size < key_len + sizeof(*ais_msg))
2091 {
2092 GNUNET_break (0);
2093 return GNUNET_SYSERR;
2094 }
2095 return GNUNET_OK;
2096}
2097
2098
2105static void
2107 const struct AttributeIterationStartMessage *ais_msg)
2108{
2109 struct IdpClient *idp = cls;
2110 struct Iterator *ai;
2112 size_t key_len;
2113 size_t read;
2114
2116 "Received ATTRIBUTE_ITERATION_START message\n");
2117 key_len = ntohs (ais_msg->key_len);
2118 if ((GNUNET_SYSERR ==
2120 key_len,
2121 &identity,
2122 &read)) ||
2123 (read != key_len))
2124 {
2126 "Failed to read private key.\n");
2128 return;
2129 }
2130 ai = GNUNET_new (struct Iterator);
2131 ai->request_id = ntohl (ais_msg->id);
2132 ai->client = idp;
2133 ai->identity = identity;
2134
2135 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
2137 &ai->identity,
2139 ai,
2140 &attr_iter_cb,
2141 ai,
2143 ai);
2145}
2146
2147
2154static void
2156 const struct AttributeIterationStopMessage *ais_msg)
2157{
2158 struct IdpClient *idp = cls;
2159 struct Iterator *ai;
2160 uint32_t rid;
2161
2163 "Received `%s' message\n",
2164 "ATTRIBUTE_ITERATION_STOP");
2165 rid = ntohl (ais_msg->id);
2166 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2167 if (ai->request_id == rid)
2168 break;
2169 if (NULL == ai)
2170 {
2171 GNUNET_break (0);
2173 return;
2174 }
2175 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
2176 GNUNET_free (ai);
2178}
2179
2180
2187static void
2189 const struct AttributeIterationNextMessage *ais_msg)
2190{
2191 struct IdpClient *idp = cls;
2192 struct Iterator *ai;
2193 uint32_t rid;
2194
2196 "Received ATTRIBUTE_ITERATION_NEXT message\n");
2197 rid = ntohl (ais_msg->id);
2198 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2199 if (ai->request_id == rid)
2200 break;
2201 if (NULL == ai)
2202 {
2203 GNUNET_break (0);
2205 return;
2206 }
2209}
2210
2211
2212/*************************************************
2213 * Credential iteration
2214 *************************************************/
2215
2216
2222static void
2224{
2225 struct Iterator *ai = cls;
2226 struct GNUNET_MQ_Envelope *env;
2227 struct CredentialResultMessage *arm;
2228
2229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2231 arm->id = htonl (ai->request_id);
2232 arm->credential_len = htons (0);
2233 arm->key_len = htons (0);
2234 GNUNET_MQ_send (ai->client->mq, env);
2235 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2236 ai->client->cred_iter_tail,
2237 ai);
2238 GNUNET_free (ai);
2239}
2240
2241
2247static void
2249{
2250 struct Iterator *ai = cls;
2251
2252 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2254}
2255
2256
2266static void
2267cred_iter_cb (void *cls,
2268 const struct GNUNET_CRYPTO_PrivateKey *zone,
2269 const char *label,
2270 unsigned int rd_count,
2271 const struct GNUNET_GNSRECORD_Data *rd)
2272{
2273 struct Iterator *ai = cls;
2274 struct GNUNET_MQ_Envelope *env;
2275 struct CredentialResultMessage *arm;
2277 char *data_tmp;
2278 size_t key_len;
2279 ssize_t written;
2280
2281 if ((rd_count != 1) ||
2283 {
2285 return;
2286 }
2287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2288 label);
2290 "Sending CREDENTIAL_RESULT message\n");
2293 env = GNUNET_MQ_msg_extra (arm,
2294 rd->data_size + key_len,
2296 arm->id = htonl (ai->request_id);
2297 arm->credential_len = htons (rd->data_size);
2298 arm->key_len = htons (key_len);
2299 data_tmp = (char *) &arm[1];
2301 data_tmp,
2302 key_len);
2303 GNUNET_assert (written >= 0);
2304 data_tmp += written;
2305 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2306 GNUNET_MQ_send (ai->client->mq, env);
2307}
2308
2309
2310static enum GNUNET_GenericReturnValue
2312 void *cls,
2313 const struct CredentialIterationStartMessage *cis_msg)
2314{
2315 uint16_t size;
2316 size_t key_len;
2317
2318 size = ntohs (cis_msg->header.size);
2319 key_len = ntohs (cis_msg->key_len);
2320
2321 if (size < key_len + sizeof(*cis_msg))
2322 {
2323 GNUNET_break (0);
2324 return GNUNET_SYSERR;
2325 }
2326 return GNUNET_OK;
2327}
2328
2329
2336static void
2338 const struct
2340{
2341 struct IdpClient *idp = cls;
2342 struct Iterator *ai;
2344 size_t key_len;
2345 size_t read;
2346
2348 "Received CREDENTIAL_ITERATION_START message\n");
2349 key_len = ntohs (ais_msg->key_len);
2350 if ((GNUNET_SYSERR ==
2352 key_len,
2353 &identity,
2354 &read)) ||
2355 (read != key_len))
2356 {
2358 "Failed to read private key.\n");
2360 return;
2361 }
2362 ai = GNUNET_new (struct Iterator);
2363 ai->request_id = ntohl (ais_msg->id);
2364 ai->client = idp;
2365 ai->identity = identity;
2366
2367 GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2368 ai);
2370 &ai->identity,
2372 ai,
2373 &cred_iter_cb,
2374 ai,
2376 ai);
2378}
2379
2380
2387static void
2389 const struct
2391{
2392 struct IdpClient *idp = cls;
2393 struct Iterator *ai;
2394 uint32_t rid;
2395
2397 "Received `%s' message\n",
2398 "CREDENTIAL_ITERATION_STOP");
2399 rid = ntohl (ais_msg->id);
2400 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2401 if (ai->request_id == rid)
2402 break;
2403 if (NULL == ai)
2404 {
2405 GNUNET_break (0);
2407 return;
2408 }
2409 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2410 ai);
2411 GNUNET_free (ai);
2413}
2414
2415
2422static void
2424 const struct
2426{
2427 struct IdpClient *idp = cls;
2428 struct Iterator *ai;
2429 uint32_t rid;
2430
2432 "Received CREDENTIAL_ITERATION_NEXT message\n");
2433 rid = ntohl (ais_msg->id);
2434 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2435 if (ai->request_id == rid)
2436 break;
2437 if (NULL == ai)
2438 {
2439 GNUNET_break (0);
2441 return;
2442 }
2445}
2446
2447
2448/******************************************************
2449 * Ticket iteration
2450 ******************************************************/
2451
2452static void
2453ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, const char*
2454 rp_uri)
2455{
2456 struct TicketIteration *ti = cls;
2457 struct GNUNET_MQ_Envelope *env;
2458 struct TicketResultMessage *trm;
2459 size_t tkt_len;
2460 size_t rp_uri_len;
2461
2462 if (NULL == ticket)
2463 tkt_len = 0;
2464 else
2465 tkt_len = strlen (ticket->gns_name) + 1;
2466
2467 if (NULL == rp_uri)
2468 rp_uri_len = 0;
2469 else
2470 rp_uri_len = strlen (rp_uri) + 1;
2471 env = GNUNET_MQ_msg_extra (trm,
2474 if (NULL == ticket)
2475 {
2476 /* send empty response to indicate end of list */
2479 ti);
2480 }
2481 else
2482 {
2483 memcpy (&trm[1], ticket, tkt_len);
2484 }
2485 memcpy ((char*) &trm[1] + tkt_len, rp_uri, rp_uri_len);
2486 trm->id = htonl (ti->r_id);
2487 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2488 trm->tkt_len = htons (tkt_len);
2489 trm->rp_uri_len = htons (rp_uri_len);
2490 trm->presentations_len = htons (0);
2491 GNUNET_MQ_send (ti->client->mq, env);
2492 if (NULL == ticket)
2493 GNUNET_free (ti);
2494}
2495
2496
2497static enum GNUNET_GenericReturnValue
2499 void *cls,
2500 const struct TicketIterationStartMessage *tis_msg)
2501{
2502 uint16_t size;
2503 size_t key_len;
2504
2505 size = ntohs (tis_msg->header.size);
2506 key_len = ntohs (tis_msg->key_len);
2507
2508 if (size < key_len + sizeof(*tis_msg))
2509 {
2510 GNUNET_break (0);
2511 return GNUNET_SYSERR;
2512 }
2513 return GNUNET_OK;
2514}
2515
2516
2523static void
2525 void *cls,
2526 const struct TicketIterationStartMessage *tis_msg)
2527{
2529 struct IdpClient *client = cls;
2530 struct TicketIteration *ti;
2531 size_t key_len;
2532 size_t read;
2533
2535 "Received TICKET_ITERATION_START message\n");
2536 key_len = ntohs (tis_msg->key_len);
2537 if ((GNUNET_SYSERR ==
2539 key_len,
2540 &identity,
2541 &read)) ||
2542 (read != key_len))
2543 {
2545 "Failed to read private key\n");
2547 return;
2548 }
2549 ti = GNUNET_new (struct TicketIteration);
2550 ti->r_id = ntohl (tis_msg->id);
2551 ti->client = client;
2554 ti);
2555 ti->iter
2558}
2559
2560
2567static void
2569 const struct TicketIterationStopMessage *tis_msg)
2570{
2571 struct IdpClient *client = cls;
2572 struct TicketIteration *ti;
2573 uint32_t rid;
2574
2576 "Received `%s' message\n",
2577 "TICKET_ITERATION_STOP");
2578 rid = ntohl (tis_msg->id);
2579 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2580 if (ti->r_id == rid)
2581 break;
2582 if (NULL == ti)
2583 {
2584 GNUNET_break (0);
2586 return;
2587 }
2591 ti);
2592 GNUNET_free (ti);
2594}
2595
2596
2603static void
2605 const struct TicketIterationNextMessage *tis_msg)
2606{
2607 struct IdpClient *client = cls;
2608 struct TicketIteration *ti;
2609 uint32_t rid;
2610
2612 "Received TICKET_ITERATION_NEXT message\n");
2613 rid = ntohl (tis_msg->id);
2614 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2615 if (ti->r_id == rid)
2616 break;
2617 if (NULL == ti)
2618 {
2619 GNUNET_break (0);
2621 return;
2622 }
2625}
2626
2627
2635static void
2636run (void *cls,
2637 const struct GNUNET_CONFIGURATION_Handle *c,
2638 struct GNUNET_SERVICE_Handle *server)
2639{
2640 cfg = c;
2641
2643 {
2645 "Unable to initialize TICKETS subsystem.\n");
2647 return;
2648 }
2649 // Connect to identity and namestore services
2651 if (NULL == nsh)
2652 {
2654 "error connecting to namestore");
2655 }
2656
2658}
2659
2660
2668static void
2671 void *app_ctx)
2672{
2673 struct IdpClient *idp = app_ctx;
2674
2675 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2678 idp);
2680}
2681
2682
2691static void *
2694 struct GNUNET_MQ_Handle *mq)
2695{
2696 struct IdpClient *idp;
2697
2698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2699 idp = GNUNET_new (struct IdpClient);
2700 idp->client = client;
2701 idp->mq = mq;
2704 idp);
2705 return idp;
2706}
2707
2708
2714 "reclaim",
2716 &run,
2719 NULL,
2720 GNUNET_MQ_hd_var_size (attribute_store_message,
2722 struct AttributeStoreMessage,
2723 NULL),
2724 GNUNET_MQ_hd_var_size (credential_store_message,
2726 struct AttributeStoreMessage,
2727 NULL),
2728 GNUNET_MQ_hd_var_size (attribute_delete_message,
2731 NULL),
2732 GNUNET_MQ_hd_var_size (credential_delete_message,
2735 NULL),
2736 GNUNET_MQ_hd_var_size (iteration_start,
2739 NULL),
2740 GNUNET_MQ_hd_fixed_size (iteration_next,
2743 NULL),
2744 GNUNET_MQ_hd_fixed_size (iteration_stop,
2747 NULL),
2748 GNUNET_MQ_hd_var_size (credential_iteration_start,
2751 NULL),
2752 GNUNET_MQ_hd_fixed_size (credential_iteration_next,
2755 NULL),
2756 GNUNET_MQ_hd_fixed_size (credential_iteration_stop,
2759 NULL),
2760
2761 GNUNET_MQ_hd_var_size (issue_ticket_message,
2763 struct IssueTicketMessage,
2764 NULL),
2765 GNUNET_MQ_hd_var_size (consume_ticket_message,
2767 struct ConsumeTicketMessage,
2768 NULL),
2769 GNUNET_MQ_hd_var_size (ticket_iteration_start,
2772 NULL),
2773 GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
2776 NULL),
2777 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
2780 NULL),
2781 GNUNET_MQ_hd_var_size (revoke_ticket_message,
2783 struct RevokeTicketMessage,
2784 NULL),
2786/* end of gnunet-service-reclaim.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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 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 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_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm)
Check revocation message format.
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 * 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 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_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 void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
static int check_attribute_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Check attribute delete message format.
static void handle_iteration_stop(void *cls, const struct AttributeIterationStopMessage *ais_msg)
Handle iteration stop message from client.
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), "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 attr_store_task(void *cls)
Add a new attribute.
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.
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_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.
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const char *rp, 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_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
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:85
#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:430
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.
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
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ 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:305
#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:61
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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.
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.
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_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.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#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.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy credential list.
#define GNUNET_RECLAIM_id_is_zero(a)
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.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize 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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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:1304
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2418
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
@ 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:787
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.
#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).
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:529
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:538
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:533
uint16_t rp_uri_len
RP URI length.
Definition: reclaim.h:548
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:543
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:560
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:584
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:589
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:569
uint16_t key_len
The length of the identity public key.
Definition: reclaim.h:594
uint32_t result
Result.
Definition: reclaim.h:574
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
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:325
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:390
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.
char gns_name[63 *2+2]
The ticket.
Entry in list of pending tasks.
Definition: scheduler.c:136
Handle to a client that is connected to a service.
Definition: service.c:249
Handle to a service.
Definition: service.c:116
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 rp_uri_len
The length of the relying party URI.
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 initiated 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 initiated 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:516
uint16_t tkt_len
Ticket length.
Definition: reclaim.h:506
uint16_t rp_uri_len
RP URI length.
Definition: reclaim.h:511
Ticket revocation request handle.
struct TicketRevocationOperation * next
DLL.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct TicketRevocationOperation * prev
DLL.
struct IdpClient * client
Client connection.