aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-11-02 15:42:09 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:04 +0100
commit554abc7d4c13e59a64d95770e68da8033de44c51 (patch)
treee9c89f63b182b966ce3e3a2dba3f79f16db26bb1
parent0688b167e707e1c60d1aa3c220bc6b99d60fd662 (diff)
downloadgnunet-554abc7d4c13e59a64d95770e68da8033de44c51.tar.gz
gnunet-554abc7d4c13e59a64d95770e68da8033de44c51.zip
Prepared JWT Plugin
-rw-r--r--src/reclaim/gnunet-service-reclaim.c24
-rw-r--r--src/reclaim/plugin_rest_reclaim.c26
-rw-r--r--src/reclaim/reclaim.h39
-rw-r--r--src/reclaim/reclaim_api.c37
4 files changed, 93 insertions, 33 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 11ff2cd2d..bad69f298 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -2035,7 +2035,6 @@ attr_iter_cb (void *cls,
2035 const struct GNUNET_GNSRECORD_Data *rd) 2035 const struct GNUNET_GNSRECORD_Data *rd)
2036{ 2036{
2037 struct AttributeIterator *ai = cls; 2037 struct AttributeIterator *ai = cls;
2038 struct AttributeResultMessage *arm;
2039 struct GNUNET_MQ_Envelope *env; 2038 struct GNUNET_MQ_Envelope *env;
2040 char *data_tmp; 2039 char *data_tmp;
2041 2040
@@ -2067,6 +2066,7 @@ attr_iter_cb (void *cls,
2067 2066
2068 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type ) 2067 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type )
2069 { 2068 {
2069 struct AttributeResultMessage *arm;
2070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", 2070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2071 label); 2071 label);
2072 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2072 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2085,6 +2085,7 @@ attr_iter_cb (void *cls,
2085 { 2085 {
2086 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type ) 2086 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type )
2087 { 2087 {
2088 struct AttributeResultMessage *arm;
2088 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", 2089 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
2089 label); 2090 label);
2090 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2091 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2101,25 +2102,30 @@ attr_iter_cb (void *cls,
2101 } 2102 }
2102 else 2103 else
2103 { 2104 {
2105 struct ReferenceResultMessage *rrm;
2106 char *data_tmp2;
2104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n", 2107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
2105 label); 2108 label);
2106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2107 "Sending REFERENCE_RESULT message\n"); 2110 "Sending REFERENCE_RESULT message\n");
2108 env = GNUNET_MQ_msg_extra (arm, 2111 env = GNUNET_MQ_msg_extra (rrm,
2109 rd[i].data_size, 2112 rd[i].data_size + rd[0].data_size,
2110 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT); 2113 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT);
2111 arm->id = htonl (ai->request_id); 2114 rrm->id = htonl (ai->request_id);
2112 arm->attr_len = htons (rd[i].data_size); 2115 rrm->attest_len = htons (rd[0].data_size);
2113 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); 2116 rrm->ref_len = htons (rd[i].data_size);
2114 data_tmp = (char *) &arm[1]; 2117 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity);
2115 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); 2118 data_tmp = (char *) &rrm[1];
2119 GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
2120 data_tmp2 = (char *) &rrm[2];
2121 GNUNET_memcpy (data_tmp2, rd[i].data, rd[i].data_size);
2122
2116 GNUNET_MQ_send (ai->client->mq, env); 2123 GNUNET_MQ_send (ai->client->mq, env);
2117 } 2124 }
2118 } 2125 }
2119 } 2126 }
2120} 2127}
2121 2128
2122
2123/** 2129/**
2124 * Iterate over zone to get attributes 2130 * Iterate over zone to get attributes
2125 * 2131 *
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 6a14132c4..dcf5d51b4 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -653,7 +653,6 @@ ref_collect (void *cls,
653 653
654 if ((NULL == reference->name) || (NULL == reference->reference_value)) 654 if ((NULL == reference->name) || (NULL == reference->reference_value))
655 { 655 {
656 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
657 return; 656 return;
658 } 657 }
659 658
@@ -671,7 +670,6 @@ ref_collect (void *cls,
671 json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str)); 670 json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str));
672 json_array_append (handle->resp_object, attr_obj); 671 json_array_append (handle->resp_object, attr_obj);
673 json_decref (attr_obj); 672 json_decref (attr_obj);
674 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
675} 673}
676 674
677/** 675/**
@@ -747,14 +745,25 @@ attest_collect (void *cls,
747 char *tmp_value; 745 char *tmp_value;
748 char *id_str; 746 char *id_str;
749 747
748
749 if (NULL != reference)
750 {
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752 "Attestation Collection with Reference\n");
753 return;
754 }
750 if (NULL == attest) 755 if (NULL == attest)
751 { 756 {
757 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
758 "Attestation Collection with empty Attestation\n");
752 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 759 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
753 return; 760 return;
754 } 761 }
755 762
756 if ((NULL == attest->name) || (NULL == attest->data)) 763 if ((NULL == attest->name) || (NULL == attest->data))
757 { 764 {
765 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
766 "Attestation Collection with empty Name/Value\n");
758 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 767 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
759 return; 768 return;
760 } 769 }
@@ -1174,9 +1183,10 @@ attr_collect (void *cls,
1174 const char *type; 1183 const char *type;
1175 char *id_str; 1184 char *id_str;
1176 1185
1177 if ((NULL == attr)&& (NULL == reference)) 1186 if ((NULL == attr) && (NULL == reference))
1178 { 1187 {
1179 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty Attribute/Reference\n"); 1188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1189 "Attribute Collection with empty Attribute/Reference\n");
1180 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1190 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1181 return; 1191 return;
1182 } 1192 }
@@ -1186,8 +1196,8 @@ attr_collect (void *cls,
1186 1196
1187 if ((NULL == reference->name) || (NULL == reference->reference_value)) 1197 if ((NULL == reference->name) || (NULL == reference->reference_value))
1188 { 1198 {
1189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty Reference Name/Value\n"); 1199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1190 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1200 "Attribute Collection with empty Reference Name/Value\n");
1191 return; 1201 return;
1192 } 1202 }
1193 1203
@@ -1207,14 +1217,14 @@ attr_collect (void *cls,
1207 json_object_set_new (attr_obj, "type", json_string (type)); 1217 json_object_set_new (attr_obj, "type", json_string (type));
1208 json_array_append (handle->resp_object, attr_obj); 1218 json_array_append (handle->resp_object, attr_obj);
1209 json_decref (attr_obj); 1219 json_decref (attr_obj);
1210 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1211 1220
1212 } 1221 }
1213 else 1222 else
1214 { 1223 {
1215 if ((NULL == attr->name) || (NULL == attr->data)) 1224 if ((NULL == attr->name) || (NULL == attr->data))
1216 { 1225 {
1217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty Attribute Name/Value\n"); 1226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1227 "Attribute Collection with empty Attribute Name/Value\n");
1218 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1228 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1219 return; 1229 return;
1220 } 1230 }
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 8e731812e..ff953a096 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -153,6 +153,45 @@ struct AttributeResultMessage
153 */ 153 */
154}; 154};
155 155
156/**
157 * Reference plus Attestation is returned from the idp.
158 */
159struct ReferenceResultMessage
160{
161 /**
162 * Message header
163 */
164 struct GNUNET_MessageHeader header;
165
166 /**
167 * Unique identifier for this request (for key collisions).
168 */
169 uint32_t id GNUNET_PACKED;
170
171 /**
172 * Length of serialized attestation data
173 */
174 uint16_t attest_len GNUNET_PACKED;
175
176 /**
177 * Length of serialized reference data
178 */
179 uint16_t ref_len GNUNET_PACKED;
180
181 /**
182 * always zero (for alignment)
183 */
184 uint16_t reserved GNUNET_PACKED;
185
186 /**
187 * The public key of the identity.
188 */
189 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
190
191 /* followed by:
192 * serialized reference data + attestation data
193 */
194};
156 195
157/** 196/**
158 * Start a attribute iteration for the given identity 197 * Start a attribute iteration for the given identity
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index ede2daf28..1d2b9d8b4 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -731,14 +731,16 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
731 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 731 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
732 */ 732 */
733static int 733static int
734check_reference_result (void *cls, const struct AttributeResultMessage *msg) 734check_reference_result (void *cls, const struct ReferenceResultMessage *msg)
735{ 735{
736 size_t msg_len; 736 size_t msg_len;
737 size_t attr_len; 737 size_t attr_len;
738 size_t ref_len;
738 739
739 msg_len = ntohs (msg->header.size); 740 msg_len = ntohs (msg->header.size);
740 attr_len = ntohs (msg->attr_len); 741 attr_len = ntohs (msg->attest_len);
741 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) 742 ref_len = ntohs (msg->ref_len);
743 if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len)
742 { 744 {
743 GNUNET_break (0); 745 GNUNET_break (0);
744 return GNUNET_SYSERR; 746 return GNUNET_SYSERR;
@@ -754,19 +756,18 @@ check_reference_result (void *cls, const struct AttributeResultMessage *msg)
754* @param msg the message we received 756* @param msg the message we received
755*/ 757*/
756static void 758static void
757handle_reference_result (void *cls, const struct AttributeResultMessage *msg) 759handle_reference_result (void *cls, const struct ReferenceResultMessage *msg)
758{ 760{
759 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; 761 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
760 struct GNUNET_RECLAIM_Handle *h = cls; 762 struct GNUNET_RECLAIM_Handle *h = cls;
761 struct GNUNET_RECLAIM_AttributeIterator *it; 763 struct GNUNET_RECLAIM_AttributeIterator *it;
762 struct GNUNET_RECLAIM_Operation *op; 764 struct GNUNET_RECLAIM_Operation *op;
763 size_t attr_len; 765 size_t attest_len;
766 size_t ref_len;
764 uint32_t r_id = ntohl (msg->id); 767 uint32_t r_id = ntohl (msg->id);
765 768 attest_len = ntohs (msg->attest_len);
766 attr_len = ntohs (msg->attr_len); 769 ref_len = ntohs (msg->ref_len);
767 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n"); 770 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
768
769
770 for (it = h->it_head; NULL != it; it = it->next) 771 for (it = h->it_head; NULL != it; it = it->next)
771 if (it->r_id == r_id) 772 if (it->r_id == r_id)
772 break; 773 break;
@@ -802,20 +803,24 @@ handle_reference_result (void *cls, const struct AttributeResultMessage *msg)
802 } 803 }
803 804
804 { 805 {
805 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr; 806 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
806 attr = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1], 807 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
807 attr_len); 808 attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
809 attest_len);
810 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[2],
811 ref_len);
808 if (NULL != it) 812 if (NULL != it)
809 { 813 {
810 if (NULL != it->proc) 814 if (NULL != it->proc)
811 it->proc (it->proc_cls, &msg->identity, NULL, NULL, attr); 815 it->proc (it->proc_cls, &msg->identity, NULL, attest, ref);
812 } 816 }
813 else if (NULL != op) 817 else if (NULL != op)
814 { 818 {
815 if (NULL != op->ar_cb) 819 if (NULL != op->ar_cb)
816 op->ar_cb (op->cls, &msg->identity, NULL, NULL, attr); 820 op->ar_cb (op->cls, &msg->identity, NULL, attest, ref);
817 } 821 }
818 GNUNET_free (attr); 822 GNUNET_free (ref);
823 GNUNET_free (attest);
819 return; 824 return;
820 } 825 }
821 GNUNET_assert (0); 826 GNUNET_assert (0);
@@ -945,7 +950,7 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
945 h), 950 h),
946 GNUNET_MQ_hd_var_size (reference_result, 951 GNUNET_MQ_hd_var_size (reference_result,
947 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT, 952 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
948 struct AttributeResultMessage, 953 struct ReferenceResultMessage,
949 h), 954 h),
950 GNUNET_MQ_hd_fixed_size (ticket_result, 955 GNUNET_MQ_hd_fixed_size (ticket_result,
951 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 956 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,