aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-03 21:51:57 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:10 +0100
commit5b6bb2ce4d60635b2af950d72b45f12686fd5218 (patch)
treeef3b5786591f6a8473a4a2174dd95a439f22af68 /src/reclaim/gnunet-service-reclaim_tickets.c
parent99d70615e37294d4f964992c6be0495e95777a27 (diff)
downloadgnunet-5b6bb2ce4d60635b2af950d72b45f12686fd5218.tar.gz
gnunet-5b6bb2ce4d60635b2af950d72b45f12686fd5218.zip
move to 256-bit identifier; some cleanups
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c133
1 files changed, 67 insertions, 66 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index b022225b8..bdb9e6dd9 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -236,12 +236,12 @@ struct RevokedAttributeEntry
236 /** 236 /**
237 * Old ID of the attribute 237 * Old ID of the attribute
238 */ 238 */
239 uint64_t old_id; 239 struct GNUNET_RECLAIM_Identifier old_id;
240 240
241 /** 241 /**
242 * New ID of the attribute 242 * New ID of the attribute
243 */ 243 */
244 uint64_t new_id; 244 struct GNUNET_RECLAIM_Identifier new_id;
245}; 245};
246 246
247 247
@@ -435,7 +435,7 @@ process_tickets (void *cls)
435 continue; 435 continue;
436 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 436 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
437 { 437 {
438 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) 438 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
439 continue; 439 continue;
440 rd[i].data = &ae->new_id; 440 rd[i].data = &ae->new_id;
441 } 441 }
@@ -497,7 +497,7 @@ rvk_ticket_update (void *cls,
497 continue; 497 continue;
498 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 498 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
499 { 499 {
500 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) 500 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
501 continue; 501 continue;
502 has_changed = GNUNET_YES; 502 has_changed = GNUNET_YES;
503 break; 503 break;
@@ -532,9 +532,6 @@ rvk_ns_iter_err (void *cls)
532 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 532 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
533 533
534 rvk->ns_it = NULL; 534 rvk->ns_it = NULL;
535 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
536 "Namestore error on revocation (id=%" PRIu64 "\n",
537 rvk->move_attr->old_id);
538 rvk->cb (rvk->cb_cls, GNUNET_SYSERR); 535 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
539 cleanup_rvk (rvk); 536 cleanup_rvk (rvk);
540} 537}
@@ -551,9 +548,6 @@ rvk_ns_err (void *cls)
551 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 548 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
552 549
553 rvk->ns_qe = NULL; 550 rvk->ns_qe = NULL;
554 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
555 "Namestore error on revocation (id=%" PRIu64 "\n",
556 rvk->move_attr->old_id);
557 rvk->cb (rvk->cb_cls, GNUNET_SYSERR); 551 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
558 cleanup_rvk (rvk); 552 cleanup_rvk (rvk);
559} 553}
@@ -636,7 +630,7 @@ move_attr_finished (void *cls, int32_t success, const char *emsg)
636 return; 630 return;
637 } 631 }
638 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, 632 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
639 sizeof(uint64_t)); 633 sizeof(rvk->move_attr->old_id));
640 GNUNET_assert (NULL != label); 634 GNUNET_assert (NULL != label);
641 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); 635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
642 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 636 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
@@ -685,67 +679,80 @@ rvk_move_attr_cb (void *cls,
685 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); 679 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk);
686 return; 680 return;
687 } 681 }
688 rvk->move_attr->new_id =GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 682 GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id);
689 new_label=NULL; 683 new_label = NULL;
690 attr_data=NULL; 684 attr_data = NULL;
691 //new_rd = *rd; 685 // new_rd = *rd;
692 for (int i = 0; i < rd_count; i++) 686 for (int i = 0; i < rd_count; i++)
693 { 687 {
694 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 688 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
695 { 689 {
696 /** find a new place for this attribute **/ 690 /** find a new place for this attribute **/
697 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 691 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
698 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size); 692 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data,
693 rd[i].data_size);
699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
700 "Attribute to update: Name=%s, ID=%" PRIu64 "\n", 695 "Attribute to update: Name=%s\n",
701 claim->name, 696 claim->name);
702 claim->id);
703 claim->id = rvk->move_attr->new_id; 697 claim->id = rvk->move_attr->new_id;
704 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); 698 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim);
705 attr_data = GNUNET_malloc (rd[i].data_size); 699 attr_data = GNUNET_malloc (rd[i].data_size);
706 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data); 700 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim,
701 attr_data);
707 new_rd[i].data = attr_data; 702 new_rd[i].data = attr_data;
708 new_rd[i].record_type = rd[i].record_type; 703 new_rd[i].record_type = rd[i].record_type;
709 new_rd[i].flags = rd[i].flags; 704 new_rd[i].flags = rd[i].flags;
710 new_rd[i].expiration_time = rd[i].expiration_time; 705 new_rd[i].expiration_time = rd[i].expiration_time;
711 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 706 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
712 sizeof(uint64_t)); 707 sizeof (rvk->move_attr->
708 new_id));
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
714 GNUNET_free (claim); 710 GNUNET_free (claim);
715 } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 711 }
712 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
716 { 713 {
717 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 714 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
718 attest=GNUNET_RECLAIM_ATTESTATION_deserialize(rd[i].data, rd[i].data_size); 715 attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data,
716 rd[i].data_size);
719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
720 "Attestation to update: Name=%s, ID=%" PRIu64 "\n", 718 "Attestation to update: Name=%s\n",
721 attest->name, 719 attest->name);
722 attest->id);
723 attest->id = rvk->move_attr->new_id; 720 attest->id = rvk->move_attr->new_id;
724 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attest); 721 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (
722 attest);
725 attr_data = GNUNET_malloc (rd[i].data_size); 723 attr_data = GNUNET_malloc (rd[i].data_size);
726 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, attr_data); 724 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest,
725 attr_data);
727 new_rd[i].data = attr_data; 726 new_rd[i].data = attr_data;
728 new_rd[i].record_type = rd[i].record_type; 727 new_rd[i].record_type = rd[i].record_type;
729 new_rd[i].flags = rd[i].flags; 728 new_rd[i].flags = rd[i].flags;
730 new_rd[i].expiration_time = rd[i].expiration_time; 729 new_rd[i].expiration_time = rd[i].expiration_time;
731 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t)); 730 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", new_label); 731 sizeof (rvk->move_attr->
732 new_id));
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n",
734 new_label);
733 GNUNET_free (attest); 735 GNUNET_free (attest);
734 } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type) 736 }
737 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
735 { 738 {
736 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; 739 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
737 reference=GNUNET_RECLAIM_ATTESTATION_REF_deserialize(rd[i].data, rd[i].data_size); 740 reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
741 rd[i].data_size);
738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
739 "Reference to update: Name=%s, ID=%" PRIu64 "\n", 743 "Reference to update: Name=%s\n",
740 reference->name, 744 reference->name);
741 reference->id);
742 reference->id = rvk->move_attr->new_id; 745 reference->id = rvk->move_attr->new_id;
743 reference->id_attest = rvk->move_attr->new_id; 746 reference->id_attest = rvk->move_attr->new_id;
744 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (reference); 747 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
748 reference);
745 attr_data = GNUNET_malloc (rd[i].data_size); 749 attr_data = GNUNET_malloc (rd[i].data_size);
746 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference, attr_data); 750 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference,
751 attr_data);
747 new_rd[i].data = attr_data; 752 new_rd[i].data = attr_data;
748 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t)); 753 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
754 sizeof (rvk->move_attr->
755 new_id));
749 new_rd[i].record_type = rd[i].record_type; 756 new_rd[i].record_type = rd[i].record_type;
750 new_rd[i].flags = rd[i].flags; 757 new_rd[i].flags = rd[i].flags;
751 new_rd[i].expiration_time = rd[i].expiration_time; 758 new_rd[i].expiration_time = rd[i].expiration_time;
@@ -754,12 +761,12 @@ rvk_move_attr_cb (void *cls,
754 } 761 }
755 } 762 }
756 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 763 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
757 &rvk->identity, 764 &rvk->identity,
758 new_label, 765 new_label,
759 rd_count, 766 rd_count,
760 new_rd, 767 new_rd,
761 &move_attr_finished, 768 &move_attr_finished,
762 rvk); 769 rvk);
763 GNUNET_free (new_label); 770 GNUNET_free (new_label);
764 GNUNET_free (attr_data); 771 GNUNET_free (attr_data);
765} 772}
@@ -793,7 +800,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk)
793 return; 800 return;
794 } 801 }
795 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, 802 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
796 sizeof(uint64_t)); 803 sizeof (rvk->move_attr->old_id));
797 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label); 804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
798 805
799 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, 806 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
@@ -876,7 +883,7 @@ revoke_attrs_cb (void *cls,
876 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 883 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
877 continue; 884 continue;
878 le = GNUNET_new (struct RevokedAttributeEntry); 885 le = GNUNET_new (struct RevokedAttributeEntry);
879 le->old_id = *((uint64_t *) rd[i].data); 886 le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
880 GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); 887 GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le);
881 rvk->ticket_attrs++; 888 rvk->ticket_attrs++;
882 } 889 }
@@ -934,7 +941,8 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
934 rvk->ticket = *ticket; 941 rvk->ticket = *ticket;
935 GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); 942 GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity);
936 /** Get shared attributes **/ 943 /** Get shared attributes **/
937 label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); 944 label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd,
945 sizeof(ticket->rnd));
938 GNUNET_assert (NULL != label); 946 GNUNET_assert (NULL != label);
939 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, 947 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
940 identity, 948 identity,
@@ -1231,7 +1239,8 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1231 cth->cb = cb; 1239 cth->cb = cb;
1232 cth->cb_cls = cb_cls; 1240 cth->cb_cls = cb_cls;
1233 label = 1241 label =
1234 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t)); 1242 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd,
1243 sizeof(cth->ticket.rnd));
1235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1236 "Looking for AuthZ info under %s\n", 1245 "Looking for AuthZ info under %s\n",
1237 label); 1246 label);
@@ -1393,7 +1402,8 @@ issue_ticket (struct TicketIssueHandle *ih)
1393 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; 1402 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1394 1403
1395 label = 1404 label =
1396 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t)); 1405 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd,
1406 sizeof(ih->ticket.rnd));
1397 // Publish record 1407 // Publish record
1398 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 1408 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1399 &ih->identity, 1409 &ih->identity,
@@ -1488,29 +1498,21 @@ filter_tickets_cb (void *cls,
1488 // cmp attr_ref id with requested attr id 1498 // cmp attr_ref id with requested attr id
1489 if (NULL !=le->claim) 1499 if (NULL !=le->claim)
1490 { 1500 {
1491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1501 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(le->claim->id)))
1492 " %" PRIu64 "\n %" PRIu64 "\n",
1493 *((uint64_t *) rd[i].data),
1494 le->claim->id);
1495 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t)))
1496 found_attrs_cnt++; 1502 found_attrs_cnt++;
1497 } 1503 }
1498 else if (NULL !=le->attest) 1504 else if (NULL !=le->attest)
1499 { 1505 {
1500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1506 if (0 == memcmp (rd[i].data,
1501 " %" PRIu64 "\n %" PRIu64 "\n", 1507 &le->attest->id,
1502 *((uint64_t *) rd[i].data), 1508 sizeof(le->attest->id)))
1503 le->attest->id);
1504 if (0 == memcmp (rd[i].data, &le->attest->id, sizeof(uint64_t)))
1505 found_attrs_cnt++; 1509 found_attrs_cnt++;
1506 } 1510 }
1507 else if (NULL != le->reference) 1511 else if (NULL != le->reference)
1508 { 1512 {
1509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1513 if (0 == memcmp (rd[i].data,
1510 " %" PRIu64 "\n %" PRIu64 "\n", 1514 &le->reference->id,
1511 *((uint64_t *) rd[i].data), 1515 sizeof(le->reference->id)))
1512 le->reference->id);
1513 if (0 == memcmp (rd[i].data, &le->reference->id, sizeof(uint64_t)))
1514 found_attrs_cnt++; 1516 found_attrs_cnt++;
1515 } 1517 }
1516 1518
@@ -1547,8 +1549,7 @@ filter_tickets_finished_cb (void *cls)
1547 struct TicketIssueHandle *tih = cls; 1549 struct TicketIssueHandle *tih = cls;
1548 1550
1549 GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity); 1551 GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity);
1550 tih->ticket.rnd = 1552 GNUNET_RECLAIM_id_generate (&tih->ticket.rnd);
1551 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
1552 issue_ticket (tih); 1553 issue_ticket (tih);
1553} 1554}
1554 1555