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 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.
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.
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/>.
20 * @author Martin Schanzenbach
23 * Identity attribute definitions
25 * @defgroup identity-provider Identity Provider service
28 #ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H
29 #define GNUNET_IDENTITY_ATTRIBUTE_LIB_H
34 #if 0 /* keep Emacsens' auto-indent happy */
39 #include "gnunet_util_lib.h"
45 #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_NONE 0
50 #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING 1
57 struct GNUNET_IDENTITY_ATTRIBUTE_Claim
60 * The name of the attribute. Note "name" must never be individually
76 * Number of bytes in @e data.
81 * Binary value stored as attribute value. Note: "data" must never
82 * be individually 'malloc'ed, but instead always points into some
89 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList
94 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_head;
99 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_tail;
102 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry
107 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *prev;
112 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *next;
115 * The attribute claim
117 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim;
121 * Create a new attribute claim.
123 * @param attr_name the attribute name
124 * @param type the attribute type
125 * @param data the attribute value
126 * @param data_size the attribute value size
127 * @return the new attribute
129 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
130 GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name,
137 * Get required size for serialization buffer
139 * @param attrs the attribute list to serialize
141 * @return the required buffer size
144 GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
147 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
150 GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
151 const char* attr_name,
157 * Serialize an attribute list
159 * @param attrs the attribute list to serialize
160 * @param result the serialized attribute
162 * @return length of serialized data
165 GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
169 * Deserialize an attribute list
171 * @param data the serialized attribute list
172 * @param data_size the length of the serialized data
174 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
176 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *
177 GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data,
182 * Get required size for serialization buffer
184 * @param attr the attribute to serialize
186 * @return the required buffer size
189 GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr);
194 * Serialize an attribute
196 * @param attr the attribute to serialize
197 * @param result the serialized attribute
199 * @return length of serialized data
202 GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
206 * Deserialize an attribute
208 * @param data the serialized attribute
209 * @param data_size the length of the serialized data
211 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
213 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
214 GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data,
217 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList*
218 GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
221 * Convert a type name to the corresponding number
223 * @param typename name to convert
224 * @return corresponding number, UINT32_MAX on error
227 GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename);
230 * Convert human-readable version of a 'claim' of an attribute to the binary
233 * @param type type of the claim
234 * @param s human-readable string
235 * @param data set to value in binary encoding (will be allocated)
236 * @param data_size set to number of bytes in @a data
237 * @return #GNUNET_OK on success
240 GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type,
246 * Convert the 'claim' of an attribute to a string
248 * @param type the type of attribute
249 * @param data claim in binary encoding
250 * @param data_size number of bytes in @a data
251 * @return NULL on error, otherwise human-readable representation of the claim
254 GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
259 * Convert a type number to the corresponding type string
261 * @param type number of a type
262 * @return corresponding typestring, NULL on error
265 GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type);
268 #if 0 /* keep Emacsens' auto-indent happy */
276 /* ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H */
279 /** @} */ /* end of group identity */
281 /* end of gnunet_identity_attribute_lib.h */