aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-04 18:42:04 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:10 +0100
commit55f6d26b7424d660c99bc89f3677b20294e87a27 (patch)
treea8080fdcf0d9688c154417e50c58055e364f8b6b /src/include
parent5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff)
downloadgnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz
gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip
Refactoring reclaim attestations
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_gnsrecord_lib.h12
-rw-r--r--src/include/gnunet_reclaim_attribute_lib.h337
-rw-r--r--src/include/gnunet_reclaim_plugin.h (renamed from src/include/gnunet_reclaim_attribute_plugin.h)127
-rw-r--r--src/include/gnunet_reclaim_service.h66
4 files changed, 299 insertions, 243 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 797c71380..e06dcebc7 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -95,7 +95,7 @@ extern "C" {
95/** 95/**
96 * Record type for identity attributes (of RECLAIM). 96 * Record type for identity attributes (of RECLAIM).
97 */ 97 */
98#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR 65544 98#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544
99 99
100/** 100/**
101 * Record type for local ticket references 101 * Record type for local ticket references
@@ -123,7 +123,7 @@ extern "C" {
123/** 123/**
124 * Record type for reclaim records 124 * Record type for reclaim records
125 */ 125 */
126#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF 65550 126#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550
127 127
128/** 128/**
129 * Record type for RECLAIM master 129 * Record type for RECLAIM master
@@ -141,14 +141,14 @@ extern "C" {
141#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 141#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553
142 142
143/** 143/**
144 * Record type for reclaim identity attestation 144 * Record type for an attribute attestation
145 */ 145 */
146#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR 65554 146#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION 65554
147 147
148/** 148/**
149 * Record type for reclaim identity references 149 * Record type for an attestation reference in a ticket
150 */ 150 */
151#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE 65555 151#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF 65555
152 152
153 153
154/** 154/**
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
77static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; 77static 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 */
97struct GNUNET_RECLAIM_ATTRIBUTE_Claim 99struct 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 */
135struct GNUNET_RECLAIM_ATTESTATION_Claim 143struct 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 */
174struct GNUNET_RECLAIM_ATTESTATION_REFERENCE 183struct 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
197struct 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 */
202struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList 219struct 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
216struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry 233struct 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
243struct 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 */
258struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 263struct GNUNET_RECLAIM_Attribute *
259GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, 264GNUNET_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 */
271size_t 277size_t
272GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( 278GNUNET_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 */
281void 287void
282GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( 288GNUNET_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 */
294void 302void
295GNUNET_RECLAIM_ATTRIBUTE_list_add ( 303GNUNET_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 */
310size_t 319size_t
311GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( 320GNUNET_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 */
323struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 332struct GNUNET_RECLAIM_AttributeList *
324GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size); 333GNUNET_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 */
331int
332GNUNET_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 */
341size_t 341size_t
342GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( 342GNUNET_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 */
353size_t 353size_t
354GNUNET_RECLAIM_ATTRIBUTE_serialize ( 354GNUNET_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 */
367struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 366struct GNUNET_RECLAIM_Attribute *
368GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size); 367GNUNET_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 */
376struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 375struct GNUNET_RECLAIM_AttributeList *
377GNUNET_RECLAIM_ATTRIBUTE_list_dup ( 376GNUNET_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 */
387uint32_t 386uint32_t
388GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename); 387GNUNET_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 */
400int 399int
401GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, 400GNUNET_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 */
415char * 414char *
416GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, 415GNUNET_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 */
427const char * 425const char *
428GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); 426GNUNET_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. 435size_t
438 * 436GNUNET_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 */
445void
446GNUNET_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 */
458void
459GNUNET_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 */
474size_t
475GNUNET_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 */
487struct GNUNET_RECLAIM_AttestationList *
488GNUNET_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 */
442size_t 497size_t
443GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( 498GNUNET_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 */
454size_t 509size_t
455GNUNET_RECLAIM_ATTESTATION_serialize ( 510GNUNET_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 */
468struct GNUNET_RECLAIM_ATTESTATION_Claim * 523struct GNUNET_RECLAIM_Attestation *
469GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size); 524GNUNET_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 */
481struct GNUNET_RECLAIM_ATTESTATION_Claim * 536struct GNUNET_RECLAIM_Attestation *
482GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name, 537GNUNET_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 */
495char * 550char *
496GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type, 551GNUNET_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 */
510int 565int
511GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type, 566GNUNET_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 */
522const char * 577const char *
523GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type); 578GNUNET_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 */
531uint32_t 586uint32_t
532GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename); 587GNUNET_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 */
541struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
542GNUNET_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 */
552size_t
553GNUNET_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 */
563size_t
564GNUNET_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 */
576struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
577GNUNET_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{
diff --git a/src/include/gnunet_reclaim_attribute_plugin.h b/src/include/gnunet_reclaim_plugin.h
index e61cca5b2..4dd5252d2 100644
--- a/src/include/gnunet_reclaim_attribute_plugin.h
+++ b/src/include/gnunet_reclaim_plugin.h
@@ -27,8 +27,8 @@
27 * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims 27 * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims
28 * @{ 28 * @{
29 */ 29 */
30#ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H 30#ifndef GNUNET_RECLAIM_AttributePLUGIN_H
31#define GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H 31#define GNUNET_RECLAIM_AttributePLUGIN_H
32 32
33#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
34#include "gnunet_reclaim_attribute_lib.h" 34#include "gnunet_reclaim_attribute_lib.h"
@@ -51,7 +51,7 @@ extern "C" {
51 * @param data_size number of bytes in @a data 51 * @param data_size number of bytes in @a data
52 * @return NULL on error, otherwise human-readable representation of the value 52 * @return NULL on error, otherwise human-readable representation of the value
53 */ 53 */
54typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) ( 54typedef char *(*GNUNET_RECLAIM_AttributeValueToStringFunction) (
55 void *cls, 55 void *cls,
56 uint32_t type, 56 uint32_t type,
57 const void *data, 57 const void *data,
@@ -70,7 +70,7 @@ typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (
70 * @param data_size set to number of bytes in @a data 70 * @param data_size set to number of bytes in @a data
71 * @return #GNUNET_OK on success 71 * @return #GNUNET_OK on success
72 */ 72 */
73typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) ( 73typedef int (*GNUNET_RECLAIM_AttributeStringToValueFunction) (
74 void *cls, 74 void *cls,
75 uint32_t type, 75 uint32_t type,
76 const char *s, 76 const char *s,
@@ -86,7 +86,7 @@ typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (
86 * @param typename name to convert 86 * @param typename name to convert
87 * @return corresponding number, UINT32_MAX on error 87 * @return corresponding number, UINT32_MAX on error
88 */ 88 */
89typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) ( 89typedef uint32_t (*GNUNET_RECLAIM_AttributeTypenameToNumberFunction) (
90 void *cls, 90 void *cls,
91 const char *typename); 91 const char *typename);
92 92
@@ -99,16 +99,79 @@ typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (
99 * @param type number of a type to convert 99 * @param type number of a type to convert
100 * @return corresponding typestring, NULL on error 100 * @return corresponding typestring, NULL on error
101 */ 101 */
102typedef const char *(*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) ( 102typedef const char *(*GNUNET_RECLAIM_AttributeNumberToTypenameFunction) (
103 void *cls, 103 void *cls,
104 uint32_t type); 104 uint32_t type);
105 105
106/**
107 * Function called to convert the binary value @a data of an attribute of
108 * type @a type to a human-readable string.
109 *
110 * @param cls closure
111 * @param type type of the attribute
112 * @param data value in binary encoding
113 * @param data_size number of bytes in @a data
114 * @return NULL on error, otherwise human-readable representation of the value
115 */
116typedef char *(*GNUNET_RECLAIM_AttestationValueToStringFunction) (
117 void *cls,
118 uint32_t type,
119 const void *data,
120 size_t data_size);
121
122
123/**
124 * Function called to convert human-readable version of the value @a s
125 * of an attribute of type @a type to the respective binary
126 * representation.
127 *
128 * @param cls closure
129 * @param type type of the attribute
130 * @param s human-readable string
131 * @param data set to value in binary encoding (will be allocated)
132 * @param data_size set to number of bytes in @a data
133 * @return #GNUNET_OK on success
134 */
135typedef int (*GNUNET_RECLAIM_AttestationStringToValueFunction) (
136 void *cls,
137 uint32_t type,
138 const char *s,
139 void **data,
140 size_t *data_size);
141
142
143/**
144 * Function called to convert a type name to the
145 * corresponding number.
146 *
147 * @param cls closure
148 * @param typename name to convert
149 * @return corresponding number, UINT32_MAX on error
150 */
151typedef uint32_t (*GNUNET_RECLAIM_AttestationTypenameToNumberFunction) (
152 void *cls,
153 const char *typename);
154
155
156/**
157 * Function called to convert a type number (i.e. 1) to the
158 * corresponding type string
159 *
160 * @param cls closure
161 * @param type number of a type to convert
162 * @return corresponding typestring, NULL on error
163 */
164typedef const char *(*GNUNET_RECLAIM_AttestationNumberToTypenameFunction) (
165 void *cls,
166 uint32_t type);
167
168
106 169
107/** 170/**
108 * Each plugin is required to return a pointer to a struct of this 171 * Each plugin is required to return a pointer to a struct of this
109 * type as the return value from its entry point. 172 * type as the return value from its entry point.
110 */ 173 */
111struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions 174struct GNUNET_RECLAIM_AttributePluginFunctions
112{ 175{
113 /** 176 /**
114 * Closure for all of the callbacks. 177 * Closure for all of the callbacks.
@@ -118,52 +181,60 @@ struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
118 /** 181 /**
119 * Conversion to string. 182 * Conversion to string.
120 */ 183 */
121 GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string; 184 GNUNET_RECLAIM_AttributeValueToStringFunction value_to_string;
122 185
123 /** 186 /**
124 * Conversion to binary. 187 * Conversion to binary.
125 */ 188 */
126 GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value; 189 GNUNET_RECLAIM_AttributeStringToValueFunction string_to_value;
127 190
128 /** 191 /**
129 * Typename to number. 192 * Typename to number.
130 */ 193 */
131 GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number; 194 GNUNET_RECLAIM_AttributeTypenameToNumberFunction typename_to_number;
132 195
133 /** 196 /**
134 * Number to typename. 197 * Number to typename.
135 */ 198 */
136 GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename; 199 GNUNET_RECLAIM_AttributeNumberToTypenameFunction number_to_typename;
137 200
201};
202
203/**
204 * Each plugin is required to return a pointer to a struct of this
205 * type as the return value from its entry point.
206 */
207struct GNUNET_RECLAIM_AttestationPluginFunctions
208{
138 /** 209 /**
139 * FIXME: It is odd that attestation functions are withing the attribute 210 * Closure for all of the callbacks.
140 * plugin. An attribute type may be backed by an attestation, but not
141 * necessarily.
142 * Maybe it would make more sense to refactor this into an attestation
143 * plugin?
144 *
145 * Attestation Conversion to string.
146 */ 211 */
147 GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string_attest; 212 void *cls;
148 213
149 /** 214 /**
150 * Attestation Conversion to binary. 215 * Conversion to string.
151 */ 216 */
152 GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value_attest; 217 GNUNET_RECLAIM_AttestationValueToStringFunction value_to_string;
153 218
154 /** 219 /**
155 * Attestation Typename to number. 220 * Conversion to binary.
156 */ 221 */
157 GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number_attest; 222 GNUNET_RECLAIM_AttestationStringToValueFunction string_to_value;
158 223
159 /** 224 /**
160 * Attestation Number to typename. 225 * Typename to number.
161 */ 226 */
162 GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename_attest; 227 GNUNET_RECLAIM_AttestationTypenameToNumberFunction typename_to_number;
228
229 /**
230 * Number to typename.
231 */
232 GNUNET_RECLAIM_AttestationNumberToTypenameFunction number_to_typename;
163 233
164}; 234};
165 235
166 236
237
167#if 0 /* keep Emacsens' auto-indent happy */ 238#if 0 /* keep Emacsens' auto-indent happy */
168{ 239{
169#endif 240#endif
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index b20809a49..4ead87003 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -114,12 +114,24 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls,
114 * @param cls The callback closure 114 * @param cls The callback closure
115 * @param identity The identity authoritative over the attributes 115 * @param identity The identity authoritative over the attributes
116 * @param attr The attribute 116 * @param attr The attribute
117 * @param attestation The attestation for the attribute (may be NULL)
117 */ 118 */
118typedef void (*GNUNET_RECLAIM_AttributeResult) ( 119typedef void (*GNUNET_RECLAIM_AttributeResult) (
119 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 120 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
120 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 121 const struct GNUNET_RECLAIM_Attribute *attr,
121 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 122 const struct GNUNET_RECLAIM_Attestation *attestation);
122 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference); 123
124
125/**
126 * Callback used to notify the client of attestation results.
127 *
128 * @param cls The callback closure
129 * @param identity The identity authoritative over the attributes
130 * @param attr The attribute
131 */
132typedef void (*GNUNET_RECLAIM_AttestationResult) (
133 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
134 const struct GNUNET_RECLAIM_Attestation *attestation);
123 135
124 136
125/** 137/**
@@ -148,7 +160,7 @@ struct GNUNET_RECLAIM_Operation *
148GNUNET_RECLAIM_attribute_store ( 160GNUNET_RECLAIM_attribute_store (
149 struct GNUNET_RECLAIM_Handle *h, 161 struct GNUNET_RECLAIM_Handle *h,
150 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 162 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
151 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 163 const struct GNUNET_RECLAIM_Attribute *attr,
152 const struct GNUNET_TIME_Relative *exp_interval, 164 const struct GNUNET_TIME_Relative *exp_interval,
153 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); 165 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
154 166
@@ -169,7 +181,7 @@ struct GNUNET_RECLAIM_Operation *
169GNUNET_RECLAIM_attestation_store ( 181GNUNET_RECLAIM_attestation_store (
170 struct GNUNET_RECLAIM_Handle *h, 182 struct GNUNET_RECLAIM_Handle *h,
171 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 183 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
172 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, 184 const struct GNUNET_RECLAIM_Attestation *attestation,
173 const struct GNUNET_TIME_Relative *exp_interval, 185 const struct GNUNET_TIME_Relative *exp_interval,
174 GNUNET_RECLAIM_ContinuationWithStatus cont, 186 GNUNET_RECLAIM_ContinuationWithStatus cont,
175 void *cont_cls); 187 void *cont_cls);
@@ -190,7 +202,7 @@ struct GNUNET_RECLAIM_Operation *
190GNUNET_RECLAIM_attribute_delete ( 202GNUNET_RECLAIM_attribute_delete (
191 struct GNUNET_RECLAIM_Handle *h, 203 struct GNUNET_RECLAIM_Handle *h,
192 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 204 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
193 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 205 const struct GNUNET_RECLAIM_Attribute *attr,
194 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); 206 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
195 207
196/** 208/**
@@ -208,29 +220,11 @@ struct GNUNET_RECLAIM_Operation *
208GNUNET_RECLAIM_attestation_delete ( 220GNUNET_RECLAIM_attestation_delete (
209 struct GNUNET_RECLAIM_Handle *h, 221 struct GNUNET_RECLAIM_Handle *h,
210 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 222 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
211 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, 223 const struct GNUNET_RECLAIM_Attestation *attr,
212 GNUNET_RECLAIM_ContinuationWithStatus cont, 224 GNUNET_RECLAIM_ContinuationWithStatus cont,
213 void *cont_cls); 225 void *cont_cls);
214 226
215/** 227/**
216 * Delete an attestation reference. Tickets used to share this reference are updated
217 * accordingly.
218 *
219 * @param h handle to the re:claimID service
220 * @param pkey Private key of the identity to delete the reference from
221 * @param attr The reference
222 * @param cont Continuation to call when done
223 * @param cont_cls Closure for @a cont
224 * @return handle Used to to abort the request
225 */
226struct GNUNET_RECLAIM_Operation *
227GNUNET_RECLAIM_attestation_reference_delete (
228 struct GNUNET_RECLAIM_Handle *h,
229 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
230 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
231 GNUNET_RECLAIM_ContinuationWithStatus cont,
232 void *cont_cls);
233/**
234 * List all attributes for a local identity. 228 * List all attributes for a local identity.
235 * This MUST lock the `struct GNUNET_RECLAIM_Handle` 229 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
236 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and 230 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and
@@ -262,26 +256,6 @@ GNUNET_RECLAIM_get_attributes_start (
262 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, 256 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
263 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); 257 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
264 258
265/**
266 * Store an attestation reference. If the reference is already present,
267 * it is replaced with the new reference.
268 *
269 * @param h handle to the re:claimID service
270 * @param pkey private key of the identity
271 * @param attr the reference value
272 * @param exp_interval the relative expiration interval for the reference
273 * @param cont continuation to call when done
274 * @param cont_cls closure for @a cont
275 * @return handle to abort the request
276 */
277struct GNUNET_RECLAIM_Operation *
278GNUNET_RECLAIM_attestation_reference_store (
279 struct GNUNET_RECLAIM_Handle *h,
280 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
281 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
282 const struct GNUNET_TIME_Relative *exp_interval,
283 GNUNET_RECLAIM_ContinuationWithStatus cont,
284 void *cont_cls);
285 259
286/** 260/**
287 * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start 261 * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start
@@ -324,7 +298,7 @@ GNUNET_RECLAIM_ticket_issue (
324 struct GNUNET_RECLAIM_Handle *h, 298 struct GNUNET_RECLAIM_Handle *h,
325 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 299 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
326 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 300 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
327 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 301 const struct GNUNET_RECLAIM_AttributeList *attrs,
328 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls); 302 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
329 303
330 304