GNUnet 0.21.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 "platform.h"
26#include "gnunet_util_lib.h"
29#include "gnunet_protocols.h"
30#include "gnunet_reclaim_lib.h"
32#include "reclaim.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
1526 if (NULL == adh->tickets_to_update_head)
1527 {
1529 "Finished updating tickets, success\n");
1531 cleanup_adh (adh);
1532 return;
1533 }
1534 le = adh->tickets_to_update_head;
1537 le);
1538 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1539 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1541 le->data,
1542 le->rd_count,
1543 rd))
1544 {
1546 "Unable to deserialize record data!\n");
1548 cleanup_adh (adh);
1549 return;
1550 }
1551 int j = 0;
1552 int i = 0;
1555 struct GNUNET_RECLAIM_Presentation *presentation;
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, readding...\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 for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1580 cle->next)
1581 {
1583 &presentation->credential_id,
1584 &cle->credential->id))
1585 {
1587 "Found presentation for credential %s, readding...\n",
1588 cle->credential->name);
1589 rd_new[j] = rd[i];
1590 j++;
1591 break; // Found and added
1592 }
1593 }
1594 GNUNET_free (presentation);
1595 break;
1597 rd_new[j] = rd[i];
1598 j++;
1599 break; // Found and added
1600 default:
1601 GNUNET_break (0);
1602 }
1603 }
1605 "Updating ticket with %d entries (%d before)...\n",
1606 j, i);
1608 &adh->identity,
1609 le->label,
1610 j,
1611 rd_new,
1613 adh);
1614 GNUNET_free (le->label);
1615 GNUNET_free (le->data);
1616 GNUNET_free (le);
1617}
1618
1619
1624static void
1625purge_attributes (void *cls);;
1626
1627static void
1629{
1630 struct AttributeDeleteHandle *adh = cls;
1631
1632 adh->ns_qe = NULL;
1633 if (GNUNET_EC_NONE != ec)
1634 {
1636 "Error deleting attribute %s\n",
1637 adh->label);
1639 cleanup_adh (adh);
1640 return;
1641 }
1642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1644}
1645
1646
1651static void
1653{
1654 struct AttributeDeleteHandle *adh = cls;
1657
1658 for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1659 {
1660 if (GNUNET_YES ==
1662 continue;
1663
1664 for (cle = adh->existing_credentials->list_head;
1665 NULL != cle; cle = cle->next)
1666 {
1667 if (GNUNET_YES !=
1669 &ale->attribute->credential))
1670 continue;
1671 break;
1672 }
1673 if (NULL == cle)
1674 {
1676 "Found attribute with missing credential\n");
1677 break;
1678 }
1679 }
1680 if (NULL == ale)
1681 {
1683 "Attributes consistent, updating tickets.\n");
1685 return;
1686 }
1688 "Attributes inconsistent, deleting offending attribute.\n");
1689 char *label
1691 sizeof(ale->attribute->id));
1692
1694 &adh->identity,
1695 label,
1696 0,
1697 NULL,
1699 adh);
1702 ale);
1703 GNUNET_free (ale);
1704 GNUNET_free (label);
1705}
1706
1707
1713static void
1715{
1716 struct AttributeDeleteHandle *adh = cls;
1717 adh->ns_it = NULL;
1719}
1720
1721
1727static void
1729{
1730 struct AttributeDeleteHandle *adh = cls;
1731
1732 adh->ns_it = NULL;
1734 "Namestore error on consistency check\n");
1736 cleanup_adh (adh);
1737}
1738
1739
1746static void
1748{
1749 struct AttributeDeleteHandle *adh = cls;
1750
1753
1755 &adh->identity,
1757 adh,
1759 adh,
1761 adh);
1762}
1763
1764
1772static void
1774{
1775 struct AttributeDeleteHandle *adh = cls;
1776
1777 adh->ns_qe = NULL;
1778 if (GNUNET_EC_NONE != ec)
1779 {
1781 "Error deleting attribute %s\n",
1782 adh->label);
1784 cleanup_adh (adh);
1785 return;
1786 }
1787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1789}
1790
1791
1798static int
1800 const struct AttributeDeleteMessage *dam)
1801{
1802 uint16_t size;
1803
1804 size = ntohs (dam->header.size);
1805 if (size <= sizeof(struct AttributeDeleteMessage))
1806 {
1807 GNUNET_break (0);
1808 return GNUNET_SYSERR;
1809 }
1810 return GNUNET_OK;
1811}
1812
1813
1820static void
1822 const struct AttributeDeleteMessage *dam)
1823{
1824 struct AttributeDeleteHandle *adh;
1825 struct IdpClient *idp = cls;
1827 size_t data_len;
1828 size_t key_len;
1829 size_t read;
1830 char *buf;
1831
1832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1833
1834 data_len = ntohs (dam->attr_len);
1835 key_len = ntohs (dam->key_len);
1836 buf = (char *) &dam[1];
1837 if ((GNUNET_SYSERR ==
1839 &identity, &read)) ||
1840 (read != key_len))
1841 {
1843 "Failed to read private key\n");
1845 return;
1846 }
1847 buf += read;
1848 adh = GNUNET_new (struct AttributeDeleteHandle);
1850 data_len,
1851 &adh->claim);
1852 adh->credential = NULL;
1853
1854 adh->r_id = ntohl (dam->id);
1855 adh->identity = identity;
1856 adh->label
1858 sizeof(adh->claim->id));
1860 adh->client = idp;
1861 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1863 &adh->identity,
1864 adh->label,
1865 0,
1866 NULL,
1868 adh);
1869}
1870
1871
1879static void
1881{
1882 struct AttributeDeleteHandle *adh = cls;
1883
1884 adh->ns_qe = NULL;
1885 if (GNUNET_EC_NONE != ec)
1886 {
1888 "Error deleting credential `%s'\n",
1889 adh->label);
1891 cleanup_adh (adh);
1892 return;
1893 }
1894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1896}
1897
1898
1905static int
1907 const struct AttributeDeleteMessage *dam)
1908{
1909 uint16_t size;
1910
1911 size = ntohs (dam->header.size);
1912 if (size <= sizeof(struct AttributeDeleteMessage))
1913 {
1914 GNUNET_break (0);
1915 return GNUNET_SYSERR;
1916 }
1917 return GNUNET_OK;
1918}
1919
1920
1927static void
1929 const struct AttributeDeleteMessage *dam)
1930{
1931 struct AttributeDeleteHandle *adh;
1932 struct IdpClient *idp = cls;
1934 size_t data_len;
1935 size_t key_len;
1936 size_t read;
1937 char *buf;
1938
1939 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1940
1941 data_len = ntohs (dam->attr_len);
1942 key_len = ntohs (dam->key_len);
1943 buf = (char *) &dam[1];
1944 if ((GNUNET_SYSERR ==
1946 &identity, &read)) ||
1947 (read != key_len))
1948 {
1950 "Failed to read private key\n");
1952 return;
1953 }
1954 buf += read;
1955 adh = GNUNET_new (struct AttributeDeleteHandle);
1957 data_len);
1958 adh->claim = NULL;
1959
1960 adh->r_id = ntohl (dam->id);
1961 adh->identity = identity;
1962 adh->label
1964 sizeof(adh->credential->id));
1966 adh->client = idp;
1967 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1969 &adh->identity,
1970 adh->label,
1971 0,
1972 NULL,
1974 adh);
1975}
1976
1977
1978/*************************************************
1979 * Attribute iteration
1980 *************************************************/
1981
1982
1988static void
1990{
1991 struct Iterator *ai = cls;
1992 struct GNUNET_MQ_Envelope *env;
1993 struct AttributeResultMessage *arm;
1994
1995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1997 arm->id = htonl (ai->request_id);
1998 arm->attr_len = htons (0);
1999 arm->pkey_len = htons (0);
2000 GNUNET_MQ_send (ai->client->mq, env);
2001 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2002 ai->client->attr_iter_tail,
2003 ai);
2004 GNUNET_free (ai);
2005}
2006
2007
2013static void
2015{
2016 struct Iterator *ai = cls;
2017
2018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2020}
2021
2022
2032static void
2033attr_iter_cb (void *cls,
2034 const struct GNUNET_CRYPTO_PrivateKey *zone,
2035 const char *label,
2036 unsigned int rd_count,
2037 const struct GNUNET_GNSRECORD_Data *rd)
2038{
2039 struct Iterator *ai = cls;
2040 struct GNUNET_MQ_Envelope *env;
2042 char *data_tmp;
2043 size_t key_len;
2044 ssize_t written;
2045
2046 if ((rd_count != 1) ||
2048 {
2050 return;
2051 }
2052 struct AttributeResultMessage *arm;
2053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2054 label);
2056 "Sending ATTRIBUTE_RESULT message\n");
2059 env = GNUNET_MQ_msg_extra (arm,
2060 rd->data_size + key_len,
2062 arm->id = htonl (ai->request_id);
2063 arm->attr_len = htons (rd->data_size);
2064 data_tmp = (char *) &arm[1];
2065 arm->pkey_len = htons (key_len);
2067 data_tmp,
2068 key_len);
2069 GNUNET_assert (0 <= written);
2070 data_tmp += written;
2071 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2072 GNUNET_MQ_send (ai->client->mq, env);
2073}
2074
2075
2076static enum GNUNET_GenericReturnValue
2078 void *cls,
2079 const struct AttributeIterationStartMessage *ais_msg)
2080{
2081 uint16_t size;
2082 size_t key_len;
2083
2084 size = ntohs (ais_msg->header.size);
2085 key_len = ntohs (ais_msg->key_len);
2086
2087 if (size < key_len + sizeof(*ais_msg))
2088 {
2089 GNUNET_break (0);
2090 return GNUNET_SYSERR;
2091 }
2092 return GNUNET_OK;
2093}
2094
2095
2102static void
2104 const struct AttributeIterationStartMessage *ais_msg)
2105{
2106 struct IdpClient *idp = cls;
2107 struct Iterator *ai;
2109 size_t key_len;
2110 size_t read;
2111
2113 "Received ATTRIBUTE_ITERATION_START message\n");
2114 key_len = ntohs (ais_msg->key_len);
2115 if ((GNUNET_SYSERR ==
2117 key_len,
2118 &identity,
2119 &read)) ||
2120 (read != key_len))
2121 {
2123 "Failed to read private key.\n");
2125 return;
2126 }
2127 ai = GNUNET_new (struct Iterator);
2128 ai->request_id = ntohl (ais_msg->id);
2129 ai->client = idp;
2130 ai->identity = identity;
2131
2132 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
2134 &ai->identity,
2136 ai,
2137 &attr_iter_cb,
2138 ai,
2140 ai);
2142}
2143
2144
2151static void
2153 const struct AttributeIterationStopMessage *ais_msg)
2154{
2155 struct IdpClient *idp = cls;
2156 struct Iterator *ai;
2157 uint32_t rid;
2158
2160 "Received `%s' message\n",
2161 "ATTRIBUTE_ITERATION_STOP");
2162 rid = ntohl (ais_msg->id);
2163 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2164 if (ai->request_id == rid)
2165 break;
2166 if (NULL == ai)
2167 {
2168 GNUNET_break (0);
2170 return;
2171 }
2172 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
2173 GNUNET_free (ai);
2175}
2176
2177
2184static void
2186 const struct AttributeIterationNextMessage *ais_msg)
2187{
2188 struct IdpClient *idp = cls;
2189 struct Iterator *ai;
2190 uint32_t rid;
2191
2193 "Received ATTRIBUTE_ITERATION_NEXT message\n");
2194 rid = ntohl (ais_msg->id);
2195 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2196 if (ai->request_id == rid)
2197 break;
2198 if (NULL == ai)
2199 {
2200 GNUNET_break (0);
2202 return;
2203 }
2206}
2207
2208
2209/*************************************************
2210 * Credential iteration
2211 *************************************************/
2212
2213
2219static void
2221{
2222 struct Iterator *ai = cls;
2223 struct GNUNET_MQ_Envelope *env;
2224 struct CredentialResultMessage *arm;
2225
2226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2228 arm->id = htonl (ai->request_id);
2229 arm->credential_len = htons (0);
2230 arm->key_len = htons (0);
2231 GNUNET_MQ_send (ai->client->mq, env);
2232 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2233 ai->client->cred_iter_tail,
2234 ai);
2235 GNUNET_free (ai);
2236}
2237
2238
2244static void
2246{
2247 struct Iterator *ai = cls;
2248
2249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2251}
2252
2253
2263static void
2264cred_iter_cb (void *cls,
2265 const struct GNUNET_CRYPTO_PrivateKey *zone,
2266 const char *label,
2267 unsigned int rd_count,
2268 const struct GNUNET_GNSRECORD_Data *rd)
2269{
2270 struct Iterator *ai = cls;
2271 struct GNUNET_MQ_Envelope *env;
2272 struct CredentialResultMessage *arm;
2274 char *data_tmp;
2275 size_t key_len;
2276 ssize_t written;
2277
2278 if ((rd_count != 1) ||
2280 {
2282 return;
2283 }
2284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2285 label);
2287 "Sending CREDENTIAL_RESULT message\n");
2290 env = GNUNET_MQ_msg_extra (arm,
2291 rd->data_size + key_len,
2293 arm->id = htonl (ai->request_id);
2294 arm->credential_len = htons (rd->data_size);
2295 arm->key_len = htons (key_len);
2296 data_tmp = (char *) &arm[1];
2298 data_tmp,
2299 key_len);
2300 GNUNET_assert (written >= 0);
2301 data_tmp += written;
2302 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2303 GNUNET_MQ_send (ai->client->mq, env);
2304}
2305
2306
2307static enum GNUNET_GenericReturnValue
2309 void *cls,
2310 const struct CredentialIterationStartMessage *cis_msg)
2311{
2312 uint16_t size;
2313 size_t key_len;
2314
2315 size = ntohs (cis_msg->header.size);
2316 key_len = ntohs (cis_msg->key_len);
2317
2318 if (size < key_len + sizeof(*cis_msg))
2319 {
2320 GNUNET_break (0);
2321 return GNUNET_SYSERR;
2322 }
2323 return GNUNET_OK;
2324}
2325
2326
2333static void
2335 const struct
2337{
2338 struct IdpClient *idp = cls;
2339 struct Iterator *ai;
2341 size_t key_len;
2342 size_t read;
2343
2345 "Received CREDENTIAL_ITERATION_START message\n");
2346 key_len = ntohs (ais_msg->key_len);
2347 if ((GNUNET_SYSERR ==
2349 key_len,
2350 &identity,
2351 &read)) ||
2352 (read != key_len))
2353 {
2355 "Failed to read private key.\n");
2357 return;
2358 }
2359 ai = GNUNET_new (struct Iterator);
2360 ai->request_id = ntohl (ais_msg->id);
2361 ai->client = idp;
2362 ai->identity = identity;
2363
2364 GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2365 ai);
2367 &ai->identity,
2369 ai,
2370 &cred_iter_cb,
2371 ai,
2373 ai);
2375}
2376
2377
2384static void
2386 const struct
2388{
2389 struct IdpClient *idp = cls;
2390 struct Iterator *ai;
2391 uint32_t rid;
2392
2394 "Received `%s' message\n",
2395 "CREDENTIAL_ITERATION_STOP");
2396 rid = ntohl (ais_msg->id);
2397 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2398 if (ai->request_id == rid)
2399 break;
2400 if (NULL == ai)
2401 {
2402 GNUNET_break (0);
2404 return;
2405 }
2406 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2407 ai);
2408 GNUNET_free (ai);
2410}
2411
2412
2419static void
2421 const struct
2423{
2424 struct IdpClient *idp = cls;
2425 struct Iterator *ai;
2426 uint32_t rid;
2427
2429 "Received CREDENTIAL_ITERATION_NEXT message\n");
2430 rid = ntohl (ais_msg->id);
2431 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2432 if (ai->request_id == rid)
2433 break;
2434 if (NULL == ai)
2435 {
2436 GNUNET_break (0);
2438 return;
2439 }
2442}
2443
2444
2445/******************************************************
2446 * Ticket iteration
2447 ******************************************************/
2448
2449static void
2450ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, const char*
2451 rp_uri)
2452{
2453 struct TicketIteration *ti = cls;
2454 struct GNUNET_MQ_Envelope *env;
2455 struct TicketResultMessage *trm;
2456 size_t tkt_len;
2457 size_t rp_uri_len;
2458
2459 if (NULL == ticket)
2460 tkt_len = 0;
2461 else
2462 tkt_len = strlen (ticket->gns_name) + 1;
2463
2464 if (NULL == rp_uri)
2465 rp_uri_len = 0;
2466 else
2467 rp_uri_len = strlen (rp_uri) + 1;
2468 env = GNUNET_MQ_msg_extra (trm,
2471 if (NULL == ticket)
2472 {
2473 /* send empty response to indicate end of list */
2476 ti);
2477 }
2478 else
2479 {
2480 memcpy (&trm[1], ticket, tkt_len);
2481 }
2482 memcpy ((char*) &trm[1] + tkt_len, rp_uri, rp_uri_len);
2483 trm->id = htonl (ti->r_id);
2484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2485 trm->tkt_len = htons (tkt_len);
2486 trm->rp_uri_len = htons (rp_uri_len);
2487 trm->presentations_len = htons (0);
2488 GNUNET_MQ_send (ti->client->mq, env);
2489 if (NULL == ticket)
2490 GNUNET_free (ti);
2491}
2492
2493
2494static enum GNUNET_GenericReturnValue
2496 void *cls,
2497 const struct TicketIterationStartMessage *tis_msg)
2498{
2499 uint16_t size;
2500 size_t key_len;
2501
2502 size = ntohs (tis_msg->header.size);
2503 key_len = ntohs (tis_msg->key_len);
2504
2505 if (size < key_len + sizeof(*tis_msg))
2506 {
2507 GNUNET_break (0);
2508 return GNUNET_SYSERR;
2509 }
2510 return GNUNET_OK;
2511}
2512
2513
2520static void
2522 void *cls,
2523 const struct TicketIterationStartMessage *tis_msg)
2524{
2526 struct IdpClient *client = cls;
2527 struct TicketIteration *ti;
2528 size_t key_len;
2529 size_t read;
2530
2532 "Received TICKET_ITERATION_START message\n");
2533 key_len = ntohs (tis_msg->key_len);
2534 if ((GNUNET_SYSERR ==
2536 key_len,
2537 &identity,
2538 &read)) ||
2539 (read != key_len))
2540 {
2542 "Failed to read private key\n");
2544 return;
2545 }
2546 ti = GNUNET_new (struct TicketIteration);
2547 ti->r_id = ntohl (tis_msg->id);
2548 ti->client = client;
2551 ti);
2552 ti->iter
2555}
2556
2557
2564static void
2566 const struct TicketIterationStopMessage *tis_msg)
2567{
2568 struct IdpClient *client = cls;
2569 struct TicketIteration *ti;
2570 uint32_t rid;
2571
2573 "Received `%s' message\n",
2574 "TICKET_ITERATION_STOP");
2575 rid = ntohl (tis_msg->id);
2576 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2577 if (ti->r_id == rid)
2578 break;
2579 if (NULL == ti)
2580 {
2581 GNUNET_break (0);
2583 return;
2584 }
2588 ti);
2589 GNUNET_free (ti);
2591}
2592
2593
2600static void
2602 const struct TicketIterationNextMessage *tis_msg)
2603{
2604 struct IdpClient *client = cls;
2605 struct TicketIteration *ti;
2606 uint32_t rid;
2607
2609 "Received TICKET_ITERATION_NEXT message\n");
2610 rid = ntohl (tis_msg->id);
2611 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2612 if (ti->r_id == rid)
2613 break;
2614 if (NULL == ti)
2615 {
2616 GNUNET_break (0);
2618 return;
2619 }
2622}
2623
2624
2632static void
2633run (void *cls,
2634 const struct GNUNET_CONFIGURATION_Handle *c,
2635 struct GNUNET_SERVICE_Handle *server)
2636{
2637 cfg = c;
2638
2640 {
2642 "Unable to initialize TICKETS subsystem.\n");
2644 return;
2645 }
2646 // Connect to identity and namestore services
2648 if (NULL == nsh)
2649 {
2651 "error connecting to namestore");
2652 }
2653
2655}
2656
2657
2665static void
2668 void *app_ctx)
2669{
2670 struct IdpClient *idp = app_ctx;
2671
2672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2675 idp);
2677}
2678
2679
2688static void *
2691 struct GNUNET_MQ_Handle *mq)
2692{
2693 struct IdpClient *idp;
2694
2695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2696 idp = GNUNET_new (struct IdpClient);
2697 idp->client = client;
2698 idp->mq = mq;
2701 idp);
2702 return idp;
2703}
2704
2705
2710 "reclaim",
2712 &run,
2715 NULL,
2716 GNUNET_MQ_hd_var_size (attribute_store_message,
2718 struct AttributeStoreMessage,
2719 NULL),
2720 GNUNET_MQ_hd_var_size (credential_store_message,
2722 struct AttributeStoreMessage,
2723 NULL),
2724 GNUNET_MQ_hd_var_size (attribute_delete_message,
2727 NULL),
2728 GNUNET_MQ_hd_var_size (credential_delete_message,
2731 NULL),
2732 GNUNET_MQ_hd_var_size (iteration_start,
2735 NULL),
2736 GNUNET_MQ_hd_fixed_size (iteration_next,
2739 NULL),
2740 GNUNET_MQ_hd_fixed_size (iteration_stop,
2743 NULL),
2744 GNUNET_MQ_hd_var_size (credential_iteration_start,
2747 NULL),
2748 GNUNET_MQ_hd_fixed_size (credential_iteration_next,
2751 NULL),
2752 GNUNET_MQ_hd_fixed_size (credential_iteration_stop,
2755 NULL),
2756
2757 GNUNET_MQ_hd_var_size (issue_ticket_message,
2759 struct IssueTicketMessage,
2760 NULL),
2761 GNUNET_MQ_hd_var_size (consume_ticket_message,
2763 struct ConsumeTicketMessage,
2764 NULL),
2765 GNUNET_MQ_hd_var_size (ticket_iteration_start,
2768 NULL),
2769 GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
2772 NULL),
2773 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
2776 NULL),
2777 GNUNET_MQ_hd_var_size (revoke_ticket_message,
2779 struct RevokeTicketMessage,
2780 NULL),
2782/* 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.
static void attr_store_task(void *cls)
Add a new attribute.
GNUNET_SERVICE_MAIN("reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(credential_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(credential_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(credential_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, struct CredentialIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, struct CredentialIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, struct CredentialIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL), GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL), GNUNET_MQ_hd_var_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static enum GNUNET_GenericReturnValue check_iteration_start(void *cls, const struct AttributeIterationStartMessage *ais_msg)
static void handle_credential_iteration_stop(void *cls, const struct CredentialIterationStopMessage *ais_msg)
Handle iteration stop message from client.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
static enum GNUNET_GenericReturnValue check_credential_iteration_start(void *cls, const struct CredentialIterationStartMessage *cis_msg)
static void handle_iteration_next(void *cls, const struct AttributeIterationNextMessage *ais_msg)
Client requests next attribute from iterator.
static void handle_ticket_iteration_stop(void *cls, const struct TicketIterationStopMessage *tis_msg)
Client has had enough tickets.
static enum GNUNET_GenericReturnValue check_ticket_iteration_start(void *cls, const struct TicketIterationStartMessage *tis_msg)
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
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:145
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:619
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:163
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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.
#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:1340
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
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:1305
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2484
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2455
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static unsigned int size
Size of the "table".
Definition: peer.c:68
Common type definitions for the identity provider service and API.
#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:246
Handle to a service.
Definition: service.c:117
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 intiated this zone iteration.
struct GNUNET_CRYPTO_PrivateKey identity
Key of the zone we are iterating over.
void * ctx
Context.
struct Iterator * next
Next element in the DLL.
uint32_t request_id
The operation id for the zone iteration in the response for the client.
Ticket revocation request handle.
Ticket revoke message.
Definition: reclaim.h:438
uint16_t key_len
The length of the private key.
Definition: reclaim.h:452
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:447
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:457
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:442
Ticket revoke message.
Definition: reclaim.h:470
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:479
uint32_t success
Revocation result.
Definition: reclaim.h:484
Attribute store/delete response message.
Definition: reclaim.h:106
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:115
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:120
Ticket issue operation handle.
struct TicketIssueOperation * next
DLL.
struct IdpClient * client
Client connection.
struct TicketIssueOperation * prev
DLL.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:362
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:371
Start a ticket iteration for the given identity.
Definition: reclaim.h:331
uint16_t key_len
The length of the private key.
Definition: reclaim.h:350
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:340
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:335
Stop ticket iteration for the given operation.
Definition: reclaim.h:379
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
A ticket iteration operation.
struct TicketIteration * next
DLL.
struct IdpClient * client
Client which intiated this zone iteration.
uint32_t r_id
The operation id for the iteration in the response for the client.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
struct TicketIteration * prev
DLL.
unsigned int rd_count
Record count.
Ticket result message.
Definition: reclaim.h:492
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:501
uint16_t presentations_len
Length of new presentations created.
Definition: reclaim.h: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.