2 This file is part of GNUnet.
3 Copyright (C) 2017 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Martin Schanzenbach
25 * Identity attribute definitions
27 * @defgroup identity-provider Identity Provider service
30 #ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H
31 #define GNUNET_IDENTITY_ATTRIBUTE_LIB_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_util_lib.h"
47 #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_NONE 0
52 #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING 1
59 struct GNUNET_IDENTITY_ATTRIBUTE_Claim
62 * The name of the attribute. Note "name" must never be individually
78 * Number of bytes in @e data.
83 * Binary value stored as attribute value. Note: "data" must never
84 * be individually 'malloc'ed, but instead always points into some
91 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList
96 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_head;
101 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_tail;
104 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry
109 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *prev;
114 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *next;
117 * The attribute claim
119 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim;
123 * Create a new attribute claim.
125 * @param attr_name the attribute name
126 * @param type the attribute type
127 * @param data the attribute value
128 * @param data_size the attribute value size
129 * @return the new attribute
131 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
132 GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name,
139 * Get required size for serialization buffer
141 * @param attrs the attribute list to serialize
143 * @return the required buffer size
146 GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
149 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
153 * Serialize an attribute list
155 * @param attrs the attribute list to serialize
156 * @param result the serialized attribute
158 * @return length of serialized data
161 GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
165 * Deserialize an attribute list
167 * @param data the serialized attribute list
168 * @param data_size the length of the serialized data
170 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
172 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *
173 GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data,
178 * Get required size for serialization buffer
180 * @param attr the attribute to serialize
182 * @return the required buffer size
185 GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr);
190 * Serialize an attribute
192 * @param attr the attribute to serialize
193 * @param result the serialized attribute
195 * @return length of serialized data
198 GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
202 * Deserialize an attribute
204 * @param data the serialized attribute
205 * @param data_size the length of the serialized data
207 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
209 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
210 GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data,
213 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList*
214 GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
217 * Convert a type name to the corresponding number
219 * @param typename name to convert
220 * @return corresponding number, UINT32_MAX on error
223 GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename);
226 * Convert human-readable version of a 'claim' of an attribute to the binary
229 * @param type type of the claim
230 * @param s human-readable string
231 * @param data set to value in binary encoding (will be allocated)
232 * @param data_size set to number of bytes in @a data
233 * @return #GNUNET_OK on success
236 GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type,
242 * Convert the 'claim' of an attribute to a string
244 * @param type the type of attribute
245 * @param data claim in binary encoding
246 * @param data_size number of bytes in @a data
247 * @return NULL on error, otherwise human-readable representation of the claim
250 GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
255 * Convert a type number to the corresponding type string
257 * @param type number of a type
258 * @return corresponding typestring, NULL on error
261 GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type);
264 #if 0 /* keep Emacsens' auto-indent happy */
272 /* ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H */
275 /** @} */ /* end of group identity */
277 /* end of gnunet_identity_attribute_lib.h */