GNUnet  0.11.x
Data Structures | Macros | Enumerations | 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_Credential
 A credential. More...
 
struct  GNUNET_RECLAIM_Presentation
 A credential presentation. More...
 
struct  GNUNET_RECLAIM_AttributeList
 A list of GNUNET_RECLAIM_Attribute structures. More...
 
struct  GNUNET_RECLAIM_AttributeListEntry
 
struct  GNUNET_RECLAIM_CredentialList
 A list of GNUNET_RECLAIM_Credential structures. More...
 
struct  GNUNET_RECLAIM_CredentialListEntry
 
struct  GNUNET_RECLAIM_PresentationList
 A list of GNUNET_RECLAIM_Presentation structures. More...
 
struct  GNUNET_RECLAIM_PresentationListEntry
 

Macros

#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)
 

Enumerations

enum  GNUNET_RECLAIM_AttributeType { GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE = 0, GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING = 1 }
 
enum  GNUNET_RECLAIM_CredentialType { GNUNET_RECLAIM_CREDENTIAL_TYPE_NONE = 0, GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT = 1, GNUNET_RECLAIM_CREDENTIAL_TYPE_PABC = 2 }
 

Functions

struct GNUNET_RECLAIM_AttributeGNUNET_RECLAIM_attribute_new (const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, 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 *credential, 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...
 
ssize_t GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
 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_credential_list_serialize_get_size (const struct GNUNET_RECLAIM_CredentialList *credentials)
 Get required size for serialization buffer. More...
 
void GNUNET_RECLAIM_credential_list_destroy (struct GNUNET_RECLAIM_CredentialList *credentials)
 Destroy claim list. More...
 
void GNUNET_RECLAIM_credential_list_add (struct GNUNET_RECLAIM_CredentialList *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_credential_list_serialize (const struct GNUNET_RECLAIM_CredentialList *attrs, char *result)
 Serialize an attribute list. More...
 
struct GNUNET_RECLAIM_CredentialListGNUNET_RECLAIM_credential_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
 
size_t GNUNET_RECLAIM_credential_serialize_get_size (const struct GNUNET_RECLAIM_Credential *credential)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_credential_serialize (const struct GNUNET_RECLAIM_Credential *credential, char *result)
 Serialize an credential. More...
 
struct GNUNET_RECLAIM_CredentialGNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size)
 Deserialize an credential. More...
 
struct GNUNET_RECLAIM_CredentialGNUNET_RECLAIM_credential_new (const char *name, uint32_t type, const void *data, size_t data_size)
 Create a new credential. More...
 
char * GNUNET_RECLAIM_credential_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an credential to a string. More...
 
int GNUNET_RECLAIM_credential_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an credential to the binary representation. More...
 
const char * GNUNET_RECLAIM_credential_number_to_typename (uint32_t type)
 Convert an credential type number to the corresponding credential type string. More...
 
uint32_t GNUNET_RECLAIM_credential_typename_to_number (const char *typename)
 Convert an credential type name to the corresponding number. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_credential_get_attributes (const struct GNUNET_RECLAIM_Credential *cred)
 Convert an credential type name to the corresponding number. More...
 
char * GNUNET_RECLAIM_credential_get_issuer (const struct GNUNET_RECLAIM_Credential *cred)
 
int GNUNET_RECLAIM_credential_get_expiration (const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
 
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size (const struct GNUNET_RECLAIM_PresentationList *presentations)
 Get required size for serialization buffer. More...
 
void GNUNET_RECLAIM_presentation_list_destroy (struct GNUNET_RECLAIM_PresentationList *presentations)
 Destroy presentations list. More...
 
size_t GNUNET_RECLAIM_presentation_list_serialize (const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
 Serialize a presentation list. More...
 
struct GNUNET_RECLAIM_PresentationListGNUNET_RECLAIM_presentation_list_deserialize (const char *data, size_t data_size)
 Deserialize a presentation list. More...
 
size_t GNUNET_RECLAIM_presentation_serialize_get_size (const struct GNUNET_RECLAIM_Presentation *presentation)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_presentation_serialize (const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
 Serialize a presentation. More...
 
struct GNUNET_RECLAIM_PresentationGNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size)
 Deserialize a presentation. More...
 
char * GNUNET_RECLAIM_presentation_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of a presentation to a string. More...
 
struct GNUNET_RECLAIM_PresentationGNUNET_RECLAIM_presentation_new (uint32_t type, const void *data, size_t data_size)
 
int GNUNET_RECLAIM_presentation_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of a presentation to the binary representation. More...
 
const char * GNUNET_RECLAIM_presentation_number_to_typename (uint32_t type)
 Convert a presentation type number to the corresponding credential type string. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_presentation_get_attributes (const struct GNUNET_RECLAIM_Presentation *cred)
 
char * GNUNET_RECLAIM_presentation_get_issuer (const struct GNUNET_RECLAIM_Presentation *cred)
 
int GNUNET_RECLAIM_presentation_get_expiration (const struct GNUNET_RECLAIM_Presentation *cred, struct GNUNET_TIME_Absolute *exp)
 
int GNUNET_RECLAIM_credential_get_presentation (const struct GNUNET_RECLAIM_Credential *cred, const struct GNUNET_RECLAIM_AttributeList *attrs, struct GNUNET_RECLAIM_Presentation **presentation)
 Create a presentation from a credential and a lift of (selected) attributes in the credential. More...
 

Variables

static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
 

Detailed Description

Macro Definition Documentation

◆ 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 74 of file gnunet_reclaim_lib.h.

◆ GNUNET_RECLAIM_id_is_equal

#define GNUNET_RECLAIM_id_is_equal (   a,
 
)

◆ 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 102 of file gnunet_reclaim_lib.h.

Referenced by add_attribute_cont(), add_credential_cont(), attr_store_task(), cred_store_task(), filter_tickets_finished_cb(), and rvk_move_attr_cb().

Enumeration Type Documentation

◆ GNUNET_RECLAIM_AttributeType

Enumerator
GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 

No value attribute.

GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 

String attribute.

Definition at line 42 of file gnunet_reclaim_lib.h.

◆ GNUNET_RECLAIM_CredentialType

Enumerator
GNUNET_RECLAIM_CREDENTIAL_TYPE_NONE 

No value credential.

GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT 

A JSON Web Token credential.

GNUNET_RECLAIM_CREDENTIAL_TYPE_PABC 

libpabc credential

Definition at line 54 of file gnunet_reclaim_lib.h.

Function Documentation

◆ GNUNET_RECLAIM_attribute_new()

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

Create a new attribute claim.

Parameters
attr_namethe attribute name
credentialID of the credential (may be NULL)
typethe attribute type
datathe attribute value. Must be attr_name if credential not NULL
data_sizethe attribute value size
Returns
the new attribute

Create a new attribute claim.

Parameters
attr_namethe attribute name
credentialcredential 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 credential, GNUNET_RECLAIM_Attribute::credential, 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, type, and GNUNET_RECLAIM_Attribute::type.

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

238 {
239  struct GNUNET_RECLAIM_Attribute *attr;
240  char *write_ptr;
241  char *attr_name_tmp = GNUNET_strdup (attr_name);
242 
243  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
244 
245  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
246  + strlen (attr_name_tmp) + 1 + data_size);
247  if (NULL != credential)
248  attr->credential = *credential;
249  attr->type = type;
250  attr->data_size = data_size;
251  attr->flag = 0;
252  write_ptr = (char *) &attr[1];
253  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
254  attr->name = write_ptr;
255  write_ptr += strlen (attr->name) + 1;
256  GNUNET_memcpy (write_ptr, data, data_size);
257  attr->data = write_ptr;
258  GNUNET_free (attr_name_tmp);
259  return attr;
260 }
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.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * attr_name
The attribute.
size_t data_size
Number of bytes in data.
static struct GNUNET_RECLAIM_Identifier credential
Credential 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:568
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 299 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().

301 {
303  size_t len = 0;
304 
305  for (ale = al->list_head; NULL != ale; ale = ale->next)
306  {
307  GNUNET_assert (NULL != ale->attribute);
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 428 of file reclaim_attribute.c.

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

Referenced by cleanup_cth(), cleanup_handle(), cred_collect(), cred_iter_cb(), handle_consume_ticket_result(), handle_issue_ticket_message(), oidc_cred_collect_finished_cb(), and token_endpoint().

430 {
432  struct GNUNET_RECLAIM_AttributeListEntry *tmp_ale;
433 
434  for (ale = al->list_head; NULL != ale;)
435  {
436  if (NULL != ale->attribute)
437  GNUNET_free (ale->attribute);
438  tmp_ale = ale;
439  ale = ale->next;
440  GNUNET_free (tmp_ale);
441  }
442  GNUNET_free (al);
443 }
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 credential,
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
credentialcredential 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 272 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().

279 {
281 
283  ale->attribute =
285  type, data, data_size);
287  al->list_tail,
288  ale);
289 }
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
#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.
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, data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_attribute_deserialize(), 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  size_t left = data_size;
358 
360  if (data_size < sizeof(struct Attribute))
361  return al;
362  read_ptr = data;
363  while (left >= sizeof(struct Attribute))
364  {
366  attr_len =
368  left,
369  &ale->attribute);
370  if (-1 == attr_len)
371  {
373  "Failed to deserialize malformed attribute.\n");
374  GNUNET_free (ale);
375  return al;
376  }
377  left -= attr_len;
379  read_ptr += attr_len;
380  }
381  return al;
382 }
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
#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.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
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 453 of file reclaim_attribute.c.

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

455 {
456  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
457 }
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 468 of file reclaim_attribute.c.

References Attribute::attribute_flag, Attribute::attribute_id, Attribute::attribute_type, GNUNET_RECLAIM_Attribute::credential, Attribute::credential_id, 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().

471 {
472  size_t data_len_ser;
473  size_t name_len;
474  struct Attribute *attr_ser;
475  char *write_ptr;
476 
477  attr_ser = (struct Attribute *) result;
478  attr_ser->attribute_type = htons (attr->type);
479  attr_ser->attribute_flag = htonl (attr->flag);
480  attr_ser->attribute_id = attr->id;
481  attr_ser->credential_id = attr->credential;
482  name_len = strlen (attr->name);
483  attr_ser->name_len = htons (name_len);
484  write_ptr = (char *) &attr_ser[1];
485  GNUNET_memcpy (write_ptr, attr->name, name_len);
486  write_ptr += name_len;
487  // TODO plugin-ize
488  // data_len_ser = plugin->serialize_attribute_value (attr,
489  // &attr_ser[1]);
490  data_len_ser = attr->data_size;
491  GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
492  attr_ser->data_size = htons (data_len_ser);
493 
494  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
495 }
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 credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
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 credential_id
Credential 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()

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

Deserialize an attribute.

Parameters
datathe serialized attribute
data_sizethe length of the serialized data
attrdeserialized attribute. Will be allocated. Must be free'd
Returns
number of bytes read or -1 for error
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 507 of file reclaim_attribute.c.

References Attribute::attribute_flag, Attribute::attribute_id, Attribute::attribute_type, GNUNET_RECLAIM_Attribute::credential, Attribute::credential_id, 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().

509 {
510  struct Attribute *attr_ser;
511  struct GNUNET_RECLAIM_Attribute *attribute;
512  size_t data_len;
513  size_t name_len;
514  char *write_ptr;
515 
516  if (data_size < sizeof(struct Attribute))
517  return -1;
518 
519  attr_ser = (struct Attribute *) data;
520  data_len = ntohs (attr_ser->data_size);
521  name_len = ntohs (attr_ser->name_len);
522  if (data_size < sizeof(struct Attribute) + data_len + name_len)
523  {
525  "Buffer too small to deserialize\n");
526  return -1;
527  }
528  attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
529  + data_len + name_len + 1);
530  attribute->type = ntohs (attr_ser->attribute_type);
531  attribute->flag = ntohl (attr_ser->attribute_flag);
532  attribute->id = attr_ser->attribute_id;
533  attribute->credential = attr_ser->credential_id;
534  attribute->data_size = data_len;
535 
536  write_ptr = (char *) &attribute[1];
537  GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
538  write_ptr[name_len] = '\0';
539  attribute->name = write_ptr;
540 
541  write_ptr += name_len + 1;
542  GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len,
543  attribute->data_size);
544  *attr = attribute;
545  attribute->data = write_ptr;
546  return sizeof(struct Attribute) + data_len + name_len;
547 }
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 credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
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 credential_id
Credential 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 391 of file reclaim_attribute.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::credential, 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().

393 {
395  struct GNUNET_RECLAIM_AttributeListEntry *result_ale;
397 
398  result = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
399  for (ale = al->list_head; NULL != ale; ale = ale->next)
400  {
401  result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
402  GNUNET_assert (NULL != ale->attribute);
403  {
404  result_ale->attribute =
406  &ale->attribute->credential,
407  ale->attribute->type,
408  ale->attribute->data,
409  ale->attribute->data_size);
410 
411  result_ale->attribute->id = ale->attribute->id;
412  result_ale->attribute->flag = ale->attribute->flag;
413  }
415  result->list_tail,
416  result_ale);
417  }
418  return result;
419 }
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
#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_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
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.
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 attr_collect(), consume_cont(), cred_collect(), cred_iter_cb(), generate_userinfo_json(), iter_cb(), 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 attr_collect(), cred_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_credential_list_serialize_get_size()

size_t GNUNET_RECLAIM_credential_list_serialize_get_size ( const struct GNUNET_RECLAIM_CredentialList credentials)

Get required size for serialization buffer.

Parameters
attrsthe attribute list to serialize
Returns
the required buffer size

Definition at line 265 of file reclaim_credential.c.

References GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_assert, GNUNET_RECLAIM_credential_serialize_get_size(), len, GNUNET_RECLAIM_CredentialList::list_head, and GNUNET_RECLAIM_CredentialListEntry::next.

267 {
269  size_t len = 0;
270 
271  for (le = credentials->list_head; NULL != le; le = le->next)
272  {
273  GNUNET_assert (NULL != le->credential);
275  len += sizeof(struct GNUNET_RECLAIM_CredentialListEntry);
276  }
277  return len;
278 }
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_Credential * credential
The credential.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
struct GNUNET_RECLAIM_CredentialListEntry * 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:

◆ GNUNET_RECLAIM_credential_list_destroy()

void GNUNET_RECLAIM_credential_list_destroy ( struct GNUNET_RECLAIM_CredentialList al)

Destroy claim list.

Parameters
attrslist to destroy

Destroy claim list.

Parameters
attrslist to destroy

Definition at line 392 of file reclaim_credential.c.

References GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_free, GNUNET_RECLAIM_CredentialList::list_head, and GNUNET_RECLAIM_CredentialListEntry::next.

Referenced by cleanup_handle().

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

◆ GNUNET_RECLAIM_credential_list_add()

void GNUNET_RECLAIM_credential_list_add ( struct GNUNET_RECLAIM_CredentialList 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_credential_list_serialize()

size_t GNUNET_RECLAIM_credential_list_serialize ( const struct GNUNET_RECLAIM_CredentialList credentials,
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_credential.c.

References GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_assert, GNUNET_RECLAIM_credential_serialize(), len, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_CredentialListEntry::next, and result.

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 = credentials->list_head; NULL != le; le = le->next)
300  {
301  GNUNET_assert (NULL != le->credential);
302  len = GNUNET_RECLAIM_credential_serialize (le->credential, write_ptr);
303  total_len += len;
304  write_ptr += len;
305  }
306  return total_len;
307 }
struct GNUNET_RECLAIM_Credential * credential
The credential.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
static int result
Global testing status.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
struct GNUNET_RECLAIM_CredentialListEntry * 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:

◆ GNUNET_RECLAIM_credential_list_deserialize()

struct GNUNET_RECLAIM_CredentialList* GNUNET_RECLAIM_credential_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_credential.c.

References GNUNET_RECLAIM_CredentialListEntry::credential, data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_credential_deserialize(), GNUNET_RECLAIM_credential_serialize_get_size(), GNUNET_RECLAIM_CredentialList::list_head, and GNUNET_RECLAIM_CredentialList::list_tail.

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

◆ GNUNET_RECLAIM_credential_serialize_get_size()

size_t GNUNET_RECLAIM_credential_serialize_get_size ( const struct GNUNET_RECLAIM_Credential credential)

Get required size for serialization buffer.

Parameters
credentialthe credential to serialize
Returns
the required buffer size
Parameters
attrthe credential to serialize
Returns
the required buffer size

Definition at line 417 of file reclaim_credential.c.

Referenced by cred_add_cb(), GNUNET_RECLAIM_credential_delete(), GNUNET_RECLAIM_credential_list_deserialize(), GNUNET_RECLAIM_credential_list_serialize_get_size(), GNUNET_RECLAIM_credential_store(), and rvk_move_attr_cb().

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

◆ GNUNET_RECLAIM_credential_serialize()

size_t GNUNET_RECLAIM_credential_serialize ( const struct GNUNET_RECLAIM_Credential credential,
char *  result 
)

Serialize an credential.

Parameters
credentialthe credential to serialize
resultthe serialized credential
Returns
length of serialized data
Parameters
attrthe credential to serialize
resultthe serialized credential
Returns
length of serialized data

Definition at line 433 of file reclaim_credential.c.

References Credential::credential_flag, Credential::credential_id, Credential::credential_type, GNUNET_RECLAIM_Credential::data, Credential::data_size, GNUNET_RECLAIM_Credential::data_size, GNUNET_RECLAIM_Credential::flag, GNUNET_memcpy, GNUNET_RECLAIM_Credential::id, GNUNET_RECLAIM_Credential::name, Credential::name_len, and GNUNET_RECLAIM_Credential::type.

Referenced by cred_add_cb(), GNUNET_RECLAIM_credential_delete(), GNUNET_RECLAIM_credential_list_serialize(), GNUNET_RECLAIM_credential_store(), and rvk_move_attr_cb().

436 {
437  size_t data_len_ser;
438  size_t name_len;
439  struct Credential *atts;
440  char *write_ptr;
441 
442  atts = (struct Credential *) result;
443  atts->credential_type = htons (credential->type);
444  atts->credential_flag = htonl (credential->flag);
445  atts->credential_id = credential->id;
446  name_len = strlen (credential->name);
447  atts->name_len = htons (name_len);
448  write_ptr = (char *) &atts[1];
449  GNUNET_memcpy (write_ptr, credential->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 = credential->data_size;
455  GNUNET_memcpy (write_ptr, credential->data, credential->data_size);
456  atts->data_size = htons (data_len_ser);
457 
458  return sizeof(struct Credential) + strlen (credential->name)
459  + credential->data_size;
460 }
Serialized credential claim.
uint32_t data_size
Data size.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
uint32_t name_len
Name length.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
size_t data_size
Number of bytes in data.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const void * data
Binary value stored as credential value.
uint32_t credential_type
Credential type.
static int result
Global testing status.
const char * name
The name of the credential.
struct GNUNET_RECLAIM_Identifier credential_id
Credential ID.
const char * name
uint32_t credential_flag
Credential flag.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_credential_deserialize()

struct GNUNET_RECLAIM_Credential* GNUNET_RECLAIM_credential_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an credential.

Parameters
datathe serialized credential
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_credential.c.

References credential, Credential::credential_flag, Credential::credential_id, Credential::credential_type, GNUNET_RECLAIM_Credential::data, Credential::data_size, GNUNET_RECLAIM_Credential::data_size, GNUNET_RECLAIM_Credential::flag, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_RECLAIM_Credential::id, GNUNET_RECLAIM_Credential::name, Credential::name_len, and GNUNET_RECLAIM_Credential::type.

Referenced by filter_tickets_cb(), GNUNET_RECLAIM_credential_list_deserialize(), handle_credential_delete_message(), handle_credential_result(), handle_credential_store_message(), and rvk_move_attr_cb().

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

◆ GNUNET_RECLAIM_credential_new()

struct GNUNET_RECLAIM_Credential* GNUNET_RECLAIM_credential_new ( const char *  attr_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Create a new credential.

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

Definition at line 231 of file reclaim_credential.c.

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

Referenced by cred_iter_finished(), GNUNET_RECLAIM_credential_list_dup(), oidc_cred_collect(), and parse_credential().

235 {
236  struct GNUNET_RECLAIM_Credential *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_Credential)
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 }
uint32_t type
Type/Format of Claim.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
size_t data_size
Number of bytes in data.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const void * data
Binary value stored as credential value.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * attr_name
The attribute.
const char * name
The name of the credential.
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:568
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_credential_value_to_string()

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

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

Parameters
typethe type of credential
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_credential.c.

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

Referenced by cred_collect(), cred_iter_cb(), 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 = credential_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 ** credential_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
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_credential_string_to_value()

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

Convert human-readable version of a 'claim' of an credential 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_credential.c.

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

Referenced by parse_credential().

171 {
172  unsigned int i;
173  struct Plugin *plugin;
174 
175  init ();
176  for (i = 0; i < num_plugins; i++)
177  {
178  plugin = credential_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 ** credential_plugins
Plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_credential_number_to_typename()

const char* GNUNET_RECLAIM_credential_number_to_typename ( uint32_t  type)

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

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

Definition at line 138 of file reclaim_credential.c.

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

Referenced by cred_collect(), and cred_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 = credential_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 ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_credential_typename_to_number()

uint32_t GNUNET_RECLAIM_credential_typename_to_number ( const char *  typename)

Convert an credential type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 113 of file reclaim_credential.c.

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

Referenced by cred_iter_finished(), and parse_credential().

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 = credential_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 ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_credential_get_attributes()

struct GNUNET_RECLAIM_AttributeList* GNUNET_RECLAIM_credential_get_attributes ( const struct GNUNET_RECLAIM_Credential cred)

Convert an credential type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 513 of file reclaim_credential.c.

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

Referenced by cred_collect(), and cred_iter_cb().

515 {
516  unsigned int i;
517  struct Plugin *plugin;
519  init ();
520  for (i = 0; i < num_plugins; i++)
521  {
522  plugin = credential_plugins[i];
523  if (NULL !=
524  (ret = plugin->api->get_attributes (plugin->api->cls,
525  credential)))
526  return ret;
527  }
528  return NULL;
529 }
static struct Plugin ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static char * plugin
Solver plugin name as string.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
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_credential_get_issuer()

char* GNUNET_RECLAIM_credential_get_issuer ( const struct GNUNET_RECLAIM_Credential cred)

Definition at line 533 of file reclaim_credential.c.

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

Referenced by cred_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 = credential_plugins[i];
543  if (NULL !=
544  (ret = plugin->api->get_issuer (plugin->api->cls,
545  credential)))
546  return ret;
547  }
548  return NULL;
549 }
static struct Plugin ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static char * plugin
Solver plugin name as string.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
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_credential_get_expiration()

int GNUNET_RECLAIM_credential_get_expiration ( const struct GNUNET_RECLAIM_Credential cred,
struct GNUNET_TIME_Absolute exp 
)

Definition at line 553 of file reclaim_credential.c.

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

Referenced by cred_collect().

556 {
557  unsigned int i;
558  struct Plugin *plugin;
559  init ();
560  for (i = 0; i < num_plugins; i++)
561  {
562  plugin = credential_plugins[i];
563  if (GNUNET_OK != plugin->api->get_expiration (plugin->api->cls,
564  credential,
565  exp))
566  continue;
567  return GNUNET_OK;
568  }
569  return GNUNET_SYSERR;
570 }
static struct Plugin ** credential_plugins
Plugins.
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load plugins.
static char * plugin
Solver plugin name as string.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
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_presentation_list_serialize_get_size()

size_t GNUNET_RECLAIM_presentation_list_serialize_get_size ( const struct GNUNET_RECLAIM_PresentationList presentations)

Get required size for serialization buffer.

Parameters
presentationsthe presentation list to serialize
Returns
the required buffer size
Parameters
attrsthe attribute list to serialize
Returns
the required buffer size

Definition at line 714 of file reclaim_credential.c.

References GNUNET_assert, GNUNET_RECLAIM_presentation_serialize_get_size(), len, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationListEntry::next, and GNUNET_RECLAIM_PresentationListEntry::presentation.

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

716 {
718  size_t len = 0;
719 
720  for (le = presentations->list_head; NULL != le; le = le->next)
721  {
722  GNUNET_assert (NULL != le->presentation);
724  len += sizeof(struct GNUNET_RECLAIM_PresentationListEntry);
725  }
726  return len;
727 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
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_presentation_list_destroy()

void GNUNET_RECLAIM_presentation_list_destroy ( struct GNUNET_RECLAIM_PresentationList al)

Destroy presentations list.

Parameters
presentationslist to destroy

Destroy presentations list.

Parameters
attrslist to destroy

Definition at line 841 of file reclaim_credential.c.

References GNUNET_free, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationListEntry::next, and GNUNET_RECLAIM_PresentationListEntry::presentation.

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

843 {
845  struct GNUNET_RECLAIM_PresentationListEntry *tmp_ale;
846 
847  for (ale = al->list_head; NULL != ale;)
848  {
849  if (NULL != ale->presentation)
850  GNUNET_free (ale->presentation);
851  tmp_ale = ale;
852  ale = ale->next;
853  GNUNET_free (tmp_ale);
854  }
855  GNUNET_free (al);
856 }
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_presentation_list_serialize()

size_t GNUNET_RECLAIM_presentation_list_serialize ( const struct GNUNET_RECLAIM_PresentationList presentations,
char *  result 
)

Serialize a presentation list.

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

Serialize a presentation list.

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

Definition at line 738 of file reclaim_credential.c.

References GNUNET_assert, GNUNET_RECLAIM_presentation_serialize(), len, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationListEntry::next, GNUNET_RECLAIM_PresentationListEntry::presentation, and result.

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

741 {
743  size_t len;
744  size_t total_len;
745  char *write_ptr;
746  write_ptr = result;
747  total_len = 0;
748  for (le = presentations->list_head; NULL != le; le = le->next)
749  {
750  GNUNET_assert (NULL != le->presentation);
752  total_len += len;
753  write_ptr += len;
754  }
755  return total_len;
756 }
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize an presentation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
static int result
Global testing status.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
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_presentation_list_deserialize()

struct GNUNET_RECLAIM_PresentationList* GNUNET_RECLAIM_presentation_list_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize a presentation list.

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

Deserialize a presentation 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 767 of file reclaim_credential.c.

References data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_presentation_deserialize(), GNUNET_RECLAIM_presentation_serialize_get_size(), GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationList::list_tail, and GNUNET_RECLAIM_PresentationListEntry::presentation.

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

769 {
772  size_t att_len;
773  const char *read_ptr;
774 
776 
777  if ((data_size < sizeof(struct Presentation)
778  + sizeof(struct GNUNET_RECLAIM_PresentationListEntry)))
779  return al;
780 
781  read_ptr = data;
782  while (((data + data_size) - read_ptr) >= sizeof(struct Presentation))
783  {
785  ale->presentation =
787  data_size - (read_ptr - data));
788  if (NULL == ale->presentation)
789  {
791  "Failed to deserialize malformed presentation.\n");
792  GNUNET_free (ale);
793  return al;
794  }
797  ale->presentation);
798  read_ptr += att_len;
799  }
800  return al;
801 }
#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_PresentationListEntry * list_head
List head.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Serialized presentation claim.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize an presentation.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
A list of GNUNET_RECLAIM_Presentation structures.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
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_presentation_serialize_get_size()

size_t GNUNET_RECLAIM_presentation_serialize_get_size ( const struct GNUNET_RECLAIM_Presentation presentation)

Get required size for serialization buffer.

Parameters
presentationthe presentation to serialize
Returns
the required buffer size
Parameters
attrthe presentation to serialize
Returns
the required buffer size

Definition at line 866 of file reclaim_credential.c.

Referenced by GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_list_serialize_get_size(), and issue_ticket().

868 {
869  return sizeof(struct Presentation) + presentation->data_size;
870 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
Serialized presentation claim.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_presentation_serialize()

size_t GNUNET_RECLAIM_presentation_serialize ( const struct GNUNET_RECLAIM_Presentation presentation,
char *  result 
)

Serialize a presentation.

Parameters
presentationthe presentation to serialize
resultthe serialized presentation
Returns
length of serialized data

Serialize a presentation.

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

Definition at line 881 of file reclaim_credential.c.

References Presentation::credential_id, GNUNET_RECLAIM_Presentation::credential_id, GNUNET_RECLAIM_Presentation::data, Presentation::data_size, GNUNET_RECLAIM_Presentation::data_size, GNUNET_memcpy, Presentation::presentation_type, and GNUNET_RECLAIM_Presentation::type.

Referenced by GNUNET_RECLAIM_presentation_list_serialize(), and issue_ticket().

884 {
885  struct Presentation *atts;
886  char *write_ptr;
887 
888  atts = (struct Presentation *) result;
889  atts->presentation_type = htons (presentation->type);
890  atts->credential_id = presentation->credential_id;
891  write_ptr = (char *) &atts[1];
892  GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size);
893  atts->data_size = htons (presentation->data_size);
894 
895  return sizeof(struct Presentation) + presentation->data_size;
896 }
uint32_t type
Type/Format of Claim.
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 presentation claim.
struct GNUNET_RECLAIM_Identifier credential_id
Credential ID.
static int result
Global testing status.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
const void * data
Binary value stored as presentation value.
size_t data_size
Number of bytes in data.
uint32_t data_size
Data size.
uint32_t presentation_type
Presentation type.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_presentation_deserialize()

struct GNUNET_RECLAIM_Presentation* GNUNET_RECLAIM_presentation_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize a presentation.

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

Deserialize a presentation.

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

Definition at line 908 of file reclaim_credential.c.

References Presentation::credential_id, GNUNET_RECLAIM_Presentation::credential_id, GNUNET_RECLAIM_Presentation::data, Presentation::data_size, GNUNET_RECLAIM_Presentation::data_size, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, Presentation::presentation_type, and GNUNET_RECLAIM_Presentation::type.

Referenced by filter_tickets_cb(), GNUNET_RECLAIM_presentation_list_deserialize(), issue_ticket(), and lookup_authz_cb().

909 {
910  struct GNUNET_RECLAIM_Presentation *presentation;
911  struct Presentation *atts;
912  size_t data_len;
913  char *write_ptr;
914 
915  if (data_size < sizeof(struct Presentation))
916  return NULL;
917 
918  atts = (struct Presentation *) data;
919  data_len = ntohs (atts->data_size);
920  if (data_size < sizeof(struct Presentation) + data_len)
921  {
923  "Buffer too small to deserialize\n");
924  return NULL;
925  }
926  presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
927  + data_len);
928  presentation->type = ntohs (atts->presentation_type);
929  presentation->credential_id = atts->credential_id;
930  presentation->data_size = data_len;
931 
932  write_ptr = (char *) &presentation[1];
933  GNUNET_memcpy (write_ptr, &atts[1], data_len);
934  presentation->data = write_ptr;
935  return presentation;
936 }
uint32_t type
Type/Format of Claim.
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 presentation claim.
struct GNUNET_RECLAIM_Identifier credential_id
Credential ID.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
const void * data
Binary value stored as presentation value.
A credential presentation.
size_t data_size
Number of bytes in data.
uint32_t data_size
Data size.
uint32_t presentation_type
Presentation type.
#define GNUNET_log(kind,...)
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_presentation_value_to_string()

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

Convert the 'claim' of a presentation to a string.

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

Convert the 'claim' of a presentation to a string.

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

Definition at line 666 of file reclaim_credential.c.

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

Referenced by generate_userinfo_json().

669 {
670  unsigned int i;
671  struct Plugin *plugin;
672  char *ret;
673 
674  init ();
675  for (i = 0; i < num_plugins; i++)
676  {
677  plugin = credential_plugins[i];
678  if (NULL != (ret = plugin->api->value_to_string_p (plugin->api->cls,
679  type,
680  data,
681  data_size)))
682  return ret;
683  }
684  return NULL;
685 }
static struct Plugin ** credential_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
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_presentation_new()

struct GNUNET_RECLAIM_Presentation* GNUNET_RECLAIM_presentation_new ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Definition at line 689 of file reclaim_credential.c.

References GNUNET_RECLAIM_Presentation::data, data_size, GNUNET_RECLAIM_Presentation::data_size, GNUNET_malloc, GNUNET_memcpy, type, and GNUNET_RECLAIM_Presentation::type.

Referenced by consume_ticket(), GNUNET_RECLAIM_presentation_list_dup(), and jwt_create_presentation().

692 {
693  struct GNUNET_RECLAIM_Presentation *attr;
694  char *write_ptr;
695 
696  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
697  + data_size);
698  attr->type = type;
699  attr->data_size = data_size;
700  write_ptr = (char *) &attr[1];
701  GNUNET_memcpy (write_ptr, data, data_size);
702  attr->data = write_ptr;
703  return attr;
704 }
uint32_t type
Type/Format of Claim.
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.
const void * data
Binary value stored as presentation value.
A credential presentation.
size_t data_size
Number of bytes in data.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_presentation_string_to_value()

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

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

Parameters
typetype of the presentation
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

Convert human-readable version of a 'claim' of a presentation 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 634 of file reclaim_credential.c.

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

638 {
639  unsigned int i;
640  struct Plugin *plugin;
641 
642  init ();
643  for (i = 0; i < num_plugins; i++)
644  {
645  plugin = credential_plugins[i];
646  if (GNUNET_OK == plugin->api->string_to_value_p (plugin->api->cls,
647  type,
648  s,
649  data,
650  data_size))
651  return GNUNET_OK;
652  }
653  return GNUNET_SYSERR;
654 }
static struct Plugin ** credential_plugins
Plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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:

◆ GNUNET_RECLAIM_presentation_number_to_typename()

const char* GNUNET_RECLAIM_presentation_number_to_typename ( uint32_t  type)

Convert a presentation type number to the corresponding credential type string.

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

Convert a presentation type number to the corresponding credential type string.

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

Definition at line 605 of file reclaim_credential.c.

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

Referenced by generate_userinfo_json().

606 {
607  unsigned int i;
608  struct Plugin *plugin;
609  const char *ret;
610 
611  init ();
612  for (i = 0; i < num_plugins; i++)
613  {
614  plugin = credential_plugins[i];
615  if (NULL !=
616  (ret = plugin->api->number_to_typename_p (plugin->api->cls, type)))
617  return ret;
618  }
619  return NULL;
620 }
static struct Plugin ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_presentation_get_attributes()

struct GNUNET_RECLAIM_AttributeList* GNUNET_RECLAIM_presentation_get_attributes ( const struct GNUNET_RECLAIM_Presentation cred)

Definition at line 940 of file reclaim_credential.c.

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

Referenced by process_attrs().

943 {
944  unsigned int i;
945  struct Plugin *plugin;
947  init ();
948  for (i = 0; i < num_plugins; i++)
949  {
950  plugin = credential_plugins[i];
951  if (NULL !=
952  (ret = plugin->api->get_attributes_p (plugin->api->cls,
953  presentation)))
954  return ret;
955  }
956  return NULL;
957 }
static struct Plugin ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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_presentation_get_issuer()

char* GNUNET_RECLAIM_presentation_get_issuer ( const struct GNUNET_RECLAIM_Presentation cred)

Definition at line 961 of file reclaim_credential.c.

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

964 {
965  unsigned int i;
966  struct Plugin *plugin;
967  char *ret;
968  init ();
969  for (i = 0; i < num_plugins; i++)
970  {
971  plugin = credential_plugins[i];
972  if (NULL !=
973  (ret = plugin->api->get_issuer_p (plugin->api->cls,
974  presentation)))
975  return ret;
976  }
977  return NULL;
978 }
static struct Plugin ** credential_plugins
Plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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:

◆ GNUNET_RECLAIM_presentation_get_expiration()

int GNUNET_RECLAIM_presentation_get_expiration ( const struct GNUNET_RECLAIM_Presentation cred,
struct GNUNET_TIME_Absolute exp 
)

Definition at line 982 of file reclaim_credential.c.

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

986 {
987  unsigned int i;
988  struct Plugin *plugin;
989  init ();
990  for (i = 0; i < num_plugins; i++)
991  {
992  plugin = credential_plugins[i];
993  if (GNUNET_OK != plugin->api->get_expiration_p (plugin->api->cls,
994  presentation,
995  exp))
996  continue;
997  return GNUNET_OK;
998  }
999  return GNUNET_SYSERR;
1000 }
static struct Plugin ** credential_plugins
Plugins.
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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:

◆ GNUNET_RECLAIM_credential_get_presentation()

int GNUNET_RECLAIM_credential_get_presentation ( const struct GNUNET_RECLAIM_Credential cred,
const struct GNUNET_RECLAIM_AttributeList attrs,
struct GNUNET_RECLAIM_Presentation **  pres 
)

Create a presentation from a credential and a lift of (selected) attributes in the credential.

FIXME not yet implemented

Parameters
credthe credential to use
attrsthe attributes to present from the credential
presentationthe credential presentation presenting the attributes according to the presentation mechanism of the credential or NULL on error.
Returns
GNUNET_OK on success.

FIXME not yet implemented

Parameters
credthe credential to use
attrsthe attributes to present from the credential
Returns
the credential presentation presenting the attributes according to the presentation mechanism of the credential or NULL on error.

Definition at line 1014 of file reclaim_credential.c.

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

Referenced by filter_tickets_cb().

1018 {
1019  unsigned int i;
1020  struct Plugin *plugin;
1021  init ();
1022  for (i = 0; i < num_plugins; i++)
1023  {
1024  plugin = credential_plugins[i];
1025  if (GNUNET_OK != plugin->api->create_presentation (plugin->api->cls,
1026  cred,
1027  attrs,
1028  pres))
1029  continue;
1030  (*pres)->credential_id = cred->id;
1031  return GNUNET_OK;
1032  }
1033  return GNUNET_SYSERR;
1034 }
struct GNUNET_RECLAIM_Identifier id
ID.
static struct Plugin ** credential_plugins
Plugins.
static unsigned int num_plugins
Number of plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void init()
Load 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 88 of file gnunet_reclaim_lib.h.

Referenced by start_process().