GNUnet  0.17.6
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 
33 #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H
34 #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #if 0 /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42 
43 #include "gnunet_util_lib.h"
44 
50 
55 };
56 
62 
67 
72 };
73 
77 #define GNUNET_RECLAIM_ID_LENGTH (256 / 8)
78 
85 {
87 };
88 
90 
92 
93 #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \
94  memcmp (a, \
95  b, \
96  sizeof (GNUNET_RECLAIM_ID_ZERO))) \
97  ? \
98  GNUNET_YES : GNUNET_NO)
99 
100 
101 #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \
102  & \
103  GNUNET_RECLAIM_ID_ZERO)
104 
105 #define GNUNET_RECLAIM_id_generate(id) \
106  (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \
107  id, \
108  sizeof (GNUNET_RECLAIM_ID_ZERO)))
109 
114 {
119 
125 
129  uint32_t type;
130 
134  uint32_t flag;
135 
140  const char *name;
141 
145  size_t data_size;
146 
152  const void *data;
153 };
154 
159 {
164 
168  uint32_t type;
169 
173  uint32_t flag;
174 
179  const char *name;
180 
184  size_t data_size;
185 
191  const void *data;
192 };
193 
194 
199 {
204 
208  uint32_t type;
209 
213  size_t data_size;
214 
220  const void *data;
221 };
222 
223 
224 
229 {
234 
239 };
240 
241 
243 {
248 
253 
258 
259 };
260 
265 {
270 
275 };
276 
277 
279 {
284 
289 
294 
295 };
296 
297 
302 {
307 
312 };
313 
314 
316 {
321 
326 
331 
332 };
333 
334 
335 
348  const struct
350  uint32_t type,
351  const void *data,
352  size_t data_size);
353 
354 
361 size_t
363  const struct GNUNET_RECLAIM_AttributeList *attrs);
364 
365 
371 void
373  struct GNUNET_RECLAIM_AttributeList *attrs);
374 
375 
386 void
388  struct GNUNET_RECLAIM_AttributeList *attrs,
389  const char *attr_name,
391  uint32_t type,
392  const void *data,
393  size_t data_size);
394 
395 
403 size_t
405  const struct GNUNET_RECLAIM_AttributeList *attrs,
406  char *result);
407 
408 
418 
425 size_t
427  const struct GNUNET_RECLAIM_Attribute *attr);
428 
429 
437 size_t
439  char *result);
440 
441 
451 ssize_t
453  struct GNUNET_RECLAIM_Attribute **attr);
454 
455 
463  const struct GNUNET_RECLAIM_AttributeList *attrs);
464 
465 
472 uint32_t
473 GNUNET_RECLAIM_attribute_typename_to_number (const char *typename);
474 
485 int
487  const char *s,
488  void **data,
489  size_t *data_size);
490 
491 
500 char *
502  const void *data,
503  size_t data_size);
504 
511 const char *
513 
514 
521 size_t
523  const struct GNUNET_RECLAIM_CredentialList *credentials);
524 
525 
531 void
533  struct GNUNET_RECLAIM_CredentialList *credentials);
534 
535 
544 void
546  struct GNUNET_RECLAIM_CredentialList *attrs,
547  const char *att_name,
548  uint32_t type,
549  const void *data,
550  size_t data_size);
551 
552 
560 size_t
562  const struct GNUNET_RECLAIM_CredentialList *attrs,
563  char *result);
564 
565 
575  size_t data_size);
576 
577 
582 size_t
584  const struct GNUNET_RECLAIM_Credential *credential);
585 
586 
594 size_t
597  char *result);
598 
599 
610 
611 
623  uint32_t type,
624  const void *data,
625  size_t data_size);
626 
635 char *
637  const void *data,
638  size_t data_size);
639 
650 int
652  const char *s,
653  void **data,
654  size_t *data_size);
655 
662 const char *
664 
671 uint32_t
672 GNUNET_RECLAIM_credential_typename_to_number (const char *typename);
673 
683 
684 char*
687 
688 int
691  struct GNUNET_TIME_Absolute *exp);
692 
699 size_t
701  const struct GNUNET_RECLAIM_PresentationList *presentations);
702 
703 
709 void
711  struct GNUNET_RECLAIM_PresentationList *presentations);
712 
713 
721 size_t
723  const struct GNUNET_RECLAIM_PresentationList *presentations,
724  char *result);
725 
726 
736  size_t data_size);
737 
738 
743 size_t
745  const struct GNUNET_RECLAIM_Presentation *presentation);
746 
747 
755 size_t
757  const struct GNUNET_RECLAIM_Presentation *presentation,
758  char *result);
759 
760 
771 
772 
781 char *
783  const void *data,
784  size_t data_size);
785 
788  const void *data,
789  size_t data_size);
790 
801 int
803  const char *s,
804  void **data,
805  size_t *data_size);
806 
814 const char *
816 
820 
821 char*
824 
825 int
828  struct GNUNET_TIME_Absolute *exp);
829 
830 
831 
844 int
846  const struct GNUNET_RECLAIM_Credential *cred,
847  const struct GNUNET_RECLAIM_AttributeList *attrs,
848  struct GNUNET_RECLAIM_Presentation **presentation);
849 
850 
851 #if 0 /* keep Emacsens' auto-indent happy */
852 {
853 #endif
854 #ifdef __cplusplus
855 }
856 #endif
857 
858 
859 /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
860 #endif
861  /* end of group reclaim-attribute */
863  /* end of group addition */
865 
866 /* end of gnunet_reclaim_attribute_lib.h */
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t data
The data value.
static char * attr_name
The attribute.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
static int result
Global testing status.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
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.
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.
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.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
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.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy claim list.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
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.
char * GNUNET_RECLAIM_credential_get_issuer(const struct GNUNET_RECLAIM_Credential *cred)
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize a presentation.
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.
size_t GNUNET_RECLAIM_credential_list_serialize_get_size(const struct GNUNET_RECLAIM_CredentialList *credentials)
Get required size for serialization buffer.
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.
#define GNUNET_RECLAIM_ID_LENGTH
We want an ID to be a 256-bit symmetric key.
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
char * GNUNET_RECLAIM_presentation_get_issuer(const struct GNUNET_RECLAIM_Presentation *cred)
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
size_t GNUNET_RECLAIM_credential_list_serialize(const struct GNUNET_RECLAIM_CredentialList *attrs, char *result)
Serialize an attribute list.
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.
int GNUNET_RECLAIM_presentation_get_expiration(const struct GNUNET_RECLAIM_Presentation *cred, struct GNUNET_TIME_Absolute *exp)
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
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.
GNUNET_RECLAIM_CredentialType
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_expiration(const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_new(uint32_t type, const void *data, size_t data_size)
uint32_t GNUNET_RECLAIM_credential_typename_to_number(const char *typename)
Convert an credential type name to the corresponding number.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
size_t GNUNET_RECLAIM_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize a presentation list.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
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.
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.
const char * GNUNET_RECLAIM_presentation_number_to_typename(uint32_t type)
Convert a presentation type number to the corresponding credential type string.
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.
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size(const struct GNUNET_RECLAIM_PresentationList *presentations)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
GNUNET_RECLAIM_AttributeType
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_presentation_get_attributes(const struct GNUNET_RECLAIM_Presentation *cred)
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_dup(const struct GNUNET_RECLAIM_AttributeList *attrs)
Make a (deep) copy of a claim list.
@ GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT
A JSON Web Token credential.
@ GNUNET_RECLAIM_CREDENTIAL_TYPE_PABC
libpabc credential
@ GNUNET_RECLAIM_CREDENTIAL_TYPE_NONE
No value credential.
@ GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
@ GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE
No value attribute.
const char * name
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * prev
DLL.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type of Claim.
const void * data
Binary value stored as attribute value.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
struct GNUNET_RECLAIM_Credential * credential
The credential.
struct GNUNET_RECLAIM_CredentialListEntry * prev
DLL.
A list of GNUNET_RECLAIM_Credential structures.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
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.
A reclaim identifier FIXME maybe put this in a different namespace.
struct GNUNET_RECLAIM_PresentationListEntry * prev
DLL.
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.
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
A credential presentation.
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.
Time for absolute times used by GNUnet, in microseconds.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model