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 
42 
46 #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 0
47 
51 #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1
52 
56 #define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE 10
57 
61 #define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT 11
62 
66 #define GNUNET_RECLAIM_ID_LENGTH (256 / 8)
67 
73 {
75 };
76 
78 
79 #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \
80  memcmp (a, \
81  b, \
82  sizeof (GNUNET_RECLAIM_ID_ZERO))) \
83  ? \
84  GNUNET_YES : GNUNET_NO)
85 
86 
87 #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \
88  & \
89  GNUNET_RECLAIM_ID_ZERO)
90 
91 #define GNUNET_RECLAIM_id_generate(id) \
92  (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \
93  id, \
94  sizeof (GNUNET_RECLAIM_ID_ZERO)))
95 
100 {
105 
110 
114  uint32_t type;
115 
119  uint32_t flag;
120 
125  const char *name;
126 
130  size_t data_size;
131 
137  const void *data;
138 };
139 
144 {
149 
153  uint32_t type;
154 
158  uint32_t flag;
159 
164  const char *name;
165 
169  size_t data_size;
170 
176  const void *data;
177 };
178 
179 
184 {
189 
194 };
195 
196 
198 {
203 
208 
213 
214 };
215 
220 {
225 
230 };
231 
232 
234 {
239 
244 
249 
250 };
251 
252 
265  const struct
267  uint32_t type,
268  const void *data,
269  size_t data_size);
270 
271 
278 size_t
280  const struct GNUNET_RECLAIM_AttributeList *attrs);
281 
282 
288 void
290  struct GNUNET_RECLAIM_AttributeList *attrs);
291 
292 
303 void
305  struct GNUNET_RECLAIM_AttributeList *attrs,
306  const char *attr_name,
308  uint32_t type,
309  const void *data,
310  size_t data_size);
311 
312 
320 size_t
322  const struct GNUNET_RECLAIM_AttributeList *attrs,
323  char *result);
324 
325 
335 
342 size_t
344  const struct GNUNET_RECLAIM_Attribute *attr);
345 
346 
354 size_t
356  char *result);
357 
358 
369 
370 
378  const struct GNUNET_RECLAIM_AttributeList *attrs);
379 
380 
387 uint32_t
388 GNUNET_RECLAIM_attribute_typename_to_number (const char *typename);
389 
400 int
402  const char *s,
403  void **data,
404  size_t *data_size);
405 
406 
415 char *
417  const void *data,
418  size_t data_size);
419 
426 const char *
428 
429 
436 size_t
438  const struct GNUNET_RECLAIM_AttestationList *attestations);
439 
440 
446 void
448  struct GNUNET_RECLAIM_AttestationList *attestations);
449 
450 
459 void
461  struct GNUNET_RECLAIM_AttestationList *attrs,
462  const char *att_name,
463  uint32_t type,
464  const void *data,
465  size_t data_size);
466 
467 
475 size_t
477  const struct GNUNET_RECLAIM_AttestationList *attrs,
478  char *result);
479 
480 
490  size_t data_size);
491 
492 
497 size_t
500 
501 
509 size_t
512  char *result);
513 
514 
525 
526 
538  uint32_t type,
539  const void *data,
540  size_t data_size);
541 
550 char *
552  const void *data,
553  size_t data_size);
554 
565 int
567  const char *s,
568  void **data,
569  size_t *data_size);
570 
577 const char *
579 
586 uint32_t
587 GNUNET_RECLAIM_attestation_typename_to_number (const char *typename);
588 
598 
599 char*
602 
603 int
606  struct GNUNET_TIME_Absolute *exp);
607 
608 #if 0 /* keep Emacsens' auto-indent happy */
609 {
610 #endif
611 #ifdef __cplusplus
612 }
613 #endif
614 
615 
616 /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
617 #endif
618  /* end of group reclaim-attribute */
620 
621 /* end of gnunet_reclaim_attribute_lib.h */
size_t GNUNET_RECLAIM_attestation_list_serialize(const struct GNUNET_RECLAIM_AttestationList *attrs, char *result)
Serialize an attribute list.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attestation_get_attributes(const struct GNUNET_RECLAIM_Attestation *attest)
Convert an attestation type name to the corresponding number.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
size_t GNUNET_RECLAIM_attestation_serialize(const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
Serialize an attestation.
void GNUNET_RECLAIM_attestation_list_destroy(struct GNUNET_RECLAIM_AttestationList *attestations)
Destroy claim list.
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.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_AttributeListEntry * prev
DLL.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
A list of GNUNET_RECLAIM_Attribute structures.
A list of GNUNET_RECLAIM_Attestation structures.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
uint32_t GNUNET_RECLAIM_attestation_typename_to_number(const char *typename)
Convert an attestation type name to the corresponding number.
void GNUNET_RECLAIM_attribute_list_add(struct GNUNET_RECLAIM_AttributeList *attrs, const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Add a new attribute to a claim list.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
char * GNUNET_RECLAIM_attestation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
static char * attr_name
The attribute.
int GNUNET_RECLAIM_attestation_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 attestation to the binary representation.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO
const char * GNUNET_RECLAIM_attestation_number_to_typename(uint32_t type)
Convert an attestation type number to the corresponding attestation type string.
#define GNUNET_RECLAIM_ID_LENGTH
We want an ID to be a 256-bit symmetric key.
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.
int GNUNET_RECLAIM_attestation_get_expiration(const struct GNUNET_RECLAIM_Attestation *attest, struct GNUNET_TIME_Absolute *exp)
size_t data_size
Number of bytes in data.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_new(const char *name, uint32_t type, const void *data, size_t data_size)
Create a new attestation.
size_t GNUNET_RECLAIM_attestation_serialize_get_size(const struct GNUNET_RECLAIM_Attestation *attestation)
Get required size for serialization buffer.
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.
const char * name
The name of the attribute.
A reclaim identifier FIXME maybe put this in a different namespace.
uint32_t type
Type/Format of Claim.
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
void GNUNET_RECLAIM_attestation_list_add(struct GNUNET_RECLAIM_AttestationList *attrs, const char *att_name, uint32_t type, const void *data, size_t data_size)
Add a new attribute to a claim list.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
const void * data
Binary value stored as attribute value.
static struct GNUNET_RECLAIM_Identifier attestation
Attestation ID.
struct GNUNET_RECLAIM_AttestationListEntry * list_tail
List tail.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
struct GNUNET_RECLAIM_AttestationListEntry * prev
DLL.
const char * name
char * GNUNET_RECLAIM_attestation_get_issuer(const struct GNUNET_RECLAIM_Attestation *attest)
const void * data
Binary value stored as attribute value.
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.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_RECLAIM_AttestationList * GNUNET_RECLAIM_attestation_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
uint32_t data
The data value.
size_t GNUNET_RECLAIM_attestation_list_serialize_get_size(const struct GNUNET_RECLAIM_AttestationList *attestations)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.