attr_ser->attribute_type = htons (attr->type);
attr_ser->attribute_flag = htonl (attr->flag);
attr_ser->attribute_id = attr->id;
+ attr_ser->attestation_id = attr->attestation;
name_len = strlen (attr->name);
attr_ser->name_len = htons (name_len);
write_ptr = (char *) &attr_ser[1];
attr->type = ntohs (attr_ser->attribute_type);
attr->flag = ntohl (attr_ser->attribute_flag);
attr->id = attr_ser->attribute_id;
+ attr->attestation = attr_ser->attestation_id;
attr->data_size = data_len;
write_ptr = (char *) &attr[1];
ret = 1;
return;
}
- value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
- 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(attr->id));
+ value_str = NULL;
+ if (NULL == attest)
+ {
+ value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
+ attr->data,
+ attr->data_size);
+ }
+ else
+ {
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
+ struct GNUNET_RECLAIM_AttributeList *al
+ = GNUNET_RECLAIM_attestation_get_attributes (attest);
+
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
+ {
+ if (0 != strncmp (attr->data, ale->attribute->name, attr->data_size))
+ continue;
+ value_str
+ = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
+ ale->attribute->
+ data,
+ ale->attribute->
+ data_size);
+ break;
+ }
+ }
fprintf (stdout,
"Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
attr->name,
- value_str,
+ (NULL != value_str) ? value_str : "???",
attr_type,
attr->flag,
id,
- (NULL == attest) ? "" : "ATTESTED");
+ (NULL == attest) ? "" : "(ATTESTED)");
+ GNUNET_free_non_null (value_str);
GNUNET_free (id);
}
if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
{
fprintf (stdout,
- "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
+ "%s: ``%s'' (%s); ID: %s\n",
attr->name,
attr_str,
attr_type,
- attr->flag,
id);
}
else
{
+ char *attest_id =
+ GNUNET_STRINGS_data_to_string_alloc (&attr->attestation,
+ sizeof(attr->attestation));
fprintf (stdout,
- "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
+ "%s: <``%s'' in attestation %s> (%s); ID: %s\n",
attr->name,
attr_str,
+ attest_id,
attr_type,
- attr->flag,
id);
+ GNUNET_free (attest_id);
}
GNUNET_free (id);
attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
fprintf (stdout,
- "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
+ "%s: ``%s'' (%s); ID: %s\n",
attest->name,
attest_str,
attest_type,
- attest->flag,
id);
if (NULL != attrs)
{
"\t Attributes:\n");
for (ale = attrs->list_head; NULL != ale; ale = ale->next)
{
- attr_str = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
- ale->attribute->data,
- ale->attribute->data_size);
+ attr_str = GNUNET_RECLAIM_attribute_value_to_string (
+ ale->attribute->type,
+ ale->attribute->
+ data,
+ ale->attribute->
+ data_size);
fprintf (stdout,
"\t %s: %s\n", ale->attribute->name, attr_str);
consume_result_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_AttributeList *attrs,
+ const struct GNUNET_RECLAIM_AttestationList *attests,
int32_t success,
const char *emsg)
{
struct GNUNET_MQ_Envelope *env;
char *data_tmp;
size_t attrs_len;
+ size_t attests_len;
if (GNUNET_OK != success)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
}
attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
+ attests_len = GNUNET_RECLAIM_attestation_list_serialize_get_size (attests);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending CONSUME_TICKET_RESULT message\n");
env = GNUNET_MQ_msg_extra (crm,
- attrs_len,
+ attrs_len + attests_len,
GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
crm->id = htonl (cop->r_id);
crm->attrs_len = htons (attrs_len);
+ crm->attestations_len = htons (attests_len);
crm->identity = *identity;
crm->result = htonl (success);
data_tmp = (char *) &crm[1];
GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
+ data_tmp += attrs_len;
+ GNUNET_RECLAIM_attestation_list_serialize (attests, data_tmp);
GNUNET_MQ_send (cop->client->mq, env);
GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
cop->client->consume_op_tail,
if (NULL != cth->parallel_lookups_head)
return; // Wait for more
/* Else we are done */
- cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
+ cth->cb (cth->cb_cls, &cth->ticket.identity,
+ cth->attrs, cth->attests, GNUNET_OK, NULL);
cleanup_cth (cth);
}
GNUNET_free (lu);
lu = tmp;
}
- cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted");
+ cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
}
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
+ (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
continue;
lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
parallel_lookup = GNUNET_new (struct ParallelLookup);
parallel_lookup->handle = cth;
parallel_lookup->label = lbl;
/**
* No references found, return empty attribute list
*/
- cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
+ cth->cb (cth->cb_cls, &cth->ticket.identity,
+ cth->attrs, cth->attests, GNUNET_OK, NULL);
cleanup_cth (cth);
}
cth->identity = *id;
GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
+ cth->attests = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
cth->ticket = *ticket;
cth->cb = cb;
cth->cb_cls = cb_cls;
struct GNUNET_RECLAIM_AttributeListEntry *le;
struct GNUNET_GNSRECORD_Data *attrs_record;
char *label;
- size_t list_len = 1;
int i;
+ int attrs_count = 0;
for (le = ih->attrs->list_head; NULL != le; le = le->next)
- {
- list_len++;
- if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
- list_len++;
- }
+ attrs_count++;
+ //Worst case we have one attestation per attribute
attrs_record =
- GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
+ GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
i = 0;
for (le = ih->attrs->list_head; NULL != le; le = le->next)
{
attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
+ i++;
if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
{
- i++;
+ int j;
+ for (j = 0; j < i; j++)
+ {
+ if (attrs_record[j].record_type
+ != GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF)
+ continue;
+ if (0 == memcmp (attrs_record[j].data,
+ &le->attribute->attestation,
+ sizeof (le->attribute->attestation)))
+ break;
+ }
+ if (j < i)
+ continue; // Skip as we have already added this attestation.
attrs_record[i].data = &le->attribute->attestation;
attrs_record[i].data_size = sizeof(le->attribute->attestation);
attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
attrs_record[i].record_type =
GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
+ i++;
}
- i++;
}
attrs_record[i].data = &ih->ticket;
attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
attrs_record[i].flags =
GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
+ i++;
label =
GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd,
ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
&ih->identity,
label,
- list_len,
+ i,
attrs_record,
&store_ticket_issue_cont,
ih);
typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_AttributeList *l,
+ const struct GNUNET_RECLAIM_AttributeList *attributes,
+ const struct GNUNET_RECLAIM_AttestationList *attestations,
int32_t success,
const char *emsg);
{
size_t msg_len;
size_t attrs_len;
+ size_t attests_len;
msg_len = ntohs (msg->header.size);
attrs_len = ntohs (msg->attrs_len);
- if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len)
+ attests_len = ntohs (msg->attestations_len);
+ if (msg_len !=
+ sizeof(struct ConsumeTicketResultMessage) + attrs_len + attests_len)
{
GNUNET_break (0);
return GNUNET_SYSERR;
for (ale = attests->list_head; NULL != ale; ale = ale->next)
{
if (GNUNET_YES ==
- GNUNET_RECLAIM_id_is_equal (&le->attribute->id,
+ GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation,
&ale->attestation->id))
{
op->atr_cb (op->cls, &msg->identity,