*/
#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.
*/
/**
* ID
*/
- uint64_t id;
+ struct GNUNET_RECLAIM_Identifier id;
/**
* Type of Claim
/**
* ID
*/
- uint64_t id;
+ struct GNUNET_RECLAIM_Identifier id;
/**
* Type/Format of Claim
uint32_t type;
/**
- * Version
+ * Flag
*/
- uint32_t version;
+ uint32_t flag;
/**
* The name of the attribute. Note "name" must never be individually
/**
* 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
struct GNUNET_CRYPTO_EcdsaPublicKey audience;
/**
- * The ticket random (NBO)
+ * The ticket random identifier
*/
- uint64_t rnd;
+ struct GNUNET_RECLAIM_Identifier rnd;
};
+ 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;
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];
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];
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];
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];
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);
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);
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
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
/**
* 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
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;
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,
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));
}
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,
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,
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;
cleanup_as_handle (ash);
}
+
/**
* Send a reference error response
*
cleanup_as_handle (ash);
}
+
/**
* Error looking up potential attestation. Abort.
*
return;
}
+
/**
* Check for existing record before storing reference
*
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");
GNUNET_free (buf);
}
+
/**
* Add a new attestation
*
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
GNUNET_free (label);
}
+
/**
* Check an attestation store message
*
return GNUNET_OK;
}
+
/**
* Handle an attestation store message
*
GNUNET_SCHEDULER_add_now (&attest_store_task, ash);
}
+
/**
* Error looking up potential reference value. Abort.
*
return;
}
+
/**
* Error looking up potential reference value. Abort.
*
GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
+
+
/**
* Reference store result handler
*
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");
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,
GNUNET_free (buf);
}
+
/**
* Add a new reference
*
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
{
}
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
GNUNET_free (label);
}
+
/**
* Check an attestation reference store message
*
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
*
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",
{
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++;
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);
adh);
}
+
/**
* Attestation deleted callback
*
GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
}
+
/**
* Check attestation delete message format
*
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);
}
-
/**
* Reference deleted callback
*
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,
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");
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",
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,
adh);
}
+
/**
* Check an attestation reference delete message
*
return GNUNET_OK;
}
+
/**
* Handle reference deletion
*
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);
}
-
/*************************************************
* Attrubute iteration
*************************************************/
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",
}
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",
}
}
+
/**
* Iterate over zone to get attributes
*
/**
* 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;
};
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;
}
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;
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);
}
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);
}
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,
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;
}
}
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);
}
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,
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++;
}
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,
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);
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,
// 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++;
}
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);
}
}
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;
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);
}
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;
}
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;
*attr = NULL;
return ret;
-}
\ No newline at end of file
+}
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 ();
int j = 0;
while (j<i)
{
- if (attest_arr[j] == le->reference->id_attest)
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j],
+ &le->reference->id_attest))
break;
j++;
}
int j = 0;
while (j<i)
{
- if (attest_arr[j] == le->attest->id)
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j],
+ &le->attest->id))
break;
j++;
}
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);
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);
/**
* 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;
/**
* 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,
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);
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);
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,
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,
/**
* 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,
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);
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);
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,
{
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;
}
GNUNET_assert (0);
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
GNUNET_assert (0);
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
return GNUNET_OK;
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
GNUNET_assert (0);
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
return op;
}
+
/**
* Store an attestation. If the attestation is already present,
* it is replaced with the new attestation.
return op;
}
+
/**
* Delete an attestation. Tickets used to share this attestation are updated
* accordingly.
return op;
}
+
/**
* Store an attestation reference. If the reference is already present,
* it is replaced with the new reference.
return op;
}
+
/**
* Delete an attestation reference. Tickets used to share this reference are updated
* accordingly.
return op;
}
+
/**
* List all attributes for a local identity.
* This MUST lock the `struct GNUNET_RECLAIM_Handle`