GNUnet  0.19.2
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 
44 #include "gnunet_util_lib.h"
45 
51 
56 };
57 
63 
68 
73 };
74 
78 #define GNUNET_RECLAIM_ID_LENGTH (256 / 8)
79 
86 {
88 };
89 
91 
93 
94 #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \
95  memcmp (a, \
96  b, \
97  sizeof (GNUNET_RECLAIM_ID_ZERO))) \
98  ? \
99  GNUNET_YES : GNUNET_NO)
100 
101 
102 #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \
103  & \
104  GNUNET_RECLAIM_ID_ZERO)
105 
106 #define GNUNET_RECLAIM_id_generate(id) \
107  (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \
108  id, \
109  sizeof (GNUNET_RECLAIM_ID_ZERO)))
110 
115 {
120 
126 
130  uint32_t type;
131 
135  uint32_t flag;
136 
141  const char *name;
142 
146  size_t data_size;
147 
153  const void *data;
154 };
155 
160 {
165 
169  uint32_t type;
170 
174  uint32_t flag;
175 
180  const char *name;
181 
185  size_t data_size;
186 
192  const void *data;
193 };
194 
195 
200 {
205 
209  uint32_t type;
210 
214  size_t data_size;
215 
221  const void *data;
222 };
223 
224 
225 
230 {
235 
240 };
241 
242 
244 {
249 
254 
259 
260 };
261 
266 {
271 
276 };
277 
278 
280 {
285 
290 
295 
296 };
297 
298 
303 {
308 
313 };
314 
315 
317 {
322 
327 
332 
333 };
334 
335 
336 
349  const struct
351  uint32_t type,
352  const void *data,
353  size_t data_size);
354 
355 
362 size_t
364  const struct GNUNET_RECLAIM_AttributeList *attrs);
365 
366 
372 void
374  struct GNUNET_RECLAIM_AttributeList *attrs);
375 
376 
387 void
389  struct GNUNET_RECLAIM_AttributeList *attrs,
390  const char *attr_name,
392  uint32_t type,
393  const void *data,
394  size_t data_size);
395 
396 
404 size_t
406  const struct GNUNET_RECLAIM_AttributeList *attrs,
407  char *result);
408 
409 
419 
426 size_t
428  const struct GNUNET_RECLAIM_Attribute *attr);
429 
430 
438 size_t
440  char *result);
441 
442 
452 ssize_t
454  struct GNUNET_RECLAIM_Attribute **attr);
455 
456 
464  const struct GNUNET_RECLAIM_AttributeList *attrs);
465 
466 
473 uint32_t
474 GNUNET_RECLAIM_attribute_typename_to_number (const char *typename);
475 
486 int
488  const char *s,
489  void **data,
490  size_t *data_size);
491 
492 
501 char *
503  const void *data,
504  size_t data_size);
505 
512 const char *
514 
515 
522 size_t
524  const struct GNUNET_RECLAIM_CredentialList *credentials);
525 
526 
532 void
534  struct GNUNET_RECLAIM_CredentialList *credentials);
535 
536 
545 void
547  struct GNUNET_RECLAIM_CredentialList *attrs,
548  const char *att_name,
549  uint32_t type,
550  const void *data,
551  size_t data_size);
552 
553 
561 size_t
563  const struct GNUNET_RECLAIM_CredentialList *credentials,
564  char *result);
565 
566 
576  size_t data_size);
577 
578 
583 size_t
585  const struct GNUNET_RECLAIM_Credential *credential);
586 
587 
595 size_t
598  char *result);
599 
600 
611 
612 
624  uint32_t type,
625  const void *data,
626  size_t data_size);
627 
636 char *
638  const void *data,
639  size_t data_size);
640 
651 int
653  const char *s,
654  void **data,
655  size_t *data_size);
656 
663 const char *
665 
672 uint32_t
673 GNUNET_RECLAIM_credential_typename_to_number (const char *typename);
674 
684 
685 char*
688 
689 int
692  struct GNUNET_TIME_Absolute *exp);
693 
700 size_t
702  const struct GNUNET_RECLAIM_PresentationList *presentations);
703 
704 
710 void
712  struct GNUNET_RECLAIM_PresentationList *presentations);
713 
714 
722 size_t
724  const struct GNUNET_RECLAIM_PresentationList *presentations,
725  char *result);
726 
727 
737  size_t data_size);
738 
739 
744 size_t
746  const struct GNUNET_RECLAIM_Presentation *presentation);
747 
748 
756 size_t
758  const struct GNUNET_RECLAIM_Presentation *presentation,
759  char *result);
760 
761 
772 
773 
782 char *
784  const void *data,
785  size_t data_size);
786 
789  const void *data,
790  size_t data_size);
791 
802 int
804  const char *s,
805  void **data,
806  size_t *data_size);
807 
815 const char *
817 
821 
822 char*
825 
826 int
829  struct GNUNET_TIME_Absolute *exp);
830 
831 
832 
845 int
847  const struct GNUNET_RECLAIM_Credential *cred,
848  const struct GNUNET_RECLAIM_AttributeList *attrs,
849  struct GNUNET_RECLAIM_Presentation **presentation);
850 
851 
852 #if 0 /* keep Emacsens' auto-indent happy */
853 {
854 #endif
855 #ifdef __cplusplus
856 }
857 #endif
858 
859 
860 /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
861 #endif
862  /* end of group reclaim-attribute */
864  /* end of group addition */
866 
867 /* 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 credential 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.
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.
size_t GNUNET_RECLAIM_credential_list_serialize(const struct GNUNET_RECLAIM_CredentialList *credentials, char *result)
Serialize a credential list.
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