aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-11-06 18:09:20 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:04 +0100
commit854dfdf7031a4e06322b592b1c583cb8301afeb4 (patch)
tree704d24e60c94af20d8440f8144832c4fea9d8b1f
parent554abc7d4c13e59a64d95770e68da8033de44c51 (diff)
downloadgnunet-854dfdf7031a4e06322b592b1c583cb8301afeb4.tar.gz
gnunet-854dfdf7031a4e06322b592b1c583cb8301afeb4.zip
Fixed Open Issues with Listing
-rw-r--r--src/reclaim/gnunet-service-reclaim.c6
-rw-r--r--src/reclaim/plugin_rest_reclaim.c104
-rw-r--r--src/reclaim/reclaim_api.c3
3 files changed, 96 insertions, 17 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index bad69f298..fcbd9413f 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -2103,7 +2103,6 @@ attr_iter_cb (void *cls,
2103 else 2103 else
2104 { 2104 {
2105 struct ReferenceResultMessage *rrm; 2105 struct ReferenceResultMessage *rrm;
2106 char *data_tmp2;
2107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n", 2106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
2108 label); 2107 label);
2109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2117,9 +2116,8 @@ attr_iter_cb (void *cls,
2117 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity); 2116 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity);
2118 data_tmp = (char *) &rrm[1]; 2117 data_tmp = (char *) &rrm[1];
2119 GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size); 2118 GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
2120 data_tmp2 = (char *) &rrm[2]; 2119 data_tmp += rd[0].data_size;
2121 GNUNET_memcpy (data_tmp2, rd[i].data, rd[i].data_size); 2120 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2122
2123 GNUNET_MQ_send (ai->client->mq, env); 2121 GNUNET_MQ_send (ai->client->mq, env);
2124 } 2122 }
2125 } 2123 }
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index dcf5d51b4..3b3674112 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -37,6 +37,8 @@
37#include "gnunet_rest_plugin.h" 37#include "gnunet_rest_plugin.h"
38#include "gnunet_signatures.h" 38#include "gnunet_signatures.h"
39#include "json_reclaim.h" 39#include "json_reclaim.h"
40#include <openssl/bio.h>
41#include <openssl/evp.h>
40 42
41/** 43/**
42 * REST root namespace 44 * REST root namespace
@@ -1168,6 +1170,76 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1168} 1170}
1169 1171
1170/** 1172/**
1173 * Parse a JWT and return the respective claim value as Attribute
1174 *
1175 * @param attest the jwt attestation
1176 * @param claim the name of the claim in the JWT
1177 *
1178 * @return a GNUNET_RECLAIM_ATTRIBUTE_Claim, containing the new value
1179 */
1180struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
1181parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1182 const char *claim)
1183{
1184 char *jwt_string;
1185 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
1186 char delim[] = ".";
1187 const char *type_str = NULL;
1188 const char *val_str = NULL;
1189 char *data;
1190 size_t data_size;
1191 uint32_t type;
1192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
1193 char *decoded_jwt;
1194
1195 jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type,
1196 attest->data,
1197 attest->data_size);
1198 char *jwt_body = strtok (jwt_string, delim);
1199 jwt_body = strtok (NULL, delim);
1200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "JWT Body: %s\n",
1201 jwt_body);
1202 /*const char* jwt_base64 = jwt_body;
1203 //No padding assumed
1204 int jwt_len = (strlen(jwt_base64)*3)/4;
1205 BIO *bio, *b64;
1206 decoded_jwt = (char *) malloc(jwt_len + 1);
1207
1208 decoded_jwt[jwt_len] = '\0';
1209
1210 bio = BIO_new_mem_buf(jwt_base64, -1);
1211 b64 = BIO_new(BIO_f_base64());
1212 bio = BIO_push(b64, bio);
1213 BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
1214 /**length = BIO_read(bio, *buffer, strlen(jwt_base64));
1215 assert(*length == jwt_len); //length should equal jwt_len, else something went horribly wrong
1216
1217 BIO_free_all(bio);
1218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsed JWT Body: %s\n",
1219 decoded_jwt);
1220*/
1221
1222
1223 val_str = "String from JWT, which is stored under claim";
1224 type_str = "String";
1225
1226 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
1227 if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,val_str,
1228 (void **) &data,
1229 &data_size)))
1230 {
1231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1232 "Attribute value from JWT Parser invalid!\n");
1233 return NULL;
1234 }
1235 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size);
1236 attr->id = attest->id;
1237 attr->flag = 1;
1238 return attr;
1239}
1240
1241
1242/**
1171 * Collect all attributes for an ego 1243 * Collect all attributes for an ego
1172 * 1244 *
1173 */ 1245 */
@@ -1200,24 +1272,32 @@ attr_collect (void *cls,
1200 "Attribute Collection with empty Reference Name/Value\n"); 1272 "Attribute Collection with empty Reference Name/Value\n");
1201 return; 1273 return;
1202 } 1274 }
1203 1275 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2;
1276 attr2 = parse_jwt (attest, reference->name);
1277 if (NULL == attr2)
1278 {
1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1280 "Attribute Collection with unparsed Attestation\n");
1281 return;
1282 }
1204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n", 1283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n",
1205 reference->name); 1284 reference->name);
1285 char *tmp_value;
1286 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr2->type,
1287 attr2->data,
1288 attr2->data_size);
1206 attr_obj = json_object (); 1289 attr_obj = json_object ();
1207 json_object_set_new (attr_obj, "name", json_string (reference->name)); 1290
1208 json_object_set_new (attr_obj, "value", json_string ( 1291 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1209 reference->reference_value)); 1292 json_object_set_new (attr_obj, "name", json_string (attr2->name));
1210 id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id, 1293 json_object_set_new (attr_obj, "flag", json_string ("1"));
1211 sizeof(uint64_t)); 1294 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr2->type);
1212 json_object_set_new (attr_obj, "id", json_string (id_str));
1213 char *flag;
1214 flag = "1";
1215 json_object_set_new (attr_obj, "flag", json_string (flag));
1216 type = "String";
1217 json_object_set_new (attr_obj, "type", json_string (type)); 1295 json_object_set_new (attr_obj, "type", json_string (type));
1296 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id, sizeof(uint64_t));
1297 json_object_set_new (attr_obj, "id", json_string (id_str));
1218 json_array_append (handle->resp_object, attr_obj); 1298 json_array_append (handle->resp_object, attr_obj);
1219 json_decref (attr_obj); 1299 json_decref (attr_obj);
1220 1300 GNUNET_free (tmp_value);
1221 } 1301 }
1222 else 1302 else
1223 { 1303 {
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 1d2b9d8b4..75ef22c8c 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -807,7 +807,8 @@ handle_reference_result (void *cls, const struct ReferenceResultMessage *msg)
807 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 807 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
808 attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], 808 attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
809 attest_len); 809 attest_len);
810 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[2], 810 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1]
811 + attest_len,
811 ref_len); 812 ref_len);
812 if (NULL != it) 813 if (NULL != it)
813 { 814 {