GNUnet  0.11.x
gnunet_reclaim_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2017 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 
30 #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H
31 #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #if 0 /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39 
40 #include "gnunet_util_lib.h"
41 
47 
52 };
53 
59 
64 
69 };
70 
74 #define GNUNET_RECLAIM_ID_LENGTH (256 / 8)
75 
82 {
84 };
85 
87 
89 
90 #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \
91  memcmp (a, \
92  b, \
93  sizeof (GNUNET_RECLAIM_ID_ZERO))) \
94  ? \
95  GNUNET_YES : GNUNET_NO)
96 
97 
98 #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \
99  & \
100  GNUNET_RECLAIM_ID_ZERO)
101 
102 #define GNUNET_RECLAIM_id_generate(id) \
103  (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \
104  id, \
105  sizeof (GNUNET_RECLAIM_ID_ZERO)))
106 
111 {
116 
122 
126  uint32_t type;
127 
131  uint32_t flag;
132 
137  const char *name;
138 
142  size_t data_size;
143 
149  const void *data;
150 };
151 
156 {
161 
165  uint32_t type;
166 
170  uint32_t flag;
171 
176  const char *name;
177 
181  size_t data_size;
182 
188  const void *data;
189 };
190 
191 
196 {
201 
205  uint32_t type;
206 
210  size_t data_size;
211 
217  const void *data;
218 };
219 
220 
221 
226 {
231 
236 };
237 
238 
240 {
245 
250 
255 
256 };
257 
262 {
267 
272 };
273 
274 
276 {
281 
286 
291 
292 };
293 
294 
299 {
304 
309 };
310 
311 
313 {
318 
323 
328 
329 };
330 
331 
332 
345  const struct
347  uint32_t type,
348  const void *data,
349  size_t data_size);
350 
351 
358 size_t
360  const struct GNUNET_RECLAIM_AttributeList *attrs);
361 
362 
368 void
370  struct GNUNET_RECLAIM_AttributeList *attrs);
371 
372 
383 void
385  struct GNUNET_RECLAIM_AttributeList *attrs,
386  const char *attr_name,
388  uint32_t type,
389  const void *data,
390  size_t data_size);
391 
392 
400 size_t
402  const struct GNUNET_RECLAIM_AttributeList *attrs,
403  char *result);
404 
405 
415 
422 size_t
424  const struct GNUNET_RECLAIM_Attribute *attr);
425 
426 
434 size_t
436  char *result);
437 
438 
448 ssize_t
450  struct GNUNET_RECLAIM_Attribute **attr);
451 
452 
460  const struct GNUNET_RECLAIM_AttributeList *attrs);
461 
462 
469 uint32_t
470 GNUNET_RECLAIM_attribute_typename_to_number (const char *typename);
471 
482 int
484  const char *s,
485  void **data,
486  size_t *data_size);
487 
488 
497 char *
499  const void *data,
500  size_t data_size);
501 
508 const char *
510 
511 
518 size_t
520  const struct GNUNET_RECLAIM_CredentialList *credentials);
521 
522 
528 void
530  struct GNUNET_RECLAIM_CredentialList *credentials);
531 
532 
541 void
543  struct GNUNET_RECLAIM_CredentialList *attrs,
544  const char *att_name,
545  uint32_t type,
546  const void *data,
547  size_t data_size);
548 
549 
557 size_t
559  const struct GNUNET_RECLAIM_CredentialList *attrs,
560  char *result);
561 
562 
572  size_t data_size);
573 
574 
579 size_t
581  const struct GNUNET_RECLAIM_Credential *credential);
582 
583 
591 size_t
594  char *result);
595 
596 
607 
608 
620  uint32_t type,
621  const void *data,
622  size_t data_size);
623 
632 char *
634  const void *data,
635  size_t data_size);
636 
647 int
649  const char *s,
650  void **data,
651  size_t *data_size);
652 
659 const char *
661 
668 uint32_t
669 GNUNET_RECLAIM_credential_typename_to_number (const char *typename);
670 
680 
681 char*
684 
685 int
688  struct GNUNET_TIME_Absolute *exp);
689 
696 size_t
698  const struct GNUNET_RECLAIM_PresentationList *presentations);
699 
700 
706 void
708  struct GNUNET_RECLAIM_PresentationList *presentations);
709 
710 
718 size_t
720  const struct GNUNET_RECLAIM_PresentationList *presentations,
721  char *result);
722 
723 
733  size_t data_size);
734 
735 
740 size_t
742  const struct GNUNET_RECLAIM_Presentation *presentation);
743 
744 
752 size_t
754  const struct GNUNET_RECLAIM_Presentation *presentation,
755  char *result);
756 
757 
768 
769 
778 char *
780  const void *data,
781  size_t data_size);
782 
785  const void *data,
786  size_t data_size);
787 
798 int
800  const char *s,
801  void **data,
802  size_t *data_size);
803 
811 const char *
813 
817 
818 char*
821 
822 int
825  struct GNUNET_TIME_Absolute *exp);
826 
827 
828 
841 int
843  const struct GNUNET_RECLAIM_Credential *cred,
844  const struct GNUNET_RECLAIM_AttributeList *attrs,
845  struct GNUNET_RECLAIM_Presentation **presentation);
846 
847 
848 #if 0 /* keep Emacsens' auto-indent happy */
849 {
850 #endif
851 #ifdef __cplusplus
852 }
853 #endif
854 
855 
856 /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
857 #endif
858  /* end of group reclaim-attribute */
860 
861 /* end of gnunet_reclaim_attribute_lib.h */
struct GNUNET_RECLAIM_PresentationListEntry * prev
DLL.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
int GNUNET_RECLAIM_presentation_get_expiration(const struct GNUNET_RECLAIM_Presentation *cred, 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_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.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
struct GNUNET_RECLAIM_CredentialListEntry * prev
DLL.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize a presentation.
uint32_t type
Type/Format of Claim.
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.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_dup(const struct GNUNET_RECLAIM_AttributeList *attrs)
Make a (deep) copy of a claim list.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Credential * credential
The credential.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
int GNUNET_RECLAIM_credential_get_expiration(const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
struct GNUNET_RECLAIM_AttributeListEntry * prev
DLL.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
static char * credential_id
Credential ID string.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
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 *attrs, char *result)
Serialize an attribute list.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
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.
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 *cred)
struct GNUNET_RECLAIM_CredentialList * GNUNET_RECLAIM_credential_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
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...
static char * attr_name
The attribute.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_presentation_get_attributes(const struct GNUNET_RECLAIM_Presentation *cred)
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
#define GNUNET_RECLAIM_ID_LENGTH
We want an ID to be a 256-bit symmetric key.
const char * GNUNET_RECLAIM_presentation_number_to_typename(uint32_t type)
Convert a presentation type number to the corresponding credential type string.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy claim list.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
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.
const void * data
Binary value stored as presentation value.
size_t data_size
Number of bytes in data.
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 a presentation to the binary representation.
GNUNET_RECLAIM_AttributeType
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 &#39;claim&#39; of an attribute to the binary representation.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
A reclaim identifier FIXME maybe put this in a different namespace.
A credential presentation.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
size_t data_size
Number of bytes in data.
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
const char * name
The name of the credential.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
char * GNUNET_RECLAIM_presentation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of a presentation to a string.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
A list of GNUNET_RECLAIM_Presentation structures.
const char * name
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)
GNUNET_RECLAIM_CredentialType
const void * data
Binary value stored as attribute value.
char * GNUNET_RECLAIM_presentation_get_issuer(const struct GNUNET_RECLAIM_Presentation *cred)
char * GNUNET_RECLAIM_attribute_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
uint32_t type
Type of Claim.
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.
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 *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.
size_t GNUNET_RECLAIM_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize a presentation list.
uint32_t data
The data value.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
A JSON Web Token credential.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_credential_get_attributes(const struct GNUNET_RECLAIM_Credential *cred)
Convert an credential type name to the corresponding number.