[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 18/25: Prepared JWT Plugin
From: |
gnunet |
Subject: |
[gnunet] 18/25: Prepared JWT Plugin |
Date: |
Mon, 13 Jan 2020 13:47:03 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 554abc7d4c13e59a64d95770e68da8033de44c51
Author: Markus Voggenreiter <address@hidden>
AuthorDate: Sat Nov 2 15:42:09 2019 +0100
Prepared JWT Plugin
---
src/reclaim/gnunet-service-reclaim.c | 24 +++++++++++++---------
src/reclaim/plugin_rest_reclaim.c | 26 ++++++++++++++++--------
src/reclaim/reclaim.h | 39 ++++++++++++++++++++++++++++++++++++
src/reclaim/reclaim_api.c | 37 +++++++++++++++++++---------------
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,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct AttributeIterator *ai = cls;
- struct AttributeResultMessage *arm;
struct GNUNET_MQ_Envelope *env;
char *data_tmp;
@@ -2067,6 +2066,7 @@ attr_iter_cb (void *cls,
if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type )
{
+ struct AttributeResultMessage *arm;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
label);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2085,6 +2085,7 @@ attr_iter_cb (void *cls,
{
if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type )
{
+ struct AttributeResultMessage *arm;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
label);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2101,25 +2102,30 @@ attr_iter_cb (void *cls,
}
else
{
+ struct ReferenceResultMessage *rrm;
+ char *data_tmp2;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
label);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending REFERENCE_RESULT message\n");
- env = GNUNET_MQ_msg_extra (arm,
- rd[i].data_size,
+ env = GNUNET_MQ_msg_extra (rrm,
+ rd[i].data_size + rd[0].data_size,
GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT);
- arm->id = htonl (ai->request_id);
- arm->attr_len = htons (rd[i].data_size);
- GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
- data_tmp = (char *) &arm[1];
- GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
+ rrm->id = htonl (ai->request_id);
+ rrm->attest_len = htons (rd[0].data_size);
+ rrm->ref_len = htons (rd[i].data_size);
+ GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity);
+ data_tmp = (char *) &rrm[1];
+ GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
+ data_tmp2 = (char *) &rrm[2];
+ GNUNET_memcpy (data_tmp2, rd[i].data, rd[i].data_size);
+
GNUNET_MQ_send (ai->client->mq, env);
}
}
}
}
-
/**
* Iterate over zone to get attributes
*
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,
if ((NULL == reference->name) || (NULL == reference->reference_value))
{
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
return;
}
@@ -671,7 +670,6 @@ ref_collect (void *cls,
json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str));
json_array_append (handle->resp_object, attr_obj);
json_decref (attr_obj);
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
}
/**
@@ -747,14 +745,25 @@ attest_collect (void *cls,
char *tmp_value;
char *id_str;
+
+ if (NULL != reference)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attestation Collection with Reference\n");
+ return;
+ }
if (NULL == attest)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attestation Collection with empty Attestation\n");
GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
return;
}
if ((NULL == attest->name) || (NULL == attest->data))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attestation Collection with empty Name/Value\n");
GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
return;
}
@@ -1174,9 +1183,10 @@ attr_collect (void *cls,
const char *type;
char *id_str;
- if ((NULL == attr)&& (NULL == reference))
+ if ((NULL == attr) && (NULL == reference))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty
Attribute/Reference\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attribute Collection with empty Attribute/Reference\n");
GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
return;
}
@@ -1186,8 +1196,8 @@ attr_collect (void *cls,
if ((NULL == reference->name) || (NULL == reference->reference_value))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty
Reference Name/Value\n");
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attribute Collection with empty Reference Name/Value\n");
return;
}
@@ -1207,14 +1217,14 @@ attr_collect (void *cls,
json_object_set_new (attr_obj, "type", json_string (type));
json_array_append (handle->resp_object, attr_obj);
json_decref (attr_obj);
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
}
else
{
if ((NULL == attr->name) || (NULL == attr->data))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute Collection with empty
Attribute Name/Value\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Attribute Collection with empty Attribute Name/Value\n");
GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
return;
}
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
*/
};
+/**
+ * Reference plus Attestation is returned from the idp.
+ */
+struct ReferenceResultMessage
+{
+ /**
+ * Message header
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Unique identifier for this request (for key collisions).
+ */
+ uint32_t id GNUNET_PACKED;
+
+ /**
+ * Length of serialized attestation data
+ */
+ uint16_t attest_len GNUNET_PACKED;
+
+ /**
+ * Length of serialized reference data
+ */
+ uint16_t ref_len GNUNET_PACKED;
+
+ /**
+ * always zero (for alignment)
+ */
+ uint16_t reserved GNUNET_PACKED;
+
+ /**
+ * The public key of the identity.
+ */
+ struct GNUNET_CRYPTO_EcdsaPublicKey identity;
+
+ /* followed by:
+ * serialized reference data + attestation data
+ */
+};
/**
* 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)
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
-check_reference_result (void *cls, const struct AttributeResultMessage *msg)
+check_reference_result (void *cls, const struct ReferenceResultMessage *msg)
{
size_t msg_len;
size_t attr_len;
+ size_t ref_len;
msg_len = ntohs (msg->header.size);
- attr_len = ntohs (msg->attr_len);
- if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
+ attr_len = ntohs (msg->attest_len);
+ ref_len = ntohs (msg->ref_len);
+ if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len)
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -754,19 +756,18 @@ check_reference_result (void *cls, const struct
AttributeResultMessage *msg)
* @param msg the message we received
*/
static void
-handle_reference_result (void *cls, const struct AttributeResultMessage *msg)
+handle_reference_result (void *cls, const struct ReferenceResultMessage *msg)
{
static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
struct GNUNET_RECLAIM_Handle *h = cls;
struct GNUNET_RECLAIM_AttributeIterator *it;
struct GNUNET_RECLAIM_Operation *op;
- size_t attr_len;
+ size_t attest_len;
+ size_t ref_len;
uint32_t r_id = ntohl (msg->id);
-
- attr_len = ntohs (msg->attr_len);
+ attest_len = ntohs (msg->attest_len);
+ ref_len = ntohs (msg->ref_len);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
-
-
for (it = h->it_head; NULL != it; it = it->next)
if (it->r_id == r_id)
break;
@@ -802,20 +803,24 @@ handle_reference_result (void *cls, const struct
AttributeResultMessage *msg)
}
{
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
- attr = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1],
- attr_len);
+ struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
+ struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
+ attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
+ attest_len);
+ ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[2],
+ ref_len);
if (NULL != it)
{
if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, NULL, NULL, attr);
+ it->proc (it->proc_cls, &msg->identity, NULL, attest, ref);
}
else if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, NULL, NULL, attr);
+ op->ar_cb (op->cls, &msg->identity, NULL, attest, ref);
}
- GNUNET_free (attr);
+ GNUNET_free (ref);
+ GNUNET_free (attest);
return;
}
GNUNET_assert (0);
@@ -945,7 +950,7 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
h),
GNUNET_MQ_hd_var_size (reference_result,
GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
- struct AttributeResultMessage,
+ struct ReferenceResultMessage,
h),
GNUNET_MQ_hd_fixed_size (ticket_result,
GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnunet] 08/25: Prepare Listing Attestations, (continued)
- [gnunet] 08/25: Prepare Listing Attestations, gnunet, 2020/01/13
- [gnunet] 10/25: some comments, gnunet, 2020/01/13
- [gnunet] 09/25: Listing Attestations through service, gnunet, 2020/01/13
- [gnunet] 11/25: Preparation for Reference Type, gnunet, 2020/01/13
- [gnunet] 12/25: Adding Reference Type Implemented, gnunet, 2020/01/13
- [gnunet] 13/25: Deletion of Reference Type, gnunet, 2020/01/13
- [gnunet] 14/25: Fixed Reference Deletion, gnunet, 2020/01/13
- [gnunet] 16/25: Listing of References with Attributes, gnunet, 2020/01/13
- [gnunet] 17/25: Pure Listing of References, gnunet, 2020/01/13
- [gnunet] 15/25: Prepared Listing of References, gnunet, 2020/01/13
- [gnunet] 18/25: Prepared JWT Plugin,
gnunet <=
- [gnunet] 20/25: JWT Plugin, Prepared Ticketing, gnunet, 2020/01/13
- [gnunet] 22/25: JWT Parser Implemented, gnunet, 2020/01/13
- [gnunet] 19/25: Fixed Open Issues with Listing, gnunet, 2020/01/13
- [gnunet] 23/25: Fixed Adding Attestations, gnunet, 2020/01/13
- [gnunet] 24/25: Fixed Ticket Management, gnunet, 2020/01/13
- [gnunet] 21/25: Basic Functionality Implemented, gnunet, 2020/01/13
- [gnunet] 25/25: JWT Parsing API, gnunet, 2020/01/13