aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-07 15:36:43 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:11 +0100
commit141a279fb55bc9b11aaa765ca3ad54689003e291 (patch)
tree2519ee820288fae481ae972963dea24fd86ffb59 /src/reclaim/gnunet-service-reclaim_tickets.c
parentd06446f143610790d9a0530d524d8e9db2a03b8c (diff)
downloadgnunet-141a279fb55bc9b11aaa765ca3ad54689003e291.tar.gz
gnunet-141a279fb55bc9b11aaa765ca3ad54689003e291.zip
bugfixes; CLI improvements
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 019ce51b0..205886c78 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -1058,7 +1058,8 @@ process_parallel_lookup_result (void *cls,
1058 if (NULL != cth->parallel_lookups_head) 1058 if (NULL != cth->parallel_lookups_head)
1059 return; // Wait for more 1059 return; // Wait for more
1060 /* Else we are done */ 1060 /* Else we are done */
1061 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1061 cth->cb (cth->cb_cls, &cth->ticket.identity,
1062 cth->attrs, cth->attests, GNUNET_OK, NULL);
1062 cleanup_cth (cth); 1063 cleanup_cth (cth);
1063} 1064}
1064 1065
@@ -1087,7 +1088,7 @@ abort_parallel_lookups (void *cls)
1087 GNUNET_free (lu); 1088 GNUNET_free (lu);
1088 lu = tmp; 1089 lu = tmp;
1089 } 1090 }
1090 cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); 1091 cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1091} 1092}
1092 1093
1093 1094
@@ -1124,10 +1125,11 @@ lookup_authz_cb (void *cls,
1124 1125
1125 for (int i = 0; i < rd_count; i++) 1126 for (int i = 0; i < rd_count; i++)
1126 { 1127 {
1127 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) 1128 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1129 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
1128 continue; 1130 continue;
1129 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 1131 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1131 parallel_lookup = GNUNET_new (struct ParallelLookup); 1133 parallel_lookup = GNUNET_new (struct ParallelLookup);
1132 parallel_lookup->handle = cth; 1134 parallel_lookup->handle = cth;
1133 parallel_lookup->label = lbl; 1135 parallel_lookup->label = lbl;
@@ -1159,7 +1161,8 @@ lookup_authz_cb (void *cls,
1159 /** 1161 /**
1160 * No references found, return empty attribute list 1162 * No references found, return empty attribute list
1161 */ 1163 */
1162 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1164 cth->cb (cth->cb_cls, &cth->ticket.identity,
1165 cth->attrs, cth->attests, GNUNET_OK, NULL);
1163 cleanup_cth (cth); 1166 cleanup_cth (cth);
1164} 1167}
1165 1168
@@ -1189,6 +1192,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1189 cth->identity = *id; 1192 cth->identity = *id;
1190 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); 1193 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1191 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 1194 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1195 cth->attests = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
1192 cth->ticket = *ticket; 1196 cth->ticket = *ticket;
1193 cth->cb = cb; 1197 cth->cb = cb;
1194 cth->cb_cls = cb_cls; 1198 cth->cb_cls = cb_cls;
@@ -1282,18 +1286,15 @@ issue_ticket (struct TicketIssueHandle *ih)
1282 struct GNUNET_RECLAIM_AttributeListEntry *le; 1286 struct GNUNET_RECLAIM_AttributeListEntry *le;
1283 struct GNUNET_GNSRECORD_Data *attrs_record; 1287 struct GNUNET_GNSRECORD_Data *attrs_record;
1284 char *label; 1288 char *label;
1285 size_t list_len = 1;
1286 int i; 1289 int i;
1290 int attrs_count = 0;
1287 1291
1288 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1292 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1289 { 1293 attrs_count++;
1290 list_len++;
1291 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1292 list_len++;
1293 }
1294 1294
1295 //Worst case we have one attestation per attribute
1295 attrs_record = 1296 attrs_record =
1296 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1297 GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1297 i = 0; 1298 i = 0;
1298 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1299 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1299 { 1300 {
@@ -1302,17 +1303,30 @@ issue_ticket (struct TicketIssueHandle *ih)
1302 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1303 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1303 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF; 1304 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
1304 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1305 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1306 i++;
1305 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 1307 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1306 { 1308 {
1307 i++; 1309 int j;
1310 for (j = 0; j < i; j++)
1311 {
1312 if (attrs_record[j].record_type
1313 != GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF)
1314 continue;
1315 if (0 == memcmp (attrs_record[j].data,
1316 &le->attribute->attestation,
1317 sizeof (le->attribute->attestation)))
1318 break;
1319 }
1320 if (j < i)
1321 continue; // Skip as we have already added this attestation.
1308 attrs_record[i].data = &le->attribute->attestation; 1322 attrs_record[i].data = &le->attribute->attestation;
1309 attrs_record[i].data_size = sizeof(le->attribute->attestation); 1323 attrs_record[i].data_size = sizeof(le->attribute->attestation);
1310 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1324 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1311 attrs_record[i].record_type = 1325 attrs_record[i].record_type =
1312 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF; 1326 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
1313 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1327 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1328 i++;
1314 } 1329 }
1315 i++;
1316 } 1330 }
1317 attrs_record[i].data = &ih->ticket; 1331 attrs_record[i].data = &ih->ticket;
1318 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); 1332 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
@@ -1320,6 +1334,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1320 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; 1334 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
1321 attrs_record[i].flags = 1335 attrs_record[i].flags =
1322 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; 1336 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1337 i++;
1323 1338
1324 label = 1339 label =
1325 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, 1340 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd,
@@ -1328,7 +1343,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1328 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 1343 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1329 &ih->identity, 1344 &ih->identity,
1330 label, 1345 label,
1331 list_len, 1346 i,
1332 attrs_record, 1347 attrs_record,
1333 &store_ticket_issue_cont, 1348 &store_ticket_issue_cont,
1334 ih); 1349 ih);