GNUnet  0.11.x
reclaim_credential.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2010-2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_reclaim_plugin.h"
29 #include "reclaim_credential.h"
30 
31 
35 struct Plugin
36 {
40  char *library_name;
41 
46 };
47 
48 
52 static struct Plugin **credential_plugins;
53 
54 
58 static unsigned int num_plugins;
59 
60 
64 static int initialized;
65 
66 
74 static void
75 add_plugin (void *cls, const char *library_name, void *lib_ret)
76 {
78  struct Plugin *plugin;
79 
81  "Loading credential plugin `%s'\n",
82  library_name);
83  plugin = GNUNET_new (struct Plugin);
84  plugin->api = api;
85  plugin->library_name = GNUNET_strdup (library_name);
86  GNUNET_array_append (credential_plugins, num_plugins, plugin);
87 }
88 
89 
93 static void
94 init ()
95 {
96  if (GNUNET_YES == initialized)
97  return;
99  GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_credential_",
100  NULL,
101  &add_plugin,
102  NULL);
103 }
104 
105 
112 uint32_t
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 }
129 
130 
137 const char *
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 }
154 
155 
166 int
168  const char *s,
169  void **data,
170  size_t *data_size)
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 }
188 
189 
198 char *
200  const void *data,
201  size_t data_size)
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 }
219 
220 
232  uint32_t type,
233  const void *data,
234  size_t data_size)
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 }
256 
257 
264 size_t
266  const struct GNUNET_RECLAIM_CredentialList *credentials)
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 }
279 
280 
288 size_t
290  const struct GNUNET_RECLAIM_CredentialList *credentials,
291  char *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 }
308 
309 
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 }
352 
353 
361  const struct GNUNET_RECLAIM_CredentialList *al)
362 {
364  struct GNUNET_RECLAIM_CredentialListEntry *result_ale;
366 
367  result = GNUNET_new (struct GNUNET_RECLAIM_CredentialList);
368  for (ale = al->list_head; NULL != ale; ale = ale->next)
369  {
370  result_ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry);
371  GNUNET_assert (NULL != ale->credential);
372  result_ale->credential =
374  ale->credential->type,
375  ale->credential->data,
376  ale->credential->data_size);
377  result_ale->credential->id = ale->credential->id;
379  result->list_tail,
380  result_ale);
381  }
382  return result;
383 }
384 
385 
391 void
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 }
408 
409 
416 size_t
419 {
420  return sizeof(struct Credential) + strlen (credential->name)
421  + credential->data_size;
422 }
423 
424 
432 size_t
435  char *result)
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 }
461 
462 
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 }
510 
511 
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 }
530 
531 
532 char*
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 }
550 
551 
552 int
555  struct GNUNET_TIME_Absolute*exp)
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 }
571 
572 
579 uint32_t
581 {
582  unsigned int i;
583  struct Plugin *plugin;
584  uint32_t ret;
585  init ();
586  for (i = 0; i < num_plugins; i++)
587  {
588  plugin = credential_plugins[i];
589  if (UINT32_MAX !=
590  (ret = plugin->api->typename_to_number_p (plugin->api->cls,
591  typename)))
592  return ret;
593  }
594  return UINT32_MAX;
595 }
596 
597 
604 const char *
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 }
621 
622 
633 int
635  const char *s,
636  void **data,
637  size_t *data_size)
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 }
655 
656 
665 char *
667  const void *data,
668  size_t data_size)
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 }
686 
687 
690  const void *data,
691  size_t data_size)
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 }
705 
706 
713 size_t
715  const struct GNUNET_RECLAIM_PresentationList *presentations)
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 }
728 
729 
737 size_t
739  const struct GNUNET_RECLAIM_PresentationList *presentations,
740  char *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 }
757 
758 
768  data_size)
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 }
802 
803 
811  const struct GNUNET_RECLAIM_PresentationList *al)
812 {
814  struct GNUNET_RECLAIM_PresentationListEntry *result_ale;
816 
818  for (ale = al->list_head; NULL != ale; ale = ale->next)
819  {
820  result_ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
821  GNUNET_assert (NULL != ale->presentation);
822  result_ale->presentation =
824  ale->presentation->data,
825  ale->presentation->data_size);
828  result->list_tail,
829  result_ale);
830  }
831  return result;
832 }
833 
834 
840 void
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 }
857 
858 
865 size_t
868 {
869  return sizeof(struct Presentation) + presentation->data_size;
870 }
871 
872 
880 size_t
882  const struct GNUNET_RECLAIM_Presentation *presentation,
883  char *result)
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 }
897 
898 
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 }
937 
938 
942  presentation)
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 }
958 
959 
960 char*
963  presentation)
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 }
979 
980 
981 int
984  presentation,
985  struct GNUNET_TIME_Absolute*exp)
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 }
1001 
1013 int
1015  const struct GNUNET_RECLAIM_Credential *cred,
1016  const struct GNUNET_RECLAIM_AttributeList *attrs,
1017  struct GNUNET_RECLAIM_Presentation **pres)
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 }
1035 
1036 
1037 
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin.
Serialized credential claim.
uint32_t data_size
Data size.
int GNUNET_RECLAIM_presentation_get_expiration(const struct GNUNET_RECLAIM_Presentation *presentation, struct GNUNET_TIME_Absolute *exp)
uint32_t GNUNET_RECLAIM_credential_typename_to_number(const char *typename)
Convert an credential type name to the corresponding number.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize an presentation.
uint32_t type
Type/Format of Claim.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint32_t type
Type/Format of Claim.
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 &#39;claim&#39; of an credential to the binary representation.
static struct Plugin ** credential_plugins
Plugins.
uint32_t name_len
Name length.
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_RECLAIM_credential_get_expiration(const struct GNUNET_RECLAIM_Credential *credential, struct GNUNET_TIME_Absolute *exp)
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static unsigned int num_plugins
Number of plugins.
struct GNUNET_RECLAIM_CredentialPluginFunctions * api
Plugin API.
A list of GNUNET_RECLAIM_Attribute structures.
const void * data
Binary value stored as credential value.
size_t GNUNET_RECLAIM_credential_list_serialize(const struct GNUNET_RECLAIM_CredentialList *credentials, char *result)
Serialize an attribute list.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUnet reclaim identity attribute credentials.
char * library_name
Name of the shared library.
Definition: block.c:42
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
Serialized presentation claim.
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
size_t GNUNET_RECLAIM_credential_list_serialize_get_size(const struct GNUNET_RECLAIM_CredentialList *credentials)
Get required size for serialization buffer.
char * GNUNET_RECLAIM_credential_get_issuer(const struct GNUNET_RECLAIM_Credential *credential)
struct GNUNET_RECLAIM_Identifier credential_id
Credential ID.
struct GNUNET_RECLAIM_CredentialList * GNUNET_RECLAIM_credential_list_deserialize(const char *data, size_t data_size)
Deserialize an credential list.
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...
static char * attr_name
The attribute.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_presentation_get_attributes(const struct GNUNET_RECLAIM_Presentation *presentation)
uint32_t credential_type
Credential type.
const char * GNUNET_RECLAIM_presentation_number_to_typename(uint32_t type)
Convert an presentation type number to the corresponding presentation type string.
static int initialized
Init canary.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *al)
Destroy credential list.
static int result
Global testing status.
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size(const struct GNUNET_RECLAIM_PresentationList *presentations)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
const void * data
Binary value stored as presentation 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 &#39;claim&#39; of an presentation to the binary representation.
static void init()
Load plugins.
static char * plugin
Solver plugin name as string.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
A credential presentation.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *al)
Destroy presentation list.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
const char * name
The name of the credential.
void GNUNET_PLUGIN_load_all(const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name.
Definition: plugin.c:372
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize an presentation.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
uint32_t data_size
Data size.
struct GNUNET_RECLAIM_CredentialList * GNUNET_RECLAIM_credential_list_dup(const struct GNUNET_RECLAIM_CredentialList *al)
Make a (deep) copy of the credential list.
uint32_t presentation_type
Presentation type.
char * GNUNET_RECLAIM_presentation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an presentation to a string.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
A list of GNUNET_RECLAIM_Presentation structures.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_RECLAIM_Identifier credential_id
Credential ID.
uint32_t GNUNET_RECLAIM_presentation_typename_to_number(const char *typename)
Convert an presentation type name to the corresponding number.
A list of GNUNET_RECLAIM_Credential structures.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_new(uint32_t type, const void *data, size_t data_size)
#define GNUNET_log(kind,...)
char * GNUNET_RECLAIM_presentation_get_issuer(const struct GNUNET_RECLAIM_Presentation *presentation)
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_dup(const struct GNUNET_RECLAIM_PresentationList *al)
Make a (deep) copy of the presentation list.
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
Time for absolute times used by GNUnet, in microseconds.
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.
char * GNUNET_RECLAIM_credential_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an credential to a string.
void * cls
Closure for all of the callbacks.
size_t GNUNET_RECLAIM_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize an attribute list.
uint32_t data
The data value.
uint32_t credential_flag
Credential flag.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize an presentation list.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:568
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_credential_get_attributes(const struct GNUNET_RECLAIM_Credential *credential)
Convert an credential type name to the corresponding number.