diff options
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r-- | src/reclaim/reclaim_api.c | 433 |
1 files changed, 175 insertions, 258 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 5a3bee218..0fcf95ee3 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -72,6 +72,11 @@ struct GNUNET_RECLAIM_Operation | |||
72 | GNUNET_RECLAIM_AttributeResult ar_cb; | 72 | GNUNET_RECLAIM_AttributeResult ar_cb; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Attestation result callback | ||
76 | */ | ||
77 | GNUNET_RECLAIM_AttestationResult at_cb; | ||
78 | |||
79 | /** | ||
75 | * Revocation result callback | 80 | * Revocation result callback |
76 | */ | 81 | */ |
77 | GNUNET_RECLAIM_ContinuationWithStatus rvk_cb; | 82 | GNUNET_RECLAIM_ContinuationWithStatus rvk_cb; |
@@ -228,6 +233,73 @@ struct GNUNET_RECLAIM_AttributeIterator | |||
228 | uint32_t r_id; | 233 | uint32_t r_id; |
229 | }; | 234 | }; |
230 | 235 | ||
236 | /** | ||
237 | * Handle for a attestation iterator operation | ||
238 | */ | ||
239 | struct GNUNET_RECLAIM_AttestationIterator | ||
240 | { | ||
241 | /** | ||
242 | * Kept in a DLL. | ||
243 | */ | ||
244 | struct GNUNET_RECLAIM_AttestationIterator *next; | ||
245 | |||
246 | /** | ||
247 | * Kept in a DLL. | ||
248 | */ | ||
249 | struct GNUNET_RECLAIM_AttestationIterator *prev; | ||
250 | |||
251 | /** | ||
252 | * Main handle to access the service. | ||
253 | */ | ||
254 | struct GNUNET_RECLAIM_Handle *h; | ||
255 | |||
256 | /** | ||
257 | * Function to call on completion. | ||
258 | */ | ||
259 | GNUNET_SCHEDULER_TaskCallback finish_cb; | ||
260 | |||
261 | /** | ||
262 | * Closure for @e finish_cb. | ||
263 | */ | ||
264 | void *finish_cb_cls; | ||
265 | |||
266 | /** | ||
267 | * The continuation to call with the results | ||
268 | */ | ||
269 | GNUNET_RECLAIM_AttestationResult proc; | ||
270 | |||
271 | /** | ||
272 | * Closure for @e proc. | ||
273 | */ | ||
274 | void *proc_cls; | ||
275 | |||
276 | /** | ||
277 | * Function to call on errors. | ||
278 | */ | ||
279 | GNUNET_SCHEDULER_TaskCallback error_cb; | ||
280 | |||
281 | /** | ||
282 | * Closure for @e error_cb. | ||
283 | */ | ||
284 | void *error_cb_cls; | ||
285 | |||
286 | /** | ||
287 | * Envelope of the message to send to the service, if not yet | ||
288 | * sent. | ||
289 | */ | ||
290 | struct GNUNET_MQ_Envelope *env; | ||
291 | |||
292 | /** | ||
293 | * Private key of the zone. | ||
294 | */ | ||
295 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | ||
296 | |||
297 | /** | ||
298 | * The operation id this zone iteration operation has | ||
299 | */ | ||
300 | uint32_t r_id; | ||
301 | }; | ||
302 | |||
231 | 303 | ||
232 | /** | 304 | /** |
233 | * Handle to the service. | 305 | * Handle to the service. |
@@ -272,6 +344,16 @@ struct GNUNET_RECLAIM_Handle | |||
272 | /** | 344 | /** |
273 | * Head of active iterations | 345 | * Head of active iterations |
274 | */ | 346 | */ |
347 | struct GNUNET_RECLAIM_AttestationIterator *ait_head; | ||
348 | |||
349 | /** | ||
350 | * Tail of active iterations | ||
351 | */ | ||
352 | struct GNUNET_RECLAIM_AttestationIterator *ait_tail; | ||
353 | |||
354 | /** | ||
355 | * Head of active iterations | ||
356 | */ | ||
275 | struct GNUNET_RECLAIM_TicketIterator *ticket_it_head; | 357 | struct GNUNET_RECLAIM_TicketIterator *ticket_it_head; |
276 | 358 | ||
277 | /** | 359 | /** |
@@ -372,6 +454,23 @@ free_it (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
372 | 454 | ||
373 | 455 | ||
374 | /** | 456 | /** |
457 | * Free @a it. | ||
458 | * | ||
459 | * @param ait entry to free | ||
460 | */ | ||
461 | static void | ||
462 | free_ait (struct GNUNET_RECLAIM_AttestationIterator *ait) | ||
463 | { | ||
464 | struct GNUNET_RECLAIM_Handle *h = ait->h; | ||
465 | |||
466 | GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait); | ||
467 | if (NULL != ait->env) | ||
468 | GNUNET_MQ_discard (ait->env); | ||
469 | GNUNET_free (ait); | ||
470 | } | ||
471 | |||
472 | |||
473 | /** | ||
375 | * Free @a op | 474 | * Free @a op |
376 | * | 475 | * |
377 | * @param op the operation to free | 476 | * @param op the operation to free |
@@ -483,9 +582,12 @@ handle_consume_ticket_result (void *cls, | |||
483 | struct GNUNET_RECLAIM_Handle *h = cls; | 582 | struct GNUNET_RECLAIM_Handle *h = cls; |
484 | struct GNUNET_RECLAIM_Operation *op; | 583 | struct GNUNET_RECLAIM_Operation *op; |
485 | size_t attrs_len; | 584 | size_t attrs_len; |
585 | size_t attests_len; | ||
486 | uint32_t r_id = ntohl (msg->id); | 586 | uint32_t r_id = ntohl (msg->id); |
587 | char *read_ptr; | ||
487 | 588 | ||
488 | attrs_len = ntohs (msg->attrs_len); | 589 | attrs_len = ntohs (msg->attrs_len); |
590 | attests_len = ntohs (msg->attestations_len); | ||
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); | 591 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); |
490 | 592 | ||
491 | 593 | ||
@@ -496,42 +598,53 @@ handle_consume_ticket_result (void *cls, | |||
496 | return; | 598 | return; |
497 | 599 | ||
498 | { | 600 | { |
499 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; | 601 | struct GNUNET_RECLAIM_AttributeList *attrs; |
500 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 602 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
501 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le2; | 603 | struct GNUNET_RECLAIM_AttestationList *attests; |
604 | struct GNUNET_RECLAIM_AttestationListEntry *ale; | ||
502 | attrs = | 605 | attrs = |
503 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len); | 606 | GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len); |
607 | read_ptr = ((char *) &msg[1]) + attrs_len; | ||
608 | attests = | ||
609 | GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len); | ||
504 | if (NULL != op->ar_cb) | 610 | if (NULL != op->ar_cb) |
505 | { | 611 | { |
506 | if (NULL == attrs) | 612 | if (NULL == attrs) |
507 | { | 613 | { |
508 | op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL); | 614 | op->ar_cb (op->cls, &msg->identity, NULL, NULL); |
509 | } | 615 | } |
510 | else | 616 | else |
511 | { | 617 | { |
512 | for (le = attrs->list_head; NULL != le; le = le->next) | 618 | for (le = attrs->list_head; NULL != le; le = le->next) |
513 | { | 619 | { |
514 | if ((le->reference != NULL) && (le->attest == NULL)) | 620 | if (GNUNET_NO == |
621 | GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) | ||
515 | { | 622 | { |
516 | for (le2 = attrs->list_head; NULL != le2; le2 = le2->next) | 623 | for (ale = attests->list_head; NULL != ale; ale = ale->next) |
517 | { | 624 | { |
518 | if ((le2->attest != NULL) && | 625 | if (GNUNET_YES == |
519 | (0 == memcmp (&le2->attest->id, | 626 | GNUNET_RECLAIM_id_is_equal (&le->attribute->id, |
520 | &le->reference->id_attest, | 627 | &ale->attestation->id)) |
521 | sizeof (le2->attest->id)))) | ||
522 | { | 628 | { |
523 | op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest, | 629 | op->ar_cb (op->cls, &msg->identity, |
524 | le->reference); | 630 | le->attribute, ale->attestation); |
525 | break; | 631 | break; |
526 | } | 632 | } |
527 | 633 | ||
528 | } | 634 | } |
529 | } | 635 | } |
636 | else // No attestations | ||
637 | { | ||
638 | op->ar_cb (op->cls, &msg->identity, | ||
639 | le->attribute, NULL); | ||
640 | } | ||
530 | } | 641 | } |
531 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); | 642 | GNUNET_RECLAIM_attribute_list_destroy (attrs); |
643 | GNUNET_RECLAIM_attestation_list_destroy (attests); | ||
532 | attrs = NULL; | 644 | attrs = NULL; |
645 | attests = NULL; | ||
533 | } | 646 | } |
534 | op->ar_cb (op->cls, NULL, NULL, NULL, NULL); | 647 | op->ar_cb (op->cls, NULL, NULL, NULL); |
535 | } | 648 | } |
536 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 649 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); |
537 | free_op (op); | 650 | free_op (op); |
@@ -582,9 +695,11 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
582 | struct GNUNET_RECLAIM_AttributeIterator *it; | 695 | struct GNUNET_RECLAIM_AttributeIterator *it; |
583 | struct GNUNET_RECLAIM_Operation *op; | 696 | struct GNUNET_RECLAIM_Operation *op; |
584 | size_t attr_len; | 697 | size_t attr_len; |
698 | size_t attest_len; | ||
585 | uint32_t r_id = ntohl (msg->id); | 699 | uint32_t r_id = ntohl (msg->id); |
586 | 700 | ||
587 | attr_len = ntohs (msg->attr_len); | 701 | attr_len = ntohs (msg->attr_len); |
702 | attest_len = ntohs (msg->attestation_len); | ||
588 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); | 703 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); |
589 | 704 | ||
590 | 705 | ||
@@ -615,7 +730,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
615 | if (NULL != op) | 730 | if (NULL != op) |
616 | { | 731 | { |
617 | if (NULL != op->ar_cb) | 732 | if (NULL != op->ar_cb) |
618 | op->ar_cb (op->cls, NULL, NULL, NULL, NULL); | 733 | op->ar_cb (op->cls, NULL, NULL, NULL); |
619 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 734 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); |
620 | free_op (op); | 735 | free_op (op); |
621 | } | 736 | } |
@@ -623,17 +738,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
623 | } | 738 | } |
624 | 739 | ||
625 | { | 740 | { |
626 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; | 741 | struct GNUNET_RECLAIM_Attribute *attr; |
627 | attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len); | 742 | struct GNUNET_RECLAIM_Attestation *attest; |
743 | char *read_ptr; | ||
744 | attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len); | ||
745 | read_ptr = ((char *) &msg[1]) + attr_len; | ||
746 | attest = GNUNET_RECLAIM_attestation_deserialize (read_ptr, attest_len); | ||
628 | if (NULL != it) | 747 | if (NULL != it) |
629 | { | 748 | { |
630 | if (NULL != it->proc) | 749 | if (NULL != it->proc) |
631 | it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL); | 750 | it->proc (it->proc_cls, &msg->identity, attr, attest); |
632 | } | 751 | } |
633 | else if (NULL != op) | 752 | else if (NULL != op) |
634 | { | 753 | { |
635 | if (NULL != op->ar_cb) | 754 | if (NULL != op->ar_cb) |
636 | op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL); | 755 | op->ar_cb (op->cls, &msg->identity, attr, attest); |
637 | } | 756 | } |
638 | GNUNET_free (attr); | 757 | GNUNET_free (attr); |
639 | return; | 758 | return; |
@@ -644,21 +763,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
644 | 763 | ||
645 | /** | 764 | /** |
646 | * Handle an incoming message of type | 765 | * Handle an incoming message of type |
647 | * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT | 766 | * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT |
648 | * | 767 | * |
649 | * @param cls | 768 | * @param cls |
650 | * @param msg the message we received | 769 | * @param msg the message we received |
651 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 770 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
652 | */ | 771 | */ |
653 | static int | 772 | static int |
654 | check_attestation_result (void *cls, const struct AttributeResultMessage *msg) | 773 | check_attestation_result (void *cls, const struct AttestationResultMessage *msg) |
655 | { | 774 | { |
656 | size_t msg_len; | 775 | size_t msg_len; |
657 | size_t attr_len; | 776 | size_t attr_len; |
658 | 777 | ||
659 | msg_len = ntohs (msg->header.size); | 778 | msg_len = ntohs (msg->header.size); |
660 | attr_len = ntohs (msg->attr_len); | 779 | attr_len = ntohs (msg->attestation_len); |
661 | if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) | 780 | if (msg_len != sizeof(struct AttestationResultMessage) + attr_len) |
662 | { | 781 | { |
663 | GNUNET_break (0); | 782 | GNUNET_break (0); |
664 | return GNUNET_SYSERR; | 783 | return GNUNET_SYSERR; |
@@ -669,26 +788,27 @@ check_attestation_result (void *cls, const struct AttributeResultMessage *msg) | |||
669 | 788 | ||
670 | /** | 789 | /** |
671 | * Handle an incoming message of type | 790 | * Handle an incoming message of type |
672 | * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT | 791 | * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT |
673 | * | 792 | * |
674 | * @param cls | 793 | * @param cls |
675 | * @param msg the message we received | 794 | * @param msg the message we received |
676 | */ | 795 | */ |
677 | static void | 796 | static void |
678 | handle_attestation_result (void *cls, const struct AttributeResultMessage *msg) | 797 | handle_attestation_result (void *cls, const struct |
798 | AttestationResultMessage *msg) | ||
679 | { | 799 | { |
680 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | 800 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; |
681 | struct GNUNET_RECLAIM_Handle *h = cls; | 801 | struct GNUNET_RECLAIM_Handle *h = cls; |
682 | struct GNUNET_RECLAIM_AttributeIterator *it; | 802 | struct GNUNET_RECLAIM_AttestationIterator *it; |
683 | struct GNUNET_RECLAIM_Operation *op; | 803 | struct GNUNET_RECLAIM_Operation *op; |
684 | size_t attr_len; | 804 | size_t att_len; |
685 | uint32_t r_id = ntohl (msg->id); | 805 | uint32_t r_id = ntohl (msg->id); |
686 | 806 | ||
687 | attr_len = ntohs (msg->attr_len); | 807 | att_len = ntohs (msg->attestation_len); |
688 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); | 808 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); |
689 | 809 | ||
690 | 810 | ||
691 | for (it = h->it_head; NULL != it; it = it->next) | 811 | for (it = h->ait_head; NULL != it; it = it->next) |
692 | if (it->r_id == r_id) | 812 | if (it->r_id == r_id) |
693 | break; | 813 | break; |
694 | for (op = h->op_head; NULL != op; op = op->next) | 814 | for (op = h->op_head; NULL != op; op = op->next) |
@@ -710,12 +830,12 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg) | |||
710 | { | 830 | { |
711 | if (NULL != it->finish_cb) | 831 | if (NULL != it->finish_cb) |
712 | it->finish_cb (it->finish_cb_cls); | 832 | it->finish_cb (it->finish_cb_cls); |
713 | free_it (it); | 833 | free_ait (it); |
714 | } | 834 | } |
715 | if (NULL != op) | 835 | if (NULL != op) |
716 | { | 836 | { |
717 | if (NULL != op->ar_cb) | 837 | if (NULL != op->at_cb) |
718 | op->ar_cb (op->cls, NULL, NULL, NULL, NULL); | 838 | op->at_cb (op->cls, NULL, NULL); |
719 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 839 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); |
720 | free_op (op); | 840 | free_op (op); |
721 | } | 841 | } |
@@ -723,126 +843,19 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg) | |||
723 | } | 843 | } |
724 | 844 | ||
725 | { | 845 | { |
726 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attr; | 846 | struct GNUNET_RECLAIM_Attestation *att; |
727 | attr = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], attr_len); | 847 | att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); |
728 | if (NULL != it) | 848 | if (NULL != it) |
729 | { | 849 | { |
730 | if (NULL != it->proc) | 850 | if (NULL != it->proc) |
731 | it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL); | 851 | it->proc (it->proc_cls, &msg->identity, att); |
732 | } | 852 | } |
733 | else if (NULL != op) | 853 | else if (NULL != op) |
734 | { | 854 | { |
735 | if (NULL != op->ar_cb) | 855 | if (NULL != op->at_cb) |
736 | op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL); | 856 | op->at_cb (op->cls, &msg->identity, att); |
737 | } | 857 | } |
738 | GNUNET_free (attr); | 858 | GNUNET_free (att); |
739 | return; | ||
740 | } | ||
741 | GNUNET_assert (0); | ||
742 | } | ||
743 | |||
744 | |||
745 | /** | ||
746 | * Handle an incoming message of type | ||
747 | * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT | ||
748 | * | ||
749 | * @param cls | ||
750 | * @param msg the message we received | ||
751 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
752 | */ | ||
753 | static int | ||
754 | check_reference_result (void *cls, const struct ReferenceResultMessage *msg) | ||
755 | { | ||
756 | size_t msg_len; | ||
757 | size_t attr_len; | ||
758 | size_t ref_len; | ||
759 | |||
760 | msg_len = ntohs (msg->header.size); | ||
761 | attr_len = ntohs (msg->attest_len); | ||
762 | ref_len = ntohs (msg->ref_len); | ||
763 | if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len) | ||
764 | { | ||
765 | GNUNET_break (0); | ||
766 | return GNUNET_SYSERR; | ||
767 | } | ||
768 | return GNUNET_OK; | ||
769 | } | ||
770 | |||
771 | |||
772 | /** | ||
773 | * Handle an incoming message of type | ||
774 | * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT | ||
775 | * | ||
776 | * @param cls | ||
777 | * @param msg the message we received | ||
778 | */ | ||
779 | static void | ||
780 | handle_reference_result (void *cls, const struct ReferenceResultMessage *msg) | ||
781 | { | ||
782 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | ||
783 | struct GNUNET_RECLAIM_Handle *h = cls; | ||
784 | struct GNUNET_RECLAIM_AttributeIterator *it; | ||
785 | struct GNUNET_RECLAIM_Operation *op; | ||
786 | size_t attest_len; | ||
787 | size_t ref_len; | ||
788 | uint32_t r_id = ntohl (msg->id); | ||
789 | attest_len = ntohs (msg->attest_len); | ||
790 | ref_len = ntohs (msg->ref_len); | ||
791 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n"); | ||
792 | for (it = h->it_head; NULL != it; it = it->next) | ||
793 | if (it->r_id == r_id) | ||
794 | break; | ||
795 | for (op = h->op_head; NULL != op; op = op->next) | ||
796 | if (op->r_id == r_id) | ||
797 | break; | ||
798 | if ((NULL == it) && (NULL == op)) | ||
799 | return; | ||
800 | |||
801 | if ((0 == | ||
802 | (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy))))) | ||
803 | { | ||
804 | if ((NULL == it) && (NULL == op)) | ||
805 | { | ||
806 | GNUNET_break (0); | ||
807 | force_reconnect (h); | ||
808 | return; | ||
809 | } | ||
810 | if (NULL != it) | ||
811 | { | ||
812 | if (NULL != it->finish_cb) | ||
813 | it->finish_cb (it->finish_cb_cls); | ||
814 | free_it (it); | ||
815 | } | ||
816 | if (NULL != op) | ||
817 | { | ||
818 | if (NULL != op->ar_cb) | ||
819 | op->ar_cb (op->cls, NULL, NULL, NULL, NULL); | ||
820 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | ||
821 | free_op (op); | ||
822 | } | ||
823 | return; | ||
824 | } | ||
825 | |||
826 | { | ||
827 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
828 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | ||
829 | attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], | ||
830 | attest_len); | ||
831 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1] | ||
832 | + attest_len, | ||
833 | ref_len); | ||
834 | if (NULL != it) | ||
835 | { | ||
836 | if (NULL != it->proc) | ||
837 | it->proc (it->proc_cls, &msg->identity, NULL, attest, ref); | ||
838 | } | ||
839 | else if (NULL != op) | ||
840 | { | ||
841 | if (NULL != op->ar_cb) | ||
842 | op->ar_cb (op->cls, &msg->identity, NULL, attest, ref); | ||
843 | } | ||
844 | GNUNET_free (ref); | ||
845 | GNUNET_free (attest); | ||
846 | return; | 859 | return; |
847 | } | 860 | } |
848 | GNUNET_assert (0); | 861 | GNUNET_assert (0); |
@@ -969,11 +982,7 @@ reconnect (struct GNUNET_RECLAIM_Handle *h) | |||
969 | h), | 982 | h), |
970 | GNUNET_MQ_hd_var_size (attestation_result, | 983 | GNUNET_MQ_hd_var_size (attestation_result, |
971 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, | 984 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, |
972 | struct AttributeResultMessage, | 985 | struct AttestationResultMessage, |
973 | h), | ||
974 | GNUNET_MQ_hd_var_size (reference_result, | ||
975 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT, | ||
976 | struct ReferenceResultMessage, | ||
977 | h), | 986 | h), |
978 | GNUNET_MQ_hd_fixed_size (ticket_result, | 987 | GNUNET_MQ_hd_fixed_size (ticket_result, |
979 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, | 988 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, |
@@ -1083,7 +1092,7 @@ struct GNUNET_RECLAIM_Operation * | |||
1083 | GNUNET_RECLAIM_attribute_store ( | 1092 | GNUNET_RECLAIM_attribute_store ( |
1084 | struct GNUNET_RECLAIM_Handle *h, | 1093 | struct GNUNET_RECLAIM_Handle *h, |
1085 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1094 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1086 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 1095 | const struct GNUNET_RECLAIM_Attribute *attr, |
1087 | const struct GNUNET_TIME_Relative *exp_interval, | 1096 | const struct GNUNET_TIME_Relative *exp_interval, |
1088 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1097 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1089 | void *cont_cls) | 1098 | void *cont_cls) |
@@ -1098,7 +1107,7 @@ GNUNET_RECLAIM_attribute_store ( | |||
1098 | op->cls = cont_cls; | 1107 | op->cls = cont_cls; |
1099 | op->r_id = h->r_id_gen++; | 1108 | op->r_id = h->r_id_gen++; |
1100 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1109 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1101 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); | 1110 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); |
1102 | op->env = GNUNET_MQ_msg_extra (sam, | 1111 | op->env = GNUNET_MQ_msg_extra (sam, |
1103 | attr_len, | 1112 | attr_len, |
1104 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); | 1113 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); |
@@ -1106,7 +1115,7 @@ GNUNET_RECLAIM_attribute_store ( | |||
1106 | sam->id = htonl (op->r_id); | 1115 | sam->id = htonl (op->r_id); |
1107 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 1116 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
1108 | 1117 | ||
1109 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]); | 1118 | GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]); |
1110 | 1119 | ||
1111 | sam->attr_len = htons (attr_len); | 1120 | sam->attr_len = htons (attr_len); |
1112 | if (NULL != h->mq) | 1121 | if (NULL != h->mq) |
@@ -1130,7 +1139,7 @@ struct GNUNET_RECLAIM_Operation * | |||
1130 | GNUNET_RECLAIM_attribute_delete ( | 1139 | GNUNET_RECLAIM_attribute_delete ( |
1131 | struct GNUNET_RECLAIM_Handle *h, | 1140 | struct GNUNET_RECLAIM_Handle *h, |
1132 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1141 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1133 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 1142 | const struct GNUNET_RECLAIM_Attribute *attr, |
1134 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1143 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1135 | void *cont_cls) | 1144 | void *cont_cls) |
1136 | { | 1145 | { |
@@ -1144,13 +1153,13 @@ GNUNET_RECLAIM_attribute_delete ( | |||
1144 | op->cls = cont_cls; | 1153 | op->cls = cont_cls; |
1145 | op->r_id = h->r_id_gen++; | 1154 | op->r_id = h->r_id_gen++; |
1146 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1155 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1147 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); | 1156 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); |
1148 | op->env = GNUNET_MQ_msg_extra (dam, | 1157 | op->env = GNUNET_MQ_msg_extra (dam, |
1149 | attr_len, | 1158 | attr_len, |
1150 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); | 1159 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); |
1151 | dam->identity = *pkey; | 1160 | dam->identity = *pkey; |
1152 | dam->id = htonl (op->r_id); | 1161 | dam->id = htonl (op->r_id); |
1153 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]); | 1162 | GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]); |
1154 | 1163 | ||
1155 | dam->attr_len = htons (attr_len); | 1164 | dam->attr_len = htons (attr_len); |
1156 | if (NULL != h->mq) | 1165 | if (NULL != h->mq) |
@@ -1175,7 +1184,7 @@ struct GNUNET_RECLAIM_Operation * | |||
1175 | GNUNET_RECLAIM_attestation_store ( | 1184 | GNUNET_RECLAIM_attestation_store ( |
1176 | struct GNUNET_RECLAIM_Handle *h, | 1185 | struct GNUNET_RECLAIM_Handle *h, |
1177 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1186 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1178 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, | 1187 | const struct GNUNET_RECLAIM_Attestation *attr, |
1179 | const struct GNUNET_TIME_Relative *exp_interval, | 1188 | const struct GNUNET_TIME_Relative *exp_interval, |
1180 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1189 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1181 | void *cont_cls) | 1190 | void *cont_cls) |
@@ -1190,7 +1199,7 @@ GNUNET_RECLAIM_attestation_store ( | |||
1190 | op->cls = cont_cls; | 1199 | op->cls = cont_cls; |
1191 | op->r_id = h->r_id_gen++; | 1200 | op->r_id = h->r_id_gen++; |
1192 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1201 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1193 | attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr); | 1202 | attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); |
1194 | op->env = GNUNET_MQ_msg_extra (sam, | 1203 | op->env = GNUNET_MQ_msg_extra (sam, |
1195 | attr_len, | 1204 | attr_len, |
1196 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE); | 1205 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE); |
@@ -1198,7 +1207,7 @@ GNUNET_RECLAIM_attestation_store ( | |||
1198 | sam->id = htonl (op->r_id); | 1207 | sam->id = htonl (op->r_id); |
1199 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 1208 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
1200 | 1209 | ||
1201 | GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &sam[1]); | 1210 | GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]); |
1202 | 1211 | ||
1203 | sam->attr_len = htons (attr_len); | 1212 | sam->attr_len = htons (attr_len); |
1204 | if (NULL != h->mq) | 1213 | if (NULL != h->mq) |
@@ -1222,7 +1231,7 @@ struct GNUNET_RECLAIM_Operation * | |||
1222 | GNUNET_RECLAIM_attestation_delete ( | 1231 | GNUNET_RECLAIM_attestation_delete ( |
1223 | struct GNUNET_RECLAIM_Handle *h, | 1232 | struct GNUNET_RECLAIM_Handle *h, |
1224 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1233 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1225 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, | 1234 | const struct GNUNET_RECLAIM_Attestation *attr, |
1226 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1235 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1227 | void *cont_cls) | 1236 | void *cont_cls) |
1228 | { | 1237 | { |
@@ -1236,105 +1245,13 @@ GNUNET_RECLAIM_attestation_delete ( | |||
1236 | op->cls = cont_cls; | 1245 | op->cls = cont_cls; |
1237 | op->r_id = h->r_id_gen++; | 1246 | op->r_id = h->r_id_gen++; |
1238 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1247 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1239 | attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr); | 1248 | attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); |
1240 | op->env = GNUNET_MQ_msg_extra (dam, | 1249 | op->env = GNUNET_MQ_msg_extra (dam, |
1241 | attr_len, | 1250 | attr_len, |
1242 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE); | 1251 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE); |
1243 | dam->identity = *pkey; | 1252 | dam->identity = *pkey; |
1244 | dam->id = htonl (op->r_id); | 1253 | dam->id = htonl (op->r_id); |
1245 | GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &dam[1]); | 1254 | GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]); |
1246 | |||
1247 | dam->attr_len = htons (attr_len); | ||
1248 | if (NULL != h->mq) | ||
1249 | GNUNET_MQ_send_copy (h->mq, op->env); | ||
1250 | return op; | ||
1251 | } | ||
1252 | |||
1253 | |||
1254 | /** | ||
1255 | * Store an attestation reference. If the reference is already present, | ||
1256 | * it is replaced with the new reference. | ||
1257 | * | ||
1258 | * @param h handle to the re:claimID service | ||
1259 | * @param pkey private key of the identity | ||
1260 | * @param attr the reference value | ||
1261 | * @param exp_interval the relative expiration interval for the reference | ||
1262 | * @param cont continuation to call when done | ||
1263 | * @param cont_cls closure for @a cont | ||
1264 | * @return handle to abort the request | ||
1265 | */ | ||
1266 | struct GNUNET_RECLAIM_Operation * | ||
1267 | GNUNET_RECLAIM_attestation_reference_store ( | ||
1268 | struct GNUNET_RECLAIM_Handle *h, | ||
1269 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
1270 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, | ||
1271 | const struct GNUNET_TIME_Relative *exp_interval, | ||
1272 | GNUNET_RECLAIM_ContinuationWithStatus cont, | ||
1273 | void *cont_cls) | ||
1274 | { | ||
1275 | struct GNUNET_RECLAIM_Operation *op; | ||
1276 | struct AttributeStoreMessage *sam; | ||
1277 | size_t attr_len; | ||
1278 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | ||
1279 | op->h = h; | ||
1280 | op->as_cb = cont; | ||
1281 | op->cls = cont_cls; | ||
1282 | op->r_id = h->r_id_gen++; | ||
1283 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | ||
1284 | attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr); | ||
1285 | op->env = GNUNET_MQ_msg_extra (sam, | ||
1286 | attr_len, | ||
1287 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE); | ||
1288 | sam->identity = *pkey; | ||
1289 | sam->id = htonl (op->r_id); | ||
1290 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | ||
1291 | |||
1292 | GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &sam[1]); | ||
1293 | |||
1294 | sam->attr_len = htons (attr_len); | ||
1295 | if (NULL != h->mq) | ||
1296 | GNUNET_MQ_send_copy (h->mq, op->env); | ||
1297 | return op; | ||
1298 | } | ||
1299 | |||
1300 | |||
1301 | /** | ||
1302 | * Delete an attestation reference. Tickets used to share this reference are updated | ||
1303 | * accordingly. | ||
1304 | * | ||
1305 | * @param h handle to the re:claimID service | ||
1306 | * @param pkey Private key of the identity to delete the reference from | ||
1307 | * @param attr The reference | ||
1308 | * @param cont Continuation to call when done | ||
1309 | * @param cont_cls Closure for @a cont | ||
1310 | * @return handle Used to to abort the request | ||
1311 | */ | ||
1312 | struct GNUNET_RECLAIM_Operation * | ||
1313 | GNUNET_RECLAIM_attestation_reference_delete ( | ||
1314 | struct GNUNET_RECLAIM_Handle *h, | ||
1315 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
1316 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, | ||
1317 | GNUNET_RECLAIM_ContinuationWithStatus cont, | ||
1318 | void *cont_cls) | ||
1319 | { | ||
1320 | |||
1321 | struct GNUNET_RECLAIM_Operation *op; | ||
1322 | struct AttributeDeleteMessage *dam; | ||
1323 | size_t attr_len; | ||
1324 | |||
1325 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | ||
1326 | op->h = h; | ||
1327 | op->as_cb = cont; | ||
1328 | op->cls = cont_cls; | ||
1329 | op->r_id = h->r_id_gen++; | ||
1330 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | ||
1331 | attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr); | ||
1332 | op->env = GNUNET_MQ_msg_extra (dam, | ||
1333 | attr_len, | ||
1334 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE); | ||
1335 | dam->identity = *pkey; | ||
1336 | dam->id = htonl (op->r_id); | ||
1337 | GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &dam[1]); | ||
1338 | 1255 | ||
1339 | dam->attr_len = htons (attr_len); | 1256 | dam->attr_len = htons (attr_len); |
1340 | if (NULL != h->mq) | 1257 | if (NULL != h->mq) |
@@ -1470,7 +1387,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1470 | struct GNUNET_RECLAIM_Handle *h, | 1387 | struct GNUNET_RECLAIM_Handle *h, |
1471 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 1388 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
1472 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 1389 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
1473 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 1390 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
1474 | GNUNET_RECLAIM_TicketCallback cb, | 1391 | GNUNET_RECLAIM_TicketCallback cb, |
1475 | void *cb_cls) | 1392 | void *cb_cls) |
1476 | { | 1393 | { |
@@ -1485,7 +1402,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1485 | op->cls = cb_cls; | 1402 | op->cls = cb_cls; |
1486 | op->r_id = h->r_id_gen++; | 1403 | op->r_id = h->r_id_gen++; |
1487 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1404 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1488 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); | 1405 | attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); |
1489 | op->env = GNUNET_MQ_msg_extra (tim, | 1406 | op->env = GNUNET_MQ_msg_extra (tim, |
1490 | attr_len, | 1407 | attr_len, |
1491 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); | 1408 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); |
@@ -1493,7 +1410,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1493 | tim->rp = *rp; | 1410 | tim->rp = *rp; |
1494 | tim->id = htonl (op->r_id); | 1411 | tim->id = htonl (op->r_id); |
1495 | 1412 | ||
1496 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]); | 1413 | GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]); |
1497 | 1414 | ||
1498 | tim->attr_len = htons (attr_len); | 1415 | tim->attr_len = htons (attr_len); |
1499 | if (NULL != h->mq) | 1416 | if (NULL != h->mq) |