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 
109 void __attribute__ ((destructor))
110 RECLAIM_CREDENTIAL_fini ()
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  {
121  plugin = credential_plugins[i];
122  GNUNET_break (NULL ==
124  plugin->api));
125  GNUNET_free (plugin->library_name);
126  GNUNET_free (plugin);
127  }
128  GNUNET_free (credential_plugins);
129 
130  if (pd != dpd)
131  GNUNET_OS_init (pd);
132 
133  credential_plugins = NULL;
134 }
135 
136 
137 
144 uint32_t
146 {
147  unsigned int i;
148  struct Plugin *plugin;
149  uint32_t ret;
150  init ();
151  for (i = 0; i < num_plugins; i++)
152  {
153  plugin = credential_plugins[i];
154  if (UINT32_MAX !=
155  (ret = plugin->api->typename_to_number (plugin->api->cls,
156  typename)))
157  return ret;
158  }
159  return UINT32_MAX;
160 }
161 
162 
169 const char *
171 {
172  unsigned int i;
173  struct Plugin *plugin;
174  const char *ret;
175 
176  init ();
177  for (i = 0; i < num_plugins; i++)
178  {
179  plugin = credential_plugins[i];
180  if (NULL !=
181  (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
182  return ret;
183  }
184  return NULL;
185 }
186 
187 
198 int
200  const char *s,
201  void **data,
202  size_t *data_size)
203 {
204  unsigned int i;
205  struct Plugin *plugin;
206 
207  init ();
208  for (i = 0; i < num_plugins; i++)
209  {
210  plugin = credential_plugins[i];
211  if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
212  type,
213  s,
214  data,
215  data_size))
216  return GNUNET_OK;
217  }
218  return GNUNET_SYSERR;
219 }
220 
221 
230 char *
232  const void *data,
233  size_t data_size)
234 {
235  unsigned int i;
236  struct Plugin *plugin;
237  char *ret;
238 
239  init ();
240  for (i = 0; i < num_plugins; i++)
241  {
242  plugin = credential_plugins[i];
243  if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
244  type,
245  data,
246  data_size)))
247  return ret;
248  }
249  return NULL;
250 }
251 
252 
264  uint32_t type,
265  const void *data,
266  size_t data_size)
267 {
268  struct GNUNET_RECLAIM_Credential *attr;
269  char *write_ptr;
270  char *attr_name_tmp = GNUNET_strdup (attr_name);
271 
272  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
273 
274  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential)
275  + strlen (attr_name_tmp) + 1 + data_size);
276  attr->type = type;
277  attr->data_size = data_size;
278  attr->flag = 0;
279  write_ptr = (char *) &attr[1];
280  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
281  attr->name = write_ptr;
282  write_ptr += strlen (attr->name) + 1;
283  GNUNET_memcpy (write_ptr, data, data_size);
284  attr->data = write_ptr;
285  GNUNET_free (attr_name_tmp);
286  return attr;
287 }
288 
289 
296 size_t
298  const struct GNUNET_RECLAIM_CredentialList *credentials)
299 {
301  size_t len = 0;
302 
303  for (le = credentials->list_head; NULL != le; le = le->next)
304  {
305  GNUNET_assert (NULL != le->credential);
307  len += sizeof(struct GNUNET_RECLAIM_CredentialListEntry);
308  }
309  return len;
310 }
311 
312 
320 size_t
322  const struct GNUNET_RECLAIM_CredentialList *credentials,
323  char *result)
324 {
326  size_t len;
327  size_t total_len;
328  char *write_ptr;
329  write_ptr = result;
330  total_len = 0;
331  for (le = credentials->list_head; NULL != le; le = le->next)
332  {
333  GNUNET_assert (NULL != le->credential);
334  len = GNUNET_RECLAIM_credential_serialize (le->credential, write_ptr);
335  total_len += len;
336  write_ptr += len;
337  }
338  return total_len;
339 }
340 
341 
351 {
354  size_t att_len;
355  const char *read_ptr;
356 
358 
359  if ((data_size < sizeof(struct
360  Credential)
361  + sizeof(struct GNUNET_RECLAIM_CredentialListEntry)))
362  return al;
363 
364  read_ptr = data;
365  while (((data + data_size) - read_ptr) >= sizeof(struct Credential))
366  {
368  ale->credential =
370  data_size - (read_ptr - data));
371  if (NULL == ale->credential)
372  {
374  "Failed to deserialize malformed credential.\n");
375  GNUNET_free (ale);
376  return al;
377  }
380  read_ptr += att_len;
381  }
382  return al;
383 }
384 
385 
393  const struct GNUNET_RECLAIM_CredentialList *al)
394 {
396  struct GNUNET_RECLAIM_CredentialListEntry *result_ale;
398 
399  result = GNUNET_new (struct GNUNET_RECLAIM_CredentialList);
400  for (ale = al->list_head; NULL != ale; ale = ale->next)
401  {
402  result_ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry);
403  GNUNET_assert (NULL != ale->credential);
404  result_ale->credential =
406  ale->credential->type,
407  ale->credential->data,
408  ale->credential->data_size);
409  result_ale->credential->id = ale->credential->id;
411  result->list_tail,
412  result_ale);
413  }
414  return result;
415 }
416 
417 
423 void
426 {
428  struct GNUNET_RECLAIM_CredentialListEntry *tmp_ale;
429 
430  for (ale = al->list_head; NULL != ale;)
431  {
432  if (NULL != ale->credential)
433  GNUNET_free (ale->credential);
434  tmp_ale = ale;
435  ale = ale->next;
436  GNUNET_free (tmp_ale);
437  }
438  GNUNET_free (al);
439 }
440 
441 
448 size_t
451 {
452  return sizeof(struct Credential) + strlen (credential->name)
453  + credential->data_size;
454 }
455 
456 
464 size_t
467  char *result)
468 {
469  size_t data_len_ser;
470  size_t name_len;
471  struct Credential *atts;
472  char *write_ptr;
473 
474  atts = (struct Credential *) result;
475  atts->credential_type = htons (credential->type);
476  atts->credential_flag = htonl (credential->flag);
477  atts->credential_id = credential->id;
478  name_len = strlen (credential->name);
479  atts->name_len = htons (name_len);
480  write_ptr = (char *) &atts[1];
481  GNUNET_memcpy (write_ptr, credential->name, name_len);
482  write_ptr += name_len;
483  // TODO plugin-ize
484  // data_len_ser = plugin->serialize_attribute_value (attr,
485  // &attr_ser[1]);
486  data_len_ser = credential->data_size;
487  GNUNET_memcpy (write_ptr, credential->data, credential->data_size);
488  atts->data_size = htons (data_len_ser);
489 
490  return sizeof(struct Credential) + strlen (credential->name)
491  + credential->data_size;
492 }
493 
494 
505 {
507  struct Credential *atts;
508  size_t data_len;
509  size_t name_len;
510  char *write_ptr;
511 
512  if (data_size < sizeof(struct Credential))
513  return NULL;
514 
515  atts = (struct Credential *) data;
516  data_len = ntohs (atts->data_size);
517  name_len = ntohs (atts->name_len);
518  if (data_size < sizeof(struct Credential) + data_len + name_len)
519  {
521  "Buffer too small to deserialize\n");
522  return NULL;
523  }
524  credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential)
525  + data_len + name_len + 1);
526  credential->type = ntohs (atts->credential_type);
527  credential->flag = ntohl (atts->credential_flag);
528  credential->id = atts->credential_id;
529  credential->data_size = data_len;
530 
531  write_ptr = (char *) &credential[1];
532  GNUNET_memcpy (write_ptr, &atts[1], name_len);
533  write_ptr[name_len] = '\0';
534  credential->name = write_ptr;
535 
536  write_ptr += name_len + 1;
537  GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
538  credential->data_size);
539  credential->data = write_ptr;
540  return credential;
541 }
542 
543 
547 {
548  unsigned int i;
549  struct Plugin *plugin;
551  init ();
552  for (i = 0; i < num_plugins; i++)
553  {
554  plugin = credential_plugins[i];
555  if (NULL !=
556  (ret = plugin->api->get_attributes (plugin->api->cls,
557  credential)))
558  return ret;
559  }
560  return NULL;
561 }
562 
563 
564 char*
567 {
568  unsigned int i;
569  struct Plugin *plugin;
570  char *ret;
571  init ();
572  for (i = 0; i < num_plugins; i++)
573  {
574  plugin = credential_plugins[i];
575  if (NULL !=
576  (ret = plugin->api->get_issuer (plugin->api->cls,
577  credential)))
578  return ret;
579  }
580  return NULL;
581 }
582 
583 
584 int
587  struct GNUNET_TIME_Absolute*exp)
588 {
589  unsigned int i;
590  struct Plugin *plugin;
591  init ();
592  for (i = 0; i < num_plugins; i++)
593  {
594  plugin = credential_plugins[i];
595  if (GNUNET_OK != plugin->api->get_expiration (plugin->api->cls,
596  credential,
597  exp))
598  continue;
599  return GNUNET_OK;
600  }
601  return GNUNET_SYSERR;
602 }
603 
604 
611 uint32_t
613 {
614  unsigned int i;
615  struct Plugin *plugin;
616  uint32_t ret;
617  init ();
618  for (i = 0; i < num_plugins; i++)
619  {
620  plugin = credential_plugins[i];
621  if (UINT32_MAX !=
622  (ret = plugin->api->typename_to_number_p (plugin->api->cls,
623  typename)))
624  return ret;
625  }
626  return UINT32_MAX;
627 }
628 
629 
636 const char *
638 {
639  unsigned int i;
640  struct Plugin *plugin;
641  const char *ret;
642 
643  init ();
644  for (i = 0; i < num_plugins; i++)
645  {
646  plugin = credential_plugins[i];
647  if (NULL !=
648  (ret = plugin->api->number_to_typename_p (plugin->api->cls, type)))
649  return ret;
650  }
651  return NULL;
652 }
653 
654 
665 int
667  const char *s,
668  void **data,
669  size_t *data_size)
670 {
671  unsigned int i;
672  struct Plugin *plugin;
673 
674  init ();
675  for (i = 0; i < num_plugins; i++)
676  {
677  plugin = credential_plugins[i];
678  if (GNUNET_OK == plugin->api->string_to_value_p (plugin->api->cls,
679  type,
680  s,
681  data,
682  data_size))
683  return GNUNET_OK;
684  }
685  return GNUNET_SYSERR;
686 }
687 
688 
697 char *
699  const void *data,
700  size_t data_size)
701 {
702  unsigned int i;
703  struct Plugin *plugin;
704  char *ret;
705 
706  init ();
707  for (i = 0; i < num_plugins; i++)
708  {
709  plugin = credential_plugins[i];
710  if (NULL != (ret = plugin->api->value_to_string_p (plugin->api->cls,
711  type,
712  data,
713  data_size)))
714  return ret;
715  }
716  return NULL;
717 }
718 
719 
722  const void *data,
723  size_t data_size)
724 {
725  struct GNUNET_RECLAIM_Presentation *attr;
726  char *write_ptr;
727 
728  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
729  + data_size);
730  attr->type = type;
731  attr->data_size = data_size;
732  write_ptr = (char *) &attr[1];
733  GNUNET_memcpy (write_ptr, data, data_size);
734  attr->data = write_ptr;
735  return attr;
736 }
737 
738 
745 size_t
747  const struct GNUNET_RECLAIM_PresentationList *presentations)
748 {
750  size_t len = 0;
751 
752  for (le = presentations->list_head; NULL != le; le = le->next)
753  {
754  GNUNET_assert (NULL != le->presentation);
756  }
757  return len;
758 }
759 
760 
768 size_t
770  const struct GNUNET_RECLAIM_PresentationList *presentations,
771  char *result)
772 {
774  size_t len;
775  size_t total_len;
776  char *write_ptr;
777  write_ptr = result;
778  total_len = 0;
779  for (le = presentations->list_head; NULL != le; le = le->next)
780  {
781  GNUNET_assert (NULL != le->presentation);
783  total_len += len;
784  write_ptr += len;
785  }
786  return total_len;
787 }
788 
789 
799  data_size)
800 {
803  size_t att_len;
804  const char *read_ptr;
805 
807 
808  if (data_size < sizeof(struct Presentation))
809  return al;
810 
811  read_ptr = data;
812  while (((data + data_size) - read_ptr) >= sizeof(struct Presentation))
813  {
815  ale->presentation =
817  data_size - (read_ptr - data));
818  if (NULL == ale->presentation)
819  {
821  "Failed to deserialize malformed presentation.\n");
822  GNUNET_free (ale);
823  return al;
824  }
827  ale->presentation);
828  read_ptr += att_len;
829  }
830  return al;
831 }
832 
833 
841  const struct GNUNET_RECLAIM_PresentationList *al)
842 {
844  struct GNUNET_RECLAIM_PresentationListEntry *result_ale;
846 
848  for (ale = al->list_head; NULL != ale; ale = ale->next)
849  {
850  result_ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
851  GNUNET_assert (NULL != ale->presentation);
852  result_ale->presentation =
854  ale->presentation->data,
855  ale->presentation->data_size);
858  result->list_tail,
859  result_ale);
860  }
861  return result;
862 }
863 
864 
870 void
873 {
875  struct GNUNET_RECLAIM_PresentationListEntry *tmp_ale;
876 
877  for (ale = al->list_head; NULL != ale;)
878  {
879  if (NULL != ale->presentation)
880  GNUNET_free (ale->presentation);
881  tmp_ale = ale;
882  ale = ale->next;
883  GNUNET_free (tmp_ale);
884  }
885  GNUNET_free (al);
886 }
887 
888 
895 size_t
898 {
899  return sizeof(struct Presentation) + presentation->data_size;
900 }
901 
902 
910 size_t
912  const struct GNUNET_RECLAIM_Presentation *presentation,
913  char *result)
914 {
915  struct Presentation *atts;
916  char *write_ptr;
917 
918  atts = (struct Presentation *) result;
919  atts->presentation_type = htons (presentation->type);
920  atts->credential_id = presentation->credential_id;
921  write_ptr = (char *) &atts[1];
922  GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size);
923  atts->data_size = htons (presentation->data_size);
924 
925  return sizeof(struct Presentation) + presentation->data_size;
926 }
927 
928 
939 {
940  struct GNUNET_RECLAIM_Presentation *presentation;
941  struct Presentation *atts;
942  size_t data_len;
943  char *write_ptr;
944 
945  if (data_size < sizeof(struct Presentation))
946  return NULL;
947 
948  atts = (struct Presentation *) data;
949  data_len = ntohs (atts->data_size);
950  if (data_size < sizeof(struct Presentation) + data_len)
951  {
953  "Buffer too small to deserialize\n");
954  return NULL;
955  }
956  presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
957  + data_len);
958  presentation->type = ntohs (atts->presentation_type);
959  presentation->credential_id = atts->credential_id;
960  presentation->data_size = data_len;
961 
962  write_ptr = (char *) &presentation[1];
963  GNUNET_memcpy (write_ptr, &atts[1], data_len);
964  presentation->data = write_ptr;
965  return presentation;
966 }
967 
968 
972  presentation)
973 {
974  unsigned int i;
975  struct Plugin *plugin;
977  init ();
978  for (i = 0; i < num_plugins; i++)
979  {
980  plugin = credential_plugins[i];
981  if (NULL !=
982  (ret = plugin->api->get_attributes_p (plugin->api->cls,
983  presentation)))
984  return ret;
985  }
986  return NULL;
987 }
988 
989 
990 char*
993  presentation)
994 {
995  unsigned int i;
996  struct Plugin *plugin;
997  char *ret;
998  init ();
999  for (i = 0; i < num_plugins; i++)
1000  {
1001  plugin = credential_plugins[i];
1002  if (NULL !=
1003  (ret = plugin->api->get_issuer_p (plugin->api->cls,
1004  presentation)))
1005  return ret;
1006  }
1007  return NULL;
1008 }
1009 
1010 
1011 int
1014  presentation,
1015  struct GNUNET_TIME_Absolute*exp)
1016 {
1017  unsigned int i;
1018  struct Plugin *plugin;
1019  init ();
1020  for (i = 0; i < num_plugins; i++)
1021  {
1022  plugin = credential_plugins[i];
1023  if (GNUNET_OK != plugin->api->get_expiration_p (plugin->api->cls,
1024  presentation,
1025  exp))
1026  continue;
1027  return GNUNET_OK;
1028  }
1029  return GNUNET_SYSERR;
1030 }
1031 
1043 int
1045  const struct GNUNET_RECLAIM_Credential *cred,
1046  const struct GNUNET_RECLAIM_AttributeList *attrs,
1047  struct GNUNET_RECLAIM_Presentation **pres)
1048 {
1049  unsigned int i;
1050  struct Plugin *plugin;
1051  init ();
1052  for (i = 0; i < num_plugins; i++)
1053  {
1054  plugin = credential_plugins[i];
1055  if (GNUNET_OK != plugin->api->create_presentation (plugin->api->cls,
1056  cred,
1057  attrs,
1058  pres))
1059  continue;
1060  (*pres)->credential_id = cred->id;
1061  return GNUNET_OK;
1062  }
1063  return GNUNET_SYSERR;
1064 }
1065 
1066 
1067 
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.
Project-specific data used to help the OS subsystem find installation paths.
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 struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by &#39;libgnunetutil&#39; for GNUnet.
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_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
Serialized presentation claim.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:269
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.
void __attribute__((destructor))
Dual function to init().
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:397
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,...)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
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.
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
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.