GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
reclaim attributes

Data Structures

struct  GNUNET_RECLAIM_Identifier
 A reclaim identifier FIXME maybe put this in a different namespace. More...
 
struct  GNUNET_RECLAIM_Attribute
 An attribute. More...
 
struct  GNUNET_RECLAIM_Attestation
 An attestation. More...
 
struct  GNUNET_RECLAIM_AttributeList
 A list of GNUNET_RECLAIM_Attribute structures. More...
 
struct  GNUNET_RECLAIM_AttributeListEntry
 
struct  GNUNET_RECLAIM_AttestationList
 A list of GNUNET_RECLAIM_Attestation structures. More...
 
struct  GNUNET_RECLAIM_AttestationListEntry
 

Macros

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE   0
 No value attribute. More...
 
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING   1
 String attribute. More...
 
#define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE   10
 No value attestation. More...
 
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT   11
 A JSON Web Token attestation. More...
 
#define GNUNET_RECLAIM_ID_LENGTH   (256 / 8)
 We want an ID to be a 256-bit symmetric key. More...
 
#define GNUNET_RECLAIM_id_is_equal(a, b)
 
#define GNUNET_RECLAIM_id_is_zero(a)
 
#define GNUNET_RECLAIM_id_generate(id)
 

Functions

struct GNUNET_RECLAIM_AttributeGNUNET_RECLAIM_attribute_new (const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
 Create a new attribute claim. More...
 
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size (const struct GNUNET_RECLAIM_AttributeList *attrs)
 Get required size for serialization buffer. More...
 
void GNUNET_RECLAIM_attribute_list_destroy (struct GNUNET_RECLAIM_AttributeList *attrs)
 Destroy claim list. More...
 
void GNUNET_RECLAIM_attribute_list_add (struct GNUNET_RECLAIM_AttributeList *attrs, const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
 Add a new attribute to a claim list. More...
 
size_t GNUNET_RECLAIM_attribute_list_serialize (const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
 Serialize an attribute list. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
 
size_t GNUNET_RECLAIM_attribute_serialize_get_size (const struct GNUNET_RECLAIM_Attribute *attr)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_attribute_serialize (const struct GNUNET_RECLAIM_Attribute *attr, char *result)
 Serialize an attribute. More...
 
struct GNUNET_RECLAIM_AttributeGNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size)
 Deserialize an attribute. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attribute_list_dup (const struct GNUNET_RECLAIM_AttributeList *attrs)
 Make a (deep) copy of a claim list. More...
 
uint32_t GNUNET_RECLAIM_attribute_typename_to_number (const char *typename)
 Convert a type name to the corresponding number. More...
 
int GNUNET_RECLAIM_attribute_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attribute to the binary representation. More...
 
char * GNUNET_RECLAIM_attribute_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attribute to a string. More...
 
const char * GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type)
 Convert a type number to the corresponding type string. More...
 
size_t GNUNET_RECLAIM_attestation_list_serialize_get_size (const struct GNUNET_RECLAIM_AttestationList *attestations)
 Get required size for serialization buffer. More...
 
void GNUNET_RECLAIM_attestation_list_destroy (struct GNUNET_RECLAIM_AttestationList *attestations)
 Destroy claim list. More...
 
void GNUNET_RECLAIM_attestation_list_add (struct GNUNET_RECLAIM_AttestationList *attrs, const char *att_name, uint32_t type, const void *data, size_t data_size)
 Add a new attribute to a claim list. More...
 
size_t GNUNET_RECLAIM_attestation_list_serialize (const struct GNUNET_RECLAIM_AttestationList *attrs, char *result)
 Serialize an attribute list. More...
 
struct GNUNET_RECLAIM_AttestationListGNUNET_RECLAIM_attestation_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
 
size_t GNUNET_RECLAIM_attestation_serialize_get_size (const struct GNUNET_RECLAIM_Attestation *attestation)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_attestation_serialize (const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
 Serialize an attestation. More...
 
struct GNUNET_RECLAIM_AttestationGNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size)
 Deserialize an attestation. More...
 
struct GNUNET_RECLAIM_AttestationGNUNET_RECLAIM_attestation_new (const char *name, uint32_t type, const void *data, size_t data_size)
 Create a new attestation. More...
 
char * GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attestation to a string. More...
 
int GNUNET_RECLAIM_attestation_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attestation to the binary representation. More...
 
const char * GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type)
 Convert an attestation type number to the corresponding attestation type string. More...
 
uint32_t GNUNET_RECLAIM_attestation_typename_to_number (const char *typename)
 Convert an attestation type name to the corresponding number. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attestation_get_attributes (const struct GNUNET_RECLAIM_Attestation *attest)
 Convert an attestation type name to the corresponding number. More...
 
char * GNUNET_RECLAIM_attestation_get_issuer (const struct GNUNET_RECLAIM_Attestation *attest)
 
int GNUNET_RECLAIM_attestation_get_expiration (const struct GNUNET_RECLAIM_Attestation *attest, struct GNUNET_TIME_Absolute *exp)
 

Variables

static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
 

Detailed Description

Macro Definition Documentation

◆ GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE   0

No value attribute.

Definition at line 46 of file gnunet_reclaim_lib.h.

◆ GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING   1

String attribute.

Definition at line 51 of file gnunet_reclaim_lib.h.

Referenced by basic_string_to_value(), basic_value_to_string(), iter_finished(), and jwt_parse_attributes().

◆ GNUNET_RECLAIM_ATTESTATION_TYPE_NONE

#define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE   10

No value attestation.

Definition at line 56 of file gnunet_reclaim_lib.h.

◆ GNUNET_RECLAIM_ATTESTATION_TYPE_JWT

#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT   11

◆ GNUNET_RECLAIM_ID_LENGTH

#define GNUNET_RECLAIM_ID_LENGTH   (256 / 8)

We want an ID to be a 256-bit symmetric key.

Definition at line 66 of file gnunet_reclaim_lib.h.

◆ GNUNET_RECLAIM_id_is_equal

#define GNUNET_RECLAIM_id_is_equal (   a,
 
)
Value:
((0 == \
memcmp (a, \
b, \
? \
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO

Definition at line 79 of file gnunet_reclaim_lib.h.

Referenced by attest_iter_cb(), attribute_list_merge(), filter_tickets_cb(), handle_consume_ticket_result(), oidc_attest_collect(), OIDC_id_token_new(), ticket_iter(), and update_tickets().

◆ GNUNET_RECLAIM_id_is_zero

#define GNUNET_RECLAIM_id_is_zero (   a)

◆ GNUNET_RECLAIM_id_generate

#define GNUNET_RECLAIM_id_generate (   id)
Value:
id, \
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
High-quality operations are desired.

Definition at line 91 of file gnunet_reclaim_lib.h.

Referenced by add_attestation_cont(), add_attribute_cont(), attest_store_task(), attr_store_task(), filter_tickets_finished_cb(), and rvk_move_attr_cb().

Function Documentation

◆ GNUNET_RECLAIM_attribute_new()

struct GNUNET_RECLAIM_Attribute* GNUNET_RECLAIM_attribute_new ( const char *  attr_name,
const struct GNUNET_RECLAIM_Identifier attestation,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Create a new attribute claim.

Parameters
attr_namethe attribute name
attestationID of the attestation (may be NULL)
typethe attribute type
datathe attribute value. Must be the mapped name if attestation not NULL
data_sizethe attribute value size
Returns
the new attribute

Create a new attribute claim.

Parameters
attr_namethe attribute name
attestationattestation ID of the attribute (maybe NULL)
typethe attribute type
datathe attribute value
data_sizethe attribute value size
Returns
the new attribute

Definition at line 232 of file reclaim_attribute.c.

References attestation, GNUNET_RECLAIM_Attribute::attestation, GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Attribute::data_size, data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Attribute::type, and type.

Referenced by attribute_list_merge(), GNUNET_RECLAIM_attribute_list_add(), GNUNET_RECLAIM_attribute_list_dup(), iter_cb(), iter_finished(), oidc_attr_collect(), parse_attr(), and parse_jwt().

237 {
238  struct GNUNET_RECLAIM_Attribute *attr;
239  char *write_ptr;
240  char *attr_name_tmp = GNUNET_strdup (attr_name);
241 
242  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
243 
244  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
245  + strlen (attr_name_tmp) + 1 + data_size);
246  if (NULL != attestation)
247  attr->attestation = *attestation;
248  attr->type = type;
249  attr->data_size = data_size;
250  attr->flag = 0;
251  write_ptr = (char *) &attr[1];
252  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
253  attr->name = write_ptr;
254  write_ptr += strlen (attr->name) + 1;
255  GNUNET_memcpy (write_ptr, data, data_size);
256  attr->data = write_ptr;
257  GNUNET_free (attr_name_tmp);
258  return attr;
259 }
const char * name
The name of the attribute.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
static char * attr_name
The attribute.
size_t data_size
Number of bytes in data.
static struct GNUNET_RECLAIM_Identifier attestation
Attestation ID.
const void * data
Binary value stored as attribute value.
uint32_t type
Type of Claim.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:567
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_serialize_get_size()

size_t GNUNET_RECLAIM_attribute_list_serialize_get_size ( const struct GNUNET_RECLAIM_AttributeList al)

Get required size for serialization buffer.

Parameters
attrsthe attribute list to serialize
Returns
the required buffer size

Definition at line 298 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_assert, GNUNET_RECLAIM_attribute_serialize_get_size(), len, GNUNET_RECLAIM_AttributeList::list_head, and GNUNET_RECLAIM_AttributeListEntry::next.

Referenced by consume_result_cb(), GNUNET_RECLAIM_ticket_issue(), and OIDC_build_authz_code().

300 {
302  size_t len = 0;
303 
304  for (ale = al->list_head; NULL != ale; ale = ale->next)
305  {
306  GNUNET_assert (NULL != ale->attribute);
308  len += sizeof(struct GNUNET_RECLAIM_AttributeListEntry);
309  }
310  return len;
311 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_destroy()

void GNUNET_RECLAIM_attribute_list_destroy ( struct GNUNET_RECLAIM_AttributeList al)

Destroy claim list.

Parameters
attrslist to destroy

Definition at line 427 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_free, GNUNET_RECLAIM_AttributeList::list_head, and GNUNET_RECLAIM_AttributeListEntry::next.

Referenced by attest_collect(), attest_iter_cb(), cleanup_cth(), cleanup_handle(), handle_consume_ticket_result(), handle_issue_ticket_message(), oidc_attest_collect_finished_cb(), and token_endpoint().

429 {
431  struct GNUNET_RECLAIM_AttributeListEntry *tmp_ale;
432 
433  for (ale = al->list_head; NULL != ale;)
434  {
435  if (NULL != ale->attribute)
436  GNUNET_free (ale->attribute);
437  tmp_ale = ale;
438  ale = ale->next;
439  GNUNET_free (tmp_ale);
440  }
441  GNUNET_free (al);
442 }
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_add()

void GNUNET_RECLAIM_attribute_list_add ( struct GNUNET_RECLAIM_AttributeList al,
const char *  attr_name,
const struct GNUNET_RECLAIM_Identifier attestation,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Add a new attribute to a claim list.

Parameters
attrsthe attribute list to add to
attr_namethe name of the new attribute claim
attestationattestation ID (may be NULL)
typethe type of the claim
dataclaim payload
data_sizeclaim payload size
attr_namethe name of the new attribute claim
typethe type of the claim
dataclaim payload
data_sizeclaim payload size

Definition at line 271 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_AttributeList::list_head, and GNUNET_RECLAIM_AttributeList::list_tail.

Referenced by jwt_parse_attributes().

278 {
280 
282  ale->attribute =
284  type, data, data_size);
286  al->list_tail,
287  ale);
288 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
static char * attr_name
The attribute.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_serialize()

size_t GNUNET_RECLAIM_attribute_list_serialize ( const struct GNUNET_RECLAIM_AttributeList al,
char *  result 
)

Serialize an attribute list.

Parameters
attrsthe attribute list to serialize
resultthe serialized attribute
Returns
length of serialized data

Definition at line 322 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_assert, GNUNET_RECLAIM_attribute_serialize(), len, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttributeListEntry::next, and result.

Referenced by consume_result_cb(), GNUNET_RECLAIM_ticket_issue(), and OIDC_build_authz_code().

325 {
327  size_t len;
328  size_t total_len;
329  char *write_ptr;
330  write_ptr = result;
331  total_len = 0;
332  for (ale = al->list_head; NULL != ale; ale = ale->next)
333  {
334  GNUNET_assert (NULL != ale->attribute);
335  len = GNUNET_RECLAIM_attribute_serialize (ale->attribute, write_ptr);
336  total_len += len;
337  write_ptr += len;
338  }
339  return total_len;
340 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
static int result
Global testing status.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_deserialize()

struct GNUNET_RECLAIM_AttributeList* GNUNET_RECLAIM_attribute_list_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attribute list.

Parameters
datathe serialized attribute list
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller

Definition at line 351 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_attribute_deserialize(), GNUNET_RECLAIM_attribute_serialize_get_size(), GNUNET_RECLAIM_AttributeList::list_head, and GNUNET_RECLAIM_AttributeList::list_tail.

Referenced by handle_consume_ticket_result(), handle_issue_ticket_message(), and OIDC_parse_authz_code().

352 {
353  struct GNUNET_RECLAIM_AttributeList *al;
355  size_t attr_len;
356  const char *read_ptr;
357 
359  if (data_size < sizeof(struct Attribute) + sizeof(struct
361  return al;
362  read_ptr = data;
363  while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
364  {
366  ale->attribute =
368  data_size - (read_ptr - data));
369  if (NULL == ale->attribute)
370  {
372  "Failed to deserialize malformed attribute.\n");
373  GNUNET_free (ale);
374  return al;
375  }
378  read_ptr += attr_len;
379  }
380  return al;
381 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
A list of GNUNET_RECLAIM_Attribute structures.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Serialized claim.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
#define GNUNET_log(kind,...)
uint32_t data
The data value.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_serialize_get_size()

size_t GNUNET_RECLAIM_attribute_serialize_get_size ( const struct GNUNET_RECLAIM_Attribute attr)

Get required size for serialization buffer.

Parameters
attrthe attribute to serialize
Returns
the required buffer size

Definition at line 452 of file reclaim_attribute.c.

Referenced by attr_store_task(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_attribute_list_serialize_get_size(), GNUNET_RECLAIM_attribute_store(), and rvk_move_attr_cb().

454 {
455  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
456 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
Serialized claim.
const char * name
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_serialize()

size_t GNUNET_RECLAIM_attribute_serialize ( const struct GNUNET_RECLAIM_Attribute attr,
char *  result 
)

Serialize an attribute.

Parameters
attrthe attribute to serialize
resultthe serialized attribute
Returns
length of serialized data

Definition at line 467 of file reclaim_attribute.c.

References GNUNET_RECLAIM_Attribute::attestation, Attribute::attestation_id, Attribute::attribute_flag, Attribute::attribute_id, Attribute::attribute_type, GNUNET_RECLAIM_Attribute::data, Attribute::data_size, GNUNET_RECLAIM_Attribute::data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_memcpy, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Attribute::name, Attribute::name_len, and GNUNET_RECLAIM_Attribute::type.

Referenced by attr_store_task(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_list_serialize(), GNUNET_RECLAIM_attribute_store(), and rvk_move_attr_cb().

470 {
471  size_t data_len_ser;
472  size_t name_len;
473  struct Attribute *attr_ser;
474  char *write_ptr;
475 
476  attr_ser = (struct Attribute *) result;
477  attr_ser->attribute_type = htons (attr->type);
478  attr_ser->attribute_flag = htonl (attr->flag);
479  attr_ser->attribute_id = attr->id;
480  attr_ser->attestation_id = attr->attestation;
481  name_len = strlen (attr->name);
482  attr_ser->name_len = htons (name_len);
483  write_ptr = (char *) &attr_ser[1];
484  GNUNET_memcpy (write_ptr, attr->name, name_len);
485  write_ptr += name_len;
486  // TODO plugin-ize
487  // data_len_ser = plugin->serialize_attribute_value (attr,
488  // &attr_ser[1]);
489  data_len_ser = attr->data_size;
490  GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
491  attr_ser->data_size = htons (data_len_ser);
492 
493  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
494 }
const char * name
The name of the attribute.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Serialized claim.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
uint32_t attribute_flag
Attribute flag.
uint32_t data_size
Data size.
static int result
Global testing status.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier attestation_id
Attestation ID.
const char * name
uint32_t name_len
Name length.
const void * data
Binary value stored as attribute value.
uint32_t type
Type of Claim.
struct GNUNET_RECLAIM_Identifier attribute_id
Attribute ID.
uint32_t attribute_type
Attribute type.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_deserialize()

struct GNUNET_RECLAIM_Attribute* GNUNET_RECLAIM_attribute_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attribute.

Parameters
datathe serialized attribute
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller

Definition at line 506 of file reclaim_attribute.c.

References GNUNET_RECLAIM_Attribute::attestation, Attribute::attestation_id, Attribute::attribute_flag, Attribute::attribute_id, Attribute::attribute_type, GNUNET_RECLAIM_Attribute::data, Attribute::data_size, GNUNET_RECLAIM_Attribute::data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Attribute::name, Attribute::name_len, and GNUNET_RECLAIM_Attribute::type.

Referenced by GNUNET_RECLAIM_attribute_list_deserialize(), handle_attribute_delete_message(), handle_attribute_result(), handle_attribute_store_message(), process_parallel_lookup_result(), and rvk_move_attr_cb().

507 {
508  struct GNUNET_RECLAIM_Attribute *attr;
509  struct Attribute *attr_ser;
510  size_t data_len;
511  size_t name_len;
512  char *write_ptr;
513 
514  if (data_size < sizeof(struct Attribute))
515  return NULL;
516 
517  attr_ser = (struct Attribute *) data;
518  data_len = ntohs (attr_ser->data_size);
519  name_len = ntohs (attr_ser->name_len);
520  if (data_size < sizeof(struct Attribute) + data_len + name_len)
521  {
523  "Buffer too small to deserialize\n");
524  return NULL;
525  }
526  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
527  + data_len + name_len + 1);
528  attr->type = ntohs (attr_ser->attribute_type);
529  attr->flag = ntohl (attr_ser->attribute_flag);
530  attr->id = attr_ser->attribute_id;
531  attr->attestation = attr_ser->attestation_id;
532  attr->data_size = data_len;
533 
534  write_ptr = (char *) &attr[1];
535  GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
536  write_ptr[name_len] = '\0';
537  attr->name = write_ptr;
538 
539  write_ptr += name_len + 1;
540  GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
541  attr->data = write_ptr;
542  return attr;
543 }
const char * name
The name of the attribute.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Serialized claim.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
uint32_t attribute_flag
Attribute flag.
uint32_t data_size
Data size.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier attestation_id
Attestation ID.
#define GNUNET_log(kind,...)
uint32_t name_len
Name length.
const void * data
Binary value stored as attribute value.
uint32_t type
Type of Claim.
struct GNUNET_RECLAIM_Identifier attribute_id
Attribute ID.
uint32_t data
The data value.
uint32_t attribute_type
Attribute type.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_list_dup()

struct GNUNET_RECLAIM_AttributeList* GNUNET_RECLAIM_attribute_list_dup ( const struct GNUNET_RECLAIM_AttributeList al)

Make a (deep) copy of a claim list.

Parameters
attrsclaim list to copy
Returns
copied claim list

Definition at line 390 of file reclaim_attribute.c.

References GNUNET_RECLAIM_Attribute::attestation, GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Attribute::data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttributeList::list_tail, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_AttributeListEntry::next, result, and GNUNET_RECLAIM_Attribute::type.

Referenced by RECLAIM_TICKETS_issue().

392 {
394  struct GNUNET_RECLAIM_AttributeListEntry *result_ale;
396 
397  result = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
398  for (ale = al->list_head; NULL != ale; ale = ale->next)
399  {
400  result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
401  GNUNET_assert (NULL != ale->attribute);
402  {
403  result_ale->attribute =
405  &ale->attribute->attestation,
406  ale->attribute->type,
407  ale->attribute->data,
408  ale->attribute->data_size);
409 
410  result_ale->attribute->id = ale->attribute->id;
411  result_ale->attribute->flag = ale->attribute->flag;
412  }
414  result->list_tail,
415  result_ale);
416  }
417  return result;
418 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
const char * name
The name of the attribute.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A list of GNUNET_RECLAIM_Attribute structures.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
static int result
Global testing status.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
const void * data
Binary value stored as attribute value.
uint32_t type
Type of Claim.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_typename_to_number()

uint32_t GNUNET_RECLAIM_attribute_typename_to_number ( const char *  typename)

Convert a type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 113 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by iter_finished(), parse_attr(), and parse_jwt().

114 {
115  unsigned int i;
116  struct Plugin *plugin;
117  uint32_t ret;
118 
119  init ();
120  for (i = 0; i < num_plugins; i++)
121  {
122  plugin = attr_plugins[i];
123  if (UINT32_MAX !=
124  (ret = plugin->api->typename_to_number (plugin->api->cls, typename)))
125  return ret;
126  }
127  return UINT32_MAX;
128 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_string_to_value()

int GNUNET_RECLAIM_attribute_string_to_value ( uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)

Convert human-readable version of a 'claim' of an attribute to the binary representation.

Parameters
typetype of the claim
shuman-readable string
dataset to value in binary encoding (will be allocated)
data_sizeset to number of bytes in data
Returns
GNUNET_OK on success

Definition at line 167 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_OK, GNUNET_SYSERR, init(), num_plugins, and plugin.

Referenced by iter_finished(), parse_attr(), and parse_jwt().

171 {
172  unsigned int i;
173  struct Plugin *plugin;
174 
175  init ();
176  for (i = 0; i < num_plugins; i++)
177  {
178  plugin = attr_plugins[i];
179  if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
180  type,
181  s,
182  data,
183  data_size))
184  return GNUNET_OK;
185  }
186  return GNUNET_SYSERR;
187 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_value_to_string()

char* GNUNET_RECLAIM_attribute_value_to_string ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Convert the 'claim' of an attribute to a string.

Parameters
typethe type of attribute
dataclaim in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the claim

Definition at line 199 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), attest_iter_cb(), attr_collect(), consume_cont(), consume_ticket(), iter_cb(), OIDC_id_token_new(), and process_attrs().

202 {
203  unsigned int i;
204  struct Plugin *plugin;
205  char *ret;
206 
207  init ();
208  for (i = 0; i < num_plugins; i++)
209  {
210  plugin = attr_plugins[i];
211  if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
212  type,
213  data,
214  data_size)))
215  return ret;
216  }
217  return NULL;
218 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attribute_number_to_typename()

const char* GNUNET_RECLAIM_attribute_number_to_typename ( uint32_t  type)

Convert a type number to the corresponding type string.

Parameters
typenumber of a type
Returns
corresponding typestring, NULL on error

Definition at line 138 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), attr_collect(), iter_cb(), and process_attrs().

139 {
140  unsigned int i;
141  struct Plugin *plugin;
142  const char *ret;
143 
144  init ();
145  for (i = 0; i < num_plugins; i++)
146  {
147  plugin = attr_plugins[i];
148  if (NULL !=
149  (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
150  return ret;
151  }
152  return NULL;
153 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_list_serialize_get_size()

size_t GNUNET_RECLAIM_attestation_list_serialize_get_size ( const struct GNUNET_RECLAIM_AttestationList attestations)

Get required size for serialization buffer.

Parameters
attrsthe attribute list to serialize
Returns
the required buffer size

Definition at line 265 of file reclaim_attestation.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, GNUNET_assert, GNUNET_RECLAIM_attestation_serialize_get_size(), len, GNUNET_RECLAIM_AttestationList::list_head, and GNUNET_RECLAIM_AttestationListEntry::next.

Referenced by consume_result_cb(), and OIDC_build_authz_code().

267 {
269  size_t len = 0;
270 
271  for (le = attestations->list_head; NULL != le; le = le->next)
272  {
273  GNUNET_assert (NULL != le->attestation);
275  len += sizeof(struct GNUNET_RECLAIM_AttestationListEntry);
276  }
277  return len;
278 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
size_t GNUNET_RECLAIM_attestation_serialize_get_size(const struct GNUNET_RECLAIM_Attestation *attestation)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_list_destroy()

void GNUNET_RECLAIM_attestation_list_destroy ( struct GNUNET_RECLAIM_AttestationList al)

Destroy claim list.

Parameters
attrslist to destroy

Destroy claim list.

Parameters
attrslist to destroy

Definition at line 392 of file reclaim_attestation.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, GNUNET_free, GNUNET_RECLAIM_AttestationList::list_head, and GNUNET_RECLAIM_AttestationListEntry::next.

Referenced by cleanup_cth(), cleanup_handle(), handle_consume_ticket_result(), and token_endpoint().

394 {
396  struct GNUNET_RECLAIM_AttestationListEntry *tmp_ale;
397 
398  for (ale = al->list_head; NULL != ale;)
399  {
400  if (NULL != ale->attestation)
401  GNUNET_free (ale->attestation);
402  tmp_ale = ale;
403  ale = ale->next;
404  GNUNET_free (tmp_ale);
405  }
406  GNUNET_free (al);
407 }
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_list_add()

void GNUNET_RECLAIM_attestation_list_add ( struct GNUNET_RECLAIM_AttestationList attrs,
const char *  att_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Add a new attribute to a claim list.

Parameters
attr_namethe name of the new attribute claim
typethe type of the claim
dataclaim payload
data_sizeclaim payload size

◆ GNUNET_RECLAIM_attestation_list_serialize()

size_t GNUNET_RECLAIM_attestation_list_serialize ( const struct GNUNET_RECLAIM_AttestationList attestations,
char *  result 
)

Serialize an attribute list.

Parameters
attrsthe attribute list to serialize
resultthe serialized attribute
Returns
length of serialized data

Definition at line 289 of file reclaim_attestation.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, GNUNET_assert, GNUNET_RECLAIM_attestation_serialize(), len, GNUNET_RECLAIM_AttestationList::list_head, GNUNET_RECLAIM_AttestationListEntry::next, and result.

Referenced by consume_result_cb(), and OIDC_build_authz_code().

292 {
294  size_t len;
295  size_t total_len;
296  char *write_ptr;
297  write_ptr = result;
298  total_len = 0;
299  for (le = attestations->list_head; NULL != le; le = le->next)
300  {
301  GNUNET_assert (NULL != le->attestation);
302  len = GNUNET_RECLAIM_attestation_serialize (le->attestation, write_ptr);
303  total_len += len;
304  write_ptr += len;
305  }
306  return total_len;
307 }
size_t GNUNET_RECLAIM_attestation_serialize(const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
Serialize an attestation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
static int result
Global testing status.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_list_deserialize()

struct GNUNET_RECLAIM_AttestationList* GNUNET_RECLAIM_attestation_list_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attribute list.

Parameters
datathe serialized attribute list
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller

Deserialize an attribute list.

Parameters
datathe serialized attribute list
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller

Definition at line 318 of file reclaim_attestation.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_attestation_deserialize(), GNUNET_RECLAIM_attestation_serialize_get_size(), GNUNET_RECLAIM_AttestationList::list_head, and GNUNET_RECLAIM_AttestationList::list_tail.

Referenced by handle_consume_ticket_result(), and OIDC_parse_authz_code().

319 {
322  size_t att_len;
323  const char *read_ptr;
324 
326 
327  if ((data_size < sizeof(struct
328  Attestation)
329  + sizeof(struct GNUNET_RECLAIM_AttestationListEntry)))
330  return al;
331 
332  read_ptr = data;
333  while (((data + data_size) - read_ptr) >= sizeof(struct Attestation))
334  {
336  ale->attestation =
338  data_size - (read_ptr - data));
339  if (NULL == ale->attestation)
340  {
342  "Failed to deserialize malformed attestation.\n");
343  GNUNET_free (ale);
344  return al;
345  }
348  read_ptr += att_len;
349  }
350  return al;
351 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
A list of GNUNET_RECLAIM_Attestation structures.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
size_t GNUNET_RECLAIM_attestation_serialize_get_size(const struct GNUNET_RECLAIM_Attestation *attestation)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_AttestationListEntry * list_tail
List tail.
#define GNUNET_log(kind,...)
Serialized attestation claim.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_serialize_get_size()

size_t GNUNET_RECLAIM_attestation_serialize_get_size ( const struct GNUNET_RECLAIM_Attestation attestation)

Get required size for serialization buffer.

Parameters
attestationthe attestation to serialize
Returns
the required buffer size
Parameters
attrthe attestation to serialize
Returns
the required buffer size

Definition at line 417 of file reclaim_attestation.c.

Referenced by attest_add_cb(), GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_attestation_list_deserialize(), GNUNET_RECLAIM_attestation_list_serialize_get_size(), GNUNET_RECLAIM_attestation_store(), and rvk_move_attr_cb().

419 {
420  return sizeof(struct Attestation) + strlen (attestation->name)
421  + attestation->data_size;
422 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
const char * name
Serialized attestation claim.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_serialize()

size_t GNUNET_RECLAIM_attestation_serialize ( const struct GNUNET_RECLAIM_Attestation attestation,
char *  result 
)

Serialize an attestation.

Parameters
attestationthe attestation to serialize
resultthe serialized attestation
Returns
length of serialized data
Parameters
attrthe attestation to serialize
resultthe serialized attestation
Returns
length of serialized data

Definition at line 433 of file reclaim_attestation.c.

References Attestation::attestation_flag, Attestation::attestation_id, Attestation::attestation_type, GNUNET_RECLAIM_Attestation::data, Attestation::data_size, GNUNET_RECLAIM_Attestation::data_size, GNUNET_RECLAIM_Attestation::flag, GNUNET_memcpy, GNUNET_RECLAIM_Attestation::id, GNUNET_RECLAIM_Attestation::name, Attestation::name_len, and GNUNET_RECLAIM_Attestation::type.

Referenced by attest_add_cb(), GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_attestation_list_serialize(), GNUNET_RECLAIM_attestation_store(), and rvk_move_attr_cb().

436 {
437  size_t data_len_ser;
438  size_t name_len;
439  struct Attestation *atts;
440  char *write_ptr;
441 
442  atts = (struct Attestation *) result;
443  atts->attestation_type = htons (attestation->type);
444  atts->attestation_flag = htonl (attestation->flag);
445  atts->attestation_id = attestation->id;
446  name_len = strlen (attestation->name);
447  atts->name_len = htons (name_len);
448  write_ptr = (char *) &atts[1];
449  GNUNET_memcpy (write_ptr, attestation->name, name_len);
450  write_ptr += name_len;
451  // TODO plugin-ize
452  // data_len_ser = plugin->serialize_attribute_value (attr,
453  // &attr_ser[1]);
454  data_len_ser = attestation->data_size;
455  GNUNET_memcpy (write_ptr, attestation->data, attestation->data_size);
456  atts->data_size = htons (data_len_ser);
457 
458  return sizeof(struct Attestation) + strlen (attestation->name)
459  + attestation->data_size;
460 }
uint32_t attestation_type
Attestation type.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t name_len
Name length.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int result
Global testing status.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
uint32_t attestation_flag
Attestation flag.
const void * data
Binary value stored as attribute value.
const char * name
struct GNUNET_RECLAIM_Identifier attestation_id
Attestation ID.
Serialized attestation claim.
uint32_t data_size
Data size.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_deserialize()

struct GNUNET_RECLAIM_Attestation* GNUNET_RECLAIM_attestation_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attestation.

Parameters
datathe serialized attestation
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller

Definition at line 472 of file reclaim_attestation.c.

References attestation, Attestation::attestation_flag, Attestation::attestation_id, Attestation::attestation_type, GNUNET_RECLAIM_Attestation::data, Attestation::data_size, GNUNET_RECLAIM_Attestation::data_size, GNUNET_RECLAIM_Attestation::flag, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_RECLAIM_Attestation::id, GNUNET_RECLAIM_Attestation::name, Attestation::name_len, and GNUNET_RECLAIM_Attestation::type.

Referenced by GNUNET_RECLAIM_attestation_list_deserialize(), handle_attestation_delete_message(), handle_attestation_result(), handle_attestation_store_message(), process_parallel_lookup_result(), and rvk_move_attr_cb().

473 {
475  struct Attestation *atts;
476  size_t data_len;
477  size_t name_len;
478  char *write_ptr;
479 
480  if (data_size < sizeof(struct Attestation))
481  return NULL;
482 
483  atts = (struct Attestation *) data;
484  data_len = ntohs (atts->data_size);
485  name_len = ntohs (atts->name_len);
486  if (data_size < sizeof(struct Attestation) + data_len + name_len)
487  {
489  "Buffer too small to deserialize\n");
490  return NULL;
491  }
492  attestation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
493  + data_len + name_len + 1);
494  attestation->type = ntohs (atts->attestation_type);
495  attestation->flag = ntohl (atts->attestation_flag);
496  attestation->id = atts->attestation_id;
497  attestation->data_size = data_len;
498 
499  write_ptr = (char *) &attestation[1];
500  GNUNET_memcpy (write_ptr, &atts[1], name_len);
501  write_ptr[name_len] = '\0';
502  attestation->name = write_ptr;
503 
504  write_ptr += name_len + 1;
505  GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
506  attestation->data_size);
507  attestation->data = write_ptr;
508  return attestation;
509 }
uint32_t attestation_type
Attestation type.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t name_len
Name length.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
uint32_t attestation_flag
Attestation flag.
const void * data
Binary value stored as attribute value.
static struct GNUNET_RECLAIM_Identifier attestation
Attestation ID.
struct GNUNET_RECLAIM_Identifier attestation_id
Attestation ID.
#define GNUNET_log(kind,...)
Serialized attestation claim.
uint32_t data_size
Data size.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_new()

struct GNUNET_RECLAIM_Attestation* GNUNET_RECLAIM_attestation_new ( const char *  attr_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Create a new attestation.

Parameters
namethe attestation name
typethe attestation type
datathe attestation value
data_sizethe attestation value size
Returns
the new attestation
Parameters
attr_namethe attestation name
typethe attestation type
datathe attestation value
data_sizethe attestation value size
Returns
the new attestation

Definition at line 231 of file reclaim_attestation.c.

References GNUNET_RECLAIM_Attestation::data, GNUNET_RECLAIM_Attestation::data_size, data_size, GNUNET_RECLAIM_Attestation::flag, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_RECLAIM_Attestation::name, type, and GNUNET_RECLAIM_Attestation::type.

Referenced by attest_iter_finished(), GNUNET_RECLAIM_attestation_list_dup(), oidc_attest_collect(), and parse_attest().

235 {
236  struct GNUNET_RECLAIM_Attestation *attr;
237  char *write_ptr;
238  char *attr_name_tmp = GNUNET_strdup (attr_name);
239 
240  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
241 
242  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
243  + strlen (attr_name_tmp) + 1 + data_size);
244  attr->type = type;
245  attr->data_size = data_size;
246  attr->flag = 0;
247  write_ptr = (char *) &attr[1];
248  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
249  attr->name = write_ptr;
250  write_ptr += strlen (attr->name) + 1;
251  GNUNET_memcpy (write_ptr, data, data_size);
252  attr->data = write_ptr;
253  GNUNET_free (attr_name_tmp);
254  return attr;
255 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * attr_name
The attribute.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
uint32_t type
Type/Format of Claim.
const void * data
Binary value stored as attribute value.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:567
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_value_to_string()

char* GNUNET_RECLAIM_attestation_value_to_string ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Convert the 'claim' of an attestation to a string.

Parameters
typethe type of attestation
dataclaim in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the claim

Definition at line 199 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), attest_iter_cb(), consume_ticket(), OIDC_id_token_new(), and parse_jwt().

202 {
203  unsigned int i;
204  struct Plugin *plugin;
205  char *ret;
206 
207  init ();
208  for (i = 0; i < num_plugins; i++)
209  {
210  plugin = attest_plugins[i];
211  if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
212  type,
213  data,
214  data_size)))
215  return ret;
216  }
217  return NULL;
218 }
static struct Plugin ** attest_plugins
Plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_string_to_value()

int GNUNET_RECLAIM_attestation_string_to_value ( uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)

Convert human-readable version of a 'claim' of an attestation to the binary representation.

Parameters
typetype of the claim
shuman-readable string
dataset to value in binary encoding (will be allocated)
data_sizeset to number of bytes in data
Returns
GNUNET_OK on success

Definition at line 167 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_OK, GNUNET_SYSERR, init(), num_plugins, and plugin.

Referenced by parse_attest().

171 {
172  unsigned int i;
173  struct Plugin *plugin;
174 
175  init ();
176  for (i = 0; i < num_plugins; i++)
177  {
178  plugin = attest_plugins[i];
179  if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
180  type,
181  s,
182  data,
183  data_size))
184  return GNUNET_OK;
185  }
186  return GNUNET_SYSERR;
187 }
static struct Plugin ** attest_plugins
Plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_number_to_typename()

const char* GNUNET_RECLAIM_attestation_number_to_typename ( uint32_t  type)

Convert an attestation type number to the corresponding attestation type string.

Parameters
typenumber of a type
Returns
corresponding typestring, NULL on error

Definition at line 138 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), and attest_iter_cb().

139 {
140  unsigned int i;
141  struct Plugin *plugin;
142  const char *ret;
143 
144  init ();
145  for (i = 0; i < num_plugins; i++)
146  {
147  plugin = attest_plugins[i];
148  if (NULL !=
149  (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
150  return ret;
151  }
152  return NULL;
153 }
static struct Plugin ** attest_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_typename_to_number()

uint32_t GNUNET_RECLAIM_attestation_typename_to_number ( const char *  typename)

Convert an attestation type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 113 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by parse_attest().

114 {
115  unsigned int i;
116  struct Plugin *plugin;
117  uint32_t ret;
118  init ();
119  for (i = 0; i < num_plugins; i++)
120  {
121  plugin = attest_plugins[i];
122  if (UINT32_MAX !=
123  (ret = plugin->api->typename_to_number (plugin->api->cls,
124  typename)))
125  return ret;
126  }
127  return UINT32_MAX;
128 }
static struct Plugin ** attest_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_get_attributes()

struct GNUNET_RECLAIM_AttributeList* GNUNET_RECLAIM_attestation_get_attributes ( const struct GNUNET_RECLAIM_Attestation attest)

Convert an attestation type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 513 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), attest_iter_cb(), and process_attrs().

515 {
516  unsigned int i;
517  struct Plugin *plugin;
519  init ();
520  for (i = 0; i < num_plugins; i++)
521  {
522  plugin = attest_plugins[i];
523  if (NULL !=
524  (ret = plugin->api->get_attributes (plugin->api->cls,
525  attest)))
526  return ret;
527  }
528  return NULL;
529 }
static struct Plugin ** attest_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_get_issuer()

char* GNUNET_RECLAIM_attestation_get_issuer ( const struct GNUNET_RECLAIM_Attestation attest)

Definition at line 533 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect().

535 {
536  unsigned int i;
537  struct Plugin *plugin;
538  char *ret;
539  init ();
540  for (i = 0; i < num_plugins; i++)
541  {
542  plugin = attest_plugins[i];
543  if (NULL !=
544  (ret = plugin->api->get_issuer (plugin->api->cls,
545  attest)))
546  return ret;
547  }
548  return NULL;
549 }
static struct Plugin ** attest_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_get_expiration()

int GNUNET_RECLAIM_attestation_get_expiration ( const struct GNUNET_RECLAIM_Attestation attest,
struct GNUNET_TIME_Absolute exp 
)

Definition at line 553 of file reclaim_attestation.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_OK, GNUNET_SYSERR, init(), num_plugins, and plugin.

Referenced by attest_collect().

556 {
557  unsigned int i;
558  struct Plugin *plugin;
559  init ();
560  for (i = 0; i < num_plugins; i++)
561  {
562  plugin = attest_plugins[i];
563  if (GNUNET_OK != plugin->api->get_expiration (plugin->api->cls,
564  attest,
565  exp))
566  continue;
567  return GNUNET_OK;
568  }
569  return GNUNET_SYSERR;
570 }
static struct Plugin ** attest_plugins
Plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GNUNET_RECLAIM_ID_ZERO

const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
static

Definition at line 77 of file gnunet_reclaim_lib.h.

Referenced by start_process().