diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-04 18:42:04 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-09 20:38:10 +0100 |
commit | 55f6d26b7424d660c99bc89f3677b20294e87a27 (patch) | |
tree | a8080fdcf0d9688c154417e50c58055e364f8b6b /src/include/gnunet_reclaim_attribute_lib.h | |
parent | 5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff) | |
download | gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip |
Refactoring reclaim attestations
Diffstat (limited to 'src/include/gnunet_reclaim_attribute_lib.h')
-rw-r--r-- | src/include/gnunet_reclaim_attribute_lib.h | 337 |
1 files changed, 174 insertions, 163 deletions
diff --git a/src/include/gnunet_reclaim_attribute_lib.h b/src/include/gnunet_reclaim_attribute_lib.h index 93b4f8a13..937a4d8f4 100644 --- a/src/include/gnunet_reclaim_attribute_lib.h +++ b/src/include/gnunet_reclaim_attribute_lib.h | |||
@@ -77,24 +77,26 @@ struct GNUNET_RECLAIM_Identifier | |||
77 | static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; | 77 | static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; |
78 | 78 | ||
79 | #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \ | 79 | #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \ |
80 | memcmp (a,\ | 80 | memcmp (a, \ |
81 | b,\ | 81 | b, \ |
82 | sizeof (GNUNET_RECLAIM_ID_ZERO))) ?\ | 82 | sizeof (GNUNET_RECLAIM_ID_ZERO))) \ |
83 | GNUNET_YES : GNUNET_NO) | 83 | ? \ |
84 | GNUNET_YES : GNUNET_NO) | ||
84 | 85 | ||
85 | 86 | ||
86 | #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal(a,\ | 87 | #define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \ |
87 | &GNUNET_RECLAIM_ID_ZERO) | 88 | & \ |
89 | GNUNET_RECLAIM_ID_ZERO) | ||
88 | 90 | ||
89 | #define GNUNET_RECLAIM_id_generate(id) \ | 91 | #define GNUNET_RECLAIM_id_generate(id) \ |
90 | (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,\ | 92 | (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \ |
91 | id,\ | 93 | id, \ |
92 | sizeof (GNUNET_RECLAIM_ID_ZERO))) | 94 | sizeof (GNUNET_RECLAIM_ID_ZERO))) |
93 | 95 | ||
94 | /** | 96 | /** |
95 | * An attribute. | 97 | * An attribute. |
96 | */ | 98 | */ |
97 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim | 99 | struct GNUNET_RECLAIM_Attribute |
98 | { | 100 | { |
99 | /** | 101 | /** |
100 | * ID | 102 | * ID |
@@ -102,6 +104,11 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
102 | struct GNUNET_RECLAIM_Identifier id; | 104 | struct GNUNET_RECLAIM_Identifier id; |
103 | 105 | ||
104 | /** | 106 | /** |
107 | * Referenced ID of Attestation (may be 0 if self-attested) | ||
108 | */ | ||
109 | struct GNUNET_RECLAIM_Identifier attestation; | ||
110 | |||
111 | /** | ||
105 | * Type of Claim | 112 | * Type of Claim |
106 | */ | 113 | */ |
107 | uint32_t type; | 114 | uint32_t type; |
@@ -110,6 +117,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
110 | * Flags | 117 | * Flags |
111 | */ | 118 | */ |
112 | uint32_t flag; | 119 | uint32_t flag; |
120 | |||
113 | /** | 121 | /** |
114 | * The name of the attribute. Note "name" must never be individually | 122 | * The name of the attribute. Note "name" must never be individually |
115 | * free'd | 123 | * free'd |
@@ -132,7 +140,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
132 | /** | 140 | /** |
133 | * An attestation. | 141 | * An attestation. |
134 | */ | 142 | */ |
135 | struct GNUNET_RECLAIM_ATTESTATION_Claim | 143 | struct GNUNET_RECLAIM_Attestation |
136 | { | 144 | { |
137 | /** | 145 | /** |
138 | * ID | 146 | * ID |
@@ -168,81 +176,77 @@ struct GNUNET_RECLAIM_ATTESTATION_Claim | |||
168 | const void *data; | 176 | const void *data; |
169 | }; | 177 | }; |
170 | 178 | ||
179 | |||
171 | /** | 180 | /** |
172 | * A reference to an Attestatiom. | 181 | * A list of GNUNET_RECLAIM_Attribute structures. |
173 | */ | 182 | */ |
174 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE | 183 | struct GNUNET_RECLAIM_AttributeList |
175 | { | 184 | { |
176 | /** | 185 | /** |
177 | * ID | 186 | * List head |
178 | */ | 187 | */ |
179 | struct GNUNET_RECLAIM_Identifier id; | 188 | struct GNUNET_RECLAIM_AttributeListEntry *list_head; |
180 | 189 | ||
181 | /** | 190 | /** |
182 | * Referenced ID of Attestation | 191 | * List tail |
183 | */ | 192 | */ |
184 | struct GNUNET_RECLAIM_Identifier id_attest; | 193 | struct GNUNET_RECLAIM_AttributeListEntry *list_tail; |
194 | }; | ||
185 | 195 | ||
196 | |||
197 | struct GNUNET_RECLAIM_AttributeListEntry | ||
198 | { | ||
186 | /** | 199 | /** |
187 | * The name of the attribute/attestation reference value. Note "name" must never be individually | 200 | * DLL |
188 | * free'd | ||
189 | */ | 201 | */ |
190 | const char *name; | 202 | struct GNUNET_RECLAIM_AttributeListEntry *prev; |
191 | 203 | ||
192 | /** | 204 | /** |
193 | * The name of the attribute/attestation reference value. Note "name" must never be individually | 205 | * DLL |
194 | * free'd | 206 | */ |
207 | struct GNUNET_RECLAIM_AttributeListEntry *next; | ||
208 | |||
209 | /** | ||
210 | * The attribute claim | ||
195 | */ | 211 | */ |
196 | const char *reference_value; | 212 | struct GNUNET_RECLAIM_Attribute *attribute; |
213 | |||
197 | }; | 214 | }; |
198 | 215 | ||
199 | /** | 216 | /** |
200 | * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures. | 217 | * A list of GNUNET_RECLAIM_Attestation structures. |
201 | */ | 218 | */ |
202 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList | 219 | struct GNUNET_RECLAIM_AttestationList |
203 | { | 220 | { |
204 | /** | 221 | /** |
205 | * List head | 222 | * List head |
206 | */ | 223 | */ |
207 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_head; | 224 | struct GNUNET_RECLAIM_AttestationListEntry *list_head; |
208 | 225 | ||
209 | /** | 226 | /** |
210 | * List tail | 227 | * List tail |
211 | */ | 228 | */ |
212 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; | 229 | struct GNUNET_RECLAIM_AttestationListEntry *list_tail; |
213 | }; | 230 | }; |
214 | 231 | ||
215 | 232 | ||
216 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | 233 | struct GNUNET_RECLAIM_AttestationListEntry |
217 | { | 234 | { |
218 | /** | 235 | /** |
219 | * DLL | 236 | * DLL |
220 | */ | 237 | */ |
221 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *prev; | 238 | struct GNUNET_RECLAIM_AttestationListEntry *prev; |
222 | 239 | ||
223 | /** | 240 | /** |
224 | * DLL | 241 | * DLL |
225 | */ | 242 | */ |
226 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *next; | 243 | struct GNUNET_RECLAIM_AttestationListEntry *next; |
227 | 244 | ||
228 | /** | 245 | /** |
229 | * The attribute claim | 246 | * The attestation |
230 | */ | 247 | */ |
231 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 248 | struct GNUNET_RECLAIM_Attestation *attestation; |
232 | /** | ||
233 | * The attestation claim | ||
234 | */ | ||
235 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | ||
236 | 249 | ||
237 | /** | ||
238 | * The reference | ||
239 | */ | ||
240 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
241 | }; | ||
242 | |||
243 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType | ||
244 | { | ||
245 | uint32_t type; | ||
246 | }; | 250 | }; |
247 | 251 | ||
248 | 252 | ||
@@ -250,16 +254,18 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType | |||
250 | * Create a new attribute claim. | 254 | * Create a new attribute claim. |
251 | * | 255 | * |
252 | * @param attr_name the attribute name | 256 | * @param attr_name the attribute name |
257 | * @param attestation ID of the attestation (may be NULL) | ||
253 | * @param type the attribute type | 258 | * @param type the attribute type |
254 | * @param data the attribute value | 259 | * @param data the attribute value. Must be the mapped name if attestation not NULL |
255 | * @param data_size the attribute value size | 260 | * @param data_size the attribute value size |
256 | * @return the new attribute | 261 | * @return the new attribute |
257 | */ | 262 | */ |
258 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 263 | struct GNUNET_RECLAIM_Attribute * |
259 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, | 264 | GNUNET_RECLAIM_attribute_new (const char *attr_name, |
260 | uint32_t type, | 265 | const struct GNUNET_RECLAIM_Identifier *attestation, |
261 | const void *data, | 266 | uint32_t type, |
262 | size_t data_size); | 267 | const void *data, |
268 | size_t data_size); | ||
263 | 269 | ||
264 | 270 | ||
265 | /** | 271 | /** |
@@ -269,8 +275,8 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, | |||
269 | * @return the required buffer size | 275 | * @return the required buffer size |
270 | */ | 276 | */ |
271 | size_t | 277 | size_t |
272 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( | 278 | GNUNET_RECLAIM_attribute_list_serialize_get_size ( |
273 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 279 | const struct GNUNET_RECLAIM_AttributeList *attrs); |
274 | 280 | ||
275 | 281 | ||
276 | /** | 282 | /** |
@@ -279,22 +285,25 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( | |||
279 | * @param attrs list to destroy | 285 | * @param attrs list to destroy |
280 | */ | 286 | */ |
281 | void | 287 | void |
282 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( | 288 | GNUNET_RECLAIM_attribute_list_destroy ( |
283 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 289 | struct GNUNET_RECLAIM_AttributeList *attrs); |
284 | 290 | ||
285 | 291 | ||
286 | /** | 292 | /** |
287 | * Add a new attribute to a claim list | 293 | * Add a new attribute to a claim list |
288 | * | 294 | * |
295 | * @param attrs the attribute list to add to | ||
289 | * @param attr_name the name of the new attribute claim | 296 | * @param attr_name the name of the new attribute claim |
297 | * @param attestation attestation ID (may be NULL) | ||
290 | * @param type the type of the claim | 298 | * @param type the type of the claim |
291 | * @param data claim payload | 299 | * @param data claim payload |
292 | * @param data_size claim payload size | 300 | * @param data_size claim payload size |
293 | */ | 301 | */ |
294 | void | 302 | void |
295 | GNUNET_RECLAIM_ATTRIBUTE_list_add ( | 303 | GNUNET_RECLAIM_attribute_list_add ( |
296 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 304 | struct GNUNET_RECLAIM_AttributeList *attrs, |
297 | const char *attr_name, | 305 | const char *attr_name, |
306 | const struct GNUNET_RECLAIM_Identifier *attestation, | ||
298 | uint32_t type, | 307 | uint32_t type, |
299 | const void *data, | 308 | const void *data, |
300 | size_t data_size); | 309 | size_t data_size); |
@@ -308,8 +317,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_add ( | |||
308 | * @return length of serialized data | 317 | * @return length of serialized data |
309 | */ | 318 | */ |
310 | size_t | 319 | size_t |
311 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( | 320 | GNUNET_RECLAIM_attribute_list_serialize ( |
312 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 321 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
313 | char *result); | 322 | char *result); |
314 | 323 | ||
315 | 324 | ||
@@ -320,17 +329,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( | |||
320 | * @param data_size the length of the serialized data | 329 | * @param data_size the length of the serialized data |
321 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 330 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
322 | */ | 331 | */ |
323 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 332 | struct GNUNET_RECLAIM_AttributeList * |
324 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size); | 333 | GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size); |
325 | |||
326 | /** | ||
327 | * Count attestations in claim list | ||
328 | * | ||
329 | * @param attrs list | ||
330 | */ | ||
331 | int | ||
332 | GNUNET_RECLAIM_ATTRIBUTE_list_count_attest ( | ||
333 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Get required size for serialization buffer | 336 | * Get required size for serialization buffer |
@@ -339,8 +339,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_count_attest ( | |||
339 | * @return the required buffer size | 339 | * @return the required buffer size |
340 | */ | 340 | */ |
341 | size_t | 341 | size_t |
342 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( | 342 | GNUNET_RECLAIM_attribute_serialize_get_size ( |
343 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); | 343 | const struct GNUNET_RECLAIM_Attribute *attr); |
344 | 344 | ||
345 | 345 | ||
346 | /** | 346 | /** |
@@ -351,9 +351,8 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( | |||
351 | * @return length of serialized data | 351 | * @return length of serialized data |
352 | */ | 352 | */ |
353 | size_t | 353 | size_t |
354 | GNUNET_RECLAIM_ATTRIBUTE_serialize ( | 354 | GNUNET_RECLAIM_attribute_serialize (const struct GNUNET_RECLAIM_Attribute *attr, |
355 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 355 | char *result); |
356 | char *result); | ||
357 | 356 | ||
358 | 357 | ||
359 | /** | 358 | /** |
@@ -364,8 +363,8 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize ( | |||
364 | * | 363 | * |
365 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 364 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
366 | */ | 365 | */ |
367 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 366 | struct GNUNET_RECLAIM_Attribute * |
368 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size); | 367 | GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size); |
369 | 368 | ||
370 | 369 | ||
371 | /** | 370 | /** |
@@ -373,9 +372,9 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size); | |||
373 | * @param attrs claim list to copy | 372 | * @param attrs claim list to copy |
374 | * @return copied claim list | 373 | * @return copied claim list |
375 | */ | 374 | */ |
376 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 375 | struct GNUNET_RECLAIM_AttributeList * |
377 | GNUNET_RECLAIM_ATTRIBUTE_list_dup ( | 376 | GNUNET_RECLAIM_attribute_list_dup ( |
378 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 377 | const struct GNUNET_RECLAIM_AttributeList *attrs); |
379 | 378 | ||
380 | 379 | ||
381 | /** | 380 | /** |
@@ -385,7 +384,7 @@ GNUNET_RECLAIM_ATTRIBUTE_list_dup ( | |||
385 | * @return corresponding number, UINT32_MAX on error | 384 | * @return corresponding number, UINT32_MAX on error |
386 | */ | 385 | */ |
387 | uint32_t | 386 | uint32_t |
388 | GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename); | 387 | GNUNET_RECLAIM_attribute_typename_to_number (const char *typename); |
389 | 388 | ||
390 | /** | 389 | /** |
391 | * Convert human-readable version of a 'claim' of an attribute to the binary | 390 | * Convert human-readable version of a 'claim' of an attribute to the binary |
@@ -398,7 +397,7 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename); | |||
398 | * @return #GNUNET_OK on success | 397 | * @return #GNUNET_OK on success |
399 | */ | 398 | */ |
400 | int | 399 | int |
401 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | 400 | GNUNET_RECLAIM_attribute_string_to_value (uint32_t type, |
402 | const char *s, | 401 | const char *s, |
403 | void **data, | 402 | void **data, |
404 | size_t *data_size); | 403 | size_t *data_size); |
@@ -413,11 +412,10 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | |||
413 | * @return NULL on error, otherwise human-readable representation of the claim | 412 | * @return NULL on error, otherwise human-readable representation of the claim |
414 | */ | 413 | */ |
415 | char * | 414 | char * |
416 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, | 415 | GNUNET_RECLAIM_attribute_value_to_string (uint32_t type, |
417 | const void *data, | 416 | const void *data, |
418 | size_t data_size); | 417 | size_t data_size); |
419 | 418 | ||
420 | |||
421 | /** | 419 | /** |
422 | * Convert a type number to the corresponding type string | 420 | * Convert a type number to the corresponding type string |
423 | * | 421 | * |
@@ -425,35 +423,92 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, | |||
425 | * @return corresponding typestring, NULL on error | 423 | * @return corresponding typestring, NULL on error |
426 | */ | 424 | */ |
427 | const char * | 425 | const char * |
428 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); | 426 | GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type); |
429 | 427 | ||
430 | /** | 428 | |
431 | * Get required size for serialization buffer | 429 | /** |
432 | * FIXME: | 430 | * Get required size for serialization buffer |
433 | * 1. The naming convention is violated here. | 431 | * |
434 | * It should GNUNET_RECLAIM_ATTRIBUTE_<lowercase from here>. | 432 | * @param attrs the attribute list to serialize |
435 | * It might make sense to refactor attestations into a separate folder. | 433 | * @return the required buffer size |
436 | * 2. The struct should be called GNUNET_RECLAIM_ATTESTATION_Data or | 434 | */ |
437 | * GNUNET_RECLAIM_ATTRIBUTE_Attestation depending on location in source. | 435 | size_t |
438 | * | 436 | GNUNET_RECLAIM_attestation_list_serialize_get_size ( |
439 | * @param attr the attestation to serialize | 437 | const struct GNUNET_RECLAIM_AttestationList *attestations); |
438 | |||
439 | |||
440 | /** | ||
441 | * Destroy claim list | ||
442 | * | ||
443 | * @param attrs list to destroy | ||
444 | */ | ||
445 | void | ||
446 | GNUNET_RECLAIM_attestation_list_destroy ( | ||
447 | struct GNUNET_RECLAIM_AttestationList *attestations); | ||
448 | |||
449 | |||
450 | /** | ||
451 | * Add a new attribute to a claim list | ||
452 | * | ||
453 | * @param attr_name the name of the new attribute claim | ||
454 | * @param type the type of the claim | ||
455 | * @param data claim payload | ||
456 | * @param data_size claim payload size | ||
457 | */ | ||
458 | void | ||
459 | GNUNET_RECLAIM_attestation_list_add ( | ||
460 | struct GNUNET_RECLAIM_AttestationList *attrs, | ||
461 | const char *att_name, | ||
462 | uint32_t type, | ||
463 | const void *data, | ||
464 | size_t data_size); | ||
465 | |||
466 | |||
467 | /** | ||
468 | * Serialize an attribute list | ||
469 | * | ||
470 | * @param attrs the attribute list to serialize | ||
471 | * @param result the serialized attribute | ||
472 | * @return length of serialized data | ||
473 | */ | ||
474 | size_t | ||
475 | GNUNET_RECLAIM_attestation_list_serialize ( | ||
476 | const struct GNUNET_RECLAIM_AttestationList *attrs, | ||
477 | char *result); | ||
478 | |||
479 | |||
480 | /** | ||
481 | * Deserialize an attribute list | ||
482 | * | ||
483 | * @param data the serialized attribute list | ||
484 | * @param data_size the length of the serialized data | ||
485 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | ||
486 | */ | ||
487 | struct GNUNET_RECLAIM_AttestationList * | ||
488 | GNUNET_RECLAIM_attestation_list_deserialize (const char *data, | ||
489 | size_t data_size); | ||
490 | |||
491 | |||
492 | |||
493 | /** | ||
494 | * @param attestation the attestation to serialize | ||
440 | * @return the required buffer size | 495 | * @return the required buffer size |
441 | */ | 496 | */ |
442 | size_t | 497 | size_t |
443 | GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( | 498 | GNUNET_RECLAIM_attestation_serialize_get_size ( |
444 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr); | 499 | const struct GNUNET_RECLAIM_Attestation *attestation); |
445 | 500 | ||
446 | 501 | ||
447 | /** | 502 | /** |
448 | * Serialize an attestation | 503 | * Serialize an attestation |
449 | * | 504 | * |
450 | * @param attr the attestation to serialize | 505 | * @param attestation the attestation to serialize |
451 | * @param result the serialized attestation | 506 | * @param result the serialized attestation |
452 | * @return length of serialized data | 507 | * @return length of serialized data |
453 | */ | 508 | */ |
454 | size_t | 509 | size_t |
455 | GNUNET_RECLAIM_ATTESTATION_serialize ( | 510 | GNUNET_RECLAIM_attestation_serialize ( |
456 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, | 511 | const struct GNUNET_RECLAIM_Attestation *attestation, |
457 | char *result); | 512 | char *result); |
458 | 513 | ||
459 | 514 | ||
@@ -465,24 +520,24 @@ GNUNET_RECLAIM_ATTESTATION_serialize ( | |||
465 | * | 520 | * |
466 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 521 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
467 | */ | 522 | */ |
468 | struct GNUNET_RECLAIM_ATTESTATION_Claim * | 523 | struct GNUNET_RECLAIM_Attestation * |
469 | GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size); | 524 | GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size); |
470 | 525 | ||
471 | 526 | ||
472 | /** | 527 | /** |
473 | * Create a new attestation. | 528 | * Create a new attestation. |
474 | * | 529 | * |
475 | * @param attr_name the attestation name | 530 | * @param name the attestation name |
476 | * @param type the attestation type | 531 | * @param type the attestation type |
477 | * @param data the attestation value | 532 | * @param data the attestation value |
478 | * @param data_size the attestation value size | 533 | * @param data_size the attestation value size |
479 | * @return the new attestation | 534 | * @return the new attestation |
480 | */ | 535 | */ |
481 | struct GNUNET_RECLAIM_ATTESTATION_Claim * | 536 | struct GNUNET_RECLAIM_Attestation * |
482 | GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name, | 537 | GNUNET_RECLAIM_attestation_new (const char *name, |
483 | uint32_t type, | 538 | uint32_t type, |
484 | const void *data, | 539 | const void *data, |
485 | size_t data_size); | 540 | size_t data_size); |
486 | 541 | ||
487 | /** | 542 | /** |
488 | * Convert the 'claim' of an attestation to a string | 543 | * Convert the 'claim' of an attestation to a string |
@@ -493,7 +548,7 @@ GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name, | |||
493 | * @return NULL on error, otherwise human-readable representation of the claim | 548 | * @return NULL on error, otherwise human-readable representation of the claim |
494 | */ | 549 | */ |
495 | char * | 550 | char * |
496 | GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type, | 551 | GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, |
497 | const void *data, | 552 | const void *data, |
498 | size_t data_size); | 553 | size_t data_size); |
499 | 554 | ||
@@ -508,7 +563,7 @@ GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type, | |||
508 | * @return #GNUNET_OK on success | 563 | * @return #GNUNET_OK on success |
509 | */ | 564 | */ |
510 | int | 565 | int |
511 | GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type, | 566 | GNUNET_RECLAIM_attestation_string_to_value (uint32_t type, |
512 | const char *s, | 567 | const char *s, |
513 | void **data, | 568 | void **data, |
514 | size_t *data_size); | 569 | size_t *data_size); |
@@ -520,7 +575,7 @@ GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type, | |||
520 | * @return corresponding typestring, NULL on error | 575 | * @return corresponding typestring, NULL on error |
521 | */ | 576 | */ |
522 | const char * | 577 | const char * |
523 | GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type); | 578 | GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type); |
524 | 579 | ||
525 | /** | 580 | /** |
526 | * Convert an attestation type name to the corresponding number | 581 | * Convert an attestation type name to the corresponding number |
@@ -529,52 +584,8 @@ GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type); | |||
529 | * @return corresponding number, UINT32_MAX on error | 584 | * @return corresponding number, UINT32_MAX on error |
530 | */ | 585 | */ |
531 | uint32_t | 586 | uint32_t |
532 | GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename); | 587 | GNUNET_RECLAIM_attestation_typename_to_number (const char *typename); |
533 | |||
534 | /** | ||
535 | * Create a new attestation reference. | ||
536 | * | ||
537 | * @param attr_name the referenced claim name | ||
538 | * @param ref_value the claim name in the attestation | ||
539 | * @return the new reference | ||
540 | */ | ||
541 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * | ||
542 | GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name, | ||
543 | const char *ref_value); | ||
544 | |||
545 | |||
546 | /** | ||
547 | * Get required size for serialization buffer | ||
548 | * | ||
549 | * @param attr the reference to serialize | ||
550 | * @return the required buffer size | ||
551 | */ | ||
552 | size_t | ||
553 | GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size ( | ||
554 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr); | ||
555 | 588 | ||
556 | /** | ||
557 | * Serialize a reference | ||
558 | * | ||
559 | * @param attr the reference to serialize | ||
560 | * @param result the serialized reference | ||
561 | * @return length of serialized data | ||
562 | */ | ||
563 | size_t | ||
564 | GNUNET_RECLAIM_ATTESTATION_REF_serialize ( | ||
565 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, | ||
566 | char *result); | ||
567 | |||
568 | /** | ||
569 | * Deserialize a reference | ||
570 | * | ||
571 | * @param data the serialized reference | ||
572 | * @param data_size the length of the serialized data | ||
573 | * | ||
574 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | ||
575 | */ | ||
576 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * | ||
577 | GNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size); | ||
578 | 589 | ||
579 | #if 0 /* keep Emacsens' auto-indent happy */ | 590 | #if 0 /* keep Emacsens' auto-indent happy */ |
580 | { | 591 | { |