From: Schanzenbach, Martin Date: Mon, 3 Feb 2020 20:51:57 +0000 (+0100) Subject: move to 256-bit identifier; some cleanups X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d8cb147dc7e3220dbeb12be76cecea9a107119f5;p=oweals%2Fgnunet.git move to 256-bit identifier; some cleanups --- diff --git a/src/include/gnunet_reclaim_attribute_lib.h b/src/include/gnunet_reclaim_attribute_lib.h index 004f2bd10..93b4f8a13 100644 --- a/src/include/gnunet_reclaim_attribute_lib.h +++ b/src/include/gnunet_reclaim_attribute_lib.h @@ -60,6 +60,37 @@ extern "C" { */ #define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT 11 +/** + * We want an ID to be a 256-bit symmetric key + */ +#define GNUNET_RECLAIM_ID_LENGTH (256 / 8) + +/** + * A reclaim identifier + * FIXME maybe put this in a different namespace + */ +struct GNUNET_RECLAIM_Identifier +{ + char id[GNUNET_RECLAIM_ID_LENGTH]; +}; + +static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; + +#define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \ + memcmp (a,\ + b,\ + sizeof (GNUNET_RECLAIM_ID_ZERO))) ?\ + GNUNET_YES : GNUNET_NO) + + +#define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal(a,\ + &GNUNET_RECLAIM_ID_ZERO) + +#define GNUNET_RECLAIM_id_generate(id) \ + (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,\ + id,\ + sizeof (GNUNET_RECLAIM_ID_ZERO))) + /** * An attribute. */ @@ -68,7 +99,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim /** * ID */ - uint64_t id; + struct GNUNET_RECLAIM_Identifier id; /** * Type of Claim @@ -106,7 +137,7 @@ struct GNUNET_RECLAIM_ATTESTATION_Claim /** * ID */ - uint64_t id; + struct GNUNET_RECLAIM_Identifier id; /** * Type/Format of Claim @@ -114,9 +145,9 @@ struct GNUNET_RECLAIM_ATTESTATION_Claim uint32_t type; /** - * Version + * Flag */ - uint32_t version; + uint32_t flag; /** * The name of the attribute. Note "name" must never be individually @@ -145,12 +176,12 @@ struct GNUNET_RECLAIM_ATTESTATION_REFERENCE /** * ID */ - uint64_t id; + struct GNUNET_RECLAIM_Identifier id; /** * Referenced ID of Attestation */ - uint64_t id_attest; + struct GNUNET_RECLAIM_Identifier id_attest; /** * The name of the attribute/attestation reference value. Note "name" must never be individually diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h index 214cdba69..b20809a49 100644 --- a/src/include/gnunet_reclaim_service.h +++ b/src/include/gnunet_reclaim_service.h @@ -77,9 +77,9 @@ struct GNUNET_RECLAIM_Ticket struct GNUNET_CRYPTO_EcdsaPublicKey audience; /** - * The ticket random (NBO) + * The ticket random identifier */ - uint64_t rnd; + struct GNUNET_RECLAIM_Identifier rnd; }; diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c index 43199c108..07d8200c6 100644 --- a/src/reclaim-attribute/reclaim_attribute.c +++ b/src/reclaim-attribute/reclaim_attribute.c @@ -389,7 +389,7 @@ GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name, + strlen (attr_name_tmp) + 1 + data_size); attr->type = type; attr->data_size = data_size; - attr->version = 0; + attr->flag = 0; write_ptr = (char *) &attr[1]; GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); attr->name = write_ptr; @@ -797,8 +797,8 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize ( attr_ser = (struct Attribute *) result; attr_ser->attribute_type = htons (attr->type); - attr_ser->attribute_version = htonl (attr->flag); - attr_ser->attribute_id = GNUNET_htonll (attr->id); + attr_ser->attribute_flag = htonl (attr->flag); + attr_ser->attribute_id = attr->id; name_len = strlen (attr->name); attr_ser->name_len = htons (name_len); write_ptr = (char *) &attr_ser[1]; @@ -847,8 +847,8 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + data_len + name_len + 1); attr->type = ntohs (attr_ser->attribute_type); - attr->flag = ntohl (attr_ser->attribute_version); - attr->id = GNUNET_ntohll (attr_ser->attribute_id); + attr->flag = ntohl (attr_ser->attribute_flag); + attr->id = attr_ser->attribute_id; attr->data_size = data_len; write_ptr = (char *) &attr[1]; @@ -895,8 +895,8 @@ GNUNET_RECLAIM_ATTESTATION_serialize ( attr_ser = (struct Attestation *) result; attr_ser->attestation_type = htons (attr->type); - attr_ser->attestation_version = htonl (attr->version); - attr_ser->attestation_id = GNUNET_htonll (attr->id); + attr_ser->attestation_flag = htonl (attr->flag); + attr_ser->attestation_id = attr->id; name_len = strlen (attr->name); attr_ser->name_len = htons (name_len); write_ptr = (char *) &attr_ser[1]; @@ -944,8 +944,8 @@ GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size) attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim) + data_len + name_len + 1); attr->type = ntohs (attr_ser->attestation_type); - attr->version = ntohl (attr_ser->attestation_version); - attr->id = GNUNET_ntohll (attr_ser->attestation_id); + attr->flag = ntohl (attr_ser->attestation_flag); + attr->id = attr_ser->attestation_id; attr->data_size = data_len; write_ptr = (char *) &attr[1]; @@ -991,8 +991,8 @@ GNUNET_RECLAIM_ATTESTATION_REF_serialize ( struct Attestation_Reference *attr_ser; char *write_ptr; attr_ser = (struct Attestation_Reference *) result; - attr_ser->reference_id = GNUNET_htonll (attr->id); - attr_ser->attestation_id = GNUNET_htonll (attr->id_attest); + attr_ser->reference_id = attr->id; + attr_ser->attestation_id = attr->id_attest; name_len = strlen (attr->name); refval_len = strlen (attr->reference_value); attr_ser->name_len = htons (name_len); @@ -1038,8 +1038,8 @@ GNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size) attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE) + refval_len + name_len + 2); - attr->id = GNUNET_ntohll (attr_ser->reference_id); - attr->id_attest = GNUNET_ntohll (attr_ser->attestation_id); + attr->id = attr_ser->reference_id; + attr->id_attest = attr_ser->attestation_id; write_ptr = (char *) &attr[1]; GNUNET_memcpy (write_ptr, &attr_ser[1], name_len); diff --git a/src/reclaim-attribute/reclaim_attribute.h b/src/reclaim-attribute/reclaim_attribute.h index 80f1e5aac..0746df48e 100644 --- a/src/reclaim-attribute/reclaim_attribute.h +++ b/src/reclaim-attribute/reclaim_attribute.h @@ -39,14 +39,14 @@ struct Attribute uint32_t attribute_type; /** - * Attribute version + * Attribute flag */ - uint32_t attribute_version; + uint32_t attribute_flag; /** * Attribute ID */ - uint64_t attribute_id; + struct GNUNET_RECLAIM_Identifier attribute_id; /** * Name length @@ -72,14 +72,14 @@ struct Attestation uint32_t attestation_type; /** - * Attestation version + * Attestation flag */ - uint32_t attestation_version; + uint32_t attestation_flag; /** * Attestation ID */ - uint64_t attestation_id; + struct GNUNET_RECLAIM_Identifier attestation_id; /** * Name length @@ -102,12 +102,12 @@ struct Attestation_Reference /** * Reference ID */ - uint64_t reference_id; + struct GNUNET_RECLAIM_Identifier reference_id; /** * The ID of the referenced attestation */ - uint64_t attestation_id; + struct GNUNET_RECLAIM_Identifier attestation_id; /** * Claim Name length diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 5f9170f05..c3d305eb5 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c @@ -227,7 +227,7 @@ static void process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, - const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, + const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) { char *value_str; @@ -249,9 +249,9 @@ process_attrs (void *cls, attr->data, attr->data_size); attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); - id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); fprintf (stdout, - "Name: %s; Value: %s (%s); Version %u; ID: %s\n", + "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", attr->name, value_str, attr_type, @@ -289,7 +289,7 @@ ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) GNUNET_STRINGS_data_to_string_alloc (&ticket->audience, sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); - ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd)); tkt = GNUNET_STRINGS_data_to_string_alloc (ticket, sizeof(struct GNUNET_RECLAIM_Ticket)); @@ -495,7 +495,7 @@ iter_cb (void *cls, } else if (attr_delete && (NULL == attr_to_delete)) { - label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); if (0 == strcasecmp (attr_delete, label)) { attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, @@ -512,9 +512,9 @@ iter_cb (void *cls, attr->data, attr->data_size); attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); - id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); fprintf (stdout, - "Name: %s; Value: %s (%s); Version %u; ID: %s\n", + "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", attr->name, attr_str, attr_type, diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 556006af0..a00bc5730 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c @@ -968,12 +968,12 @@ attr_store_task (void *cls) buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); buf = GNUNET_malloc (buf_size); // Give the ash a new id if unset - if (0 == ash->claim->id) - ash->claim->id - = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id)) + GNUNET_RECLAIM_id_generate (&ash->claim->id); GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); label - = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t)); + = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, + sizeof (ash->reference->id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); rd[0].data_size = buf_size; @@ -1086,6 +1086,7 @@ attest_store_cont (void *cls, int32_t success, const char *emsg) cleanup_as_handle (ash); } + /** * Send a reference error response * @@ -1111,6 +1112,7 @@ send_ref_error (struct AttributeStoreHandle *ash) cleanup_as_handle (ash); } + /** * Error looking up potential attestation. Abort. * @@ -1127,6 +1129,7 @@ attest_error (void *cls) return; } + /** * Check for existing record before storing reference * @@ -1149,7 +1152,7 @@ attest_add_cb (void *cls, buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest); buf = GNUNET_malloc (buf_size); GNUNET_RECLAIM_ATTESTATION_serialize (ash->attest, buf); - if (0 == rd_count ) + if (0 == rd_count) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing new Attestation\n"); @@ -1198,6 +1201,7 @@ attest_add_cb (void *cls, GNUNET_free (buf); } + /** * Add a new attestation * @@ -1210,11 +1214,10 @@ attest_store_task (void *cls) char *label; // Give the ash a new id if unset - if (0 == ash->attest->id) - ash->attest->id - = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->attest->id)) + GNUNET_RECLAIM_id_generate (&ash->attest->id); label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, - sizeof(uint64_t)); + sizeof (ash->attest->id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up existing data under label %s\n", label); // Test for the content of the existing ID @@ -1228,6 +1231,7 @@ attest_store_task (void *cls) GNUNET_free (label); } + /** * Check an attestation store message * @@ -1249,6 +1253,7 @@ check_attestation_store_message (void *cls, return GNUNET_OK; } + /** * Handle an attestation store message * @@ -1282,6 +1287,7 @@ handle_attestation_store_message (void *cls, GNUNET_SCHEDULER_add_now (&attest_store_task, ash); } + /** * Error looking up potential reference value. Abort. * @@ -1298,6 +1304,7 @@ ref_error (void *cls) return; } + /** * Error looking up potential reference value. Abort. * @@ -1313,6 +1320,8 @@ ref_del_error (void *cls) GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); return; } + + /** * Reference store result handler * @@ -1375,7 +1384,7 @@ ref_add_cb (void *cls, GNUNET_RECLAIM_ATTESTATION_REF_serialize (ash->reference, buf); struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; char *data_tmp; - if (0 == rd_count ) + if (0 == rd_count) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to find Attestation entry for Attestation reference\n"); @@ -1398,7 +1407,7 @@ ref_add_cb (void *cls, ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons ( rd[i].data_size)); rd_new[i] = rd[i]; - if ((strcmp (ash->reference->name,ref->name) == 0)&& + if ((strcmp (ash->reference->name,ref->name) == 0) && (strcmp (ash->reference->reference_value,ref->reference_value)==0) ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1423,6 +1432,7 @@ ref_add_cb (void *cls, GNUNET_free (buf); } + /** * Add a new reference * @@ -1437,13 +1447,11 @@ reference_store_task (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n"); // Give the ash a new id if unset - if (0 == ash->reference->id) + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id)) { - if (0 == ash->reference->id_attest) + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id_attest)) { - ash->reference->id = GNUNET_CRYPTO_random_u64 ( - GNUNET_CRYPTO_QUALITY_STRONG, - UINT64_MAX); + GNUNET_RECLAIM_id_generate (&ash->reference->id); } else { @@ -1452,7 +1460,7 @@ reference_store_task (void *cls) } label = GNUNET_STRINGS_data_to_string_alloc (&ash->reference->id, - sizeof(uint64_t)); + sizeof (ash->reference->id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up existing data under label %s\n", label); // Test for the content of the existing ID @@ -1467,6 +1475,7 @@ reference_store_task (void *cls) GNUNET_free (label); } + /** * Check an attestation reference store message * @@ -1521,6 +1530,8 @@ handle_reference_store_message (void *cls, GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); GNUNET_SCHEDULER_add_now (&reference_store_task, ash); } + + /** * Send a deletion success response * @@ -1570,13 +1581,16 @@ ticket_iter (void *cls, if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) continue; if (adh->claim != NULL) - if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) + if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->claim->id)) continue; if (adh->attest != NULL) - if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t))) + if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->attest->id)) continue; if (adh->reference != NULL) - if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) + if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->reference->id)) continue; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute or Attestation/Reference to delete found (%s)\n", @@ -1671,15 +1685,18 @@ update_tickets (void *cls) { if (adh->claim != NULL) if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) - && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) + && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->claim->id))) continue; if (adh->attest != NULL) if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) - && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) + && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->attest->id))) continue; if (adh->reference != NULL) if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) - && (0 == memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))) + && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, + &adh->reference->id))) continue; rd_new[j] = rd[i]; j++; @@ -1828,7 +1845,8 @@ handle_attribute_delete_message (void *cls, adh->r_id = ntohl (dam->id); adh->identity = dam->identity; adh->label - = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t)); + = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, + sizeof(adh->claim->id)); GNUNET_SERVICE_client_continue (idp->client); adh->client = idp; GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); @@ -1841,6 +1859,7 @@ handle_attribute_delete_message (void *cls, adh); } + /** * Attestation deleted callback * @@ -1867,6 +1886,7 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg) GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); } + /** * Check attestation delete message format * @@ -1916,7 +1936,8 @@ handle_attestation_delete_message (void *cls, adh->r_id = ntohl (dam->id); adh->identity = dam->identity; adh->label - = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, sizeof(uint64_t)); + = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, + sizeof(adh->attest->id)); GNUNET_SERVICE_client_continue (idp->client); adh->client = idp; GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); @@ -1930,7 +1951,6 @@ handle_attestation_delete_message (void *cls, } - /** * Reference deleted callback * @@ -1954,12 +1974,13 @@ reference_delete_cont (void *cls, int32_t success, const char *emsg) return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); - //GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); + // GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); send_delete_response (adh, GNUNET_OK); cleanup_adh (adh); return; } + static void ref_del_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, @@ -1974,7 +1995,7 @@ ref_del_cb (void *cls, struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; size_t attr_len; - if (0 == rd_count ) + if (0 == rd_count) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to find Attestation entry for Attestation reference\n"); @@ -1999,7 +2020,7 @@ ref_del_cb (void *cls, GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); attr_len = htons (rd[i].data_size); ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len); - if (NULL == ref ) + if (NULL == ref) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to parse attestation reference from %s\n", @@ -2008,7 +2029,7 @@ ref_del_cb (void *cls, j += 1; continue; } - if ((strcmp (adh->reference->name,ref->name) == 0)&& + if ((strcmp (adh->reference->name,ref->name) == 0) && (strcmp (adh->reference->reference_value,ref->reference_value)==0) ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2030,6 +2051,7 @@ ref_del_cb (void *cls, adh); } + /** * Check an attestation reference delete message * @@ -2051,6 +2073,7 @@ check_reference_delete_message (void *cls, return GNUNET_OK; } + /** * Handle reference deletion * @@ -2077,7 +2100,7 @@ handle_reference_delete_message (void *cls, adh->identity = dam->identity; adh->label = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id, - sizeof(uint64_t)); + sizeof(adh->reference->id)); GNUNET_SERVICE_client_continue (idp->client); adh->client = idp; GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); @@ -2091,7 +2114,6 @@ handle_reference_delete_message (void *cls, } - /************************************************* * Attrubute iteration *************************************************/ @@ -2190,7 +2212,7 @@ attr_iter_cb (void *cls, return; } - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type ) + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) { struct AttributeResultMessage *arm; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", @@ -2209,7 +2231,7 @@ attr_iter_cb (void *cls, } else { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type ) + 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", @@ -2250,6 +2272,7 @@ attr_iter_cb (void *cls, } } + /** * Iterate over zone to get attributes * diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index b022225b8..bdb9e6dd9 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c @@ -236,12 +236,12 @@ struct RevokedAttributeEntry /** * Old ID of the attribute */ - uint64_t old_id; + struct GNUNET_RECLAIM_Identifier old_id; /** * New ID of the attribute */ - uint64_t new_id; + struct GNUNET_RECLAIM_Identifier new_id; }; @@ -435,7 +435,7 @@ process_tickets (void *cls) continue; for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { - if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) + if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id))) continue; rd[i].data = &ae->new_id; } @@ -497,7 +497,7 @@ rvk_ticket_update (void *cls, continue; for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { - if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) + if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id))) continue; has_changed = GNUNET_YES; break; @@ -532,9 +532,6 @@ rvk_ns_iter_err (void *cls) struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_it = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Namestore error on revocation (id=%" PRIu64 "\n", - rvk->move_attr->old_id); rvk->cb (rvk->cb_cls, GNUNET_SYSERR); cleanup_rvk (rvk); } @@ -551,9 +548,6 @@ rvk_ns_err (void *cls) struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_qe = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Namestore error on revocation (id=%" PRIu64 "\n", - rvk->move_attr->old_id); rvk->cb (rvk->cb_cls, GNUNET_SYSERR); cleanup_rvk (rvk); } @@ -636,7 +630,7 @@ move_attr_finished (void *cls, int32_t success, const char *emsg) return; } label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, - sizeof(uint64_t)); + sizeof(rvk->move_attr->old_id)); GNUNET_assert (NULL != label); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, @@ -685,67 +679,80 @@ rvk_move_attr_cb (void *cls, GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); return; } - rvk->move_attr->new_id =GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); - new_label=NULL; - attr_data=NULL; - //new_rd = *rd; + GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id); + new_label = NULL; + attr_data = NULL; + // new_rd = *rd; for (int i = 0; i < rd_count; i++) { if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) { /** find a new place for this attribute **/ struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; - claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size); + claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, + rd[i].data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Attribute to update: Name=%s, ID=%" PRIu64 "\n", - claim->name, - claim->id); + "Attribute to update: Name=%s\n", + claim->name); claim->id = rvk->move_attr->new_id; new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); attr_data = GNUNET_malloc (rd[i].data_size); - new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data); + new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, + attr_data); new_rd[i].data = attr_data; new_rd[i].record_type = rd[i].record_type; new_rd[i].flags = rd[i].flags; new_rd[i].expiration_time = rd[i].expiration_time; new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, - sizeof(uint64_t)); + sizeof (rvk->move_attr-> + new_id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); GNUNET_free (claim); - } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) + } + else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) { struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; - attest=GNUNET_RECLAIM_ATTESTATION_deserialize(rd[i].data, rd[i].data_size); + attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, + rd[i].data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Attestation to update: Name=%s, ID=%" PRIu64 "\n", - attest->name, - attest->id); + "Attestation to update: Name=%s\n", + attest->name); attest->id = rvk->move_attr->new_id; - new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attest); + new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( + attest); attr_data = GNUNET_malloc (rd[i].data_size); - new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, attr_data); + new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, + attr_data); new_rd[i].data = attr_data; new_rd[i].record_type = rd[i].record_type; new_rd[i].flags = rd[i].flags; new_rd[i].expiration_time = rd[i].expiration_time; - new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t)); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", new_label); + new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, + sizeof (rvk->move_attr-> + new_id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", + new_label); GNUNET_free (attest); - } else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type) + } + else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type) { struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; - reference=GNUNET_RECLAIM_ATTESTATION_REF_deserialize(rd[i].data, rd[i].data_size); + reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data, + rd[i].data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Reference to update: Name=%s, ID=%" PRIu64 "\n", - reference->name, - reference->id); + "Reference to update: Name=%s\n", + reference->name); reference->id = rvk->move_attr->new_id; reference->id_attest = rvk->move_attr->new_id; - new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (reference); + new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size ( + reference); attr_data = GNUNET_malloc (rd[i].data_size); - new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference, attr_data); + new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference, + attr_data); new_rd[i].data = attr_data; - new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, sizeof(uint64_t)); + new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, + sizeof (rvk->move_attr-> + new_id)); new_rd[i].record_type = rd[i].record_type; new_rd[i].flags = rd[i].flags; new_rd[i].expiration_time = rd[i].expiration_time; @@ -754,12 +761,12 @@ rvk_move_attr_cb (void *cls, } } rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, - &rvk->identity, - new_label, - rd_count, - new_rd, - &move_attr_finished, - rvk); + &rvk->identity, + new_label, + rd_count, + new_rd, + &move_attr_finished, + rvk); GNUNET_free (new_label); GNUNET_free (attr_data); } @@ -793,7 +800,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) return; } label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, - sizeof(uint64_t)); + sizeof (rvk->move_attr->old_id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label); rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, @@ -876,7 +883,7 @@ revoke_attrs_cb (void *cls, if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) continue; le = GNUNET_new (struct RevokedAttributeEntry); - le->old_id = *((uint64_t *) rd[i].data); + le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data); GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); rvk->ticket_attrs++; } @@ -934,7 +941,8 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, rvk->ticket = *ticket; GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); /** Get shared attributes **/ - label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, + sizeof(ticket->rnd)); GNUNET_assert (NULL != label); rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, identity, @@ -1231,7 +1239,8 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, cth->cb = cb; cth->cb_cls = cb_cls; label = - GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t)); + GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, + sizeof(cth->ticket.rnd)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", label); @@ -1393,7 +1402,8 @@ issue_ticket (struct TicketIssueHandle *ih) GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; label = - GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t)); + GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, + sizeof(ih->ticket.rnd)); // Publish record ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ih->identity, @@ -1488,29 +1498,21 @@ filter_tickets_cb (void *cls, // cmp attr_ref id with requested attr id if (NULL !=le->claim) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " %" PRIu64 "\n %" PRIu64 "\n", - *((uint64_t *) rd[i].data), - le->claim->id); - if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t))) + if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(le->claim->id))) found_attrs_cnt++; } else if (NULL !=le->attest) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " %" PRIu64 "\n %" PRIu64 "\n", - *((uint64_t *) rd[i].data), - le->attest->id); - if (0 == memcmp (rd[i].data, &le->attest->id, sizeof(uint64_t))) + if (0 == memcmp (rd[i].data, + &le->attest->id, + sizeof(le->attest->id))) found_attrs_cnt++; } else if (NULL != le->reference) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " %" PRIu64 "\n %" PRIu64 "\n", - *((uint64_t *) rd[i].data), - le->reference->id); - if (0 == memcmp (rd[i].data, &le->reference->id, sizeof(uint64_t))) + if (0 == memcmp (rd[i].data, + &le->reference->id, + sizeof(le->reference->id))) found_attrs_cnt++; } @@ -1547,8 +1549,7 @@ filter_tickets_finished_cb (void *cls) struct TicketIssueHandle *tih = cls; GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity); - tih->ticket.rnd = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + GNUNET_RECLAIM_id_generate (&tih->ticket.rnd); issue_ticket (tih); } diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c index a464a9088..6ac60a704 100644 --- a/src/reclaim/json_reclaim.c +++ b/src/reclaim/json_reclaim.c @@ -94,12 +94,12 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) } attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size); if ((NULL == id_str) || (0 == strlen (id_str))) - attr->id = 0; + memset (&attr->id, 0, sizeof (attr->id)); else GNUNET_STRINGS_string_to_data (id_str, strlen (id_str), &attr->id, - sizeof(uint64_t)); + sizeof(attr->id)); *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr; return GNUNET_OK; @@ -192,7 +192,7 @@ parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) if (GNUNET_OK != GNUNET_STRINGS_string_to_data (rnd_str, strlen (rnd_str), &ticket->rnd, - sizeof(uint64_t))) + sizeof(ticket->rnd))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n"); GNUNET_free (ticket); @@ -327,12 +327,12 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) } attr = GNUNET_RECLAIM_ATTESTATION_claim_new (name_str, type, data, data_size); if ((NULL == id_str) || (0 == strlen (id_str))) - attr->id = 0; + memset (&attr->id, 0, sizeof (attr->id)); else GNUNET_STRINGS_string_to_data (id_str, strlen (id_str), &attr->id, - sizeof(uint64_t)); + sizeof(attr->id)); *(struct GNUNET_RECLAIM_ATTESTATION_Claim **) spec->ptr = attr; return GNUNET_OK; @@ -425,16 +425,15 @@ parse_attest_ref (void *cls, json_t *root, struct } attr = GNUNET_RECLAIM_ATTESTATION_reference_new (name_str, ref_val_str); - - attr->id = 0; + memset (&attr->id, 0, sizeof (attr->id)); if ((NULL == ref_id_str) || (0 == strlen (ref_id_str))) - attr->id_attest = 0; + memset (&attr->id_attest, 0, sizeof (attr->id_attest)); else GNUNET_STRINGS_string_to_data (ref_id_str, strlen (ref_id_str), &attr->id_attest, - sizeof(uint64_t)); + sizeof(attr->id_attest)); *(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **) spec->ptr = attr; return GNUNET_OK; @@ -480,4 +479,4 @@ GNUNET_RECLAIM_JSON_spec_claim_attest_ref (struct *attr = NULL; return ret; -} \ No newline at end of file +} diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index 2ce462854..1d23003ab 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c @@ -146,7 +146,7 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, json_t *aggr_names; json_t *aggr_sources; json_t *aggr_sources_jwt; - uint64_t attest_arr[GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (attrs)]; + struct GNUNET_RECLAIM_Identifier attest_arr[GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (attrs)]; // iat REQUIRED time now time_now = GNUNET_TIME_absolute_get (); @@ -216,7 +216,8 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, int j = 0; while (jreference->id_attest) + if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j], + &le->reference->id_attest)) break; j++; } @@ -245,7 +246,8 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, int j = 0; while (jattest->id) + if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j], + &le->attest->id)) break; j++; } diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index dcda75b65..9a6af6bcf 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -428,7 +428,7 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) char *tmp; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n"); - tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd)); json_resource = json_object (); GNUNET_free (tmp); json_array_append (handle->resp_object, json_resource); @@ -447,7 +447,7 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) value = json_string (tmp); json_object_set_new (json_resource, "audience", value); GNUNET_free (tmp); - tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd)); value = json_string (tmp); json_object_set_new (json_resource, "rnd", value); GNUNET_free (tmp); @@ -521,7 +521,7 @@ add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, /** * New ID for attribute */ - if (0 == attribute->id) + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) attribute->id = attribute->id_attest; handle->idp = GNUNET_RECLAIM_connect (cfg); exp = GNUNET_TIME_UNIT_HOURS; @@ -692,9 +692,8 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, /** * New ID for attribute */ - if (0 == attribute->id) - attribute->id = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) + GNUNET_RECLAIM_id_generate (&attribute->id); handle->idp = GNUNET_RECLAIM_connect (cfg); exp = GNUNET_TIME_UNIT_HOURS; handle->idp_op = GNUNET_RECLAIM_attestation_store (handle->idp, @@ -740,9 +739,9 @@ ref_collect (void *cls, json_object_set_new (attr_obj, "ref_value", json_string ( reference->reference_value)); id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id, - sizeof(uint64_t)); + sizeof(reference->id)); id_attest_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id_attest, - sizeof(uint64_t)); + sizeof(reference->id_attest)); json_object_set_new (attr_obj, "id", json_string (id_str)); json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str)); json_array_append (handle->resp_object, attr_obj); @@ -856,7 +855,7 @@ attest_collect (void *cls, json_object_set_new (attr_obj, "name", json_string (attest->name)); type = GNUNET_RECLAIM_ATTESTATION_number_to_typename (attest->type); json_object_set_new (attr_obj, "type", json_string (type)); - id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(uint64_t)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id)); json_object_set_new (attr_obj, "id", json_string (id_str)); json_array_append (handle->resp_object, attr_obj); json_decref (attr_obj); @@ -1017,7 +1016,7 @@ delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, GNUNET_SCHEDULER_add_now (&do_error, handle); return; } - GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(uint64_t)); + GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(attr->id)); handle->idp = GNUNET_RECLAIM_connect (cfg); handle->idp_op = GNUNET_RECLAIM_attestation_reference_delete (handle->idp, @@ -1100,7 +1099,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); handle->idp = GNUNET_RECLAIM_connect (cfg); memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)); - GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t)); + GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); attr.name = ""; handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp, priv_key, @@ -1230,9 +1229,8 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, /** * New ID for attribute */ - if (0 == attribute->id) - attribute->id = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) + GNUNET_RECLAIM_id_generate (&attribute->id); handle->idp = GNUNET_RECLAIM_connect (cfg); exp = GNUNET_TIME_UNIT_HOURS; handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp, @@ -1366,7 +1364,8 @@ attr_collect (void *cls, json_object_set_new (attr_obj, "flag", json_string ("1")); type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr2->type); json_object_set_new (attr_obj, "type", json_string (type)); - id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id, sizeof(uint64_t)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id, + sizeof(attr2->id)); json_object_set_new (attr_obj, "id", json_string (id_str)); json_array_append (handle->resp_object, attr_obj); json_decref (attr_obj); @@ -1396,7 +1395,8 @@ attr_collect (void *cls, json_object_set_new (attr_obj, "flag", json_string (flag_str)); type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); json_object_set_new (attr_obj, "type", json_string (type)); - id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, + sizeof(attr->id)); json_object_set_new (attr_obj, "id", json_string (id_str)); json_array_append (handle->resp_object, attr_obj); json_decref (attr_obj); @@ -1515,7 +1515,7 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); handle->idp = GNUNET_RECLAIM_connect (cfg); memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); - GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t)); + GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); attr.name = ""; handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp, priv_key, diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 847abb58a..5a3bee218 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c @@ -511,13 +511,17 @@ handle_consume_ticket_result (void *cls, { for (le = attrs->list_head; NULL != le; le = le->next) { - if (le->reference != NULL && le->attest == NULL) + if ((le->reference != NULL) && (le->attest == NULL)) { for (le2 = attrs->list_head; NULL != le2; le2 = le2->next) { - if (le2->attest != NULL && le2->attest->id == le->reference->id_attest) + if ((le2->attest != NULL) && + (0 == memcmp (&le2->attest->id, + &le->reference->id_attest, + sizeof (le2->attest->id)))) { - op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest, le->reference); + op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest, + le->reference); break; } @@ -637,6 +641,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) GNUNET_assert (0); } + /** * Handle an incoming message of type * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT @@ -736,6 +741,7 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg) GNUNET_assert (0); } + /** * Handle an incoming message of type * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT @@ -762,6 +768,7 @@ check_reference_result (void *cls, const struct ReferenceResultMessage *msg) return GNUNET_OK; } + /** * Handle an incoming message of type * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT @@ -841,6 +848,7 @@ handle_reference_result (void *cls, const struct ReferenceResultMessage *msg) GNUNET_assert (0); } + /** * Handle an incoming message of type * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT @@ -1150,6 +1158,7 @@ GNUNET_RECLAIM_attribute_delete ( return op; } + /** * Store an attestation. If the attestation is already present, * it is replaced with the new attestation. @@ -1197,6 +1206,7 @@ GNUNET_RECLAIM_attestation_store ( return op; } + /** * Delete an attestation. Tickets used to share this attestation are updated * accordingly. @@ -1240,6 +1250,7 @@ GNUNET_RECLAIM_attestation_delete ( return op; } + /** * Store an attestation reference. If the reference is already present, * it is replaced with the new reference. @@ -1286,6 +1297,7 @@ GNUNET_RECLAIM_attestation_reference_store ( return op; } + /** * Delete an attestation reference. Tickets used to share this reference are updated * accordingly. @@ -1330,6 +1342,7 @@ GNUNET_RECLAIM_attestation_reference_delete ( return op; } + /** * List all attributes for a local identity. * This MUST lock the `struct GNUNET_RECLAIM_Handle`