diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:06:26 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:06:26 +0900 |
commit | 0f2da4636e108c70697c589d9e38781f2bafefba (patch) | |
tree | 0e831befd71d4323596cdae55e8431df7720c531 /src/reclaim | |
parent | 4e2259f14be320c8e2fe2a672a473e09677269c4 (diff) | |
download | gnunet-0f2da4636e108c70697c589d9e38781f2bafefba.tar.gz gnunet-0f2da4636e108c70697c589d9e38781f2bafefba.zip |
IDENTITY
This commit is a major rework of the unclean GNUNET_IDENTITY_*Key
structures and its use in serialized objects (e.g. RPC messages).
The structures are now no longer to be used directly but instead through
their serialization helper functions whenever needed.
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/Makefile.am | 1 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 410 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 68 | ||||
-rw-r--r-- | src/reclaim/reclaim.h | 127 | ||||
-rw-r--r-- | src/reclaim/reclaim_api.c | 432 | ||||
-rw-r--r-- | src/reclaim/test_did_helper.c | 5 | ||||
-rw-r--r-- | src/reclaim/test_reclaim.conf | 6 | ||||
-rwxr-xr-x | src/reclaim/test_reclaim_attribute.sh | 2 | ||||
-rwxr-xr-x | src/reclaim/test_reclaim_consume.sh | 6 | ||||
-rwxr-xr-x | src/reclaim/test_reclaim_issue.sh | 4 |
10 files changed, 786 insertions, 275 deletions
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am index d29b5857a..37af360c8 100644 --- a/src/reclaim/Makefile.am +++ b/src/reclaim/Makefile.am | |||
@@ -138,6 +138,7 @@ libgnunetreclaim_la_SOURCES = \ | |||
138 | reclaim_credential.h | 138 | reclaim_credential.h |
139 | libgnunetreclaim_la_LIBADD = \ | 139 | libgnunetreclaim_la_LIBADD = \ |
140 | $(top_builddir)/src/util/libgnunetutil.la \ | 140 | $(top_builddir)/src/util/libgnunetutil.la \ |
141 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
141 | $(GN_LIBINTL) $(XLIB) | 142 | $(GN_LIBINTL) $(XLIB) |
142 | libgnunetreclaim_la_LDFLAGS = \ | 143 | libgnunetreclaim_la_LDFLAGS = \ |
143 | $(GN_LIB_LDFLAGS) \ | 144 | $(GN_LIB_LDFLAGS) \ |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 5c484e55d..ea97f8749 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -657,18 +657,27 @@ send_ticket_result (const struct IdpClient *client, | |||
657 | struct TicketResultMessage *irm; | 657 | struct TicketResultMessage *irm; |
658 | struct GNUNET_MQ_Envelope *env; | 658 | struct GNUNET_MQ_Envelope *env; |
659 | size_t pres_len = 0; | 659 | size_t pres_len = 0; |
660 | size_t tkt_len = 0; | ||
661 | ssize_t written; | ||
662 | char *buf; | ||
660 | 663 | ||
661 | if (NULL != presentations) | 664 | if (NULL != presentations) |
662 | { | 665 | { |
663 | pres_len = | 666 | pres_len = |
664 | GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations); | 667 | GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations); |
665 | } | 668 | } |
669 | if (NULL != ticket) | ||
670 | tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket); | ||
666 | env = GNUNET_MQ_msg_extra (irm, | 671 | env = GNUNET_MQ_msg_extra (irm, |
667 | pres_len, | 672 | pres_len + tkt_len, |
668 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); | 673 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); |
674 | buf = (char*) &irm[1]; | ||
669 | if (NULL != ticket) | 675 | if (NULL != ticket) |
670 | { | 676 | { |
671 | irm->ticket = *ticket; | 677 | irm->tkt_len = htonl (tkt_len); |
678 | written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); | ||
679 | GNUNET_assert (0 <= written); | ||
680 | buf += written; | ||
672 | } | 681 | } |
673 | // TODO add success member | 682 | // TODO add success member |
674 | irm->id = htonl (r_id); | 683 | irm->id = htonl (r_id); |
@@ -676,7 +685,7 @@ send_ticket_result (const struct IdpClient *client, | |||
676 | if (NULL != presentations) | 685 | if (NULL != presentations) |
677 | { | 686 | { |
678 | GNUNET_RECLAIM_presentation_list_serialize (presentations, | 687 | GNUNET_RECLAIM_presentation_list_serialize (presentations, |
679 | (char*) &irm[1]); | 688 | buf); |
680 | } | 689 | } |
681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); | 690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); |
682 | GNUNET_MQ_send (client->mq, env); | 691 | GNUNET_MQ_send (client->mq, env); |
@@ -732,11 +741,15 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
732 | { | 741 | { |
733 | uint16_t size; | 742 | uint16_t size; |
734 | size_t attrs_len; | 743 | size_t attrs_len; |
744 | size_t key_len; | ||
745 | size_t pkey_len; | ||
735 | 746 | ||
736 | size = ntohs (im->header.size); | 747 | size = ntohs (im->header.size); |
737 | attrs_len = ntohs (im->attr_len); | 748 | attrs_len = ntohs (im->attr_len); |
738 | 749 | key_len = ntohl (im->key_len); | |
739 | if (attrs_len > size - sizeof(struct IssueTicketMessage)) | 750 | pkey_len = ntohl (im->pkey_len); |
751 | if (size != attrs_len + key_len + pkey_len + sizeof(struct | ||
752 | IssueTicketMessage)) | ||
740 | { | 753 | { |
741 | GNUNET_break (0); | 754 | GNUNET_break (0); |
742 | return GNUNET_SYSERR; | 755 | return GNUNET_SYSERR; |
@@ -758,12 +771,43 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
758 | struct IdpClient *idp = cls; | 771 | struct IdpClient *idp = cls; |
759 | struct GNUNET_RECLAIM_AttributeList *attrs; | 772 | struct GNUNET_RECLAIM_AttributeList *attrs; |
760 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 773 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
774 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
775 | struct GNUNET_IDENTITY_PublicKey rp; | ||
761 | size_t attrs_len; | 776 | size_t attrs_len; |
777 | size_t key_len; | ||
778 | size_t pkey_len; | ||
779 | size_t read; | ||
780 | char *buf; | ||
762 | 781 | ||
763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); | 782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); |
783 | key_len = ntohl (im->key_len); | ||
784 | buf = (char *) &im[1]; | ||
785 | if ((GNUNET_SYSERR == | ||
786 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
787 | &identity, &read)) || | ||
788 | (read != key_len)) | ||
789 | { | ||
790 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
791 | "Failed to read private key\n"); | ||
792 | GNUNET_SERVICE_client_drop (idp->client); | ||
793 | return; | ||
794 | } | ||
795 | buf += read; | ||
796 | pkey_len = ntohl (im->pkey_len); | ||
797 | if ((GNUNET_SYSERR == | ||
798 | GNUNET_IDENTITY_read_public_key_from_buffer (buf, pkey_len, | ||
799 | &rp, &read)) || | ||
800 | (read != pkey_len)) | ||
801 | { | ||
802 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
803 | "Failed to read public key\n"); | ||
804 | GNUNET_SERVICE_client_drop (idp->client); | ||
805 | return; | ||
806 | } | ||
807 | buf += read; | ||
764 | tio = GNUNET_new (struct TicketIssueOperation); | 808 | tio = GNUNET_new (struct TicketIssueOperation); |
765 | attrs_len = ntohs (im->attr_len); | 809 | attrs_len = ntohs (im->attr_len); |
766 | attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1], | 810 | attrs = GNUNET_RECLAIM_attribute_list_deserialize (buf, |
767 | attrs_len); | 811 | attrs_len); |
768 | for (le = attrs->list_head; NULL != le; le = le->next) | 812 | for (le = attrs->list_head; NULL != le; le = le->next) |
769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 813 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -772,9 +816,9 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
772 | tio->r_id = ntohl (im->id); | 816 | tio->r_id = ntohl (im->id); |
773 | tio->client = idp; | 817 | tio->client = idp; |
774 | GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); | 818 | GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); |
775 | RECLAIM_TICKETS_issue (&im->identity, | 819 | RECLAIM_TICKETS_issue (&identity, |
776 | attrs, | 820 | attrs, |
777 | &im->rp, | 821 | &rp, |
778 | &issue_ticket_result_cb, | 822 | &issue_ticket_result_cb, |
779 | tio); | 823 | tio); |
780 | GNUNET_SERVICE_client_continue (idp->client); | 824 | GNUNET_SERVICE_client_continue (idp->client); |
@@ -846,15 +890,44 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
846 | { | 890 | { |
847 | struct TicketRevocationOperation *rop; | 891 | struct TicketRevocationOperation *rop; |
848 | struct IdpClient *idp = cls; | 892 | struct IdpClient *idp = cls; |
893 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
894 | struct GNUNET_RECLAIM_Ticket ticket; | ||
895 | size_t key_len; | ||
896 | size_t tkt_len; | ||
897 | size_t read; | ||
898 | char *buf; | ||
849 | 899 | ||
850 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); | 900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); |
901 | key_len = ntohl (rm->key_len); | ||
902 | buf = (char *) &rm[1]; | ||
903 | if ((GNUNET_SYSERR == | ||
904 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
905 | &identity, &read)) || | ||
906 | (read != key_len)) | ||
907 | { | ||
908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
909 | "Failed to read private key\n"); | ||
910 | GNUNET_SERVICE_client_drop (idp->client); | ||
911 | return; | ||
912 | } | ||
913 | buf += read; | ||
914 | tkt_len = ntohl (rm->tkt_len); | ||
915 | if ((GNUNET_SYSERR == | ||
916 | GNUNET_RECLAIM_read_ticket_from_buffer (buf, key_len, | ||
917 | &ticket, &read)) || | ||
918 | (read != tkt_len)) | ||
919 | { | ||
920 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
921 | "Failed to read ticket\n"); | ||
922 | GNUNET_SERVICE_client_drop (idp->client); | ||
923 | return; | ||
924 | } | ||
851 | rop = GNUNET_new (struct TicketRevocationOperation); | 925 | rop = GNUNET_new (struct TicketRevocationOperation); |
852 | rop->r_id = ntohl (rm->id); | 926 | rop->r_id = ntohl (rm->id); |
853 | rop->client = idp; | 927 | rop->client = idp; |
854 | GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop); | 928 | GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop); |
855 | rop->rh | 929 | rop->rh |
856 | = RECLAIM_TICKETS_revoke (&rm->ticket, &rm->identity, &revoke_result_cb, | 930 | = RECLAIM_TICKETS_revoke (&ticket, &identity, &revoke_result_cb, rop); |
857 | rop); | ||
858 | GNUNET_SERVICE_client_continue (idp->client); | 931 | GNUNET_SERVICE_client_continue (idp->client); |
859 | } | 932 | } |
860 | 933 | ||
@@ -882,6 +955,8 @@ consume_result_cb (void *cls, | |||
882 | char *data_tmp; | 955 | char *data_tmp; |
883 | size_t attrs_len = 0; | 956 | size_t attrs_len = 0; |
884 | size_t pres_len = 0; | 957 | size_t pres_len = 0; |
958 | size_t key_len; | ||
959 | ssize_t written; | ||
885 | 960 | ||
886 | if (GNUNET_OK != success) | 961 | if (GNUNET_OK != success) |
887 | { | 962 | { |
@@ -890,17 +965,23 @@ consume_result_cb (void *cls, | |||
890 | attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); | 965 | attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); |
891 | pres_len = GNUNET_RECLAIM_presentation_list_serialize_get_size ( | 966 | pres_len = GNUNET_RECLAIM_presentation_list_serialize_get_size ( |
892 | presentations); | 967 | presentations); |
968 | key_len = GNUNET_IDENTITY_public_key_get_length (identity); | ||
893 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 969 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
894 | "Sending CONSUME_TICKET_RESULT message\n"); | 970 | "Sending CONSUME_TICKET_RESULT message\n"); |
895 | env = GNUNET_MQ_msg_extra (crm, | 971 | env = GNUNET_MQ_msg_extra (crm, |
896 | attrs_len + pres_len, | 972 | attrs_len + pres_len + key_len, |
897 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); | 973 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); |
898 | crm->id = htonl (cop->r_id); | 974 | crm->id = htonl (cop->r_id); |
899 | crm->attrs_len = htons (attrs_len); | 975 | crm->attrs_len = htons (attrs_len); |
900 | crm->presentations_len = htons (pres_len); | 976 | crm->presentations_len = htons (pres_len); |
901 | crm->identity = *identity; | 977 | crm->key_len = htonl (key_len); |
902 | crm->result = htonl (success); | 978 | crm->result = htonl (success); |
903 | data_tmp = (char *) &crm[1]; | 979 | data_tmp = (char *) &crm[1]; |
980 | written = GNUNET_IDENTITY_write_public_key_to_buffer (identity, | ||
981 | data_tmp, | ||
982 | key_len); | ||
983 | GNUNET_assert (0 <= written); | ||
984 | data_tmp += written; | ||
904 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); | 985 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); |
905 | data_tmp += attrs_len; | 986 | data_tmp += attrs_len; |
906 | GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp); | 987 | GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp); |
@@ -924,7 +1005,7 @@ check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | |||
924 | uint16_t size; | 1005 | uint16_t size; |
925 | 1006 | ||
926 | size = ntohs (cm->header.size); | 1007 | size = ntohs (cm->header.size); |
927 | if (size != sizeof(struct ConsumeTicketMessage)) | 1008 | if (size <= sizeof(struct ConsumeTicketMessage)) |
928 | { | 1009 | { |
929 | GNUNET_break (0); | 1010 | GNUNET_break (0); |
930 | return GNUNET_SYSERR; | 1011 | return GNUNET_SYSERR; |
@@ -944,13 +1025,43 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | |||
944 | { | 1025 | { |
945 | struct ConsumeTicketOperation *cop; | 1026 | struct ConsumeTicketOperation *cop; |
946 | struct IdpClient *idp = cls; | 1027 | struct IdpClient *idp = cls; |
1028 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
1029 | struct GNUNET_RECLAIM_Ticket ticket; | ||
1030 | size_t key_len; | ||
1031 | size_t tkt_len; | ||
1032 | size_t read; | ||
1033 | char *buf; | ||
947 | 1034 | ||
948 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); | 1035 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); |
1036 | key_len = ntohl (cm->key_len); | ||
1037 | buf = (char *) &cm[1]; | ||
1038 | if ((GNUNET_SYSERR == | ||
1039 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
1040 | &identity, &read)) || | ||
1041 | (read != key_len)) | ||
1042 | { | ||
1043 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1044 | "Failed to read private key\n"); | ||
1045 | GNUNET_SERVICE_client_drop (idp->client); | ||
1046 | return; | ||
1047 | } | ||
1048 | buf += read; | ||
1049 | tkt_len = ntohl (cm->tkt_len); | ||
1050 | if ((GNUNET_SYSERR == | ||
1051 | GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, | ||
1052 | &ticket, &read)) || | ||
1053 | (read != tkt_len)) | ||
1054 | { | ||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1056 | "Failed to read ticket\n"); | ||
1057 | GNUNET_SERVICE_client_drop (idp->client); | ||
1058 | return; | ||
1059 | } | ||
949 | cop = GNUNET_new (struct ConsumeTicketOperation); | 1060 | cop = GNUNET_new (struct ConsumeTicketOperation); |
950 | cop->r_id = ntohl (cm->id); | 1061 | cop->r_id = ntohl (cm->id); |
951 | cop->client = idp; | 1062 | cop->client = idp; |
952 | cop->ch | 1063 | cop->ch |
953 | = RECLAIM_TICKETS_consume (&cm->identity, &cm->ticket, &consume_result_cb, | 1064 | = RECLAIM_TICKETS_consume (&identity, &ticket, &consume_result_cb, |
954 | cop); | 1065 | cop); |
955 | GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); | 1066 | GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); |
956 | GNUNET_SERVICE_client_continue (idp->client); | 1067 | GNUNET_SERVICE_client_continue (idp->client); |
@@ -1077,21 +1188,37 @@ handle_attribute_store_message (void *cls, | |||
1077 | { | 1188 | { |
1078 | struct AttributeStoreHandle *ash; | 1189 | struct AttributeStoreHandle *ash; |
1079 | struct IdpClient *idp = cls; | 1190 | struct IdpClient *idp = cls; |
1191 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
1080 | size_t data_len; | 1192 | size_t data_len; |
1193 | size_t key_len; | ||
1194 | size_t read; | ||
1195 | char *buf; | ||
1081 | 1196 | ||
1082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); | 1197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); |
1083 | 1198 | ||
1084 | data_len = ntohs (sam->attr_len); | 1199 | data_len = ntohs (sam->attr_len); |
1085 | 1200 | key_len = ntohl (sam->key_len); | |
1201 | buf = (char *) &sam[1]; | ||
1202 | if ((GNUNET_SYSERR == | ||
1203 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
1204 | &identity, &read)) || | ||
1205 | (read != key_len)) | ||
1206 | { | ||
1207 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1208 | "Failed to read private key\n"); | ||
1209 | GNUNET_SERVICE_client_drop (idp->client); | ||
1210 | return; | ||
1211 | } | ||
1212 | buf += read; | ||
1086 | ash = GNUNET_new (struct AttributeStoreHandle); | 1213 | ash = GNUNET_new (struct AttributeStoreHandle); |
1087 | GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1], | 1214 | GNUNET_RECLAIM_attribute_deserialize (buf, |
1088 | data_len, | 1215 | data_len, |
1089 | &ash->claim); | 1216 | &ash->claim); |
1090 | 1217 | ||
1091 | ash->r_id = ntohl (sam->id); | 1218 | ash->r_id = ntohl (sam->id); |
1092 | ash->identity = sam->identity; | 1219 | ash->identity = identity; |
1093 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); | 1220 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); |
1094 | GNUNET_IDENTITY_key_get_public (&sam->identity, &ash->identity_pkey); | 1221 | GNUNET_IDENTITY_key_get_public (&identity, &ash->identity_pkey); |
1095 | 1222 | ||
1096 | GNUNET_SERVICE_client_continue (idp->client); | 1223 | GNUNET_SERVICE_client_continue (idp->client); |
1097 | ash->client = idp; | 1224 | ash->client = idp; |
@@ -1262,20 +1389,36 @@ handle_credential_store_message (void *cls, | |||
1262 | { | 1389 | { |
1263 | struct AttributeStoreHandle *ash; | 1390 | struct AttributeStoreHandle *ash; |
1264 | struct IdpClient *idp = cls; | 1391 | struct IdpClient *idp = cls; |
1392 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
1265 | size_t data_len; | 1393 | size_t data_len; |
1394 | size_t key_len; | ||
1395 | size_t read; | ||
1396 | char *buf; | ||
1266 | 1397 | ||
1267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n"); | 1398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n"); |
1268 | 1399 | ||
1269 | data_len = ntohs (sam->attr_len); | 1400 | data_len = ntohs (sam->attr_len); |
1270 | 1401 | key_len = ntohl (sam->key_len); | |
1402 | buf = (char *) &sam[1]; | ||
1403 | if ((GNUNET_SYSERR == | ||
1404 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
1405 | &identity, &read)) || | ||
1406 | (read != key_len)) | ||
1407 | { | ||
1408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1409 | "Failed to read private key\n"); | ||
1410 | GNUNET_SERVICE_client_drop (idp->client); | ||
1411 | return; | ||
1412 | } | ||
1413 | buf += read; | ||
1271 | ash = GNUNET_new (struct AttributeStoreHandle); | 1414 | ash = GNUNET_new (struct AttributeStoreHandle); |
1272 | ash->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &sam[1], | 1415 | ash->credential = GNUNET_RECLAIM_credential_deserialize (buf, |
1273 | data_len); | 1416 | data_len); |
1274 | 1417 | ||
1275 | ash->r_id = ntohl (sam->id); | 1418 | ash->r_id = ntohl (sam->id); |
1276 | ash->identity = sam->identity; | 1419 | ash->identity = identity; |
1277 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); | 1420 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); |
1278 | GNUNET_IDENTITY_key_get_public (&sam->identity, &ash->identity_pkey); | 1421 | GNUNET_IDENTITY_key_get_public (&identity, &ash->identity_pkey); |
1279 | 1422 | ||
1280 | GNUNET_SERVICE_client_continue (idp->client); | 1423 | GNUNET_SERVICE_client_continue (idp->client); |
1281 | ash->client = idp; | 1424 | ash->client = idp; |
@@ -1717,20 +1860,36 @@ handle_attribute_delete_message (void *cls, | |||
1717 | { | 1860 | { |
1718 | struct AttributeDeleteHandle *adh; | 1861 | struct AttributeDeleteHandle *adh; |
1719 | struct IdpClient *idp = cls; | 1862 | struct IdpClient *idp = cls; |
1863 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
1720 | size_t data_len; | 1864 | size_t data_len; |
1865 | size_t key_len; | ||
1866 | size_t read; | ||
1867 | char *buf; | ||
1721 | 1868 | ||
1722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); | 1869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); |
1723 | 1870 | ||
1724 | data_len = ntohs (dam->attr_len); | 1871 | data_len = ntohs (dam->attr_len); |
1725 | 1872 | key_len = ntohl (dam->key_len); | |
1873 | buf = (char *) &dam[1]; | ||
1874 | if ((GNUNET_SYSERR == | ||
1875 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
1876 | &identity, &read)) || | ||
1877 | (read != key_len)) | ||
1878 | { | ||
1879 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1880 | "Failed to read private key\n"); | ||
1881 | GNUNET_SERVICE_client_drop (idp->client); | ||
1882 | return; | ||
1883 | } | ||
1884 | buf += read; | ||
1726 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1885 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1727 | GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1], | 1886 | GNUNET_RECLAIM_attribute_deserialize (buf, |
1728 | data_len, | 1887 | data_len, |
1729 | &adh->claim); | 1888 | &adh->claim); |
1730 | adh->credential = NULL; | 1889 | adh->credential = NULL; |
1731 | 1890 | ||
1732 | adh->r_id = ntohl (dam->id); | 1891 | adh->r_id = ntohl (dam->id); |
1733 | adh->identity = dam->identity; | 1892 | adh->identity = identity; |
1734 | adh->label | 1893 | adh->label |
1735 | = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, | 1894 | = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, |
1736 | sizeof(adh->claim->id)); | 1895 | sizeof(adh->claim->id)); |
@@ -1808,19 +1967,35 @@ handle_credential_delete_message (void *cls, | |||
1808 | { | 1967 | { |
1809 | struct AttributeDeleteHandle *adh; | 1968 | struct AttributeDeleteHandle *adh; |
1810 | struct IdpClient *idp = cls; | 1969 | struct IdpClient *idp = cls; |
1970 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
1811 | size_t data_len; | 1971 | size_t data_len; |
1972 | size_t key_len; | ||
1973 | size_t read; | ||
1974 | char *buf; | ||
1812 | 1975 | ||
1813 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n"); | 1976 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n"); |
1814 | 1977 | ||
1815 | data_len = ntohs (dam->attr_len); | 1978 | data_len = ntohs (dam->attr_len); |
1816 | 1979 | key_len = ntohl (dam->key_len); | |
1980 | buf = (char *) &dam[1]; | ||
1981 | if ((GNUNET_SYSERR == | ||
1982 | GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, | ||
1983 | &identity, &read)) || | ||
1984 | (read != key_len)) | ||
1985 | { | ||
1986 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1987 | "Failed to read private key\n"); | ||
1988 | GNUNET_SERVICE_client_drop (idp->client); | ||
1989 | return; | ||
1990 | } | ||
1991 | buf += read; | ||
1817 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1992 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1818 | adh->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &dam[1], | 1993 | adh->credential = GNUNET_RECLAIM_credential_deserialize (buf, |
1819 | data_len); | 1994 | data_len); |
1820 | adh->claim = NULL; | 1995 | adh->claim = NULL; |
1821 | 1996 | ||
1822 | adh->r_id = ntohl (dam->id); | 1997 | adh->r_id = ntohl (dam->id); |
1823 | adh->identity = dam->identity; | 1998 | adh->identity = identity; |
1824 | adh->label | 1999 | adh->label |
1825 | = GNUNET_STRINGS_data_to_string_alloc (&adh->credential->id, | 2000 | = GNUNET_STRINGS_data_to_string_alloc (&adh->credential->id, |
1826 | sizeof(adh->credential->id)); | 2001 | sizeof(adh->credential->id)); |
@@ -1858,6 +2033,7 @@ attr_iter_finished (void *cls) | |||
1858 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | 2033 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
1859 | arm->id = htonl (ai->request_id); | 2034 | arm->id = htonl (ai->request_id); |
1860 | arm->attr_len = htons (0); | 2035 | arm->attr_len = htons (0); |
2036 | arm->pkey_len = htonl (0); | ||
1861 | GNUNET_MQ_send (ai->client->mq, env); | 2037 | GNUNET_MQ_send (ai->client->mq, env); |
1862 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | 2038 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, |
1863 | ai->client->attr_iter_tail, | 2039 | ai->client->attr_iter_tail, |
@@ -1899,7 +2075,10 @@ attr_iter_cb (void *cls, | |||
1899 | { | 2075 | { |
1900 | struct Iterator *ai = cls; | 2076 | struct Iterator *ai = cls; |
1901 | struct GNUNET_MQ_Envelope *env; | 2077 | struct GNUNET_MQ_Envelope *env; |
2078 | struct GNUNET_IDENTITY_PublicKey identity; | ||
1902 | char *data_tmp; | 2079 | char *data_tmp; |
2080 | size_t key_len; | ||
2081 | ssize_t written; | ||
1903 | 2082 | ||
1904 | if ((rd_count != 1) || | 2083 | if ((rd_count != 1) || |
1905 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd->record_type)) | 2084 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd->record_type)) |
@@ -1912,18 +2091,44 @@ attr_iter_cb (void *cls, | |||
1912 | label); | 2091 | label); |
1913 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2092 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1914 | "Sending ATTRIBUTE_RESULT message\n"); | 2093 | "Sending ATTRIBUTE_RESULT message\n"); |
2094 | GNUNET_IDENTITY_key_get_public (zone, &identity); | ||
2095 | key_len = GNUNET_IDENTITY_public_key_get_length (&identity); | ||
1915 | env = GNUNET_MQ_msg_extra (arm, | 2096 | env = GNUNET_MQ_msg_extra (arm, |
1916 | rd->data_size, | 2097 | rd->data_size + key_len, |
1917 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | 2098 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
1918 | arm->id = htonl (ai->request_id); | 2099 | arm->id = htonl (ai->request_id); |
1919 | arm->attr_len = htons (rd->data_size); | 2100 | arm->attr_len = htons (rd->data_size); |
1920 | GNUNET_IDENTITY_key_get_public (zone, &arm->identity); | ||
1921 | data_tmp = (char *) &arm[1]; | 2101 | data_tmp = (char *) &arm[1]; |
2102 | arm->pkey_len = htonl (key_len); | ||
2103 | written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, | ||
2104 | data_tmp, | ||
2105 | key_len); | ||
2106 | GNUNET_assert (0 <= written); | ||
2107 | data_tmp += written; | ||
1922 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2108 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
1923 | GNUNET_MQ_send (ai->client->mq, env); | 2109 | GNUNET_MQ_send (ai->client->mq, env); |
1924 | } | 2110 | } |
1925 | 2111 | ||
1926 | 2112 | ||
2113 | static enum GNUNET_GenericReturnValue | ||
2114 | check_iteration_start ( | ||
2115 | void *cls, | ||
2116 | const struct AttributeIterationStartMessage *ais_msg) | ||
2117 | { | ||
2118 | uint16_t size; | ||
2119 | size_t key_len; | ||
2120 | |||
2121 | size = ntohs (ais_msg->header.size); | ||
2122 | key_len = ntohs (ais_msg->key_len); | ||
2123 | |||
2124 | if (size < key_len + sizeof(*ais_msg)) | ||
2125 | { | ||
2126 | GNUNET_break (0); | ||
2127 | return GNUNET_SYSERR; | ||
2128 | } | ||
2129 | return GNUNET_OK; | ||
2130 | } | ||
2131 | |||
1927 | /** | 2132 | /** |
1928 | * Iterate over zone to get attributes | 2133 | * Iterate over zone to get attributes |
1929 | * | 2134 | * |
@@ -1936,13 +2141,29 @@ handle_iteration_start (void *cls, | |||
1936 | { | 2141 | { |
1937 | struct IdpClient *idp = cls; | 2142 | struct IdpClient *idp = cls; |
1938 | struct Iterator *ai; | 2143 | struct Iterator *ai; |
2144 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
2145 | size_t key_len; | ||
2146 | size_t read; | ||
1939 | 2147 | ||
1940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1941 | "Received ATTRIBUTE_ITERATION_START message\n"); | 2149 | "Received ATTRIBUTE_ITERATION_START message\n"); |
2150 | key_len = ntohl (ais_msg->key_len); | ||
2151 | if ((GNUNET_SYSERR == | ||
2152 | GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], | ||
2153 | key_len, | ||
2154 | &identity, | ||
2155 | &read)) || | ||
2156 | (read != key_len)) | ||
2157 | { | ||
2158 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2159 | "Failed to read private key.\n"); | ||
2160 | GNUNET_SERVICE_client_drop (idp->client); | ||
2161 | return; | ||
2162 | } | ||
1942 | ai = GNUNET_new (struct Iterator); | 2163 | ai = GNUNET_new (struct Iterator); |
1943 | ai->request_id = ntohl (ais_msg->id); | 2164 | ai->request_id = ntohl (ais_msg->id); |
1944 | ai->client = idp; | 2165 | ai->client = idp; |
1945 | ai->identity = ais_msg->identity; | 2166 | ai->identity = identity; |
1946 | 2167 | ||
1947 | GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); | 2168 | GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); |
1948 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 2169 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
@@ -2084,7 +2305,10 @@ cred_iter_cb (void *cls, | |||
2084 | struct Iterator *ai = cls; | 2305 | struct Iterator *ai = cls; |
2085 | struct GNUNET_MQ_Envelope *env; | 2306 | struct GNUNET_MQ_Envelope *env; |
2086 | struct CredentialResultMessage *arm; | 2307 | struct CredentialResultMessage *arm; |
2308 | struct GNUNET_IDENTITY_PublicKey identity; | ||
2087 | char *data_tmp; | 2309 | char *data_tmp; |
2310 | size_t key_len; | ||
2311 | ssize_t written; | ||
2088 | 2312 | ||
2089 | if ((rd_count != 1) || | 2313 | if ((rd_count != 1) || |
2090 | (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL != rd->record_type)) | 2314 | (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL != rd->record_type)) |
@@ -2096,18 +2320,42 @@ cred_iter_cb (void *cls, | |||
2096 | label); | 2320 | label); |
2097 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2098 | "Sending CREDENTIAL_RESULT message\n"); | 2322 | "Sending CREDENTIAL_RESULT message\n"); |
2323 | GNUNET_IDENTITY_key_get_public (zone, &identity); | ||
2324 | key_len = GNUNET_IDENTITY_public_key_get_length (&identity); | ||
2099 | env = GNUNET_MQ_msg_extra (arm, | 2325 | env = GNUNET_MQ_msg_extra (arm, |
2100 | rd->data_size, | 2326 | rd->data_size + key_len, |
2101 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); | 2327 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); |
2102 | arm->id = htonl (ai->request_id); | 2328 | arm->id = htonl (ai->request_id); |
2103 | arm->credential_len = htons (rd->data_size); | 2329 | arm->credential_len = htons (rd->data_size); |
2104 | GNUNET_IDENTITY_key_get_public (zone, &arm->identity); | ||
2105 | data_tmp = (char *) &arm[1]; | 2330 | data_tmp = (char *) &arm[1]; |
2331 | written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, | ||
2332 | data_tmp, | ||
2333 | key_len); | ||
2334 | GNUNET_assert (written >= 0); | ||
2335 | data_tmp += written; | ||
2106 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2336 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
2107 | |||
2108 | GNUNET_MQ_send (ai->client->mq, env); | 2337 | GNUNET_MQ_send (ai->client->mq, env); |
2109 | } | 2338 | } |
2110 | 2339 | ||
2340 | static enum GNUNET_GenericReturnValue | ||
2341 | check_credential_iteration_start ( | ||
2342 | void *cls, | ||
2343 | const struct CredentialIterationStartMessage *cis_msg) | ||
2344 | { | ||
2345 | uint16_t size; | ||
2346 | size_t key_len; | ||
2347 | |||
2348 | size = ntohs (cis_msg->header.size); | ||
2349 | key_len = ntohs (cis_msg->key_len); | ||
2350 | |||
2351 | if (size < key_len + sizeof(*cis_msg)) | ||
2352 | { | ||
2353 | GNUNET_break (0); | ||
2354 | return GNUNET_SYSERR; | ||
2355 | } | ||
2356 | return GNUNET_OK; | ||
2357 | } | ||
2358 | |||
2111 | 2359 | ||
2112 | /** | 2360 | /** |
2113 | * Iterate over zone to get attributes | 2361 | * Iterate over zone to get attributes |
@@ -2122,13 +2370,29 @@ handle_credential_iteration_start (void *cls, | |||
2122 | { | 2370 | { |
2123 | struct IdpClient *idp = cls; | 2371 | struct IdpClient *idp = cls; |
2124 | struct Iterator *ai; | 2372 | struct Iterator *ai; |
2373 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
2374 | size_t key_len; | ||
2375 | size_t read; | ||
2125 | 2376 | ||
2126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2127 | "Received CREDENTIAL_ITERATION_START message\n"); | 2378 | "Received CREDENTIAL_ITERATION_START message\n"); |
2379 | key_len = ntohl (ais_msg->key_len); | ||
2380 | if ((GNUNET_SYSERR == | ||
2381 | GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], | ||
2382 | key_len, | ||
2383 | &identity, | ||
2384 | &read)) || | ||
2385 | (read != key_len)) | ||
2386 | { | ||
2387 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2388 | "Failed to read private key.\n"); | ||
2389 | GNUNET_SERVICE_client_drop (idp->client); | ||
2390 | return; | ||
2391 | } | ||
2128 | ai = GNUNET_new (struct Iterator); | 2392 | ai = GNUNET_new (struct Iterator); |
2129 | ai->request_id = ntohl (ais_msg->id); | 2393 | ai->request_id = ntohl (ais_msg->id); |
2130 | ai->client = idp; | 2394 | ai->client = idp; |
2131 | ai->identity = ais_msg->identity; | 2395 | ai->identity = identity; |
2132 | 2396 | ||
2133 | GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail, | 2397 | GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail, |
2134 | ai); | 2398 | ai); |
@@ -2227,8 +2491,16 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2227 | struct TicketIteration *ti = cls; | 2491 | struct TicketIteration *ti = cls; |
2228 | struct GNUNET_MQ_Envelope *env; | 2492 | struct GNUNET_MQ_Envelope *env; |
2229 | struct TicketResultMessage *trm; | 2493 | struct TicketResultMessage *trm; |
2494 | size_t tkt_len; | ||
2230 | 2495 | ||
2231 | env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); | 2496 | if (NULL == ticket) |
2497 | tkt_len = 0; | ||
2498 | else | ||
2499 | tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket); | ||
2500 | |||
2501 | env = GNUNET_MQ_msg_extra (trm, | ||
2502 | tkt_len, | ||
2503 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); | ||
2232 | if (NULL == ticket) | 2504 | if (NULL == ticket) |
2233 | { | 2505 | { |
2234 | /* send empty response to indicate end of list */ | 2506 | /* send empty response to indicate end of list */ |
@@ -2238,8 +2510,11 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2238 | } | 2510 | } |
2239 | else | 2511 | else |
2240 | { | 2512 | { |
2241 | trm->ticket = *ticket; | 2513 | GNUNET_RECLAIM_write_ticket_to_buffer (ticket, |
2514 | &trm[1], | ||
2515 | tkt_len); | ||
2242 | } | 2516 | } |
2517 | trm->tkt_len = htonl (tkt_len); | ||
2243 | trm->id = htonl (ti->r_id); | 2518 | trm->id = htonl (ti->r_id); |
2244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); | 2519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); |
2245 | GNUNET_MQ_send (ti->client->mq, env); | 2520 | GNUNET_MQ_send (ti->client->mq, env); |
@@ -2247,6 +2522,24 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2247 | GNUNET_free (ti); | 2522 | GNUNET_free (ti); |
2248 | } | 2523 | } |
2249 | 2524 | ||
2525 | static enum GNUNET_GenericReturnValue | ||
2526 | check_ticket_iteration_start ( | ||
2527 | void *cls, | ||
2528 | const struct TicketIterationStartMessage *tis_msg) | ||
2529 | { | ||
2530 | uint16_t size; | ||
2531 | size_t key_len; | ||
2532 | |||
2533 | size = ntohs (tis_msg->header.size); | ||
2534 | key_len = ntohs (tis_msg->key_len); | ||
2535 | |||
2536 | if (size < key_len + sizeof(*tis_msg)) | ||
2537 | { | ||
2538 | GNUNET_break (0); | ||
2539 | return GNUNET_SYSERR; | ||
2540 | } | ||
2541 | return GNUNET_OK; | ||
2542 | } | ||
2250 | 2543 | ||
2251 | /** | 2544 | /** |
2252 | * Client requests a ticket iteration | 2545 | * Client requests a ticket iteration |
@@ -2259,20 +2552,35 @@ handle_ticket_iteration_start ( | |||
2259 | void *cls, | 2552 | void *cls, |
2260 | const struct TicketIterationStartMessage *tis_msg) | 2553 | const struct TicketIterationStartMessage *tis_msg) |
2261 | { | 2554 | { |
2555 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
2262 | struct IdpClient *client = cls; | 2556 | struct IdpClient *client = cls; |
2263 | struct TicketIteration *ti; | 2557 | struct TicketIteration *ti; |
2558 | size_t key_len; | ||
2559 | size_t read; | ||
2264 | 2560 | ||
2265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2266 | "Received TICKET_ITERATION_START message\n"); | 2562 | "Received TICKET_ITERATION_START message\n"); |
2563 | key_len = ntohl (tis_msg->key_len); | ||
2564 | if ((GNUNET_SYSERR == | ||
2565 | GNUNET_IDENTITY_read_private_key_from_buffer (&tis_msg[1], | ||
2566 | key_len, | ||
2567 | &identity, | ||
2568 | &read)) || | ||
2569 | (read != key_len)) | ||
2570 | { | ||
2571 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2572 | "Failed to read private key\n"); | ||
2573 | GNUNET_SERVICE_client_drop (client->client); | ||
2574 | return; | ||
2575 | } | ||
2267 | ti = GNUNET_new (struct TicketIteration); | 2576 | ti = GNUNET_new (struct TicketIteration); |
2268 | ti->r_id = ntohl (tis_msg->id); | 2577 | ti->r_id = ntohl (tis_msg->id); |
2269 | ti->client = client; | 2578 | ti->client = client; |
2270 | |||
2271 | GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head, | 2579 | GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head, |
2272 | client->ticket_iter_tail, | 2580 | client->ticket_iter_tail, |
2273 | ti); | 2581 | ti); |
2274 | ti->iter | 2582 | ti->iter |
2275 | = RECLAIM_TICKETS_iteration_start (&tis_msg->identity, &ticket_iter_cb, ti); | 2583 | = RECLAIM_TICKETS_iteration_start (&identity, &ticket_iter_cb, ti); |
2276 | GNUNET_SERVICE_client_continue (client->client); | 2584 | GNUNET_SERVICE_client_continue (client->client); |
2277 | } | 2585 | } |
2278 | 2586 | ||
@@ -2451,10 +2759,10 @@ GNUNET_SERVICE_MAIN ( | |||
2451 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, | 2759 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, |
2452 | struct AttributeDeleteMessage, | 2760 | struct AttributeDeleteMessage, |
2453 | NULL), | 2761 | NULL), |
2454 | GNUNET_MQ_hd_fixed_size (iteration_start, | 2762 | GNUNET_MQ_hd_var_size (iteration_start, |
2455 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 2763 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
2456 | struct AttributeIterationStartMessage, | 2764 | struct AttributeIterationStartMessage, |
2457 | NULL), | 2765 | NULL), |
2458 | GNUNET_MQ_hd_fixed_size (iteration_next, | 2766 | GNUNET_MQ_hd_fixed_size (iteration_next, |
2459 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, | 2767 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, |
2460 | struct AttributeIterationNextMessage, | 2768 | struct AttributeIterationNextMessage, |
@@ -2463,10 +2771,10 @@ GNUNET_SERVICE_MAIN ( | |||
2463 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, | 2771 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, |
2464 | struct AttributeIterationStopMessage, | 2772 | struct AttributeIterationStopMessage, |
2465 | NULL), | 2773 | NULL), |
2466 | GNUNET_MQ_hd_fixed_size (credential_iteration_start, | 2774 | GNUNET_MQ_hd_var_size (credential_iteration_start, |
2467 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, | 2775 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, |
2468 | struct CredentialIterationStartMessage, | 2776 | struct CredentialIterationStartMessage, |
2469 | NULL), | 2777 | NULL), |
2470 | GNUNET_MQ_hd_fixed_size (credential_iteration_next, | 2778 | GNUNET_MQ_hd_fixed_size (credential_iteration_next, |
2471 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, | 2779 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, |
2472 | struct CredentialIterationNextMessage, | 2780 | struct CredentialIterationNextMessage, |
@@ -2484,10 +2792,10 @@ GNUNET_SERVICE_MAIN ( | |||
2484 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, | 2792 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, |
2485 | struct ConsumeTicketMessage, | 2793 | struct ConsumeTicketMessage, |
2486 | NULL), | 2794 | NULL), |
2487 | GNUNET_MQ_hd_fixed_size (ticket_iteration_start, | 2795 | GNUNET_MQ_hd_var_size (ticket_iteration_start, |
2488 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, | 2796 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, |
2489 | struct TicketIterationStartMessage, | 2797 | struct TicketIterationStartMessage, |
2490 | NULL), | 2798 | NULL), |
2491 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, | 2799 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, |
2492 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, | 2800 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, |
2493 | struct TicketIterationNextMessage, | 2801 | struct TicketIterationNextMessage, |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index 9552094f1..5e2a5e974 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -742,7 +742,8 @@ rvk_move_attr_cb (void *cls, | |||
742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", | 742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", |
743 | new_label); | 743 | new_label); |
744 | GNUNET_free (credential); | 744 | GNUNET_free (credential); |
745 | } else { | 745 | } |
746 | else { | ||
746 | memcpy (&new_rd[i], &rd[i], sizeof (struct GNUNET_GNSRECORD_Data)); | 747 | memcpy (&new_rd[i], &rd[i], sizeof (struct GNUNET_GNSRECORD_Data)); |
747 | } | 748 | } |
748 | } | 749 | } |
@@ -1197,9 +1198,11 @@ RECLAIM_TICKETS_consume (const struct GNUNET_IDENTITY_PrivateKey *id, | |||
1197 | label = | 1198 | label = |
1198 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, | 1199 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, |
1199 | sizeof(cth->ticket.rnd)); | 1200 | sizeof(cth->ticket.rnd)); |
1201 | char *str = GNUNET_IDENTITY_public_key_to_string (&cth->ticket.identity); | ||
1200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1201 | "Looking for AuthZ info under %s\n", | 1203 | "Looking for AuthZ info under %s in %s\n", |
1202 | label); | 1204 | label, str); |
1205 | GNUNET_free (str); | ||
1203 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); | 1206 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); |
1204 | cth->lookup_request = | 1207 | cth->lookup_request = |
1205 | GNUNET_GNS_lookup (gns, | 1208 | GNUNET_GNS_lookup (gns, |
@@ -1289,6 +1292,7 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1289 | struct GNUNET_RECLAIM_PresentationListEntry *ple; | 1292 | struct GNUNET_RECLAIM_PresentationListEntry *ple; |
1290 | struct GNUNET_GNSRECORD_Data *attrs_record; | 1293 | struct GNUNET_GNSRECORD_Data *attrs_record; |
1291 | char *label; | 1294 | char *label; |
1295 | char *tkt_data; | ||
1292 | int i; | 1296 | int i; |
1293 | int j; | 1297 | int j; |
1294 | int attrs_count = 0; | 1298 | int attrs_count = 0; |
@@ -1376,8 +1380,13 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1376 | } | 1380 | } |
1377 | } | 1381 | } |
1378 | } | 1382 | } |
1379 | attrs_record[i].data = &ih->ticket; | 1383 | attrs_record[i].data_size = |
1380 | attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); | 1384 | GNUNET_RECLAIM_ticket_serialize_get_size (&ih->ticket); |
1385 | tkt_data = GNUNET_malloc (attrs_record[i].data_size); | ||
1386 | GNUNET_RECLAIM_write_ticket_to_buffer (&ih->ticket, | ||
1387 | tkt_data, | ||
1388 | attrs_record[i].data_size); | ||
1389 | attrs_record[i].data = tkt_data; | ||
1381 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | 1390 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
1382 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; | 1391 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; |
1383 | attrs_record[i].flags = | 1392 | attrs_record[i].flags = |
@@ -1387,6 +1396,13 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1387 | label = | 1396 | label = |
1388 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, | 1397 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, |
1389 | sizeof(ih->ticket.rnd)); | 1398 | sizeof(ih->ticket.rnd)); |
1399 | struct GNUNET_IDENTITY_PublicKey pub; | ||
1400 | GNUNET_IDENTITY_key_get_public (&ih->identity, | ||
1401 | &pub); | ||
1402 | char *str = GNUNET_IDENTITY_public_key_to_string (&pub); | ||
1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1404 | "Storing AuthZ information under %s in %s\n", label, str); | ||
1405 | GNUNET_free (str); | ||
1390 | // Publish record | 1406 | // Publish record |
1391 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1407 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
1392 | &ih->identity, | 1408 | &ih->identity, |
@@ -1404,6 +1420,7 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1404 | char *ptr = (char*) attrs_record[j].data; | 1420 | char *ptr = (char*) attrs_record[j].data; |
1405 | GNUNET_free (ptr); | 1421 | GNUNET_free (ptr); |
1406 | } | 1422 | } |
1423 | GNUNET_free (tkt_data); | ||
1407 | GNUNET_free (attrs_record); | 1424 | GNUNET_free (attrs_record); |
1408 | GNUNET_free (label); | 1425 | GNUNET_free (label); |
1409 | } | 1426 | } |
@@ -1454,7 +1471,7 @@ filter_tickets_cb (void *cls, | |||
1454 | const struct GNUNET_GNSRECORD_Data *rd) | 1471 | const struct GNUNET_GNSRECORD_Data *rd) |
1455 | { | 1472 | { |
1456 | struct TicketIssueHandle *tih = cls; | 1473 | struct TicketIssueHandle *tih = cls; |
1457 | struct GNUNET_RECLAIM_Ticket *ticket = NULL; | 1474 | struct GNUNET_RECLAIM_Ticket ticket; |
1458 | struct GNUNET_RECLAIM_Presentation *presentation; | 1475 | struct GNUNET_RECLAIM_Presentation *presentation; |
1459 | struct GNUNET_RECLAIM_PresentationList *ticket_presentations; | 1476 | struct GNUNET_RECLAIM_PresentationList *ticket_presentations; |
1460 | struct GNUNET_RECLAIM_Credential *cred; | 1477 | struct GNUNET_RECLAIM_Credential *cred; |
@@ -1462,6 +1479,7 @@ filter_tickets_cb (void *cls, | |||
1462 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 1479 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
1463 | unsigned int attr_cnt = 0; | 1480 | unsigned int attr_cnt = 0; |
1464 | unsigned int pres_cnt = 0; | 1481 | unsigned int pres_cnt = 0; |
1482 | int ticket_found = GNUNET_NO; | ||
1465 | 1483 | ||
1466 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | 1484 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1467 | { | 1485 | { |
@@ -1473,6 +1491,7 @@ filter_tickets_cb (void *cls, | |||
1473 | // ticket search | 1491 | // ticket search |
1474 | unsigned int found_attrs_cnt = 0; | 1492 | unsigned int found_attrs_cnt = 0; |
1475 | unsigned int found_pres_cnt = 0; | 1493 | unsigned int found_pres_cnt = 0; |
1494 | size_t read; | ||
1476 | ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); | 1495 | ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
1477 | 1496 | ||
1478 | for (int i = 0; i < rd_count; i++) | 1497 | for (int i = 0; i < rd_count; i++) |
@@ -1480,16 +1499,28 @@ filter_tickets_cb (void *cls, | |||
1480 | // found ticket | 1499 | // found ticket |
1481 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) | 1500 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) |
1482 | { | 1501 | { |
1483 | ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data; | 1502 | if ((GNUNET_SYSERR == |
1503 | GNUNET_RECLAIM_read_ticket_from_buffer (rd[i].data, | ||
1504 | rd[i].data_size, | ||
1505 | &ticket, | ||
1506 | &read)) || | ||
1507 | (read != rd[i].data_size)) | ||
1508 | { | ||
1509 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1510 | "Failed to deserialize ticket from record\n"); | ||
1511 | continue; | ||
1512 | } | ||
1484 | // cmp audience | 1513 | // cmp audience |
1514 | // FIXME this is ugly, GNUNET_IDENTITY_PublicKey cannot be compared | ||
1515 | // like this | ||
1485 | if (0 == memcmp (&tih->ticket.audience, | 1516 | if (0 == memcmp (&tih->ticket.audience, |
1486 | &ticket->audience, | 1517 | &ticket.audience, |
1487 | sizeof(struct GNUNET_IDENTITY_PublicKey))) | 1518 | sizeof(struct GNUNET_IDENTITY_PublicKey))) |
1488 | { | 1519 | { |
1489 | tih->ticket = *ticket; | 1520 | tih->ticket = ticket; |
1521 | ticket_found = GNUNET_YES; | ||
1490 | continue; | 1522 | continue; |
1491 | } | 1523 | } |
1492 | ticket = NULL; | ||
1493 | } | 1524 | } |
1494 | 1525 | ||
1495 | // cmp requested attributes with ticket attributes | 1526 | // cmp requested attributes with ticket attributes |
@@ -1573,7 +1604,7 @@ filter_tickets_cb (void *cls, | |||
1573 | */ | 1604 | */ |
1574 | if ((attr_cnt == found_attrs_cnt) && | 1605 | if ((attr_cnt == found_attrs_cnt) && |
1575 | (pres_cnt == found_pres_cnt) && | 1606 | (pres_cnt == found_pres_cnt) && |
1576 | (NULL != ticket)) | 1607 | (GNUNET_YES == ticket_found)) |
1577 | { | 1608 | { |
1578 | GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); | 1609 | GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); |
1579 | tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL); | 1610 | tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL); |
@@ -1683,12 +1714,25 @@ collect_tickets_cb (void *cls, | |||
1683 | const struct GNUNET_GNSRECORD_Data *rd) | 1714 | const struct GNUNET_GNSRECORD_Data *rd) |
1684 | { | 1715 | { |
1685 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 1716 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1717 | struct GNUNET_RECLAIM_Ticket ticket; | ||
1718 | size_t read; | ||
1686 | 1719 | ||
1687 | for (int i = 0; i < rd_count; i++) | 1720 | for (int i = 0; i < rd_count; i++) |
1688 | { | 1721 | { |
1689 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) | 1722 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) |
1690 | continue; | 1723 | continue; |
1691 | iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data); | 1724 | if ((GNUNET_SYSERR == |
1725 | GNUNET_RECLAIM_read_ticket_from_buffer (rd[i].data, | ||
1726 | rd[i].data_size, | ||
1727 | &ticket, | ||
1728 | &read)) || | ||
1729 | (read != rd[i].data_size)) | ||
1730 | { | ||
1731 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1732 | "Failed to deserialize ticket from record\n"); | ||
1733 | continue; | ||
1734 | } | ||
1735 | iter->cb (iter->cb_cls, &ticket); | ||
1692 | return; | 1736 | return; |
1693 | } | 1737 | } |
1694 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); | 1738 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); |
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h index aae8ee89a..5813beaf7 100644 --- a/src/reclaim/reclaim.h +++ b/src/reclaim/reclaim.h | |||
@@ -45,6 +45,11 @@ struct AttributeStoreMessage | |||
45 | struct GNUNET_MessageHeader header; | 45 | struct GNUNET_MessageHeader header; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * The expiration interval of the attribute | ||
49 | */ | ||
50 | uint64_t exp GNUNET_PACKED; | ||
51 | |||
52 | /** | ||
48 | * Unique identifier for this request (for key collisions). | 53 | * Unique identifier for this request (for key collisions). |
49 | */ | 54 | */ |
50 | uint32_t id GNUNET_PACKED; | 55 | uint32_t id GNUNET_PACKED; |
@@ -55,16 +60,13 @@ struct AttributeStoreMessage | |||
55 | uint32_t attr_len GNUNET_PACKED; | 60 | uint32_t attr_len GNUNET_PACKED; |
56 | 61 | ||
57 | /** | 62 | /** |
58 | * The expiration interval of the attribute | 63 | * The length of the private key |
59 | */ | ||
60 | uint64_t exp GNUNET_PACKED; | ||
61 | |||
62 | /** | ||
63 | * Identity | ||
64 | */ | 64 | */ |
65 | struct GNUNET_IDENTITY_PrivateKey identity; | 65 | uint32_t key_len GNUNET_PACKED; |
66 | 66 | ||
67 | /* followed by the serialized attribute */ | 67 | /* |
68 | * followed by the zone private key | ||
69 | * followed by the serialized attribute */ | ||
68 | }; | 70 | }; |
69 | 71 | ||
70 | 72 | ||
@@ -89,9 +91,9 @@ struct AttributeDeleteMessage | |||
89 | uint32_t attr_len GNUNET_PACKED; | 91 | uint32_t attr_len GNUNET_PACKED; |
90 | 92 | ||
91 | /** | 93 | /** |
92 | * Identity | 94 | * The length of the private key |
93 | */ | 95 | */ |
94 | struct GNUNET_IDENTITY_PrivateKey identity; | 96 | uint32_t key_len GNUNET_PACKED; |
95 | 97 | ||
96 | /* followed by the serialized attribute */ | 98 | /* followed by the serialized attribute */ |
97 | }; | 99 | }; |
@@ -149,11 +151,13 @@ struct AttributeResultMessage | |||
149 | uint16_t reserved GNUNET_PACKED; | 151 | uint16_t reserved GNUNET_PACKED; |
150 | 152 | ||
151 | /** | 153 | /** |
152 | * The public key of the identity. | 154 | * The length of the public key |
153 | */ | 155 | */ |
154 | struct GNUNET_IDENTITY_PublicKey identity; | 156 | uint32_t pkey_len GNUNET_PACKED; |
155 | 157 | ||
156 | /* followed by: | 158 | /** |
159 | * followed by the public key key. | ||
160 | * followed by: | ||
157 | * serialized attribute data | 161 | * serialized attribute data |
158 | */ | 162 | */ |
159 | }; | 163 | }; |
@@ -184,11 +188,13 @@ struct CredentialResultMessage | |||
184 | uint16_t reserved GNUNET_PACKED; | 188 | uint16_t reserved GNUNET_PACKED; |
185 | 189 | ||
186 | /** | 190 | /** |
187 | * The public key of the identity. | 191 | * The length of the public key |
188 | */ | 192 | */ |
189 | struct GNUNET_IDENTITY_PublicKey identity; | 193 | uint32_t key_len GNUNET_PACKED; |
190 | 194 | ||
191 | /* followed by: | 195 | /** |
196 | * followed by the private key. | ||
197 | * followed by: | ||
192 | * serialized credential data | 198 | * serialized credential data |
193 | */ | 199 | */ |
194 | }; | 200 | }; |
@@ -210,9 +216,13 @@ struct AttributeIterationStartMessage | |||
210 | uint32_t id GNUNET_PACKED; | 216 | uint32_t id GNUNET_PACKED; |
211 | 217 | ||
212 | /** | 218 | /** |
213 | * Identity. | 219 | * The length of the private key |
220 | */ | ||
221 | uint32_t key_len GNUNET_PACKED; | ||
222 | |||
223 | /** | ||
224 | * followed by the private key. | ||
214 | */ | 225 | */ |
215 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
216 | }; | 226 | }; |
217 | 227 | ||
218 | 228 | ||
@@ -249,9 +259,13 @@ struct CredentialIterationStartMessage | |||
249 | uint32_t id GNUNET_PACKED; | 259 | uint32_t id GNUNET_PACKED; |
250 | 260 | ||
251 | /** | 261 | /** |
252 | * Identity. | 262 | * The length of the private key |
263 | */ | ||
264 | uint32_t key_len GNUNET_PACKED; | ||
265 | |||
266 | /** | ||
267 | * followed by the private key. | ||
253 | */ | 268 | */ |
254 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
255 | }; | 269 | }; |
256 | 270 | ||
257 | 271 | ||
@@ -321,9 +335,13 @@ struct TicketIterationStartMessage | |||
321 | uint32_t id GNUNET_PACKED; | 335 | uint32_t id GNUNET_PACKED; |
322 | 336 | ||
323 | /** | 337 | /** |
324 | * Identity. | 338 | * The length of the private key |
339 | */ | ||
340 | uint32_t key_len GNUNET_PACKED; | ||
341 | |||
342 | /** | ||
343 | * followed by the private key. | ||
325 | */ | 344 | */ |
326 | struct GNUNET_IDENTITY_PrivateKey identity; | ||
327 | }; | 345 | }; |
328 | 346 | ||
329 | 347 | ||
@@ -377,21 +395,25 @@ struct IssueTicketMessage | |||
377 | uint32_t id GNUNET_PACKED; | 395 | uint32_t id GNUNET_PACKED; |
378 | 396 | ||
379 | /** | 397 | /** |
380 | * Identity. | 398 | * length of serialized attribute list |
381 | */ | 399 | */ |
382 | struct GNUNET_IDENTITY_PrivateKey identity; | 400 | uint32_t attr_len GNUNET_PACKED; |
383 | 401 | ||
384 | /** | 402 | /** |
385 | * Requesting party. | 403 | * The length of the identity private key |
386 | */ | 404 | */ |
387 | struct GNUNET_IDENTITY_PublicKey rp; | 405 | uint32_t key_len GNUNET_PACKED; |
388 | 406 | ||
389 | /** | 407 | /** |
390 | * length of serialized attribute list | 408 | * The length of the relying party public key |
391 | */ | 409 | */ |
392 | uint32_t attr_len GNUNET_PACKED; | 410 | uint32_t pkey_len GNUNET_PACKED; |
393 | 411 | ||
394 | // Followed by a serialized attribute list | 412 | /** |
413 | * Followed by the private key. | ||
414 | * Followed by the public key. | ||
415 | * Followed by a serialized attribute list | ||
416 | */ | ||
395 | }; | 417 | }; |
396 | 418 | ||
397 | /** | 419 | /** |
@@ -410,19 +432,20 @@ struct RevokeTicketMessage | |||
410 | uint32_t id GNUNET_PACKED; | 432 | uint32_t id GNUNET_PACKED; |
411 | 433 | ||
412 | /** | 434 | /** |
413 | * Identity. | 435 | * The length of the private key |
414 | */ | 436 | */ |
415 | struct GNUNET_IDENTITY_PrivateKey identity; | 437 | uint32_t key_len GNUNET_PACKED; |
416 | 438 | ||
417 | /** | 439 | /** |
418 | * length of serialized attribute list | 440 | * The length of the ticket |
419 | */ | 441 | */ |
420 | uint32_t attrs_len GNUNET_PACKED; | 442 | uint32_t tkt_len GNUNET_PACKED; |
421 | 443 | ||
422 | /** | 444 | /** |
423 | * The ticket to revoke | 445 | * Followed by the serialized ticket. |
446 | * Followed by the private key. | ||
447 | * Followed by a serialized attribute list | ||
424 | */ | 448 | */ |
425 | struct GNUNET_RECLAIM_Ticket ticket; | ||
426 | }; | 449 | }; |
427 | 450 | ||
428 | /** | 451 | /** |
@@ -463,16 +486,19 @@ struct TicketResultMessage | |||
463 | uint32_t id GNUNET_PACKED; | 486 | uint32_t id GNUNET_PACKED; |
464 | 487 | ||
465 | /** | 488 | /** |
466 | * Length of new presentations created | 489 | * Ticket length |
467 | */ | 490 | */ |
468 | uint32_t presentations_len GNUNET_PACKED; | 491 | uint32_t tkt_len GNUNET_PACKED; |
469 | 492 | ||
470 | /** | 493 | /** |
471 | * The new ticket | 494 | * Length of new presentations created |
472 | */ | 495 | */ |
473 | struct GNUNET_RECLAIM_Ticket ticket; | 496 | uint32_t presentations_len GNUNET_PACKED; |
474 | 497 | ||
475 | /* Followed by the serialized GNUNET_RECLAIM_PresentationList */ | 498 | /* |
499 | * Followed by the serialized ticket | ||
500 | * Followed by the serialized GNUNET_RECLAIM_PresentationList | ||
501 | */ | ||
476 | }; | 502 | }; |
477 | 503 | ||
478 | /** | 504 | /** |
@@ -491,14 +517,19 @@ struct ConsumeTicketMessage | |||
491 | uint32_t id GNUNET_PACKED; | 517 | uint32_t id GNUNET_PACKED; |
492 | 518 | ||
493 | /** | 519 | /** |
494 | * Identity. | 520 | * The length of the private key |
495 | */ | 521 | */ |
496 | struct GNUNET_IDENTITY_PrivateKey identity; | 522 | uint32_t key_len GNUNET_PACKED; |
497 | 523 | ||
498 | /** | 524 | /** |
499 | * The ticket to consume | 525 | * The length of the ticket |
526 | */ | ||
527 | uint32_t tkt_len GNUNET_PACKED; | ||
528 | |||
529 | /** | ||
530 | * Followed by the private key. | ||
531 | * Followed by the serialized ticket. | ||
500 | */ | 532 | */ |
501 | struct GNUNET_RECLAIM_Ticket ticket; | ||
502 | }; | 533 | }; |
503 | 534 | ||
504 | /** | 535 | /** |
@@ -537,11 +568,13 @@ struct ConsumeTicketResultMessage | |||
537 | uint16_t reserved GNUNET_PACKED; | 568 | uint16_t reserved GNUNET_PACKED; |
538 | 569 | ||
539 | /** | 570 | /** |
540 | * The public key of the identity. | 571 | * The length of the private key |
541 | */ | 572 | */ |
542 | struct GNUNET_IDENTITY_PublicKey identity; | 573 | uint32_t key_len GNUNET_PACKED; |
543 | 574 | ||
544 | /* followed by: | 575 | /** |
576 | * Followed by the private key. | ||
577 | * followed by: | ||
545 | * serialized attributes data | 578 | * serialized attributes data |
546 | */ | 579 | */ |
547 | }; | 580 | }; |
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 6f55d62e4..efc45e616 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -567,12 +567,13 @@ check_consume_ticket_result (void *cls, | |||
567 | size_t msg_len; | 567 | size_t msg_len; |
568 | size_t attrs_len; | 568 | size_t attrs_len; |
569 | size_t pl_len; | 569 | size_t pl_len; |
570 | size_t key_len; | ||
570 | 571 | ||
571 | msg_len = ntohs (msg->header.size); | 572 | msg_len = ntohs (msg->header.size); |
572 | attrs_len = ntohs (msg->attrs_len); | 573 | attrs_len = ntohs (msg->attrs_len); |
574 | key_len = ntohl (msg->key_len); | ||
573 | pl_len = ntohs (msg->presentations_len); | 575 | pl_len = ntohs (msg->presentations_len); |
574 | if (msg_len != | 576 | if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len) |
575 | sizeof(struct ConsumeTicketResultMessage) + attrs_len + pl_len) | ||
576 | { | 577 | { |
577 | GNUNET_break (0); | 578 | GNUNET_break (0); |
578 | return GNUNET_SYSERR; | 579 | return GNUNET_SYSERR; |
@@ -592,14 +593,18 @@ static void | |||
592 | handle_consume_ticket_result (void *cls, | 593 | handle_consume_ticket_result (void *cls, |
593 | const struct ConsumeTicketResultMessage *msg) | 594 | const struct ConsumeTicketResultMessage *msg) |
594 | { | 595 | { |
596 | struct GNUNET_IDENTITY_PublicKey identity; | ||
595 | struct GNUNET_RECLAIM_Handle *h = cls; | 597 | struct GNUNET_RECLAIM_Handle *h = cls; |
596 | struct GNUNET_RECLAIM_Operation *op; | 598 | struct GNUNET_RECLAIM_Operation *op; |
597 | size_t attrs_len; | 599 | size_t attrs_len; |
598 | size_t pl_len; | 600 | size_t pl_len; |
601 | size_t key_len; | ||
602 | size_t read; | ||
599 | uint32_t r_id = ntohl (msg->id); | 603 | uint32_t r_id = ntohl (msg->id); |
600 | char *read_ptr; | 604 | char *read_ptr; |
601 | 605 | ||
602 | attrs_len = ntohs (msg->attrs_len); | 606 | attrs_len = ntohs (msg->attrs_len); |
607 | key_len = ntohl (msg->key_len); | ||
603 | pl_len = ntohs (msg->presentations_len); | 608 | pl_len = ntohs (msg->presentations_len); |
604 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); | 609 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); |
605 | 610 | ||
@@ -615,15 +620,22 @@ handle_consume_ticket_result (void *cls, | |||
615 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 620 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
616 | struct GNUNET_RECLAIM_PresentationList *pl; | 621 | struct GNUNET_RECLAIM_PresentationList *pl; |
617 | struct GNUNET_RECLAIM_PresentationListEntry *ple; | 622 | struct GNUNET_RECLAIM_PresentationListEntry *ple; |
623 | read_ptr = (char *) &msg[1]; | ||
624 | GNUNET_assert (GNUNET_SYSERR != | ||
625 | GNUNET_IDENTITY_read_public_key_from_buffer (read_ptr, | ||
626 | key_len, | ||
627 | &identity, | ||
628 | &read)); | ||
629 | read_ptr += read; | ||
618 | attrs = | 630 | attrs = |
619 | GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len); | 631 | GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len); |
620 | read_ptr = ((char *) &msg[1]) + attrs_len; | 632 | read_ptr += attrs_len; |
621 | pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len); | 633 | pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len); |
622 | if (NULL != op->atr_cb) | 634 | if (NULL != op->atr_cb) |
623 | { | 635 | { |
624 | if (NULL == attrs) | 636 | if (NULL == attrs) |
625 | { | 637 | { |
626 | op->atr_cb (op->cls, &msg->identity, NULL, NULL); | 638 | op->atr_cb (op->cls, &identity, NULL, NULL); |
627 | } | 639 | } |
628 | else | 640 | else |
629 | { | 641 | { |
@@ -638,7 +650,7 @@ handle_consume_ticket_result (void *cls, | |||
638 | GNUNET_RECLAIM_id_is_equal (&le->attribute->credential, | 650 | GNUNET_RECLAIM_id_is_equal (&le->attribute->credential, |
639 | &ple->presentation->credential_id)) | 651 | &ple->presentation->credential_id)) |
640 | { | 652 | { |
641 | op->atr_cb (op->cls, &msg->identity, | 653 | op->atr_cb (op->cls, &identity, |
642 | le->attribute, ple->presentation); | 654 | le->attribute, ple->presentation); |
643 | break; | 655 | break; |
644 | } | 656 | } |
@@ -647,7 +659,7 @@ handle_consume_ticket_result (void *cls, | |||
647 | } | 659 | } |
648 | else // No credentials | 660 | else // No credentials |
649 | { | 661 | { |
650 | op->atr_cb (op->cls, &msg->identity, | 662 | op->atr_cb (op->cls, &identity, |
651 | le->attribute, NULL); | 663 | le->attribute, NULL); |
652 | } | 664 | } |
653 | } | 665 | } |
@@ -679,10 +691,12 @@ check_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
679 | { | 691 | { |
680 | size_t msg_len; | 692 | size_t msg_len; |
681 | size_t attr_len; | 693 | size_t attr_len; |
694 | size_t key_len; | ||
682 | 695 | ||
683 | msg_len = ntohs (msg->header.size); | 696 | msg_len = ntohs (msg->header.size); |
684 | attr_len = ntohs (msg->attr_len); | 697 | attr_len = ntohs (msg->attr_len); |
685 | if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) | 698 | key_len = ntohl (msg->pkey_len); |
699 | if (msg_len != sizeof(*msg) + attr_len + key_len) | ||
686 | { | 700 | { |
687 | GNUNET_break (0); | 701 | GNUNET_break (0); |
688 | return GNUNET_SYSERR; | 702 | return GNUNET_SYSERR; |
@@ -701,17 +715,20 @@ check_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
701 | static void | 715 | static void |
702 | handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | 716 | handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) |
703 | { | 717 | { |
704 | static struct GNUNET_IDENTITY_PrivateKey identity_dummy; | 718 | static struct GNUNET_IDENTITY_PublicKey identity; |
705 | struct GNUNET_RECLAIM_Handle *h = cls; | 719 | struct GNUNET_RECLAIM_Handle *h = cls; |
706 | struct GNUNET_RECLAIM_AttributeIterator *it; | 720 | struct GNUNET_RECLAIM_AttributeIterator *it; |
707 | struct GNUNET_RECLAIM_Operation *op; | 721 | struct GNUNET_RECLAIM_Operation *op; |
708 | size_t attr_len; | 722 | size_t attr_len; |
723 | size_t key_len; | ||
724 | size_t read; | ||
709 | uint32_t r_id = ntohl (msg->id); | 725 | uint32_t r_id = ntohl (msg->id); |
726 | char *buf; | ||
710 | 727 | ||
711 | attr_len = ntohs (msg->attr_len); | 728 | attr_len = ntohs (msg->attr_len); |
729 | key_len = ntohl (msg->pkey_len); | ||
712 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); | 730 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); |
713 | 731 | ||
714 | |||
715 | for (it = h->it_head; NULL != it; it = it->next) | 732 | for (it = h->it_head; NULL != it; it = it->next) |
716 | if (it->r_id == r_id) | 733 | if (it->r_id == r_id) |
717 | break; | 734 | break; |
@@ -721,8 +738,8 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
721 | if ((NULL == it) && (NULL == op)) | 738 | if ((NULL == it) && (NULL == op)) |
722 | return; | 739 | return; |
723 | 740 | ||
724 | if ((0 == | 741 | buf = (char *) &msg[1]; |
725 | (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy))))) | 742 | if (0 == key_len) |
726 | { | 743 | { |
727 | if ((NULL == it) && (NULL == op)) | 744 | if ((NULL == it) && (NULL == op)) |
728 | { | 745 | { |
@@ -748,17 +765,22 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
748 | 765 | ||
749 | { | 766 | { |
750 | struct GNUNET_RECLAIM_Attribute *attr; | 767 | struct GNUNET_RECLAIM_Attribute *attr; |
751 | GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len, | 768 | GNUNET_assert (GNUNET_SYSERR != |
752 | &attr); | 769 | GNUNET_IDENTITY_read_public_key_from_buffer (buf, |
770 | key_len, | ||
771 | &identity, | ||
772 | &read)); | ||
773 | buf += read; | ||
774 | GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr); | ||
753 | if (NULL != it) | 775 | if (NULL != it) |
754 | { | 776 | { |
755 | if (NULL != it->proc) | 777 | if (NULL != it->proc) |
756 | it->proc (it->proc_cls, &msg->identity, attr); | 778 | it->proc (it->proc_cls, &identity, attr); |
757 | } | 779 | } |
758 | else if (NULL != op) | 780 | else if (NULL != op) |
759 | { | 781 | { |
760 | if (NULL != op->ar_cb) | 782 | if (NULL != op->ar_cb) |
761 | op->ar_cb (op->cls, &msg->identity, attr); | 783 | op->ar_cb (op->cls, &identity, attr); |
762 | } | 784 | } |
763 | GNUNET_free (attr); | 785 | GNUNET_free (attr); |
764 | return; | 786 | return; |
@@ -780,10 +802,12 @@ check_credential_result (void *cls, const struct CredentialResultMessage *msg) | |||
780 | { | 802 | { |
781 | size_t msg_len; | 803 | size_t msg_len; |
782 | size_t cred_len; | 804 | size_t cred_len; |
805 | size_t key_len; | ||
783 | 806 | ||
784 | msg_len = ntohs (msg->header.size); | 807 | msg_len = ntohs (msg->header.size); |
785 | cred_len = ntohs (msg->credential_len); | 808 | cred_len = ntohs (msg->credential_len); |
786 | if (msg_len != sizeof(struct CredentialResultMessage) + cred_len) | 809 | key_len = ntohl (msg->key_len); |
810 | if (msg_len != sizeof(*msg) + cred_len + key_len) | ||
787 | { | 811 | { |
788 | GNUNET_break (0); | 812 | GNUNET_break (0); |
789 | return GNUNET_SYSERR; | 813 | return GNUNET_SYSERR; |
@@ -803,13 +827,17 @@ static void | |||
803 | handle_credential_result (void *cls, const struct | 827 | handle_credential_result (void *cls, const struct |
804 | CredentialResultMessage *msg) | 828 | CredentialResultMessage *msg) |
805 | { | 829 | { |
806 | static struct GNUNET_IDENTITY_PrivateKey identity_dummy; | 830 | struct GNUNET_IDENTITY_PublicKey identity; |
807 | struct GNUNET_RECLAIM_Handle *h = cls; | 831 | struct GNUNET_RECLAIM_Handle *h = cls; |
808 | struct GNUNET_RECLAIM_CredentialIterator *it; | 832 | struct GNUNET_RECLAIM_CredentialIterator *it; |
809 | struct GNUNET_RECLAIM_Operation *op; | 833 | struct GNUNET_RECLAIM_Operation *op; |
810 | size_t att_len; | 834 | size_t att_len; |
835 | size_t key_len; | ||
836 | size_t read; | ||
811 | uint32_t r_id = ntohl (msg->id); | 837 | uint32_t r_id = ntohl (msg->id); |
838 | char *buf; | ||
812 | 839 | ||
840 | key_len = ntohl (msg->key_len); | ||
813 | att_len = ntohs (msg->credential_len); | 841 | att_len = ntohs (msg->credential_len); |
814 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n"); | 842 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n"); |
815 | 843 | ||
@@ -823,8 +851,17 @@ handle_credential_result (void *cls, const struct | |||
823 | if ((NULL == it) && (NULL == op)) | 851 | if ((NULL == it) && (NULL == op)) |
824 | return; | 852 | return; |
825 | 853 | ||
826 | if ((0 == | 854 | buf = (char *) &msg[1]; |
827 | (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy))))) | 855 | if (0 < key_len) |
856 | { | ||
857 | GNUNET_assert (GNUNET_SYSERR != | ||
858 | GNUNET_IDENTITY_read_public_key_from_buffer (buf, | ||
859 | key_len, | ||
860 | &identity, | ||
861 | &read)); | ||
862 | buf += read; | ||
863 | } | ||
864 | if (0 == key_len) | ||
828 | { | 865 | { |
829 | if ((NULL == it) && (NULL == op)) | 866 | if ((NULL == it) && (NULL == op)) |
830 | { | 867 | { |
@@ -850,17 +887,17 @@ handle_credential_result (void *cls, const struct | |||
850 | 887 | ||
851 | { | 888 | { |
852 | struct GNUNET_RECLAIM_Credential *att; | 889 | struct GNUNET_RECLAIM_Credential *att; |
853 | att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len); | 890 | att = GNUNET_RECLAIM_credential_deserialize (buf, att_len); |
854 | 891 | ||
855 | if (NULL != it) | 892 | if (NULL != it) |
856 | { | 893 | { |
857 | if (NULL != it->proc) | 894 | if (NULL != it->proc) |
858 | it->proc (it->proc_cls, &msg->identity, att); | 895 | it->proc (it->proc_cls, &identity, att); |
859 | } | 896 | } |
860 | else if (NULL != op) | 897 | else if (NULL != op) |
861 | { | 898 | { |
862 | if (NULL != op->at_cb) | 899 | if (NULL != op->at_cb) |
863 | op->at_cb (op->cls, &msg->identity, att); | 900 | op->at_cb (op->cls, &identity, att); |
864 | } | 901 | } |
865 | GNUNET_free (att); | 902 | GNUNET_free (att); |
866 | return; | 903 | return; |
@@ -882,10 +919,12 @@ check_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
882 | { | 919 | { |
883 | size_t msg_len; | 920 | size_t msg_len; |
884 | size_t pres_len; | 921 | size_t pres_len; |
922 | size_t tkt_len; | ||
885 | 923 | ||
886 | msg_len = ntohs (msg->header.size); | 924 | msg_len = ntohs (msg->header.size); |
887 | pres_len = ntohs (msg->presentations_len); | 925 | pres_len = ntohs (msg->presentations_len); |
888 | if (msg_len != sizeof(struct TicketResultMessage) + pres_len) | 926 | tkt_len = ntohl (msg->tkt_len); |
927 | if (msg_len != sizeof(*msg) + pres_len + tkt_len) | ||
889 | { | 928 | { |
890 | GNUNET_break (0); | 929 | GNUNET_break (0); |
891 | return GNUNET_SYSERR; | 930 | return GNUNET_SYSERR; |
@@ -909,9 +948,14 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
909 | struct GNUNET_RECLAIM_TicketIterator *it; | 948 | struct GNUNET_RECLAIM_TicketIterator *it; |
910 | struct GNUNET_RECLAIM_PresentationList *presentation; | 949 | struct GNUNET_RECLAIM_PresentationList *presentation; |
911 | uint32_t r_id = ntohl (msg->id); | 950 | uint32_t r_id = ntohl (msg->id); |
912 | static const struct GNUNET_RECLAIM_Ticket ticket; | 951 | struct GNUNET_RECLAIM_Ticket ticket; |
913 | uint32_t pres_len = ntohs (msg->presentations_len); | 952 | size_t pres_len; |
953 | size_t tkt_len; | ||
954 | size_t tb_read; | ||
955 | char *buf; | ||
914 | 956 | ||
957 | tkt_len = ntohl (msg->tkt_len); | ||
958 | pres_len = ntohs (msg->presentations_len); | ||
915 | for (op = handle->op_head; NULL != op; op = op->next) | 959 | for (op = handle->op_head; NULL != op; op = op->next) |
916 | if (op->r_id == r_id) | 960 | if (op->r_id == r_id) |
917 | break; | 961 | break; |
@@ -920,15 +964,21 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
920 | break; | 964 | break; |
921 | if ((NULL == op) && (NULL == it)) | 965 | if ((NULL == op) && (NULL == it)) |
922 | return; | 966 | return; |
967 | buf = (char*) &msg[1]; | ||
968 | GNUNET_assert (GNUNET_SYSERR != | ||
969 | GNUNET_RECLAIM_read_ticket_from_buffer (buf, | ||
970 | tkt_len, | ||
971 | &ticket, | ||
972 | &tb_read)); | ||
973 | buf += tb_read; | ||
923 | if (NULL != op) | 974 | if (NULL != op) |
924 | { | 975 | { |
925 | if (0 < pres_len) | 976 | if (0 < pres_len) |
926 | presentation = GNUNET_RECLAIM_presentation_list_deserialize ( | 977 | presentation = GNUNET_RECLAIM_presentation_list_deserialize ( |
927 | (char*) &msg[1], | 978 | buf, |
928 | pres_len); | 979 | pres_len); |
929 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); | 980 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); |
930 | if (0 == | 981 | if (0 == tb_read) |
931 | memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) | ||
932 | { | 982 | { |
933 | if (NULL != op->ti_cb) | 983 | if (NULL != op->ti_cb) |
934 | op->ti_cb (op->cls, NULL, NULL); | 984 | op->ti_cb (op->cls, NULL, NULL); |
@@ -937,7 +987,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
937 | { | 987 | { |
938 | if (NULL != op->ti_cb) | 988 | if (NULL != op->ti_cb) |
939 | op->ti_cb (op->cls, | 989 | op->ti_cb (op->cls, |
940 | &msg->ticket, | 990 | &ticket, |
941 | (0 < pres_len) ? presentation : NULL); | 991 | (0 < pres_len) ? presentation : NULL); |
942 | } | 992 | } |
943 | if (0 < pres_len) | 993 | if (0 < pres_len) |
@@ -947,8 +997,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
947 | } | 997 | } |
948 | else if (NULL != it) | 998 | else if (NULL != it) |
949 | { | 999 | { |
950 | if (0 == | 1000 | if (0 == tkt_len) |
951 | memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) | ||
952 | { | 1001 | { |
953 | GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, | 1002 | GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, |
954 | handle->ticket_it_tail, | 1003 | handle->ticket_it_tail, |
@@ -959,7 +1008,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
959 | else | 1008 | else |
960 | { | 1009 | { |
961 | if (NULL != it->tr_cb) | 1010 | if (NULL != it->tr_cb) |
962 | it->tr_cb (it->cls, &msg->ticket); | 1011 | it->tr_cb (it->cls, &ticket); |
963 | } | 1012 | } |
964 | return; | 1013 | return; |
965 | } | 1014 | } |
@@ -1110,18 +1159,6 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) | |||
1110 | } | 1159 | } |
1111 | 1160 | ||
1112 | 1161 | ||
1113 | /** | ||
1114 | * Store an attribute. If the attribute is already present, | ||
1115 | * it is replaced with the new attribute. | ||
1116 | * | ||
1117 | * @param h handle to the re:claimID service | ||
1118 | * @param pkey private key of the identity | ||
1119 | * @param attr the attribute value | ||
1120 | * @param exp_interval the relative expiration interval for the attribute | ||
1121 | * @param cont continuation to call when done | ||
1122 | * @param cont_cls closure for @a cont | ||
1123 | * @return handle to abort the request | ||
1124 | */ | ||
1125 | struct GNUNET_RECLAIM_Operation * | 1162 | struct GNUNET_RECLAIM_Operation * |
1126 | GNUNET_RECLAIM_attribute_store ( | 1163 | GNUNET_RECLAIM_attribute_store ( |
1127 | struct GNUNET_RECLAIM_Handle *h, | 1164 | struct GNUNET_RECLAIM_Handle *h, |
@@ -1134,6 +1171,9 @@ GNUNET_RECLAIM_attribute_store ( | |||
1134 | struct GNUNET_RECLAIM_Operation *op; | 1171 | struct GNUNET_RECLAIM_Operation *op; |
1135 | struct AttributeStoreMessage *sam; | 1172 | struct AttributeStoreMessage *sam; |
1136 | size_t attr_len; | 1173 | size_t attr_len; |
1174 | size_t key_len; | ||
1175 | ssize_t written; | ||
1176 | char *buf; | ||
1137 | 1177 | ||
1138 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1178 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1139 | op->h = h; | 1179 | op->h = h; |
@@ -1141,15 +1181,20 @@ GNUNET_RECLAIM_attribute_store ( | |||
1141 | op->cls = cont_cls; | 1181 | op->cls = cont_cls; |
1142 | op->r_id = h->r_id_gen++; | 1182 | op->r_id = h->r_id_gen++; |
1143 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1183 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1184 | key_len = GNUNET_IDENTITY_private_key_get_length (pkey); | ||
1144 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); | 1185 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); |
1145 | op->env = GNUNET_MQ_msg_extra (sam, | 1186 | op->env = GNUNET_MQ_msg_extra (sam, |
1146 | attr_len, | 1187 | attr_len + key_len, |
1147 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); | 1188 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); |
1148 | sam->identity = *pkey; | 1189 | sam->key_len = htonl (key_len); |
1190 | buf = (char *) &sam[1]; | ||
1191 | written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); | ||
1192 | GNUNET_assert (0 < written); | ||
1193 | buf += written; | ||
1149 | sam->id = htonl (op->r_id); | 1194 | sam->id = htonl (op->r_id); |
1150 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 1195 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
1151 | 1196 | ||
1152 | GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]); | 1197 | GNUNET_RECLAIM_attribute_serialize (attr, buf); |
1153 | 1198 | ||
1154 | sam->attr_len = htons (attr_len); | 1199 | sam->attr_len = htons (attr_len); |
1155 | if (NULL != h->mq) | 1200 | if (NULL != h->mq) |
@@ -1158,17 +1203,6 @@ GNUNET_RECLAIM_attribute_store ( | |||
1158 | } | 1203 | } |
1159 | 1204 | ||
1160 | 1205 | ||
1161 | /** | ||
1162 | * Delete an attribute. Tickets used to share this attribute are updated | ||
1163 | * accordingly. | ||
1164 | * | ||
1165 | * @param h handle to the re:claimID service | ||
1166 | * @param pkey Private key of the identity to add an attribute to | ||
1167 | * @param attr The attribute | ||
1168 | * @param cont Continuation to call when done | ||
1169 | * @param cont_cls Closure for @a cont | ||
1170 | * @return handle Used to to abort the request | ||
1171 | */ | ||
1172 | struct GNUNET_RECLAIM_Operation * | 1206 | struct GNUNET_RECLAIM_Operation * |
1173 | GNUNET_RECLAIM_attribute_delete ( | 1207 | GNUNET_RECLAIM_attribute_delete ( |
1174 | struct GNUNET_RECLAIM_Handle *h, | 1208 | struct GNUNET_RECLAIM_Handle *h, |
@@ -1180,6 +1214,9 @@ GNUNET_RECLAIM_attribute_delete ( | |||
1180 | struct GNUNET_RECLAIM_Operation *op; | 1214 | struct GNUNET_RECLAIM_Operation *op; |
1181 | struct AttributeDeleteMessage *dam; | 1215 | struct AttributeDeleteMessage *dam; |
1182 | size_t attr_len; | 1216 | size_t attr_len; |
1217 | size_t key_len; | ||
1218 | ssize_t written; | ||
1219 | char *buf; | ||
1183 | 1220 | ||
1184 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1221 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1185 | op->h = h; | 1222 | op->h = h; |
@@ -1187,13 +1224,18 @@ GNUNET_RECLAIM_attribute_delete ( | |||
1187 | op->cls = cont_cls; | 1224 | op->cls = cont_cls; |
1188 | op->r_id = h->r_id_gen++; | 1225 | op->r_id = h->r_id_gen++; |
1189 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1226 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1227 | key_len = GNUNET_IDENTITY_private_key_get_length (pkey); | ||
1190 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); | 1228 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr); |
1191 | op->env = GNUNET_MQ_msg_extra (dam, | 1229 | op->env = GNUNET_MQ_msg_extra (dam, |
1192 | attr_len, | 1230 | attr_len + key_len, |
1193 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); | 1231 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); |
1194 | dam->identity = *pkey; | 1232 | dam->key_len = htonl (key_len); |
1233 | buf = (char *) &dam[1]; | ||
1234 | written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); | ||
1235 | GNUNET_assert (0 < written); | ||
1236 | buf += written; | ||
1195 | dam->id = htonl (op->r_id); | 1237 | dam->id = htonl (op->r_id); |
1196 | GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]); | 1238 | GNUNET_RECLAIM_attribute_serialize (attr, buf); |
1197 | 1239 | ||
1198 | dam->attr_len = htons (attr_len); | 1240 | dam->attr_len = htons (attr_len); |
1199 | if (NULL != h->mq) | 1241 | if (NULL != h->mq) |
@@ -1214,22 +1256,30 @@ GNUNET_RECLAIM_credential_store ( | |||
1214 | struct GNUNET_RECLAIM_Operation *op; | 1256 | struct GNUNET_RECLAIM_Operation *op; |
1215 | struct AttributeStoreMessage *sam; | 1257 | struct AttributeStoreMessage *sam; |
1216 | size_t attr_len; | 1258 | size_t attr_len; |
1259 | size_t key_len; | ||
1260 | ssize_t written; | ||
1261 | char *buf; | ||
1217 | 1262 | ||
1218 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1263 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1219 | op->h = h; | 1264 | op->h = h; |
1220 | op->as_cb = cont; | 1265 | op->as_cb = cont; |
1221 | op->cls = cont_cls; | 1266 | op->cls = cont_cls; |
1222 | op->r_id = h->r_id_gen++; | 1267 | op->r_id = h->r_id_gen++; |
1268 | key_len = GNUNET_IDENTITY_private_key_get_length (pkey); | ||
1223 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1269 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1224 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (credential); | 1270 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (credential); |
1225 | op->env = GNUNET_MQ_msg_extra (sam, | 1271 | op->env = GNUNET_MQ_msg_extra (sam, |
1226 | attr_len, | 1272 | attr_len + key_len, |
1227 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE); | 1273 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE); |
1228 | sam->identity = *pkey; | 1274 | sam->key_len = htonl (key_len); |
1275 | buf = (char *) &sam[1]; | ||
1276 | written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); | ||
1277 | GNUNET_assert (0 <= written); | ||
1278 | buf += written; | ||
1229 | sam->id = htonl (op->r_id); | 1279 | sam->id = htonl (op->r_id); |
1230 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 1280 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
1231 | 1281 | ||
1232 | GNUNET_RECLAIM_credential_serialize (credential, (char *) &sam[1]); | 1282 | GNUNET_RECLAIM_credential_serialize (credential, buf); |
1233 | 1283 | ||
1234 | sam->attr_len = htons (attr_len); | 1284 | sam->attr_len = htons (attr_len); |
1235 | if (NULL != h->mq) | 1285 | if (NULL != h->mq) |
@@ -1249,20 +1299,28 @@ GNUNET_RECLAIM_credential_delete ( | |||
1249 | struct GNUNET_RECLAIM_Operation *op; | 1299 | struct GNUNET_RECLAIM_Operation *op; |
1250 | struct AttributeDeleteMessage *dam; | 1300 | struct AttributeDeleteMessage *dam; |
1251 | size_t attr_len; | 1301 | size_t attr_len; |
1302 | size_t key_len; | ||
1303 | ssize_t written; | ||
1304 | char *buf; | ||
1252 | 1305 | ||
1253 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1306 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1254 | op->h = h; | 1307 | op->h = h; |
1255 | op->as_cb = cont; | 1308 | op->as_cb = cont; |
1256 | op->cls = cont_cls; | 1309 | op->cls = cont_cls; |
1257 | op->r_id = h->r_id_gen++; | 1310 | op->r_id = h->r_id_gen++; |
1311 | key_len = GNUNET_IDENTITY_private_key_get_length (pkey); | ||
1258 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1312 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1259 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr); | 1313 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr); |
1260 | op->env = GNUNET_MQ_msg_extra (dam, | 1314 | op->env = GNUNET_MQ_msg_extra (dam, |
1261 | attr_len, | 1315 | attr_len + key_len, |
1262 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE); | 1316 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE); |
1263 | dam->identity = *pkey; | 1317 | dam->key_len = htonl (key_len); |
1318 | buf = (char *) &dam[1]; | ||
1319 | written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); | ||
1320 | GNUNET_assert (0 <= written); | ||
1321 | buf += written; | ||
1264 | dam->id = htonl (op->r_id); | 1322 | dam->id = htonl (op->r_id); |
1265 | GNUNET_RECLAIM_credential_serialize (attr, (char *) &dam[1]); | 1323 | GNUNET_RECLAIM_credential_serialize (attr, buf); |
1266 | 1324 | ||
1267 | dam->attr_len = htons (attr_len); | 1325 | dam->attr_len = htons (attr_len); |
1268 | if (NULL != h->mq) | 1326 | if (NULL != h->mq) |
@@ -1271,30 +1329,6 @@ GNUNET_RECLAIM_credential_delete ( | |||
1271 | } | 1329 | } |
1272 | 1330 | ||
1273 | 1331 | ||
1274 | /** | ||
1275 | * List all attributes for a local identity. | ||
1276 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | ||
1277 | * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and | ||
1278 | * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once | ||
1279 | * immediately, and then again after | ||
1280 | * #GNUNET_RECLAIM_get_attributes_next() is invoked. | ||
1281 | * | ||
1282 | * On error (disconnect), @a error_cb will be invoked. | ||
1283 | * On normal completion, @a finish_cb proc will be | ||
1284 | * invoked. | ||
1285 | * | ||
1286 | * @param h Handle to the re:claimID service | ||
1287 | * @param identity Identity to iterate over | ||
1288 | * @param error_cb Function to call on error (i.e. disconnect), | ||
1289 | * the handle is afterwards invalid | ||
1290 | * @param error_cb_cls Closure for @a error_cb | ||
1291 | * @param proc Function to call on each attribute | ||
1292 | * @param proc_cls Closure for @a proc | ||
1293 | * @param finish_cb Function to call on completion | ||
1294 | * the handle is afterwards invalid | ||
1295 | * @param finish_cb_cls Closure for @a finish_cb | ||
1296 | * @return an iterator Handle to use for iteration | ||
1297 | */ | ||
1298 | struct GNUNET_RECLAIM_AttributeIterator * | 1332 | struct GNUNET_RECLAIM_AttributeIterator * |
1299 | GNUNET_RECLAIM_get_attributes_start ( | 1333 | GNUNET_RECLAIM_get_attributes_start ( |
1300 | struct GNUNET_RECLAIM_Handle *h, | 1334 | struct GNUNET_RECLAIM_Handle *h, |
@@ -1310,6 +1344,7 @@ GNUNET_RECLAIM_get_attributes_start ( | |||
1310 | struct GNUNET_MQ_Envelope *env; | 1344 | struct GNUNET_MQ_Envelope *env; |
1311 | struct AttributeIterationStartMessage *msg; | 1345 | struct AttributeIterationStartMessage *msg; |
1312 | uint32_t rid; | 1346 | uint32_t rid; |
1347 | size_t key_len; | ||
1313 | 1348 | ||
1314 | rid = h->r_id_gen++; | 1349 | rid = h->r_id_gen++; |
1315 | it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator); | 1350 | it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator); |
@@ -1322,11 +1357,15 @@ GNUNET_RECLAIM_get_attributes_start ( | |||
1322 | it->proc_cls = proc_cls; | 1357 | it->proc_cls = proc_cls; |
1323 | it->r_id = rid; | 1358 | it->r_id = rid; |
1324 | it->identity = *identity; | 1359 | it->identity = *identity; |
1360 | key_len = GNUNET_IDENTITY_private_key_get_length (identity); | ||
1325 | GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it); | 1361 | GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it); |
1326 | env = | 1362 | env = |
1327 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); | 1363 | GNUNET_MQ_msg_extra (msg, |
1364 | key_len, | ||
1365 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); | ||
1328 | msg->id = htonl (rid); | 1366 | msg->id = htonl (rid); |
1329 | msg->identity = *identity; | 1367 | msg->key_len = htonl (key_len); |
1368 | GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len); | ||
1330 | if (NULL == h->mq) | 1369 | if (NULL == h->mq) |
1331 | it->env = env; | 1370 | it->env = env; |
1332 | else | 1371 | else |
@@ -1349,13 +1388,6 @@ GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1349 | } | 1388 | } |
1350 | 1389 | ||
1351 | 1390 | ||
1352 | /** | ||
1353 | * Stops iteration and releases the handle for further calls. Must | ||
1354 | * be called on any iteration that has not yet completed prior to calling | ||
1355 | * #GNUNET_RECLAIM_disconnect. | ||
1356 | * | ||
1357 | * @param it the iterator | ||
1358 | */ | ||
1359 | void | 1391 | void |
1360 | GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | 1392 | GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) |
1361 | { | 1393 | { |
@@ -1374,30 +1406,6 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1374 | } | 1406 | } |
1375 | 1407 | ||
1376 | 1408 | ||
1377 | /** | ||
1378 | * List all credentials for a local identity. | ||
1379 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | ||
1380 | * for any other calls than #GNUNET_RECLAIM_get_credentials_next() and | ||
1381 | * #GNUNET_RECLAIM_get_credentials_stop. @a proc will be called once | ||
1382 | * immediately, and then again after | ||
1383 | * #GNUNET_RECLAIM_get_credentials_next() is invoked. | ||
1384 | * | ||
1385 | * On error (disconnect), @a error_cb will be invoked. | ||
1386 | * On normal completion, @a finish_cb proc will be | ||
1387 | * invoked. | ||
1388 | * | ||
1389 | * @param h Handle to the re:claimID service | ||
1390 | * @param identity Identity to iterate over | ||
1391 | * @param error_cb Function to call on error (i.e. disconnect), | ||
1392 | * the handle is afterwards invalid | ||
1393 | * @param error_cb_cls Closure for @a error_cb | ||
1394 | * @param proc Function to call on each credential | ||
1395 | * @param proc_cls Closure for @a proc | ||
1396 | * @param finish_cb Function to call on completion | ||
1397 | * the handle is afterwards invalid | ||
1398 | * @param finish_cb_cls Closure for @a finish_cb | ||
1399 | * @return an iterator Handle to use for iteration | ||
1400 | */ | ||
1401 | struct GNUNET_RECLAIM_CredentialIterator * | 1409 | struct GNUNET_RECLAIM_CredentialIterator * |
1402 | GNUNET_RECLAIM_get_credentials_start ( | 1410 | GNUNET_RECLAIM_get_credentials_start ( |
1403 | struct GNUNET_RECLAIM_Handle *h, | 1411 | struct GNUNET_RECLAIM_Handle *h, |
@@ -1413,6 +1421,7 @@ GNUNET_RECLAIM_get_credentials_start ( | |||
1413 | struct GNUNET_MQ_Envelope *env; | 1421 | struct GNUNET_MQ_Envelope *env; |
1414 | struct CredentialIterationStartMessage *msg; | 1422 | struct CredentialIterationStartMessage *msg; |
1415 | uint32_t rid; | 1423 | uint32_t rid; |
1424 | size_t key_len; | ||
1416 | 1425 | ||
1417 | rid = h->r_id_gen++; | 1426 | rid = h->r_id_gen++; |
1418 | ait = GNUNET_new (struct GNUNET_RECLAIM_CredentialIterator); | 1427 | ait = GNUNET_new (struct GNUNET_RECLAIM_CredentialIterator); |
@@ -1425,12 +1434,15 @@ GNUNET_RECLAIM_get_credentials_start ( | |||
1425 | ait->proc_cls = proc_cls; | 1434 | ait->proc_cls = proc_cls; |
1426 | ait->r_id = rid; | 1435 | ait->r_id = rid; |
1427 | ait->identity = *identity; | 1436 | ait->identity = *identity; |
1437 | key_len = GNUNET_IDENTITY_private_key_get_length (identity); | ||
1428 | GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait); | 1438 | GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait); |
1429 | env = | 1439 | env = |
1430 | GNUNET_MQ_msg (msg, | 1440 | GNUNET_MQ_msg_extra (msg, |
1431 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START); | 1441 | key_len, |
1442 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START); | ||
1432 | msg->id = htonl (rid); | 1443 | msg->id = htonl (rid); |
1433 | msg->identity = *identity; | 1444 | msg->key_len = htonl (key_len); |
1445 | GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len); | ||
1434 | if (NULL == h->mq) | 1446 | if (NULL == h->mq) |
1435 | ait->env = env; | 1447 | ait->env = env; |
1436 | else | 1448 | else |
@@ -1486,23 +1498,35 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1486 | struct GNUNET_RECLAIM_Operation *op; | 1498 | struct GNUNET_RECLAIM_Operation *op; |
1487 | struct IssueTicketMessage *tim; | 1499 | struct IssueTicketMessage *tim; |
1488 | size_t attr_len; | 1500 | size_t attr_len; |
1501 | size_t key_len; | ||
1502 | size_t rpk_len; | ||
1503 | ssize_t written; | ||
1504 | char *buf; | ||
1489 | 1505 | ||
1490 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1506 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1491 | op->h = h; | 1507 | op->h = h; |
1492 | op->ti_cb = cb; | 1508 | op->ti_cb = cb; |
1493 | op->cls = cb_cls; | 1509 | op->cls = cb_cls; |
1494 | op->r_id = h->r_id_gen++; | 1510 | op->r_id = h->r_id_gen++; |
1511 | key_len = GNUNET_IDENTITY_private_key_get_length (iss); | ||
1512 | rpk_len = GNUNET_IDENTITY_public_key_get_length (rp); | ||
1495 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1513 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1496 | attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); | 1514 | attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); |
1497 | op->env = GNUNET_MQ_msg_extra (tim, | 1515 | op->env = GNUNET_MQ_msg_extra (tim, |
1498 | attr_len, | 1516 | attr_len + key_len + rpk_len, |
1499 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); | 1517 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); |
1500 | tim->identity = *iss; | 1518 | tim->key_len = htonl (key_len); |
1501 | tim->rp = *rp; | 1519 | tim->pkey_len = htonl (rpk_len); |
1520 | buf = (char *) &tim[1]; | ||
1521 | written = GNUNET_IDENTITY_write_private_key_to_buffer (iss, buf, key_len); | ||
1522 | GNUNET_assert (0 <= written); | ||
1523 | buf += written; | ||
1524 | written = GNUNET_IDENTITY_write_public_key_to_buffer (rp, buf, rpk_len); | ||
1525 | GNUNET_assert (0 <= written); | ||
1526 | buf += written; | ||
1502 | tim->id = htonl (op->r_id); | 1527 | tim->id = htonl (op->r_id); |
1503 | 1528 | ||
1504 | GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]); | 1529 | GNUNET_RECLAIM_attribute_list_serialize (attrs, buf); |
1505 | |||
1506 | tim->attr_len = htons (attr_len); | 1530 | tim->attr_len = htons (attr_len); |
1507 | if (NULL != h->mq) | 1531 | if (NULL != h->mq) |
1508 | GNUNET_MQ_send_copy (h->mq, op->env); | 1532 | GNUNET_MQ_send_copy (h->mq, op->env); |
@@ -1532,17 +1556,28 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1532 | { | 1556 | { |
1533 | struct GNUNET_RECLAIM_Operation *op; | 1557 | struct GNUNET_RECLAIM_Operation *op; |
1534 | struct ConsumeTicketMessage *ctm; | 1558 | struct ConsumeTicketMessage *ctm; |
1559 | size_t key_len; | ||
1560 | size_t tkt_len; | ||
1561 | char *buf; | ||
1535 | 1562 | ||
1536 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1563 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1537 | op->h = h; | 1564 | op->h = h; |
1538 | op->atr_cb = cb; | 1565 | op->atr_cb = cb; |
1539 | op->cls = cb_cls; | 1566 | op->cls = cb_cls; |
1540 | op->r_id = h->r_id_gen++; | 1567 | op->r_id = h->r_id_gen++; |
1568 | key_len = GNUNET_IDENTITY_private_key_get_length (identity); | ||
1569 | tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket); | ||
1541 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1570 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1542 | op->env = GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); | 1571 | op->env = GNUNET_MQ_msg_extra (ctm, |
1543 | ctm->identity = *identity; | 1572 | key_len + tkt_len, |
1573 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); | ||
1574 | ctm->key_len = htonl (key_len); | ||
1575 | buf = (char*) &ctm[1]; | ||
1576 | GNUNET_IDENTITY_write_private_key_to_buffer (identity, buf, key_len); | ||
1577 | buf += key_len; | ||
1578 | ctm->tkt_len = htonl (tkt_len); | ||
1579 | GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); | ||
1544 | ctm->id = htonl (op->r_id); | 1580 | ctm->id = htonl (op->r_id); |
1545 | ctm->ticket = *ticket; | ||
1546 | if (NULL != h->mq) | 1581 | if (NULL != h->mq) |
1547 | GNUNET_MQ_send_copy (h->mq, op->env); | 1582 | GNUNET_MQ_send_copy (h->mq, op->env); |
1548 | else | 1583 | else |
@@ -1551,23 +1586,6 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1551 | } | 1586 | } |
1552 | 1587 | ||
1553 | 1588 | ||
1554 | /** | ||
1555 | * Lists all tickets that have been issued to remote | ||
1556 | * identites (relying parties) | ||
1557 | * | ||
1558 | * @param h the reclaim to use | ||
1559 | * @param identity the issuing identity | ||
1560 | * @param error_cb function to call on error (i.e. disconnect), | ||
1561 | * the handle is afterwards invalid | ||
1562 | * @param error_cb_cls closure for @a error_cb | ||
1563 | * @param proc function to call on each ticket; it | ||
1564 | * will be called repeatedly with a value (if available) | ||
1565 | * @param proc_cls closure for @a proc | ||
1566 | * @param finish_cb function to call on completion | ||
1567 | * the handle is afterwards invalid | ||
1568 | * @param finish_cb_cls closure for @a finish_cb | ||
1569 | * @return an iterator handle to use for iteration | ||
1570 | */ | ||
1571 | struct GNUNET_RECLAIM_TicketIterator * | 1589 | struct GNUNET_RECLAIM_TicketIterator * |
1572 | GNUNET_RECLAIM_ticket_iteration_start ( | 1590 | GNUNET_RECLAIM_ticket_iteration_start ( |
1573 | struct GNUNET_RECLAIM_Handle *h, | 1591 | struct GNUNET_RECLAIM_Handle *h, |
@@ -1583,6 +1601,7 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
1583 | struct GNUNET_MQ_Envelope *env; | 1601 | struct GNUNET_MQ_Envelope *env; |
1584 | struct TicketIterationStartMessage *msg; | 1602 | struct TicketIterationStartMessage *msg; |
1585 | uint32_t rid; | 1603 | uint32_t rid; |
1604 | size_t key_len; | ||
1586 | 1605 | ||
1587 | rid = h->r_id_gen++; | 1606 | rid = h->r_id_gen++; |
1588 | it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); | 1607 | it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); |
@@ -1594,10 +1613,17 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
1594 | it->tr_cb = proc; | 1613 | it->tr_cb = proc; |
1595 | it->cls = proc_cls; | 1614 | it->cls = proc_cls; |
1596 | it->r_id = rid; | 1615 | it->r_id = rid; |
1616 | |||
1617 | key_len = GNUNET_IDENTITY_private_key_get_length (identity); | ||
1597 | GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it); | 1618 | GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it); |
1598 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); | 1619 | env = GNUNET_MQ_msg_extra (msg, |
1620 | key_len, | ||
1621 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); | ||
1599 | msg->id = htonl (rid); | 1622 | msg->id = htonl (rid); |
1600 | msg->identity = *identity; | 1623 | msg->key_len = htonl (key_len); |
1624 | GNUNET_IDENTITY_write_private_key_to_buffer (identity, | ||
1625 | &msg[1], | ||
1626 | key_len); | ||
1601 | if (NULL == h->mq) | 1627 | if (NULL == h->mq) |
1602 | it->env = env; | 1628 | it->env = env; |
1603 | else | 1629 | else |
@@ -1674,6 +1700,10 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
1674 | struct GNUNET_RECLAIM_Operation *op; | 1700 | struct GNUNET_RECLAIM_Operation *op; |
1675 | struct RevokeTicketMessage *msg; | 1701 | struct RevokeTicketMessage *msg; |
1676 | uint32_t rid; | 1702 | uint32_t rid; |
1703 | size_t key_len; | ||
1704 | size_t tkt_len; | ||
1705 | ssize_t written; | ||
1706 | char *buf; | ||
1677 | 1707 | ||
1678 | rid = h->r_id_gen++; | 1708 | rid = h->r_id_gen++; |
1679 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1709 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
@@ -1682,10 +1712,23 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
1682 | op->cls = cb_cls; | 1712 | op->cls = cb_cls; |
1683 | op->r_id = rid; | 1713 | op->r_id = rid; |
1684 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1714 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1685 | op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); | 1715 | key_len = GNUNET_IDENTITY_private_key_get_length (identity); |
1716 | tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket); | ||
1717 | op->env = GNUNET_MQ_msg_extra (msg, | ||
1718 | key_len + tkt_len, | ||
1719 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); | ||
1686 | msg->id = htonl (rid); | 1720 | msg->id = htonl (rid); |
1687 | msg->identity = *identity; | 1721 | msg->key_len = htonl (key_len); |
1688 | msg->ticket = *ticket; | 1722 | msg->tkt_len = htonl (tkt_len); |
1723 | buf = (char*) &msg[1]; | ||
1724 | written = GNUNET_IDENTITY_write_private_key_to_buffer (identity, | ||
1725 | buf, | ||
1726 | key_len); | ||
1727 | GNUNET_assert (0 <= written); | ||
1728 | buf += written; | ||
1729 | GNUNET_RECLAIM_write_ticket_to_buffer (ticket, | ||
1730 | buf, | ||
1731 | tkt_len); | ||
1689 | if (NULL != h->mq) | 1732 | if (NULL != h->mq) |
1690 | { | 1733 | { |
1691 | GNUNET_MQ_send (h->mq, op->env); | 1734 | GNUNET_MQ_send (h->mq, op->env); |
@@ -1694,5 +1737,78 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
1694 | return op; | 1737 | return op; |
1695 | } | 1738 | } |
1696 | 1739 | ||
1740 | size_t | ||
1741 | GNUNET_RECLAIM_ticket_serialize_get_size (const struct | ||
1742 | GNUNET_RECLAIM_Ticket *tkt) | ||
1743 | { | ||
1744 | size_t size = sizeof (tkt->rnd); | ||
1745 | size += GNUNET_IDENTITY_public_key_get_length (&tkt->identity); | ||
1746 | size += GNUNET_IDENTITY_public_key_get_length (&tkt->audience); | ||
1747 | return size; | ||
1748 | } | ||
1749 | |||
1750 | enum GNUNET_GenericReturnValue | ||
1751 | GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer, | ||
1752 | size_t len, | ||
1753 | struct GNUNET_RECLAIM_Ticket *tkt, | ||
1754 | size_t *tb_read) | ||
1755 | { | ||
1756 | const char *tmp = buffer; | ||
1757 | size_t read = 0; | ||
1758 | size_t left = len; | ||
1759 | if (GNUNET_SYSERR == | ||
1760 | GNUNET_IDENTITY_read_public_key_from_buffer (tmp, | ||
1761 | left, | ||
1762 | &tkt->identity, | ||
1763 | &read)) | ||
1764 | return GNUNET_SYSERR; | ||
1765 | left -= read; | ||
1766 | tmp += read; | ||
1767 | if (GNUNET_SYSERR == | ||
1768 | GNUNET_IDENTITY_read_public_key_from_buffer (tmp, | ||
1769 | left, | ||
1770 | &tkt->audience, | ||
1771 | &read)) | ||
1772 | return GNUNET_SYSERR; | ||
1773 | left -= read; | ||
1774 | tmp += read; | ||
1775 | if (left < sizeof (tkt->rnd)) | ||
1776 | return GNUNET_SYSERR; | ||
1777 | memcpy (&tkt->rnd, tmp, sizeof (tkt->rnd)); | ||
1778 | *tb_read = tmp - (char*) buffer + sizeof (tkt->rnd); | ||
1779 | return GNUNET_OK; | ||
1780 | } | ||
1781 | |||
1782 | |||
1783 | ssize_t | ||
1784 | GNUNET_RECLAIM_write_ticket_to_buffer (const struct | ||
1785 | GNUNET_RECLAIM_Ticket *tkt, | ||
1786 | void *buffer, | ||
1787 | size_t len) | ||
1788 | { | ||
1789 | char *tmp = buffer; | ||
1790 | size_t left = len; | ||
1791 | ssize_t written = 0; | ||
1792 | written = GNUNET_IDENTITY_write_public_key_to_buffer (&tkt->identity, | ||
1793 | buffer, | ||
1794 | left); | ||
1795 | if (0 > written) | ||
1796 | return written; | ||
1797 | left -= written; | ||
1798 | tmp += written; | ||
1799 | written = GNUNET_IDENTITY_write_public_key_to_buffer (&tkt->audience, | ||
1800 | tmp, | ||
1801 | left); | ||
1802 | if (0 > written) | ||
1803 | return written; | ||
1804 | left -= written; | ||
1805 | tmp += written; | ||
1806 | if (left < sizeof (tkt->rnd)) | ||
1807 | return -1; | ||
1808 | memcpy (tmp, &tkt->rnd, sizeof (tkt->rnd)); | ||
1809 | return tmp - (char*) buffer + sizeof (tkt->rnd); | ||
1810 | } | ||
1811 | |||
1812 | |||
1697 | 1813 | ||
1698 | /* end of reclaim_api.c */ | 1814 | /* end of reclaim_api.c */ |
diff --git a/src/reclaim/test_did_helper.c b/src/reclaim/test_did_helper.c index 698edf180..446c199fc 100644 --- a/src/reclaim/test_did_helper.c +++ b/src/reclaim/test_did_helper.c | |||
@@ -78,8 +78,9 @@ test_GNUNET_DID_did_to_pkey () | |||
78 | DID_did_to_pkey ((char *) test_did, &pkey); | 78 | DID_did_to_pkey ((char *) test_did, &pkey); |
79 | 79 | ||
80 | GNUNET_assert (test_pkey.type = pkey.type); | 80 | GNUNET_assert (test_pkey.type = pkey.type); |
81 | GNUNET_assert (strcmp (pkey.eddsa_key.q_y, | 81 | GNUNET_assert (memcmp (&pkey.eddsa_key, |
82 | test_pkey.eddsa_key.q_y) == 0); | 82 | &test_pkey.eddsa_key, |
83 | sizeof (test_pkey.eddsa_key)) == 0); | ||
83 | } | 84 | } |
84 | 85 | ||
85 | // void | 86 | // void |
diff --git a/src/reclaim/test_reclaim.conf b/src/reclaim/test_reclaim.conf index 2dc53fe81..faa195ae1 100644 --- a/src/reclaim/test_reclaim.conf +++ b/src/reclaim/test_reclaim.conf | |||
@@ -13,9 +13,13 @@ PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/r | |||
13 | [transport] | 13 | [transport] |
14 | PLUGINS = | 14 | PLUGINS = |
15 | 15 | ||
16 | [zonemaster] | ||
17 | START_ON_DEMAND = YES | ||
18 | IMMEDIATE_START = YES | ||
19 | |||
16 | [reclaim] | 20 | [reclaim] |
17 | START_ON_DEMAND = YES | 21 | START_ON_DEMAND = YES |
18 | TICKET_REFRESH_INTERVAL = 30 s | 22 | TICKET_REFRESH_INTERVAL = 1 h |
19 | #PREFIX = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --log-file=$GNUNET_TMP/idplog | 23 | #PREFIX = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --log-file=$GNUNET_TMP/idplog |
20 | 24 | ||
21 | [gns] | 25 | [gns] |
diff --git a/src/reclaim/test_reclaim_attribute.sh b/src/reclaim/test_reclaim_attribute.sh index 744c898ed..17f7863d4 100755 --- a/src/reclaim/test_reclaim_attribute.sh +++ b/src/reclaim/test_reclaim_attribute.sh | |||
@@ -29,7 +29,7 @@ gnunet-identity -C testego -c test_reclaim.conf | |||
29 | gnunet-identity -C rpego -c test_reclaim.conf | 29 | gnunet-identity -C rpego -c test_reclaim.conf |
30 | TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) | 30 | TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) |
31 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | 31 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf |
32 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf > /dev/null 2>&1 | 32 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf |
33 | if test $? != 0 | 33 | if test $? != 0 |
34 | then | 34 | then |
35 | echo "Failed." | 35 | echo "Failed." |
diff --git a/src/reclaim/test_reclaim_consume.sh b/src/reclaim/test_reclaim_consume.sh index c012862c3..8a88136c6 100755 --- a/src/reclaim/test_reclaim_consume.sh +++ b/src/reclaim/test_reclaim_consume.sh | |||
@@ -25,6 +25,7 @@ which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 30" | |||
25 | TEST_ATTR="test" | 25 | TEST_ATTR="test" |
26 | gnunet-arm -s -c test_reclaim.conf | 26 | gnunet-arm -s -c test_reclaim.conf |
27 | #gnunet-arm -i rest -c test_reclaim.conf | 27 | #gnunet-arm -i rest -c test_reclaim.conf |
28 | gnunet-arm -I | ||
28 | gnunet-identity -C testego -c test_reclaim.conf | 29 | gnunet-identity -C testego -c test_reclaim.conf |
29 | gnunet-identity -C rpego -c test_reclaim.conf | 30 | gnunet-identity -C rpego -c test_reclaim.conf |
30 | SUBJECT_KEY=$(gnunet-identity -d -e rpego -q -c test_reclaim.conf) | 31 | SUBJECT_KEY=$(gnunet-identity -d -e rpego -q -c test_reclaim.conf) |
@@ -32,7 +33,10 @@ TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) | |||
32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | 33 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf |
33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf | 34 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf |
34 | TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}') | 35 | TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}') |
35 | gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf #>/dev/null 2>&1 | 36 | gnunet-namestore -z testego -D -c test_reclaim.conf |
37 | gnunet-identity -d -c test_reclaim.conf | ||
38 | sleep 1 | ||
39 | gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf | ||
36 | 40 | ||
37 | RES=$? | 41 | RES=$? |
38 | gnunet-identity -D testego -c test_reclaim.conf | 42 | gnunet-identity -D testego -c test_reclaim.conf |
diff --git a/src/reclaim/test_reclaim_issue.sh b/src/reclaim/test_reclaim_issue.sh index cfddc9407..63140e54c 100755 --- a/src/reclaim/test_reclaim_issue.sh +++ b/src/reclaim/test_reclaim_issue.sh | |||
@@ -29,8 +29,8 @@ gnunet-identity -C testego -c test_reclaim.conf | |||
29 | gnunet-identity -C rpego -c test_reclaim.conf | 29 | gnunet-identity -C rpego -c test_reclaim.conf |
30 | SUBJECT_KEY=$(gnunet-identity -d -e rpego -q -c test_reclaim.conf) | 30 | SUBJECT_KEY=$(gnunet-identity -d -e rpego -q -c test_reclaim.conf) |
31 | TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) | 31 | TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) |
32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf > /dev/null 2>&1 | 32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf |
33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf > /dev/null 2>&1 | 33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf |
34 | #gnunet-reclaim -e testego -D -c test_reclaim.conf | 34 | #gnunet-reclaim -e testego -D -c test_reclaim.conf |
35 | gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf > /dev/null 2>&1 | 35 | gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf > /dev/null 2>&1 |
36 | if test $? != 0 | 36 | if test $? != 0 |