GNUnet 0.21.1
reclaim_credential.c File Reference

helper library to manage identity attribute credentials More...

Include dependency graph for reclaim_credential.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 

Functions

static void add_plugin (void *cls, const char *library_name, void *lib_ret)
 Add a plugin. More...
 
static void init ()
 Load plugins. More...
 
void __attribute__ ((destructor))
 Dual function to init(). More...
 
uint32_t GNUNET_RECLAIM_credential_typename_to_number (const char *typename)
 Convert an credential type name to the corresponding number. More...
 
const char * GNUNET_RECLAIM_credential_number_to_typename (uint32_t type)
 Convert an credential type number to the corresponding credential type 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...
 
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...
 
struct GNUNET_RECLAIM_CredentialGNUNET_RECLAIM_credential_new (const char *attr_name, uint32_t type, const void *data, size_t data_size)
 Create a new credential. More...
 
size_t GNUNET_RECLAIM_credential_list_serialize_get_size (const struct GNUNET_RECLAIM_CredentialList *credentials)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_credential_list_serialize (const struct GNUNET_RECLAIM_CredentialList *credentials, char *result)
 Serialize a credential list. More...
 
struct GNUNET_RECLAIM_CredentialListGNUNET_RECLAIM_credential_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
 
struct GNUNET_RECLAIM_CredentialListGNUNET_RECLAIM_credential_list_dup (const struct GNUNET_RECLAIM_CredentialList *al)
 Make a (deep) copy of the credential list. More...
 
void GNUNET_RECLAIM_credential_list_destroy (struct GNUNET_RECLAIM_CredentialList *credentials)
 Destroy credential 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_AttributeListGNUNET_RECLAIM_credential_get_attributes (const struct GNUNET_RECLAIM_Credential *credential)
 Convert an credential type name to the corresponding number. More...
 
char * GNUNET_RECLAIM_credential_get_issuer (const struct GNUNET_RECLAIM_Credential *credential)
 
int GNUNET_RECLAIM_credential_get_expiration (const struct GNUNET_RECLAIM_Credential *credential, struct GNUNET_TIME_Absolute *exp)
 
uint32_t GNUNET_RECLAIM_presentation_typename_to_number (const char *typename)
 Convert an presentation type name to the corresponding number. More...
 
const char * GNUNET_RECLAIM_presentation_number_to_typename (uint32_t type)
 Convert a presentation type number to the corresponding credential type string. More...
 
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 an presentation to the binary representation. More...
 
char * GNUNET_RECLAIM_presentation_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an presentation to a string. More...
 
struct GNUNET_RECLAIM_PresentationGNUNET_RECLAIM_presentation_new (uint32_t type, const void *data, size_t data_size)
 
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size (const struct GNUNET_RECLAIM_PresentationList *presentations)
 Get required size for serialization buffer. 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 an presentation list. More...
 
struct GNUNET_RECLAIM_PresentationListGNUNET_RECLAIM_presentation_list_dup (const struct GNUNET_RECLAIM_PresentationList *al)
 Make a (deep) copy of the presentation list. More...
 
void GNUNET_RECLAIM_presentation_list_destroy (struct GNUNET_RECLAIM_PresentationList *presentations)
 Destroy presentations 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 an presentation. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_presentation_get_attributes (const struct GNUNET_RECLAIM_Presentation *presentation)
 
char * GNUNET_RECLAIM_presentation_get_issuer (const struct GNUNET_RECLAIM_Presentation *presentation)
 
int GNUNET_RECLAIM_presentation_get_expiration (const struct GNUNET_RECLAIM_Presentation *presentation, 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 struct Plugin ** credential_plugins
 Plugins. More...
 
static unsigned int num_plugins
 Number of plugins. More...
 
static int initialized
 Init canary. More...
 

Detailed Description

helper library to manage identity attribute credentials

Author
Martin Schanzenbach

Definition in file reclaim_credential.c.

Function Documentation

◆ add_plugin()

static void add_plugin ( void *  cls,
const char *  library_name,
void *  lib_ret 
)
static

Add a plugin.

Parameters
clsclosure
library_namename of the API library
lib_retthe plugin API pointer

Definition at line 74 of file reclaim_credential.c.

75{
76 struct GNUNET_RECLAIM_CredentialPluginFunctions *api = lib_ret;
77 struct Plugin *plugin;
78
80 "Loading credential plugin `%s'\n",
82 plugin = GNUNET_new (struct Plugin);
83 plugin->api = api;
86}
struct TestcasePlugin * plugin
The process handle to the testbed service.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
static unsigned int num_plugins
Number of plugins.
static struct Plugin ** credential_plugins
Plugins.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
Handle for a plugin.
Definition: block.c:38
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
char * library_name
Name of the shared library.
Definition: block.c:42
char * library_name
Name of the shared library.
Definition: testing.h:98
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: testing.h:103

References Plugin::api, TestcasePlugin::api, credential_plugins, GNUNET_array_append, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_strdup, Plugin::library_name, TestcasePlugin::library_name, num_plugins, and plugin.

Referenced by init().

Here is the caller graph for this function:

◆ init()

static void init ( )
static

Load plugins.

Definition at line 93 of file reclaim_credential.c.

94{
96 return;
99 "libgnunet_plugin_reclaim_credential_",
100 NULL,
101 &add_plugin,
102 NULL);
103}
@ GNUNET_YES
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_PLUGIN_load_all_in_context(const struct GNUNET_OS_ProjectData *ctx, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name while inside the given context (i....
Definition: plugin.c:386
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin.
static int initialized
Init canary.

References add_plugin(), GNUNET_OS_project_data_default(), GNUNET_PLUGIN_load_all_in_context(), GNUNET_YES, and initialized.

Referenced by GNUNET_RECLAIM_credential_get_attributes(), GNUNET_RECLAIM_credential_get_expiration(), GNUNET_RECLAIM_credential_get_issuer(), GNUNET_RECLAIM_credential_get_presentation(), GNUNET_RECLAIM_credential_number_to_typename(), GNUNET_RECLAIM_credential_string_to_value(), GNUNET_RECLAIM_credential_typename_to_number(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_RECLAIM_presentation_get_attributes(), GNUNET_RECLAIM_presentation_get_expiration(), GNUNET_RECLAIM_presentation_get_issuer(), GNUNET_RECLAIM_presentation_number_to_typename(), GNUNET_RECLAIM_presentation_string_to_value(), GNUNET_RECLAIM_presentation_typename_to_number(), and GNUNET_RECLAIM_presentation_value_to_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ __attribute__()

void __attribute__ ( (destructor)  )

Dual function to init().

Definition at line 109 of file reclaim_credential.c.

111{
112 struct Plugin *plugin;
115
116 if (pd != dpd)
117 GNUNET_OS_init (dpd);
118
119 for (unsigned int i = 0; i < num_plugins; i++)
120 {
122 GNUNET_break (NULL ==
124 plugin->api));
127 }
129
130 if (pd != dpd)
131 GNUNET_OS_init (pd);
132
133 credential_plugins = NULL;
134}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:242
Project-specific data used to help the OS subsystem find installation paths.

References TestcasePlugin::api, credential_plugins, GNUNET_break, GNUNET_free, GNUNET_OS_init(), GNUNET_OS_project_data_default(), GNUNET_OS_project_data_get(), GNUNET_PLUGIN_unload(), TestcasePlugin::library_name, num_plugins, and plugin.

Here is the call graph for this function:

◆ GNUNET_RECLAIM_credential_list_dup()

struct GNUNET_RECLAIM_CredentialList * GNUNET_RECLAIM_credential_list_dup ( const struct GNUNET_RECLAIM_CredentialList al)

Make a (deep) copy of the credential list.

Parameters
attrsclaim list to copy
Returns
copied claim list

Definition at line 368 of file reclaim_credential.c.

370{
372 struct GNUNET_RECLAIM_CredentialListEntry *result_ale;
374
376 for (ale = al->list_head; NULL != ale; ale = ale->next)
377 {
379 GNUNET_assert (NULL != ale->credential);
380 result_ale->credential =
382 ale->credential->type,
383 ale->credential->data,
384 ale->credential->data_size);
385 result_ale->credential->id = ale->credential->id;
387 result->list_tail,
388 result_ale);
389 }
390 return result;
391}
static int result
Global testing status.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
struct GNUNET_RECLAIM_Credential * credential
The credential.
A list of GNUNET_RECLAIM_Credential structures.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
uint32_t type
Type/Format of Claim.
const char * name
The name of the credential.
const void * data
Binary value stored as credential value.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier id
ID.

References GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_RECLAIM_Credential::data, GNUNET_RECLAIM_Credential::data_size, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_credential_new(), GNUNET_RECLAIM_Credential::id, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_Credential::name, GNUNET_RECLAIM_CredentialListEntry::next, result, and GNUNET_RECLAIM_Credential::type.

Here is the call graph for this function:

◆ GNUNET_RECLAIM_presentation_typename_to_number()

uint32_t GNUNET_RECLAIM_presentation_typename_to_number ( const char *  typename)

Convert an presentation type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 576 of file reclaim_credential.c.

577{
578 unsigned int i;
579 struct Plugin *plugin;
580 uint32_t ret;
581 init ();
582 for (i = 0; i < num_plugins; i++)
583 {
585 if (UINT32_MAX !=
586 (ret = plugin->api->typename_to_number_p (plugin->api->cls,
587 typename)))
588 return ret;
589 }
590 return UINT32_MAX;
591}
static int ret
Final status code.
Definition: gnunet-arm.c:94
static void init()
Load plugins.

References TestcasePlugin::api, credential_plugins, init(), num_plugins, plugin, and ret.

Here is the call graph for this function:

◆ GNUNET_RECLAIM_presentation_list_dup()

struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_dup ( const struct GNUNET_RECLAIM_PresentationList al)

Make a (deep) copy of the presentation list.

Parameters
attrsclaim list to copy
Returns
copied claim list

Definition at line 791 of file reclaim_credential.c.

793{
795 struct GNUNET_RECLAIM_PresentationListEntry *result_ale;
797
799 for (ale = al->list_head; NULL != ale; ale = ale->next)
800 {
802 GNUNET_assert (NULL != ale->presentation);
803 result_ale->presentation =
805 ale->presentation->data,
806 ale->presentation->data_size);
809 result->list_tail,
810 result_ale);
811 }
812 return result;
813}
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_new(uint32_t type, const void *data, size_t data_size)
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
A list of GNUNET_RECLAIM_Presentation structures.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
const void * data
Binary value stored as presentation value.
uint32_t type
Type/Format of Claim.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.

References GNUNET_RECLAIM_Presentation::credential_id, GNUNET_RECLAIM_Presentation::data, GNUNET_RECLAIM_Presentation::data_size, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_presentation_new(), GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationListEntry::next, GNUNET_RECLAIM_PresentationListEntry::presentation, result, and GNUNET_RECLAIM_Presentation::type.

Here is the call graph for this function:

Variable Documentation

◆ credential_plugins

◆ num_plugins

◆ initialized

int initialized
static

Init canary.

Definition at line 63 of file reclaim_credential.c.

Referenced by init().