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 "reclaim.h"
26
28#include "gnunet_util_lib.h"
30#include "gnunet_protocols.h"
31#include "gnunet_reclaim_lib.h"
33
34
39
44
48static const struct GNUNET_CONFIGURATION_Handle *cfg;
49
53struct IdpClient;
54
59{
64
69
74
78 uint32_t r_id;
79
84};
85
86
91{
95 struct Iterator *next;
96
100 struct Iterator *prev;
101
106
111
116
120 uint32_t request_id;
121
125 void *ctx;
126};
127
128
133{
138
143
148
153
160
167
174
181
186
191
196
201
206
211
216
221
226
235
240};
241
242
247{
252
257
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
340
345
350
355
360
365
370
374 uint32_t r_id;
375};
376
377
382{
387
392
397
401 uint32_t r_id;
402
407};
408
409
414{
419
424
429
434
438 uint32_t r_id;
439};
440
441
446{
451
456
461
465 uint32_t r_id;
466};
467
468
472static struct IdpClient *client_list_head = NULL;
473
477static struct IdpClient *client_list_tail = NULL;
478
479
485static 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
524static 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
542static 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);
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 }
607}
608
609
613static 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
631static void
632do_shutdown (void *cls)
633{
634 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
635 cleanup ();
636}
637
638
647static 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 char *buf;
659
660 if (NULL != presentations)
661 {
662 pres_len =
664 }
665 if (NULL != ticket)
666 tkt_len = strlen (ticket->gns_name) + 1;
668 pres_len + tkt_len,
670 buf = (char*) &irm[1];
671 if (NULL != ticket)
672 {
673 memcpy (buf, ticket, tkt_len);
674 buf += tkt_len;
675 }
676 // TODO add success member
677 irm->id = htonl (r_id);
678 irm->tkt_len = htons (tkt_len);
679 irm->rp_uri_len = htons (0);
680 irm->presentations_len = htons (pres_len);
681 if (NULL != presentations)
682 {
684 buf);
685 }
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
687 GNUNET_MQ_send (client->mq, env);
688}
689
690
700static void
703 struct GNUNET_RECLAIM_PresentationList *presentations,
704 int32_t success,
705 const char *emsg)
706{
707 struct TicketIssueOperation *tio = cls;
708
709 if (GNUNET_OK != success)
710 {
711 send_ticket_result (tio->client, tio->r_id, NULL, NULL, GNUNET_SYSERR);
712 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
713 tio->client->issue_op_tail,
714 tio);
716 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
717 return;
718 }
719 send_ticket_result (tio->client, tio->r_id,
720 ticket, presentations, GNUNET_SYSERR);
721 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
722 tio->client->issue_op_tail,
723 tio);
725}
726
727
735static int
737{
738 uint16_t size;
739 size_t attrs_len;
740 size_t key_len;
741 size_t rp_len;
742
743 size = ntohs (im->header.size);
744 attrs_len = ntohs (im->attr_len);
745 key_len = ntohs (im->key_len);
746 rp_len = ntohs (im->rp_uri_len);
747 if (size != attrs_len + key_len + rp_len + sizeof(struct
749 {
750 GNUNET_break (0);
751 return GNUNET_SYSERR;
752 }
753 return GNUNET_OK;
754}
755
756
763static void
765{
767 struct IdpClient *idp = cls;
768 struct GNUNET_RECLAIM_AttributeList *attrs;
771 const char *rp;
772 size_t attrs_len;
773 size_t key_len;
774 size_t rp_len;
775 size_t read;
776 char *buf;
777
778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
779 key_len = ntohs (im->key_len);
780 buf = (char *) &im[1];
781 if ((GNUNET_SYSERR ==
783 &identity, &read)) ||
784 (read != key_len))
785 {
787 "Failed to read private key\n");
789 return;
790 }
791 buf += read;
792 rp_len = ntohs (im->rp_uri_len);
793 rp = buf;
794 buf += rp_len;
796 attrs_len = ntohs (im->attr_len);
798 attrs_len);
799 for (le = attrs->list_head; NULL != le; le = le->next)
801 "List entry: %s\n", le->attribute->name);
802
803 tio->r_id = ntohl (im->id);
804 tio->client = idp;
805 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
807 attrs,
808 rp,
810 tio);
813}
814
815
816/**********************************************************
817* Revocation
818**********************************************************/
819
826static void
827revoke_result_cb (void *cls, int32_t success)
828{
829 struct TicketRevocationOperation *rop = cls;
830 struct GNUNET_MQ_Envelope *env;
831 struct RevokeTicketResultMessage *trm;
832
834 "Sending REVOKE_TICKET_RESULT message\n");
835 rop->rh = NULL;
837 trm->id = htonl (rop->r_id);
838 trm->success = htonl (success);
839 GNUNET_MQ_send (rop->client->mq, env);
842 rop);
843 GNUNET_free (rop);
844}
845
846
854static int
856{
857 uint16_t size;
858 size_t key_len;
859 size_t tkt_len;
860
861 size = ntohs (rm->header.size);
862 key_len = ntohs (rm->key_len);
863 tkt_len = ntohs (rm->tkt_len);
864
865 if (size != sizeof(struct RevokeTicketMessage) + key_len + tkt_len)
866 {
867 GNUNET_break (0);
868 return GNUNET_SYSERR;
869 }
870 return GNUNET_OK;
871}
872
873
880static void
882{
883 struct TicketRevocationOperation *rop;
884 struct IdpClient *idp = cls;
887 size_t key_len;
888 size_t read;
889 char *buf;
890
891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
892 key_len = ntohs (rm->key_len);
893 buf = (char *) &rm[1];
894 if ((GNUNET_SYSERR ==
896 &identity, &read)) ||
897 (read != key_len))
898 {
900 "Failed to read private key\n");
902 return;
903 }
904 buf += read;
905 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
907 rop->r_id = ntohl (rm->id);
908 rop->client = idp;
909 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
910 rop->rh
913}
914
915
925static void
927 const struct GNUNET_CRYPTO_PublicKey *identity,
928 const struct GNUNET_RECLAIM_AttributeList *attrs,
929 const struct GNUNET_RECLAIM_PresentationList *presentations,
930 int32_t success,
931 const char *emsg)
932{
933 struct ConsumeTicketOperation *cop = cls;
934 struct ConsumeTicketResultMessage *crm;
935 struct GNUNET_MQ_Envelope *env;
936 char *data_tmp;
937 size_t attrs_len = 0;
938 size_t pres_len = 0;
939 size_t key_len;
940 ssize_t written;
941
942 if (GNUNET_OK != success)
943 {
944 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
945 }
948 presentations);
951 "Sending CONSUME_TICKET_RESULT message\n");
953 attrs_len + pres_len + key_len,
955 crm->id = htonl (cop->r_id);
956 crm->attrs_len = htons (attrs_len);
957 crm->presentations_len = htons (pres_len);
958 crm->key_len = htons (key_len);
959 crm->result = htons (success);
960 data_tmp = (char *) &crm[1];
962 data_tmp,
963 key_len);
964 GNUNET_assert (0 <= written);
965 data_tmp += written;
967 data_tmp += attrs_len;
968 GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
969 GNUNET_MQ_send (cop->client->mq, env);
972 cop);
973 GNUNET_free (cop);
974}
975
976
983static int
985{
986 uint16_t size;
987 uint16_t tkt_size;
988 uint16_t rp_uri_size;
989
990 size = ntohs (cm->header.size);
991 tkt_size = ntohs (cm->tkt_len);
992 rp_uri_size = ntohs (cm->rp_uri_len);
993 if (size < sizeof(struct ConsumeTicketMessage) + tkt_size + rp_uri_size)
994 {
995 GNUNET_break (0);
996 return GNUNET_SYSERR;
997 }
998 return GNUNET_OK;
999}
1000
1001
1008static void
1010{
1011 struct ConsumeTicketOperation *cop;
1012 struct IdpClient *idp = cls;
1014 char *buf;
1015 const char *rp_uri;
1016
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1018 buf = (char*) &cm[1];
1019 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
1020 rp_uri = buf + ntohs (cm->tkt_len);
1021 cop = GNUNET_new (struct ConsumeTicketOperation);
1022 cop->r_id = ntohl (cm->id);
1023 cop->client = idp;
1024 cop->ch
1026 rp_uri,
1028 cop);
1029 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
1031}
1032
1033
1034/*****************************************
1035* Attribute store
1036*****************************************/
1037
1038
1046static void
1048{
1049 struct AttributeStoreHandle *ash = cls;
1050 struct GNUNET_MQ_Envelope *env;
1051 struct SuccessResultMessage *acr_msg;
1052
1053 ash->ns_qe = NULL;
1055 ash->client->store_op_tail,
1056 ash);
1057
1058 if (GNUNET_EC_NONE != ec)
1059 {
1061 "Failed to store attribute %s\n",
1063 cleanup_as_handle (ash);
1065 return;
1066 }
1067
1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1070 acr_msg->id = htonl (ash->r_id);
1071 acr_msg->op_result = htonl (GNUNET_OK);
1072 GNUNET_MQ_send (ash->client->mq, env);
1073 cleanup_as_handle (ash);
1074}
1075
1076
1082static void
1084{
1085 struct AttributeStoreHandle *ash = cls;
1086 struct GNUNET_GNSRECORD_Data rd[1];
1087 char *buf;
1088 char *label;
1089 size_t buf_size;
1090
1091 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
1093 buf = GNUNET_malloc (buf_size);
1094 // Give the ash a new id if unset
1098 label
1100 sizeof (ash->claim->id));
1101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1102
1103 rd[0].data_size = buf_size;
1104 rd[0].data = buf;
1109 &ash->identity,
1110 label,
1111 1,
1112 rd,
1114 ash);
1115 GNUNET_free (buf);
1116 GNUNET_free (label);
1117}
1118
1119
1126static int
1128 const struct AttributeStoreMessage *sam)
1129{
1130 uint16_t size;
1131
1132 size = ntohs (sam->header.size);
1133 if (size <= sizeof(struct AttributeStoreMessage))
1134 {
1135 GNUNET_break (0);
1136 return GNUNET_SYSERR;
1137 }
1138 return GNUNET_OK;
1139}
1140
1141
1148static void
1150 const struct AttributeStoreMessage *sam)
1151{
1152 struct AttributeStoreHandle *ash;
1153 struct IdpClient *idp = cls;
1155 size_t data_len;
1156 size_t key_len;
1157 size_t read;
1158 char *buf;
1159
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1161
1162 data_len = ntohs (sam->attr_len);
1163 key_len = ntohs (sam->key_len);
1164 buf = (char *) &sam[1];
1165 if ((GNUNET_SYSERR ==
1167 &identity, &read)) ||
1168 (read != key_len))
1169 {
1171 "Failed to read private key\n");
1173 return;
1174 }
1175 buf += read;
1176 ash = GNUNET_new (struct AttributeStoreHandle);
1178 data_len,
1179 &ash->claim);
1180
1181 ash->r_id = ntohl (sam->id);
1182 ash->identity = identity;
1183 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1185
1187 ash->client = idp;
1188 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1190}
1191
1192
1200static void
1202{
1203 struct AttributeStoreHandle *ash = cls;
1204 struct GNUNET_MQ_Envelope *env;
1205 struct SuccessResultMessage *acr_msg;
1206
1207 ash->ns_qe = NULL;
1209 ash->client->store_op_tail,
1210 ash);
1211
1212 if (GNUNET_EC_NONE != ec)
1213 {
1215 "Failed to store credential: %s\n",
1217 cleanup_as_handle (ash);
1219 return;
1220 }
1221
1222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1224 acr_msg->id = htonl (ash->r_id);
1225 acr_msg->op_result = htonl (GNUNET_OK);
1226 GNUNET_MQ_send (ash->client->mq, env);
1227 cleanup_as_handle (ash);
1228}
1229
1230
1236static void
1237cred_error (void *cls)
1238{
1239 struct AttributeStoreHandle *ash = cls;
1241 "Failed to check for existing credential.\n");
1242 cleanup_as_handle (ash);
1244 return;
1245}
1246
1247
1257static void
1258cred_add_cb (void *cls,
1259 const struct GNUNET_CRYPTO_PrivateKey *zone,
1260 const char *label,
1261 unsigned int rd_count,
1262 const struct GNUNET_GNSRECORD_Data *rd)
1263{
1264 struct AttributeStoreHandle *ash = cls;
1265 struct GNUNET_GNSRECORD_Data rd_new[1];
1266 char *buf;
1267 size_t buf_size;
1268
1270 buf = GNUNET_malloc (buf_size);
1273 "Storing new credential under `%s'.\n",
1274 label);
1275 rd_new[0].data_size = buf_size;
1276 rd_new[0].data = buf;
1279 rd_new[0].expiration_time = ash->exp.rel_value_us;
1281 &ash->identity,
1282 label,
1283 1,
1284 rd_new,
1286 ash);
1287 GNUNET_free (buf);
1288 return;
1289}
1290
1291
1297static void
1299{
1300 struct AttributeStoreHandle *ash = cls;
1301 char *label;
1302
1303 // Give the ash a new id if unset
1307 sizeof (ash->credential->id));
1309 "Looking up existing data under label `%s'\n", label);
1311 &ash->identity,
1312 label,
1313 &cred_error,
1314 ash,
1315 &cred_add_cb,
1316 ash);
1317 GNUNET_free (label);
1318}
1319
1320
1327static int
1329 const struct AttributeStoreMessage *sam)
1330{
1331 uint16_t size;
1332
1333 size = ntohs (sam->header.size);
1334 if (size <= sizeof(struct AttributeStoreMessage))
1335 {
1336 GNUNET_break (0);
1337 return GNUNET_SYSERR;
1338 }
1339 return GNUNET_OK;
1340}
1341
1342
1349static void
1351 const struct AttributeStoreMessage *sam)
1352{
1353 struct AttributeStoreHandle *ash;
1354 struct IdpClient *idp = cls;
1356 size_t data_len;
1357 size_t key_len;
1358 size_t read;
1359 char *buf;
1360
1361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1362
1363 data_len = ntohs (sam->attr_len);
1364 key_len = ntohs (sam->key_len);
1365 buf = (char *) &sam[1];
1366 if ((GNUNET_SYSERR ==
1368 &identity, &read)) ||
1369 (read != key_len))
1370 {
1372 "Failed to read private key\n");
1374 return;
1375 }
1376 buf += read;
1377 ash = GNUNET_new (struct AttributeStoreHandle);
1379 data_len);
1380
1381 ash->r_id = ntohl (sam->id);
1382 ash->identity = identity;
1383 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1385
1387 ash->client = idp;
1388 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1390}
1391
1392
1399static void
1400send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
1401{
1402 struct GNUNET_MQ_Envelope *env;
1403 struct SuccessResultMessage *acr_msg;
1404
1406 adh->client->delete_op_tail,
1407 adh);
1408
1409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1411 acr_msg->id = htonl (adh->r_id);
1412 acr_msg->op_result = htonl (success);
1413 GNUNET_MQ_send (adh->client->mq, env);
1414}
1415
1416
1427static void
1429 const struct GNUNET_CRYPTO_PrivateKey *zone,
1430 const char *label,
1431 unsigned int rd_count,
1432 const struct GNUNET_GNSRECORD_Data *rd)
1433{
1434 struct AttributeDeleteHandle *adh = cls;
1435 struct TicketRecordsEntry *le;
1438 int is_ticket = GNUNET_NO;
1439 for (int i = 0; i < rd_count; i++)
1440 {
1441 switch (rd[i].record_type)
1442 {
1446 rd[i].data_size,
1447 &ale->attribute);
1450 ale);
1451 break;
1455 rd[i].data_size);
1458 cle);
1459 break;
1462 "Ticket to delete found (%s)\n",
1463 label);
1464 is_ticket = GNUNET_YES;
1465 break;
1466 default:
1467 break;
1468 }
1469 if (GNUNET_YES == is_ticket)
1470 break;
1471 }
1472 if (GNUNET_YES == is_ticket)
1473 {
1474 le = GNUNET_new (struct TicketRecordsEntry);
1476 le->data = GNUNET_malloc (le->data_size);
1477 le->rd_count = rd_count;
1478 le->label = GNUNET_strdup (label);
1482 le);
1483 }
1485}
1486
1487
1492static void
1493update_tickets (void *cls);
1494
1495
1503static void
1505{
1506 struct AttributeDeleteHandle *adh = cls;
1507
1508 adh->ns_qe = NULL;
1510}
1511
1512
1520static void
1522{
1523 struct AttributeDeleteHandle *adh = cls;
1524 struct TicketRecordsEntry *le;
1525 int j = 0;
1526 int i = 0;
1529 struct GNUNET_RECLAIM_Presentation *presentation;
1530
1531 if (NULL == adh->tickets_to_update_head)
1532 {
1534 "Finished updating tickets, success\n");
1536 cleanup_adh (adh);
1537 return;
1538 }
1539 le = adh->tickets_to_update_head;
1542 le);
1543 {
1544 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1545 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1547 le->data,
1548 le->rd_count,
1549 rd))
1550 {
1552 "Unable to deserialize record data!\n");
1554 cleanup_adh (adh);
1555 return;
1556 }
1557 for (i = 0; i < le->rd_count; i++)
1558 {
1559 switch (rd[i].record_type)
1560 {
1562 for (ale = adh->existing_attributes->list_head; NULL != ale; ale =
1563 ale->next)
1564 {
1566 &ale->attribute->id))
1567 {
1569 "Found attribute %s, re-adding...\n",
1570 ale->attribute->name);
1571 rd_new[j] = rd[i];
1572 j++;
1573 break; // Found and added
1574 }
1575 }
1576 break;
1579 rd[i].data_size)
1580 ;
1581 for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1582 cle->next)
1583 {
1585 &presentation->credential_id,
1586 &cle->credential->id))
1587 {
1589 "Found presentation for credential %s, re-adding...\n",
1590 cle->credential->name);
1591 rd_new[j] = rd[i];
1592 j++;
1593 break; // Found and added
1594 }
1595 }
1596 GNUNET_free (presentation);
1597 break;
1599 rd_new[j] = rd[i];
1600 j++;
1601 break; // Found and added
1602 default:
1603 GNUNET_break (0);
1604 }
1605 }
1606
1608 "Updating ticket with %d entries (%d before)...\n",
1609 j, i);
1611 &adh->identity,
1612 le->label,
1613 j,
1614 rd_new,
1616 adh);
1617 GNUNET_free (le->label);
1618 GNUNET_free (le->data);
1619 GNUNET_free (le);
1620 }
1621}
1622
1623
1628static void
1629purge_attributes (void *cls);;
1630
1631static void
1633{
1634 struct AttributeDeleteHandle *adh = cls;
1635
1636 adh->ns_qe = NULL;
1637 if (GNUNET_EC_NONE != ec)
1638 {
1640 "Error deleting attribute %s\n",
1641 adh->label);
1643 cleanup_adh (adh);
1644 return;
1645 }
1646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1648}
1649
1650
1655static void
1657{
1658 struct AttributeDeleteHandle *adh = cls;
1661 char *label;
1662
1663 for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1664 {
1665 if (GNUNET_YES ==
1667 continue;
1668
1669 for (cle = adh->existing_credentials->list_head;
1670 NULL != cle; cle = cle->next)
1671 {
1672 if (GNUNET_YES !=
1674 &ale->attribute->credential))
1675 continue;
1676 break;
1677 }
1678 if (NULL == cle)
1679 {
1681 "Found attribute with missing credential\n");
1682 break;
1683 }
1684 }
1685 if (NULL == ale)
1686 {
1688 "Attributes consistent, updating tickets.\n");
1690 return;
1691 }
1693 "Attributes inconsistent, deleting offending attribute.\n");
1695 sizeof(ale->attribute->id));
1696
1698 &adh->identity,
1699 label,
1700 0,
1701 NULL,
1703 adh);
1706 ale);
1707 GNUNET_free (ale);
1708 GNUNET_free (label);
1709}
1710
1711
1717static void
1719{
1720 struct AttributeDeleteHandle *adh = cls;
1721 adh->ns_it = NULL;
1723}
1724
1725
1731static void
1733{
1734 struct AttributeDeleteHandle *adh = cls;
1735
1736 adh->ns_it = NULL;
1738 "Namestore error on consistency check\n");
1740 cleanup_adh (adh);
1741}
1742
1743
1750static void
1752{
1753 struct AttributeDeleteHandle *adh = cls;
1754
1757
1759 &adh->identity,
1761 adh,
1763 adh,
1765 adh);
1766}
1767
1768
1776static void
1778{
1779 struct AttributeDeleteHandle *adh = cls;
1780
1781 adh->ns_qe = NULL;
1782 if (GNUNET_EC_NONE != ec)
1783 {
1785 "Error deleting attribute %s\n",
1786 adh->label);
1788 cleanup_adh (adh);
1789 return;
1790 }
1791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1793}
1794
1795
1802static int
1804 const struct AttributeDeleteMessage *dam)
1805{
1806 uint16_t size;
1807
1808 size = ntohs (dam->header.size);
1809 if (size <= sizeof(struct AttributeDeleteMessage))
1810 {
1811 GNUNET_break (0);
1812 return GNUNET_SYSERR;
1813 }
1814 return GNUNET_OK;
1815}
1816
1817
1824static void
1826 const struct AttributeDeleteMessage *dam)
1827{
1828 struct AttributeDeleteHandle *adh;
1829 struct IdpClient *idp = cls;
1831 size_t data_len;
1832 size_t key_len;
1833 size_t read;
1834 char *buf;
1835
1836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1837
1838 data_len = ntohs (dam->attr_len);
1839 key_len = ntohs (dam->key_len);
1840 buf = (char *) &dam[1];
1841 if ((GNUNET_SYSERR ==
1843 &identity, &read)) ||
1844 (read != key_len))
1845 {
1847 "Failed to read private key\n");
1849 return;
1850 }
1851 buf += read;
1852 adh = GNUNET_new (struct AttributeDeleteHandle);
1854 data_len,
1855 &adh->claim);
1856 adh->credential = NULL;
1857
1858 adh->r_id = ntohl (dam->id);
1859 adh->identity = identity;
1860 adh->label
1862 sizeof(adh->claim->id));
1864 adh->client = idp;
1865 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1867 &adh->identity,
1868 adh->label,
1869 0,
1870 NULL,
1872 adh);
1873}
1874
1875
1883static void
1885{
1886 struct AttributeDeleteHandle *adh = cls;
1887
1888 adh->ns_qe = NULL;
1889 if (GNUNET_EC_NONE != ec)
1890 {
1892 "Error deleting credential `%s'\n",
1893 adh->label);
1895 cleanup_adh (adh);
1896 return;
1897 }
1898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1900}
1901
1902
1909static int
1911 const struct AttributeDeleteMessage *dam)
1912{
1913 uint16_t size;
1914
1915 size = ntohs (dam->header.size);
1916 if (size <= sizeof(struct AttributeDeleteMessage))
1917 {
1918 GNUNET_break (0);
1919 return GNUNET_SYSERR;
1920 }
1921 return GNUNET_OK;
1922}
1923
1924
1931static void
1933 const struct AttributeDeleteMessage *dam)
1934{
1935 struct AttributeDeleteHandle *adh;
1936 struct IdpClient *idp = cls;
1938 size_t data_len;
1939 size_t key_len;
1940 size_t read;
1941 char *buf;
1942
1943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1944
1945 data_len = ntohs (dam->attr_len);
1946 key_len = ntohs (dam->key_len);
1947 buf = (char *) &dam[1];
1948 if ((GNUNET_SYSERR ==
1950 &identity, &read)) ||
1951 (read != key_len))
1952 {
1954 "Failed to read private key\n");
1956 return;
1957 }
1958 buf += read;
1959 adh = GNUNET_new (struct AttributeDeleteHandle);
1961 data_len);
1962 adh->claim = NULL;
1963
1964 adh->r_id = ntohl (dam->id);
1965 adh->identity = identity;
1966 adh->label
1968 sizeof(adh->credential->id));
1970 adh->client = idp;
1971 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1973 &adh->identity,
1974 adh->label,
1975 0,
1976 NULL,
1978 adh);
1979}
1980
1981
1982/*************************************************
1983 * Attribute iteration
1984 *************************************************/
1985
1986
1992static void
1994{
1995 struct Iterator *ai = cls;
1996 struct GNUNET_MQ_Envelope *env;
1997 struct AttributeResultMessage *arm;
1998
1999 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
2001 arm->id = htonl (ai->request_id);
2002 arm->attr_len = htons (0);
2003 arm->pkey_len = htons (0);
2004 GNUNET_MQ_send (ai->client->mq, env);
2005 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2006 ai->client->attr_iter_tail,
2007 ai);
2008 GNUNET_free (ai);
2009}
2010
2011
2017static void
2019{
2020 struct Iterator *ai = cls;
2021
2022 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2024}
2025
2026
2036static void
2037attr_iter_cb (void *cls,
2038 const struct GNUNET_CRYPTO_PrivateKey *zone,
2039 const char *label,
2040 unsigned int rd_count,
2041 const struct GNUNET_GNSRECORD_Data *rd)
2042{
2043 struct Iterator *ai = cls;
2044 struct GNUNET_MQ_Envelope *env;
2046 struct AttributeResultMessage *arm;
2047 char *data_tmp;
2048 size_t key_len;
2049 ssize_t written;
2050
2051 if ((rd_count != 1) ||
2053 {
2055 return;
2056 }
2057 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2058 label);
2060 "Sending ATTRIBUTE_RESULT message\n");
2063 env = GNUNET_MQ_msg_extra (arm,
2064 rd->data_size + key_len,
2066 arm->id = htonl (ai->request_id);
2067 arm->attr_len = htons (rd->data_size);
2068 data_tmp = (char *) &arm[1];
2069 arm->pkey_len = htons (key_len);
2071 data_tmp,
2072 key_len);
2073 GNUNET_assert (0 <= written);
2074 data_tmp += written;
2075 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2076 GNUNET_MQ_send (ai->client->mq, env);
2077}
2078
2079
2080static enum GNUNET_GenericReturnValue
2082 void *cls,
2083 const struct AttributeIterationStartMessage *ais_msg)
2084{
2085 uint16_t size;
2086 size_t key_len;
2087
2088 size = ntohs (ais_msg->header.size);
2089 key_len = ntohs (ais_msg->key_len);
2090
2091 if (size < key_len + sizeof(*ais_msg))
2092 {
2093 GNUNET_break (0);
2094 return GNUNET_SYSERR;
2095 }
2096 return GNUNET_OK;
2097}
2098
2099
2106static void
2108 const struct AttributeIterationStartMessage *ais_msg)
2109{
2110 struct IdpClient *idp = cls;
2111 struct Iterator *ai;
2113 size_t key_len;
2114 size_t read;
2115
2117 "Received ATTRIBUTE_ITERATION_START message\n");
2118 key_len = ntohs (ais_msg->key_len);
2119 if ((GNUNET_SYSERR ==
2121 key_len,
2122 &identity,
2123 &read)) ||
2124 (read != key_len))
2125 {
2127 "Failed to read private key.\n");
2129 return;
2130 }
2131 ai = GNUNET_new (struct Iterator);
2132 ai->request_id = ntohl (ais_msg->id);
2133 ai->client = idp;
2134 ai->identity = identity;
2135
2136 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
2138 &ai->identity,
2140 ai,
2141 &attr_iter_cb,
2142 ai,
2144 ai);
2146}
2147
2148
2155static void
2157 const struct AttributeIterationStopMessage *ais_msg)
2158{
2159 struct IdpClient *idp = cls;
2160 struct Iterator *ai;
2161 uint32_t rid;
2162
2164 "Received `%s' message\n",
2165 "ATTRIBUTE_ITERATION_STOP");
2166 rid = ntohl (ais_msg->id);
2167 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2168 if (ai->request_id == rid)
2169 break;
2170 if (NULL == ai)
2171 {
2172 GNUNET_break (0);
2174 return;
2175 }
2176 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
2177 GNUNET_free (ai);
2179}
2180
2181
2188static void
2190 const struct AttributeIterationNextMessage *ais_msg)
2191{
2192 struct IdpClient *idp = cls;
2193 struct Iterator *ai;
2194 uint32_t rid;
2195
2197 "Received ATTRIBUTE_ITERATION_NEXT message\n");
2198 rid = ntohl (ais_msg->id);
2199 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2200 if (ai->request_id == rid)
2201 break;
2202 if (NULL == ai)
2203 {
2204 GNUNET_break (0);
2206 return;
2207 }
2210}
2211
2212
2213/*************************************************
2214 * Credential iteration
2215 *************************************************/
2216
2217
2223static void
2225{
2226 struct Iterator *ai = cls;
2227 struct GNUNET_MQ_Envelope *env;
2228 struct CredentialResultMessage *arm;
2229
2230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2232 arm->id = htonl (ai->request_id);
2233 arm->credential_len = htons (0);
2234 arm->key_len = htons (0);
2235 GNUNET_MQ_send (ai->client->mq, env);
2236 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2237 ai->client->cred_iter_tail,
2238 ai);
2239 GNUNET_free (ai);
2240}
2241
2242
2248static void
2250{
2251 struct Iterator *ai = cls;
2252
2253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2255}
2256
2257
2267static void
2268cred_iter_cb (void *cls,
2269 const struct GNUNET_CRYPTO_PrivateKey *zone,
2270 const char *label,
2271 unsigned int rd_count,
2272 const struct GNUNET_GNSRECORD_Data *rd)
2273{
2274 struct Iterator *ai = cls;
2275 struct GNUNET_MQ_Envelope *env;
2276 struct CredentialResultMessage *arm;
2278 char *data_tmp;
2279 size_t key_len;
2280 ssize_t written;
2281
2282 if ((rd_count != 1) ||
2284 {
2286 return;
2287 }
2288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2289 label);
2291 "Sending CREDENTIAL_RESULT message\n");
2294 env = GNUNET_MQ_msg_extra (arm,
2295 rd->data_size + key_len,
2297 arm->id = htonl (ai->request_id);
2298 arm->credential_len = htons (rd->data_size);
2299 arm->key_len = htons (key_len);
2300 data_tmp = (char *) &arm[1];
2302 data_tmp,
2303 key_len);
2304 GNUNET_assert (written >= 0);
2305 data_tmp += written;
2306 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2307 GNUNET_MQ_send (ai->client->mq, env);
2308}
2309
2310
2311static enum GNUNET_GenericReturnValue
2313 void *cls,
2314 const struct CredentialIterationStartMessage *cis_msg)
2315{
2316 uint16_t size;
2317 size_t key_len;
2318
2319 size = ntohs (cis_msg->header.size);
2320 key_len = ntohs (cis_msg->key_len);
2321
2322 if (size < key_len + sizeof(*cis_msg))
2323 {
2324 GNUNET_break (0);
2325 return GNUNET_SYSERR;
2326 }
2327 return GNUNET_OK;
2328}
2329
2330
2337static void
2339 const struct
2341{
2342 struct IdpClient *idp = cls;
2343 struct Iterator *ai;
2345 size_t key_len;
2346 size_t read;
2347
2349 "Received CREDENTIAL_ITERATION_START message\n");
2350 key_len = ntohs (ais_msg->key_len);
2351 if ((GNUNET_SYSERR ==
2353 key_len,
2354 &identity,
2355 &read)) ||
2356 (read != key_len))
2357 {
2359 "Failed to read private key.\n");
2361 return;
2362 }
2363 ai = GNUNET_new (struct Iterator);
2364 ai->request_id = ntohl (ais_msg->id);
2365 ai->client = idp;
2366 ai->identity = identity;
2367
2368 GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2369 ai);
2371 &ai->identity,
2373 ai,
2374 &cred_iter_cb,
2375 ai,
2377 ai);
2379}
2380
2381
2388static void
2390 const struct
2392{
2393 struct IdpClient *idp = cls;
2394 struct Iterator *ai;
2395 uint32_t rid;
2396
2398 "Received `%s' message\n",
2399 "CREDENTIAL_ITERATION_STOP");
2400 rid = ntohl (ais_msg->id);
2401 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2402 if (ai->request_id == rid)
2403 break;
2404 if (NULL == ai)
2405 {
2406 GNUNET_break (0);
2408 return;
2409 }
2410 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2411 ai);
2412 GNUNET_free (ai);
2414}
2415
2416
2423static void
2425 const struct
2427{
2428 struct IdpClient *idp = cls;
2429 struct Iterator *ai;
2430 uint32_t rid;
2431
2433 "Received CREDENTIAL_ITERATION_NEXT message\n");
2434 rid = ntohl (ais_msg->id);
2435 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2436 if (ai->request_id == rid)
2437 break;
2438 if (NULL == ai)
2439 {
2440 GNUNET_break (0);
2442 return;
2443 }
2446}
2447
2448
2449/******************************************************
2450 * Ticket iteration
2451 ******************************************************/
2452
2453static void
2454ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, const char*
2455 rp_uri)
2456{
2457 struct TicketIteration *ti = cls;
2458 struct GNUNET_MQ_Envelope *env;
2459 struct TicketResultMessage *trm;
2460 size_t tkt_len;
2461 size_t rp_uri_len;
2462
2463 if (NULL == ticket)
2464 tkt_len = 0;
2465 else
2466 tkt_len = strlen (ticket->gns_name) + 1;
2467
2468 if (NULL == rp_uri)
2469 rp_uri_len = 0;
2470 else
2471 rp_uri_len = strlen (rp_uri) + 1;
2472 env = GNUNET_MQ_msg_extra (trm,
2475 if (NULL == ticket)
2476 {
2477 /* send empty response to indicate end of list */
2480 ti);
2481 }
2482 else
2483 {
2484 memcpy (&trm[1], ticket, tkt_len);
2485 }
2486 memcpy ((char*) &trm[1] + tkt_len, rp_uri, rp_uri_len);
2487 trm->id = htonl (ti->r_id);
2488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2489 trm->tkt_len = htons (tkt_len);
2490 trm->rp_uri_len = htons (rp_uri_len);
2491 trm->presentations_len = htons (0);
2492 GNUNET_MQ_send (ti->client->mq, env);
2493 if (NULL == ticket)
2494 GNUNET_free (ti);
2495}
2496
2497
2498static enum GNUNET_GenericReturnValue
2500 void *cls,
2501 const struct TicketIterationStartMessage *tis_msg)
2502{
2503 uint16_t size;
2504 size_t key_len;
2505
2506 size = ntohs (tis_msg->header.size);
2507 key_len = ntohs (tis_msg->key_len);
2508
2509 if (size < key_len + sizeof(*tis_msg))
2510 {
2511 GNUNET_break (0);
2512 return GNUNET_SYSERR;
2513 }
2514 return GNUNET_OK;
2515}
2516
2517
2524static void
2526 void *cls,
2527 const struct TicketIterationStartMessage *tis_msg)
2528{
2530 struct IdpClient *client = cls;
2531 struct TicketIteration *ti;
2532 size_t key_len;
2533 size_t read;
2534
2536 "Received TICKET_ITERATION_START message\n");
2537 key_len = ntohs (tis_msg->key_len);
2538 if ((GNUNET_SYSERR ==
2540 key_len,
2541 &identity,
2542 &read)) ||
2543 (read != key_len))
2544 {
2546 "Failed to read private key\n");
2548 return;
2549 }
2550 ti = GNUNET_new (struct TicketIteration);
2551 ti->r_id = ntohl (tis_msg->id);
2552 ti->client = client;
2555 ti);
2556 ti->iter
2559}
2560
2561
2568static void
2570 const struct TicketIterationStopMessage *tis_msg)
2571{
2572 struct IdpClient *client = cls;
2573 struct TicketIteration *ti;
2574 uint32_t rid;
2575
2577 "Received `%s' message\n",
2578 "TICKET_ITERATION_STOP");
2579 rid = ntohl (tis_msg->id);
2580 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2581 if (ti->r_id == rid)
2582 break;
2583 if (NULL == ti)
2584 {
2585 GNUNET_break (0);
2587 return;
2588 }
2592 ti);
2593 GNUNET_free (ti);
2595}
2596
2597
2604static void
2606 const struct TicketIterationNextMessage *tis_msg)
2607{
2608 struct IdpClient *client = cls;
2609 struct TicketIteration *ti;
2610 uint32_t rid;
2611
2613 "Received TICKET_ITERATION_NEXT message\n");
2614 rid = ntohl (tis_msg->id);
2615 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2616 if (ti->r_id == rid)
2617 break;
2618 if (NULL == ti)
2619 {
2620 GNUNET_break (0);
2622 return;
2623 }
2626}
2627
2628
2636static void
2637run (void *cls,
2638 const struct GNUNET_CONFIGURATION_Handle *c,
2639 struct GNUNET_SERVICE_Handle *server)
2640{
2641 cfg = c;
2642
2644 {
2646 "Unable to initialize TICKETS subsystem.\n");
2648 return;
2649 }
2650 // Connect to identity and namestore services
2652 if (NULL == nsh)
2653 {
2655 "error connecting to namestore");
2656 }
2657
2659}
2660
2661
2669static void
2672 void *app_ctx)
2673{
2674 struct IdpClient *idp = app_ctx;
2675
2676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2679 idp);
2681}
2682
2683
2692static void *
2695 struct GNUNET_MQ_Handle *mq)
2696{
2697 struct IdpClient *idp;
2698
2699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2700 idp = GNUNET_new (struct IdpClient);
2701 idp->client = client;
2702 idp->mq = mq;
2705 idp);
2706 return idp;
2707}
2708
2709
2715 "reclaim",
2717 &run,
2720 NULL,
2721 GNUNET_MQ_hd_var_size (attribute_store_message,
2723 struct AttributeStoreMessage,
2724 NULL),
2725 GNUNET_MQ_hd_var_size (credential_store_message,
2727 struct AttributeStoreMessage,
2728 NULL),
2729 GNUNET_MQ_hd_var_size (attribute_delete_message,
2732 NULL),
2733 GNUNET_MQ_hd_var_size (credential_delete_message,
2736 NULL),
2737 GNUNET_MQ_hd_var_size (iteration_start,
2740 NULL),
2741 GNUNET_MQ_hd_fixed_size (iteration_next,
2744 NULL),
2745 GNUNET_MQ_hd_fixed_size (iteration_stop,
2748 NULL),
2749 GNUNET_MQ_hd_var_size (credential_iteration_start,
2752 NULL),
2753 GNUNET_MQ_hd_fixed_size (credential_iteration_next,
2756 NULL),
2757 GNUNET_MQ_hd_fixed_size (credential_iteration_stop,
2760 NULL),
2761
2762 GNUNET_MQ_hd_var_size (issue_ticket_message,
2764 struct IssueTicketMessage,
2765 NULL),
2766 GNUNET_MQ_hd_var_size (consume_ticket_message,
2768 struct ConsumeTicketMessage,
2769 NULL),
2770 GNUNET_MQ_hd_var_size (ticket_iteration_start,
2773 NULL),
2774 GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
2777 NULL),
2778 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
2781 NULL),
2782 GNUNET_MQ_hd_var_size (revoke_ticket_message,
2784 struct RevokeTicketMessage,
2785 NULL),
2787/* 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
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.
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).
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.
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.