aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-04 18:42:04 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:10 +0100
commit55f6d26b7424d660c99bc89f3677b20294e87a27 (patch)
treea8080fdcf0d9688c154417e50c58055e364f8b6b /src/reclaim/gnunet-service-reclaim_tickets.c
parent5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff)
downloadgnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz
gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip
Refactoring reclaim attestations
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c271
1 files changed, 94 insertions, 177 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index bdb9e6dd9..019ce51b0 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -59,7 +59,7 @@ struct TicketReference
59 /** 59 /**
60 * Attributes 60 * Attributes
61 */ 61 */
62 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 62 struct GNUNET_RECLAIM_AttributeList *attrs;
63 63
64 /** 64 /**
65 * Tickets 65 * Tickets
@@ -111,7 +111,12 @@ struct RECLAIM_TICKETS_ConsumeHandle
111 /** 111 /**
112 * Attributes 112 * Attributes
113 */ 113 */
114 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 114 struct GNUNET_RECLAIM_AttributeList *attrs;
115
116 /**
117 * Attestations
118 */
119 struct GNUNET_RECLAIM_AttestationList *attests;
115 120
116 /** 121 /**
117 * Lookup time 122 * Lookup time
@@ -165,7 +170,7 @@ struct TicketIssueHandle
165 /** 170 /**
166 * Attributes to issue 171 * Attributes to issue
167 */ 172 */
168 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 173 struct GNUNET_RECLAIM_AttributeList *attrs;
169 174
170 /** 175 /**
171 * Issuer Key 176 * Issuer Key
@@ -431,7 +436,7 @@ process_tickets (void *cls)
431 } 436 }
432 for (int i = 0; i < le->rd_count; i++) 437 for (int i = 0; i < le->rd_count; i++)
433 { 438 {
434 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 439 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
435 continue; 440 continue;
436 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 441 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
437 { 442 {
@@ -493,7 +498,7 @@ rvk_ticket_update (void *cls,
493 /** Let everything point to the old record **/ 498 /** Let everything point to the old record **/
494 for (int i = 0; i < rd_count; i++) 499 for (int i = 0; i < rd_count; i++)
495 { 500 {
496 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 501 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
497 continue; 502 continue;
498 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 503 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
499 { 504 {
@@ -685,80 +690,55 @@ rvk_move_attr_cb (void *cls,
685 // new_rd = *rd; 690 // new_rd = *rd;
686 for (int i = 0; i < rd_count; i++) 691 for (int i = 0; i < rd_count; i++)
687 { 692 {
688 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 693 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
689 { 694 {
690 /** find a new place for this attribute **/ 695 /** find a new place for this attribute **/
691 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 696 struct GNUNET_RECLAIM_Attribute *claim;
692 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, 697 claim = GNUNET_RECLAIM_attribute_deserialize (rd[i].data,
693 rd[i].data_size); 698 rd[i].data_size);
694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
695 "Attribute to update: Name=%s\n", 700 "Attribute to update: Name=%s\n",
696 claim->name); 701 claim->name);
697 claim->id = rvk->move_attr->new_id; 702 claim->id = rvk->move_attr->new_id;
698 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); 703 new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize_get_size (claim);
699 attr_data = GNUNET_malloc (rd[i].data_size); 704 attr_data = GNUNET_malloc (rd[i].data_size);
700 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, 705 new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize (claim,
701 attr_data); 706 attr_data);
702 new_rd[i].data = attr_data; 707 new_rd[i].data = attr_data;
703 new_rd[i].record_type = rd[i].record_type; 708 new_rd[i].record_type = rd[i].record_type;
704 new_rd[i].flags = rd[i].flags; 709 new_rd[i].flags = rd[i].flags;
705 new_rd[i].expiration_time = rd[i].expiration_time; 710 new_rd[i].expiration_time = rd[i].expiration_time;
706 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 711 new_label =
707 sizeof (rvk->move_attr-> 712 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
708 new_id)); 713 sizeof (rvk->move_attr->new_id));
709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
710 GNUNET_free (claim); 715 GNUNET_free (claim);
711 } 716 }
712 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 717 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
713 { 718 {
714 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 719 struct GNUNET_RECLAIM_Attestation *attest;
715 attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, 720 attest = GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
716 rd[i].data_size); 721 rd[i].data_size);
717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
718 "Attestation to update: Name=%s\n", 723 "Attestation to update: Name=%s\n",
719 attest->name); 724 attest->name);
720 attest->id = rvk->move_attr->new_id; 725 attest->id = rvk->move_attr->new_id;
721 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( 726 new_rd[i].data_size =
722 attest); 727 GNUNET_RECLAIM_attestation_serialize_get_size (attest);
723 attr_data = GNUNET_malloc (rd[i].data_size); 728 attr_data = GNUNET_malloc (rd[i].data_size);
724 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, 729 new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest,
725 attr_data); 730 attr_data);
726 new_rd[i].data = attr_data; 731 new_rd[i].data = attr_data;
727 new_rd[i].record_type = rd[i].record_type; 732 new_rd[i].record_type = rd[i].record_type;
728 new_rd[i].flags = rd[i].flags; 733 new_rd[i].flags = rd[i].flags;
729 new_rd[i].expiration_time = rd[i].expiration_time; 734 new_rd[i].expiration_time = rd[i].expiration_time;
730 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 735 new_label =
731 sizeof (rvk->move_attr-> 736 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
732 new_id)); 737 sizeof (rvk->move_attr->new_id));
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", 738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n",
734 new_label); 739 new_label);
735 GNUNET_free (attest); 740 GNUNET_free (attest);
736 } 741 }
737 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
738 {
739 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
740 reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
741 rd[i].data_size);
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743 "Reference to update: Name=%s\n",
744 reference->name);
745 reference->id = rvk->move_attr->new_id;
746 reference->id_attest = rvk->move_attr->new_id;
747 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
748 reference);
749 attr_data = GNUNET_malloc (rd[i].data_size);
750 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference,
751 attr_data);
752 new_rd[i].data = attr_data;
753 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
754 sizeof (rvk->move_attr->
755 new_id));
756 new_rd[i].record_type = rd[i].record_type;
757 new_rd[i].flags = rd[i].flags;
758 new_rd[i].expiration_time = rd[i].expiration_time;
759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference %s\n", new_label);
760 GNUNET_free (reference);
761 }
762 } 742 }
763 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 743 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
764 &rvk->identity, 744 &rvk->identity,
@@ -880,7 +860,7 @@ revoke_attrs_cb (void *cls,
880 */ 860 */
881 for (int i = 0; i < rd_count; i++) 861 for (int i = 0; i < rd_count; i++)
882 { 862 {
883 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 863 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
884 continue; 864 continue;
885 le = GNUNET_new (struct RevokedAttributeEntry); 865 le = GNUNET_new (struct RevokedAttributeEntry);
886 le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data); 866 le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
@@ -999,7 +979,9 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
999 } 979 }
1000 980
1001 if (NULL != cth->attrs) 981 if (NULL != cth->attrs)
1002 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs); 982 GNUNET_RECLAIM_attribute_list_destroy (cth->attrs);
983 if (NULL != cth->attests)
984 GNUNET_RECLAIM_attestation_list_destroy (cth->attests);
1003 GNUNET_free (cth); 985 GNUNET_free (cth);
1004} 986}
1005 987
@@ -1018,7 +1000,7 @@ process_parallel_lookup_result (void *cls,
1018{ 1000{
1019 struct ParallelLookup *parallel_lookup = cls; 1001 struct ParallelLookup *parallel_lookup = cls;
1020 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; 1002 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1021 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; 1003 struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1022 1004
1023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1024 "Parallel lookup finished (count=%u)\n", 1006 "Parallel lookup finished (count=%u)\n",
@@ -1044,62 +1026,34 @@ process_parallel_lookup_result (void *cls,
1044 // REMARK: It is possible now to find rd_count > 1 1026 // REMARK: It is possible now to find rd_count > 1
1045 for (int i = 0; i < rd_count; i++) 1027 for (int i = 0; i < rd_count; i++)
1046 { 1028 {
1047 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 1029 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
1048 { 1030 {
1049 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1031 attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1050 attr_le->claim = 1032 attr_le->attribute =
1051 GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size); 1033 GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size);
1052 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, 1034 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1053 cth->attrs->list_tail, 1035 cth->attrs->list_tail,
1054 attr_le); 1036 attr_le);
1055 attr_le->reference = NULL;
1056 attr_le->attest = NULL;
1057 } 1037 }
1058 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 1038 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
1059 { 1039 {
1060 /**Ignore all plain attestations 1040 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1061 *attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1041 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1062 *attr_le->attest = 1042 ale->attestation =
1063 * GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, rd[i].data_size); 1043 GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
1064 *GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, 1044 rd[i].data_size);
1065 * cth->attrs->list_tail, 1045 GNUNET_CONTAINER_DLL_insert (cth->attests->list_head,
1066 * attr_le); 1046 cth->attests->list_tail,
1067 */ 1047 ale);
1068 continue;
1069 } 1048 }
1070 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type) 1049 else
1071 { 1050 {
1072 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le2; 1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1073 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1052 "Parallel Lookup of Reference without Attestation");
1074 attr_le2 = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1053 continue;
1075 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[0].record_type) 1054 }
1076 {
1077 attr_le->attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[0].data,
1078 rd[0].
1079 data_size);
1080 attr_le2->reference =
1081 GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
1082 rd[i].data_size);
1083 attr_le->claim = NULL;
1084 attr_le->reference = NULL;
1085 attr_le2->claim = NULL;
1086 attr_le2->attest = NULL;
1087 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1088 cth->attrs->list_tail,
1089 attr_le);
1090 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1091 cth->attrs->list_tail,
1092 attr_le2);
1093 }
1094 else
1095 {
1096 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1097 "Parallel Lookup of Reference without Attestation");
1098 continue;
1099 }
1100 1055
1101 1056
1102 }
1103 } 1057 }
1104 if (NULL != cth->parallel_lookups_head) 1058 if (NULL != cth->parallel_lookups_head)
1105 return; // Wait for more 1059 return; // Wait for more
@@ -1170,7 +1124,7 @@ lookup_authz_cb (void *cls,
1170 1124
1171 for (int i = 0; i < rd_count; i++) 1125 for (int i = 0; i < rd_count; i++)
1172 { 1126 {
1173 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1127 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
1174 continue; 1128 continue;
1175 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 1129 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
@@ -1234,7 +1188,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1234 1188
1235 cth->identity = *id; 1189 cth->identity = *id;
1236 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); 1190 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1237 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1191 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1238 cth->ticket = *ticket; 1192 cth->ticket = *ticket;
1239 cth->cb = cb; 1193 cth->cb = cb;
1240 cth->cb_cls = cb_cls; 1194 cth->cb_cls = cb_cls;
@@ -1249,7 +1203,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1249 GNUNET_GNS_lookup (gns, 1203 GNUNET_GNS_lookup (gns,
1250 label, 1204 label,
1251 &cth->ticket.identity, 1205 &cth->ticket.identity,
1252 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, 1206 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF,
1253 GNUNET_GNS_LO_DEFAULT, 1207 GNUNET_GNS_LO_DEFAULT,
1254 &lookup_authz_cb, 1208 &lookup_authz_cb,
1255 cth); 1209 cth);
@@ -1325,73 +1279,39 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1325static void 1279static void
1326issue_ticket (struct TicketIssueHandle *ih) 1280issue_ticket (struct TicketIssueHandle *ih)
1327{ 1281{
1328 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1282 struct GNUNET_RECLAIM_AttributeListEntry *le;
1329 struct GNUNET_GNSRECORD_Data *attrs_record; 1283 struct GNUNET_GNSRECORD_Data *attrs_record;
1330 char *label; 1284 char *label;
1331 size_t list_len = 1; 1285 size_t list_len = 1;
1332 int i; 1286 int i;
1333 char *attest_string;
1334 1287
1335 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1288 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1289 {
1336 list_len++; 1290 list_len++;
1291 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1292 list_len++;
1293 }
1337 1294
1338 attrs_record = 1295 attrs_record =
1339 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1296 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1340 i = 0; 1297 i = 0;
1341 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1298 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1342 { 1299 {
1343 if (NULL != le->claim) 1300 attrs_record[i].data = &le->attribute->id;
1344 { 1301 attrs_record[i].data_size = sizeof(le->attribute->id);
1345 attrs_record[i].data = &le->claim->id;
1346 attrs_record[i].data_size = sizeof(le->claim->id);
1347 }
1348 else if (NULL != le->attest)
1349 {
1350 // REMARK: Since we only store IDs, the references are irrelevant
1351 int j = 0;
1352 GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1353 while (j<i)
1354 {
1355 if (0 == strcmp (attest_string,GNUNET_STRINGS_data_to_string_alloc (
1356 attrs_record[j].data, attrs_record[j].data_size)))
1357 break;
1358 j++;
1359 }
1360 if (j < i)
1361 {
1362 list_len--;
1363 continue;
1364 }
1365 attrs_record[i].data = &le->attest->id;
1366 attrs_record[i].data_size = sizeof(le->attest->id);
1367 }
1368 else if (NULL != le->reference)
1369 {
1370 list_len--;
1371 continue;
1372 /*
1373 int j = 0;
1374 GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1375 while (j<i)
1376 {
1377 if (strcmp(attest_string, GNUNET_STRINGS_data_to_string_alloc (
1378 attrs_record[j].data, attrs_record[j].data_size)))
1379 break;
1380 j++;
1381 }
1382 if (j < i)
1383 continue;
1384 attrs_record[i].data = &le->reference->id;
1385 attrs_record[i].data_size = sizeof(le->reference->id);
1386 */
1387 }
1388 /**
1389 * FIXME: Should this be the attribute expiration time or ticket
1390 * refresh interval? Probably min(attrs.expiration)
1391 */
1392 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1302 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1393 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; 1303 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
1394 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1304 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1305 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1306 {
1307 i++;
1308 attrs_record[i].data = &le->attribute->attestation;
1309 attrs_record[i].data_size = sizeof(le->attribute->attestation);
1310 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1311 attrs_record[i].record_type =
1312 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
1313 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1314 }
1395 i++; 1315 i++;
1396 } 1316 }
1397 attrs_record[i].data = &ih->ticket; 1317 attrs_record[i].data = &ih->ticket;
@@ -1464,14 +1384,20 @@ filter_tickets_cb (void *cls,
1464 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1384 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1465 1385
1466 // figure out the number of requested attributes 1386 // figure out the number of requested attributes
1467 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1387 struct GNUNET_RECLAIM_AttributeListEntry *le;
1468 unsigned int attr_cnt = 0; 1388 unsigned int attr_cnt = 0;
1389 unsigned int attest_cnt = 0;
1469 1390
1470 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1391 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1392 {
1471 attr_cnt++; 1393 attr_cnt++;
1394 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1395 attest_cnt++;
1396 }
1472 1397
1473 // ticket search 1398 // ticket search
1474 unsigned int found_attrs_cnt = 0; 1399 unsigned int found_attrs_cnt = 0;
1400 unsigned int found_attests_cnt = 0;
1475 1401
1476 for (int i = 0; i < rd_count; i++) 1402 for (int i = 0; i < rd_count; i++)
1477 { 1403 {
@@ -1491,31 +1417,20 @@ filter_tickets_cb (void *cls,
1491 } 1417 }
1492 1418
1493 // cmp requested attributes with ticket attributes 1419 // cmp requested attributes with ticket attributes
1494 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1420 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1421 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
1495 continue; 1422 continue;
1496 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1423 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1497 { 1424 {
1498 // cmp attr_ref id with requested attr id 1425 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1499 if (NULL !=le->claim) 1426 &le->attribute->id))
1500 { 1427 found_attrs_cnt++;
1501 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(le->claim->id))) 1428 }
1502 found_attrs_cnt++; 1429 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1503 } 1430 {
1504 else if (NULL !=le->attest) 1431 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1505 { 1432 &le->attribute->attestation))
1506 if (0 == memcmp (rd[i].data, 1433 found_attests_cnt++;
1507 &le->attest->id,
1508 sizeof(le->attest->id)))
1509 found_attrs_cnt++;
1510 }
1511 else if (NULL != le->reference)
1512 {
1513 if (0 == memcmp (rd[i].data,
1514 &le->reference->id,
1515 sizeof(le->reference->id)))
1516 found_attrs_cnt++;
1517 }
1518
1519 } 1434 }
1520 } 1435 }
1521 1436
@@ -1523,7 +1438,9 @@ filter_tickets_cb (void *cls,
1523 * If we found a matching ticket, return that to the caller and 1438 * If we found a matching ticket, return that to the caller and
1524 * we are done. 1439 * we are done.
1525 */ 1440 */
1526 if ((attr_cnt == found_attrs_cnt) && (NULL != ticket)) 1441 if ((attr_cnt == found_attrs_cnt) &&
1442 (attest_cnt == found_attests_cnt) &&
1443 (NULL != ticket))
1527 { 1444 {
1528 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); 1445 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
1529 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); 1446 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
@@ -1567,7 +1484,7 @@ filter_tickets_finished_cb (void *cls)
1567 */ 1484 */
1568void 1485void
1569RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1486RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1570 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1487 const struct GNUNET_RECLAIM_AttributeList *attrs,
1571 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 1488 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
1572 RECLAIM_TICKETS_TicketResult cb, 1489 RECLAIM_TICKETS_TicketResult cb,
1573 void *cb_cls) 1490 void *cb_cls)
@@ -1577,7 +1494,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1577 tih = GNUNET_new (struct TicketIssueHandle); 1494 tih = GNUNET_new (struct TicketIssueHandle);
1578 tih->cb = cb; 1495 tih->cb = cb;
1579 tih->cb_cls = cb_cls; 1496 tih->cb_cls = cb_cls;
1580 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs); 1497 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs);
1581 tih->identity = *identity; 1498 tih->identity = *identity;
1582 tih->ticket.audience = *audience; 1499 tih->ticket.audience = *audience;
1583 1500