aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff)
downloadgnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz
gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip
Refactoring reclaim attestations
Diffstat (limited to 'src')
-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
-rw-r--r--src/reclaim-attribute/Makefile.am21
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attestation_jwt.c182
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_basic.c180
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c290
-rw-r--r--src/reclaim-attribute/reclaim_attestation.c502
-rw-r--r--src/reclaim-attribute/reclaim_attestation.h64
-rw-r--r--src/reclaim-attribute/reclaim_attribute.c720
-rw-r--r--src/reclaim-attribute/reclaim_attribute.h34
-rw-r--r--src/reclaim/gnunet-reclaim.c72
-rw-r--r--src/reclaim/gnunet-service-reclaim.c602
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c271
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h4
-rw-r--r--src/reclaim/json_reclaim.c149
-rw-r--r--src/reclaim/json_reclaim.h14
-rw-r--r--src/reclaim/oidc_helper.c153
-rw-r--r--src/reclaim/oidc_helper.h9
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c30
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c295
-rw-r--r--src/reclaim/plugin_rest_reclaim.c524
-rw-r--r--src/reclaim/reclaim.h46
-rw-r--r--src/reclaim/reclaim_api.c433
25 files changed, 2085 insertions, 3052 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
diff --git a/src/reclaim-attribute/Makefile.am b/src/reclaim-attribute/Makefile.am
index 490e77398..a1c220340 100644
--- a/src/reclaim-attribute/Makefile.am
+++ b/src/reclaim-attribute/Makefile.am
@@ -17,7 +17,8 @@ lib_LTLIBRARIES = \
17 17
18libgnunetreclaimattribute_la_SOURCES = \ 18libgnunetreclaimattribute_la_SOURCES = \
19 reclaim_attribute.h \ 19 reclaim_attribute.h \
20 reclaim_attribute.c 20 reclaim_attribute.c \
21 reclaim_attestation.c
21libgnunetreclaimattribute_la_LIBADD = \ 22libgnunetreclaimattribute_la_LIBADD = \
22 $(top_builddir)/src/util/libgnunetutil.la \ 23 $(top_builddir)/src/util/libgnunetutil.la \
23 $(GN_LIBINTL) 24 $(GN_LIBINTL)
@@ -27,15 +28,23 @@ libgnunetreclaimattribute_la_LDFLAGS = \
27 28
28 29
29plugin_LTLIBRARIES = \ 30plugin_LTLIBRARIES = \
30 libgnunet_plugin_reclaim_attribute_gnuid.la 31 libgnunet_plugin_reclaim_attribute_basic.la \
32 libgnunet_plugin_reclaim_attestation_jwt.la
31 33
32 34
33libgnunet_plugin_reclaim_attribute_gnuid_la_SOURCES = \ 35libgnunet_plugin_reclaim_attribute_basic_la_SOURCES = \
34 plugin_reclaim_attribute_gnuid.c 36 plugin_reclaim_attribute_basic.c
35libgnunet_plugin_reclaim_attribute_gnuid_la_LIBADD = \ 37libgnunet_plugin_reclaim_attribute_basic_la_LIBADD = \
36 $(top_builddir)/src/util/libgnunetutil.la \ 38 $(top_builddir)/src/util/libgnunetutil.la \
37 $(LTLIBINTL) 39 $(LTLIBINTL)
38libgnunet_plugin_reclaim_attribute_gnuid_la_LDFLAGS = \ 40libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \
39 $(GN_PLUGIN_LDFLAGS) 41 $(GN_PLUGIN_LDFLAGS)
40 42
43libgnunet_plugin_reclaim_attestation_jwt_la_SOURCES = \
44 plugin_reclaim_attestation_jwt.c
45libgnunet_plugin_reclaim_attestation_jwt_la_LIBADD = \
46 $(top_builddir)/src/util/libgnunetutil.la \
47 $(LTLIBINTL)
48libgnunet_plugin_reclaim_attestation_jwt_la_LDFLAGS = \
49 $(GN_PLUGIN_LDFLAGS)
41 50
diff --git a/src/reclaim-attribute/plugin_reclaim_attestation_jwt.c b/src/reclaim-attribute/plugin_reclaim_attestation_jwt.c
new file mode 100644
index 000000000..eb6043a66
--- /dev/null
+++ b/src/reclaim-attribute/plugin_reclaim_attestation_jwt.c
@@ -0,0 +1,182 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2013, 2014, 2016 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
21/**
22 * @file reclaim-attribute/plugin_reclaim_attestation_gnuid.c
23 * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
24 * fundamental
25 * attribute types.
26 *
27 * @author Martin Schanzenbach
28 */
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_reclaim_plugin.h"
32#include <inttypes.h>
33
34
35/**
36 * Convert the 'value' of an attestation to a string.
37 *
38 * @param cls closure, unused
39 * @param type type of the attestation
40 * @param data value in binary encoding
41 * @param data_size number of bytes in @a data
42 * @return NULL on error, otherwise human-readable representation of the value
43 */
44static char *
45jwt_value_to_string (void *cls,
46 uint32_t type,
47 const void *data,
48 size_t data_size)
49{
50 switch (type)
51 {
52 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
53 return GNUNET_strndup (data, data_size);
54
55 default:
56 return NULL;
57 }
58}
59
60
61/**
62 * Convert human-readable version of a 'value' of an attestation to the binary
63 * representation.
64 *
65 * @param cls closure, unused
66 * @param type type of the attestation
67 * @param s human-readable string
68 * @param data set to value in binary encoding (will be allocated)
69 * @param data_size set to number of bytes in @a data
70 * @return #GNUNET_OK on success
71 */
72static int
73jwt_string_to_value (void *cls,
74 uint32_t type,
75 const char *s,
76 void **data,
77 size_t *data_size)
78{
79 if (NULL == s)
80 return GNUNET_SYSERR;
81 switch (type)
82 {
83 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
84 *data = GNUNET_strdup (s);
85 *data_size = strlen (s);
86 return GNUNET_OK;
87
88 default:
89 return GNUNET_SYSERR;
90 }
91}
92
93
94/**
95 * Mapping of attestation type numbers to human-readable
96 * attestation type names.
97 */
98static struct
99{
100 const char *name;
101 uint32_t number;
102} jwt_attest_name_map[] = { { "JWT", GNUNET_RECLAIM_ATTESTATION_TYPE_JWT },
103 { NULL, UINT32_MAX } };
104
105/**
106 * Convert a type name to the corresponding number.
107 *
108 * @param cls closure, unused
109 * @param jwt_typename name to convert
110 * @return corresponding number, UINT32_MAX on error
111 */
112static uint32_t
113jwt_typename_to_number (void *cls, const char *jwt_typename)
114{
115 unsigned int i;
116
117 i = 0;
118 while ((NULL != jwt_attest_name_map[i].name) &&
119 (0 != strcasecmp (jwt_typename, jwt_attest_name_map[i].name)))
120 i++;
121 return jwt_attest_name_map[i].number;
122}
123
124
125/**
126 * Convert a type number (i.e. 1) to the corresponding type string
127 *
128 * @param cls closure, unused
129 * @param type number of a type to convert
130 * @return corresponding typestring, NULL on error
131 */
132static const char *
133jwt_number_to_typename (void *cls, uint32_t type)
134{
135 unsigned int i;
136
137 i = 0;
138 while ((NULL != jwt_attest_name_map[i].name) && (type !=
139 jwt_attest_name_map[i].
140 number))
141 i++;
142 return jwt_attest_name_map[i].name;
143}
144
145
146/**
147 * Entry point for the plugin.
148 *
149 * @param cls NULL
150 * @return the exported block API
151 */
152void *
153libgnunet_plugin_reclaim_attestation_jwt_init (void *cls)
154{
155 struct GNUNET_RECLAIM_AttestationPluginFunctions *api;
156
157 api = GNUNET_new (struct GNUNET_RECLAIM_AttestationPluginFunctions);
158 api->value_to_string = &jwt_value_to_string;
159 api->string_to_value = &jwt_string_to_value;
160 api->typename_to_number = &jwt_typename_to_number;
161 api->number_to_typename = &jwt_number_to_typename;
162 return api;
163}
164
165
166/**
167 * Exit point from the plugin.
168 *
169 * @param cls the return value from #libgnunet_plugin_block_test_init()
170 * @return NULL
171 */
172void *
173libgnunet_plugin_reclaim_attestation_jwt_done (void *cls)
174{
175 struct GNUNET_RECLAIM_AttestationPluginFunctions *api = cls;
176
177 GNUNET_free (api);
178 return NULL;
179}
180
181
182/* end of plugin_reclaim_attestation_type_gnuid.c */
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_basic.c b/src/reclaim-attribute/plugin_reclaim_attribute_basic.c
new file mode 100644
index 000000000..47fdd5f11
--- /dev/null
+++ b/src/reclaim-attribute/plugin_reclaim_attribute_basic.c
@@ -0,0 +1,180 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2013, 2014, 2016 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
21/**
22 * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
23 * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
24 * fundamental
25 * attribute types.
26 *
27 * @author Martin Schanzenbach
28 */
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_reclaim_plugin.h"
32#include <inttypes.h>
33
34
35/**
36 * Convert the 'value' of an attribute to a string.
37 *
38 * @param cls closure, unused
39 * @param type type of the attribute
40 * @param data value in binary encoding
41 * @param data_size number of bytes in @a data
42 * @return NULL on error, otherwise human-readable representation of the value
43 */
44static char *
45basic_value_to_string (void *cls,
46 uint32_t type,
47 const void *data,
48 size_t data_size)
49{
50 switch (type)
51 {
52 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
53 return GNUNET_strndup (data, data_size);
54
55 default:
56 return NULL;
57 }
58}
59
60
61/**
62 * Convert human-readable version of a 'value' of an attribute to the binary
63 * representation.
64 *
65 * @param cls closure, unused
66 * @param type type of the attribute
67 * @param s human-readable string
68 * @param data set to value in binary encoding (will be allocated)
69 * @param data_size set to number of bytes in @a data
70 * @return #GNUNET_OK on success
71 */
72static int
73basic_string_to_value (void *cls,
74 uint32_t type,
75 const char *s,
76 void **data,
77 size_t *data_size)
78{
79 if (NULL == s)
80 return GNUNET_SYSERR;
81 switch (type)
82 {
83 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
84 *data = GNUNET_strdup (s);
85 *data_size = strlen (s);
86 return GNUNET_OK;
87
88 default:
89 return GNUNET_SYSERR;
90 }
91}
92
93/**
94 * Mapping of attribute type numbers to human-readable
95 * attribute type names.
96 */
97static struct
98{
99 const char *name;
100 uint32_t number;
101} basic_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
102 { NULL, UINT32_MAX } };
103
104
105/**
106 * Convert a type name to the corresponding number.
107 *
108 * @param cls closure, unused
109 * @param basic_typename name to convert
110 * @return corresponding number, UINT32_MAX on error
111 */
112static uint32_t
113basic_typename_to_number (void *cls, const char *basic_typename)
114{
115 unsigned int i;
116
117 i = 0;
118 while ((NULL != basic_name_map[i].name) &&
119 (0 != strcasecmp (basic_typename, basic_name_map[i].name)))
120 i++;
121 return basic_name_map[i].number;
122}
123
124
125/**
126 * Convert a type number (i.e. 1) to the corresponding type string
127 *
128 * @param cls closure, unused
129 * @param type number of a type to convert
130 * @return corresponding typestring, NULL on error
131 */
132static const char *
133basic_number_to_typename (void *cls, uint32_t type)
134{
135 unsigned int i;
136
137 i = 0;
138 while ((NULL != basic_name_map[i].name) && (type != basic_name_map[i].number))
139 i++;
140 return basic_name_map[i].name;
141}
142
143
144/**
145 * Entry point for the plugin.
146 *
147 * @param cls NULL
148 * @return the exported block API
149 */
150void *
151libgnunet_plugin_reclaim_attribute_basic_init (void *cls)
152{
153 struct GNUNET_RECLAIM_AttributePluginFunctions *api;
154
155 api = GNUNET_new (struct GNUNET_RECLAIM_AttributePluginFunctions);
156 api->value_to_string = &basic_value_to_string;
157 api->string_to_value = &basic_string_to_value;
158 api->typename_to_number = &basic_typename_to_number;
159 api->number_to_typename = &basic_number_to_typename;
160 return api;
161}
162
163
164/**
165 * Exit point from the plugin.
166 *
167 * @param cls the return value from #libgnunet_plugin_block_test_init()
168 * @return NULL
169 */
170void *
171libgnunet_plugin_reclaim_attribute_basic_done (void *cls)
172{
173 struct GNUNET_RECLAIM_AttributePluginFunctions *api = cls;
174
175 GNUNET_free (api);
176 return NULL;
177}
178
179
180/* end of plugin_reclaim_attribute_type_gnuid.c */
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
deleted file mode 100644
index ade2a27bb..000000000
--- a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2013, 2014, 2016 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
21/**
22 * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
23 * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
24 * fundamental
25 * attribute types.
26 *
27 * @author Martin Schanzenbach
28 */
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_reclaim_attribute_plugin.h"
32#include <inttypes.h>
33
34
35/**
36 * Convert the 'value' of an attribute to a string.
37 *
38 * @param cls closure, unused
39 * @param type type of the attribute
40 * @param data value in binary encoding
41 * @param data_size number of bytes in @a data
42 * @return NULL on error, otherwise human-readable representation of the value
43 */
44static char *
45gnuid_value_to_string (void *cls,
46 uint32_t type,
47 const void *data,
48 size_t data_size)
49{
50 switch (type)
51 {
52 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
53 return GNUNET_strndup (data, data_size);
54
55 default:
56 return NULL;
57 }
58}
59
60
61/**
62 * Convert human-readable version of a 'value' of an attribute to the binary
63 * representation.
64 *
65 * @param cls closure, unused
66 * @param type type of the attribute
67 * @param s human-readable string
68 * @param data set to value in binary encoding (will be allocated)
69 * @param data_size set to number of bytes in @a data
70 * @return #GNUNET_OK on success
71 */
72static int
73gnuid_string_to_value (void *cls,
74 uint32_t type,
75 const char *s,
76 void **data,
77 size_t *data_size)
78{
79 if (NULL == s)
80 return GNUNET_SYSERR;
81 switch (type)
82 {
83 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
84 *data = GNUNET_strdup (s);
85 *data_size = strlen (s);
86 return GNUNET_OK;
87
88 default:
89 return GNUNET_SYSERR;
90 }
91}
92
93/**
94 * Convert the 'value' of an attestation to a string.
95 *
96 * @param cls closure, unused
97 * @param type type of the attestation
98 * @param data value in binary encoding
99 * @param data_size number of bytes in @a data
100 * @return NULL on error, otherwise human-readable representation of the value
101 */
102static char *
103gnuid_value_to_string_attest (void *cls,
104 uint32_t type,
105 const void *data,
106 size_t data_size)
107{
108 switch (type)
109 {
110 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
111 return GNUNET_strndup (data, data_size);
112
113 default:
114 return NULL;
115 }
116}
117
118
119/**
120 * Convert human-readable version of a 'value' of an attestation to the binary
121 * representation.
122 *
123 * @param cls closure, unused
124 * @param type type of the attestation
125 * @param s human-readable string
126 * @param data set to value in binary encoding (will be allocated)
127 * @param data_size set to number of bytes in @a data
128 * @return #GNUNET_OK on success
129 */
130static int
131gnuid_string_to_value_attest (void *cls,
132 uint32_t type,
133 const char *s,
134 void **data,
135 size_t *data_size)
136{
137 if (NULL == s)
138 return GNUNET_SYSERR;
139 switch (type)
140 {
141 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
142 *data = GNUNET_strdup (s);
143 *data_size = strlen (s);
144 return GNUNET_OK;
145
146 default:
147 return GNUNET_SYSERR;
148 }
149}
150
151/**
152 * Mapping of attribute type numbers to human-readable
153 * attribute type names.
154 */
155static struct
156{
157 const char *name;
158 uint32_t number;
159} gnuid_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
160 { NULL, UINT32_MAX } };
161
162/**
163 * Mapping of attestation type numbers to human-readable
164 * attestation type names.
165 */
166static struct
167{
168 const char *name;
169 uint32_t number;
170} gnuid_attest_name_map[] = { { "JWT", GNUNET_RECLAIM_ATTESTATION_TYPE_JWT },
171 { NULL, UINT32_MAX } };
172
173/**
174 * Convert a type name to the corresponding number.
175 *
176 * @param cls closure, unused
177 * @param gnuid_typename name to convert
178 * @return corresponding number, UINT32_MAX on error
179 */
180static uint32_t
181gnuid_typename_to_number (void *cls, const char *gnuid_typename)
182{
183 unsigned int i;
184
185 i = 0;
186 while ((NULL != gnuid_name_map[i].name) &&
187 (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name)))
188 i++;
189 return gnuid_name_map[i].number;
190}
191
192
193/**
194 * Convert a type number (i.e. 1) to the corresponding type string
195 *
196 * @param cls closure, unused
197 * @param type number of a type to convert
198 * @return corresponding typestring, NULL on error
199 */
200static const char *
201gnuid_number_to_typename (void *cls, uint32_t type)
202{
203 unsigned int i;
204
205 i = 0;
206 while ((NULL != gnuid_name_map[i].name) && (type != gnuid_name_map[i].number))
207 i++;
208 return gnuid_name_map[i].name;
209}
210
211/**
212 * Convert a type name to the corresponding number.
213 *
214 * @param cls closure, unused
215 * @param gnuid_typename name to convert
216 * @return corresponding number, UINT32_MAX on error
217 */
218static uint32_t
219gnuid_typename_to_number_attest (void *cls, const char *gnuid_typename)
220{
221 unsigned int i;
222
223 i = 0;
224 while ((NULL != gnuid_attest_name_map[i].name) &&
225 (0 != strcasecmp (gnuid_typename, gnuid_attest_name_map[i].name)))
226 i++;
227 return gnuid_attest_name_map[i].number;
228}
229
230/**
231 * Convert a type number (i.e. 1) to the corresponding type string
232 *
233 * @param cls closure, unused
234 * @param type number of a type to convert
235 * @return corresponding typestring, NULL on error
236 */
237static const char *
238gnuid_number_to_typename_attest (void *cls, uint32_t type)
239{
240 unsigned int i;
241
242 i = 0;
243 while ((NULL != gnuid_attest_name_map[i].name) && (type !=
244 gnuid_attest_name_map[i].
245 number))
246 i++;
247 return gnuid_attest_name_map[i].name;
248}
249
250/**
251 * Entry point for the plugin.
252 *
253 * @param cls NULL
254 * @return the exported block API
255 */
256void *
257libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls)
258{
259 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api;
260
261 api = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions);
262 api->value_to_string = &gnuid_value_to_string;
263 api->string_to_value = &gnuid_string_to_value;
264 api->typename_to_number = &gnuid_typename_to_number;
265 api->number_to_typename = &gnuid_number_to_typename;
266 api->value_to_string_attest = &gnuid_value_to_string_attest;
267 api->string_to_value_attest = &gnuid_string_to_value_attest;
268 api->typename_to_number_attest = &gnuid_typename_to_number_attest;
269 api->number_to_typename_attest = &gnuid_number_to_typename_attest;
270 return api;
271}
272
273
274/**
275 * Exit point from the plugin.
276 *
277 * @param cls the return value from #libgnunet_plugin_block_test_init()
278 * @return NULL
279 */
280void *
281libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls)
282{
283 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls;
284
285 GNUNET_free (api);
286 return NULL;
287}
288
289
290/* end of plugin_reclaim_attribute_type_gnuid.c */
diff --git a/src/reclaim-attribute/reclaim_attestation.c b/src/reclaim-attribute/reclaim_attestation.c
new file mode 100644
index 000000000..1a7776719
--- /dev/null
+++ b/src/reclaim-attribute/reclaim_attestation.c
@@ -0,0 +1,502 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2010-2015 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
21/**
22 * @file reclaim-attribute/reclaim_attestation.c
23 * @brief helper library to manage identity attribute attestations
24 * @author Martin Schanzenbach
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_reclaim_plugin.h"
29#include "reclaim_attestation.h"
30
31
32/**
33 * Handle for a plugin
34 */
35struct Plugin
36{
37 /**
38 * Name of the plugin
39 */
40 char *library_name;
41
42 /**
43 * Plugin API
44 */
45 struct GNUNET_RECLAIM_AttestationPluginFunctions *api;
46};
47
48
49/**
50 * Plugins
51 */
52static struct Plugin **attest_plugins;
53
54
55/**
56 * Number of plugins
57 */
58static unsigned int num_plugins;
59
60
61/**
62 * Init canary
63 */
64static int initialized;
65
66
67/**
68 * Add a plugin
69 *
70 * @param cls closure
71 * @param library_name name of the API library
72 * @param lib_ret the plugin API pointer
73 */
74static void
75add_plugin (void *cls, const char *library_name, void *lib_ret)
76{
77 struct GNUNET_RECLAIM_AttestationPluginFunctions *api = lib_ret;
78 struct Plugin *plugin;
79
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Loading attestation plugin `%s'\n",
82 library_name);
83 plugin = GNUNET_new (struct Plugin);
84 plugin->api = api;
85 plugin->library_name = GNUNET_strdup (library_name);
86 GNUNET_array_append (attest_plugins, num_plugins, plugin);
87}
88
89
90/**
91 * Load plugins
92 */
93static void
94init ()
95{
96 if (GNUNET_YES == initialized)
97 return;
98 initialized = GNUNET_YES;
99 GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attestation_",
100 NULL,
101 &add_plugin,
102 NULL);
103}
104
105
106/**
107 * Convert an attestation type name to the corresponding number
108 *
109 * @param typename name to convert
110 * @return corresponding number, UINT32_MAX on error
111 */
112uint32_t
113GNUNET_RECLAIM_attestation_typename_to_number (const char *typename)
114{
115 unsigned int i;
116 struct Plugin *plugin;
117 uint32_t ret;
118 init ();
119 for (i = 0; i < num_plugins; i++)
120 {
121 plugin = attest_plugins[i];
122 if (UINT32_MAX !=
123 (ret = plugin->api->typename_to_number (plugin->api->cls,
124 typename)))
125 return ret;
126 }
127 return UINT32_MAX;
128}
129
130
131/**
132 * Convert an attestation type number to the corresponding attestation type string
133 *
134 * @param type number of a type
135 * @return corresponding typestring, NULL on error
136 */
137const char *
138GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type)
139{
140 unsigned int i;
141 struct Plugin *plugin;
142 const char *ret;
143
144 init ();
145 for (i = 0; i < num_plugins; i++)
146 {
147 plugin = attest_plugins[i];
148 if (NULL !=
149 (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
150 return ret;
151 }
152 return NULL;
153}
154
155
156/**
157 * Convert human-readable version of a 'claim' of an attestation to the binary
158 * representation
159 *
160 * @param type type of the claim
161 * @param s human-readable string
162 * @param data set to value in binary encoding (will be allocated)
163 * @param data_size set to number of bytes in @a data
164 * @return #GNUNET_OK on success
165 */
166int
167GNUNET_RECLAIM_attestation_string_to_value (uint32_t type,
168 const char *s,
169 void **data,
170 size_t *data_size)
171{
172 unsigned int i;
173 struct Plugin *plugin;
174
175 init ();
176 for (i = 0; i < num_plugins; i++)
177 {
178 plugin = attest_plugins[i];
179 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
180 type,
181 s,
182 data,
183 data_size))
184 return GNUNET_OK;
185 }
186 return GNUNET_SYSERR;
187}
188
189
190/**
191 * Convert the 'claim' of an attestation to a string
192 *
193 * @param type the type of attestation
194 * @param data claim in binary encoding
195 * @param data_size number of bytes in @a data
196 * @return NULL on error, otherwise human-readable representation of the claim
197 */
198char *
199GNUNET_RECLAIM_attestation_value_to_string (uint32_t type,
200 const void *data,
201 size_t data_size)
202{
203 unsigned int i;
204 struct Plugin *plugin;
205 char *ret;
206
207 init ();
208 for (i = 0; i < num_plugins; i++)
209 {
210 plugin = attest_plugins[i];
211 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
212 type,
213 data,
214 data_size)))
215 return ret;
216 }
217 return NULL;
218}
219
220
221/**
222 * Create a new attestation.
223 *
224 * @param attr_name the attestation name
225 * @param type the attestation type
226 * @param data the attestation value
227 * @param data_size the attestation value size
228 * @return the new attestation
229 */
230struct GNUNET_RECLAIM_Attestation *
231GNUNET_RECLAIM_attestation_new (const char *attr_name,
232 uint32_t type,
233 const void *data,
234 size_t data_size)
235{
236 struct GNUNET_RECLAIM_Attestation *attr;
237 char *write_ptr;
238 char *attr_name_tmp = GNUNET_strdup (attr_name);
239
240 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
241
242 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
243 + strlen (attr_name_tmp) + 1 + data_size);
244 attr->type = type;
245 attr->data_size = data_size;
246 attr->flag = 0;
247 write_ptr = (char *) &attr[1];
248 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
249 attr->name = write_ptr;
250 write_ptr += strlen (attr->name) + 1;
251 GNUNET_memcpy (write_ptr, data, data_size);
252 attr->data = write_ptr;
253 GNUNET_free (attr_name_tmp);
254 return attr;
255}
256
257
258/**
259 * Get required size for serialization buffer
260 *
261 * @param attrs the attribute list to serialize
262 * @return the required buffer size
263 */
264size_t
265GNUNET_RECLAIM_attestation_list_serialize_get_size (
266 const struct GNUNET_RECLAIM_AttestationList *attestations)
267{
268 struct GNUNET_RECLAIM_AttestationListEntry *le;
269 size_t len = 0;
270
271 for (le = attestations->list_head; NULL != le; le = le->next)
272 {
273 GNUNET_assert (NULL != le->attestation);
274 len += GNUNET_RECLAIM_attestation_serialize_get_size (le->attestation);
275 len += sizeof(struct GNUNET_RECLAIM_AttestationListEntry);
276 }
277 return len;
278}
279
280
281/**
282 * Serialize an attribute list
283 *
284 * @param attrs the attribute list to serialize
285 * @param result the serialized attribute
286 * @return length of serialized data
287 */
288size_t
289GNUNET_RECLAIM_attestation_list_serialize (
290 const struct GNUNET_RECLAIM_AttestationList *attestations,
291 char *result)
292{
293 struct GNUNET_RECLAIM_AttestationListEntry *le;
294 size_t len;
295 size_t total_len;
296 char *write_ptr;
297 write_ptr = result;
298 total_len = 0;
299 for (le = attestations->list_head; NULL != le; le = le->next)
300 {
301 GNUNET_assert (NULL != le->attestation);
302 len = GNUNET_RECLAIM_attestation_serialize (le->attestation, write_ptr);
303 total_len += len;
304 write_ptr += len;
305 }
306 return total_len;
307}
308
309
310/**
311 * Deserialize an attestation list
312 *
313 * @param data the serialized attribute list
314 * @param data_size the length of the serialized data
315 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
316 */
317struct GNUNET_RECLAIM_AttestationList *
318GNUNET_RECLAIM_attestation_list_deserialize (const char *data, size_t data_size)
319{
320 struct GNUNET_RECLAIM_AttestationList *al;
321 struct GNUNET_RECLAIM_AttestationListEntry *ale;
322 size_t att_len;
323 const char *read_ptr;
324
325 al = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
326
327 if ((data_size < sizeof(struct
328 Attestation)
329 + sizeof(struct GNUNET_RECLAIM_AttestationListEntry)))
330 return al;
331
332 read_ptr = data;
333 while (((data + data_size) - read_ptr) >= sizeof(struct Attestation))
334 {
335 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
336 ale->attestation =
337 GNUNET_RECLAIM_attestation_deserialize (read_ptr,
338 data_size - (read_ptr - data));
339 GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
340 att_len = GNUNET_RECLAIM_attestation_serialize_get_size (ale->attestation);
341 read_ptr += att_len;
342 }
343 return al;
344}
345
346
347/**
348 * Make a (deep) copy of the attestation list
349 * @param attrs claim list to copy
350 * @return copied claim list
351 */
352struct GNUNET_RECLAIM_AttestationList *
353GNUNET_RECLAIM_attestation_list_dup (
354 const struct GNUNET_RECLAIM_AttestationList *al)
355{
356 struct GNUNET_RECLAIM_AttestationListEntry *ale;
357 struct GNUNET_RECLAIM_AttestationListEntry *result_ale;
358 struct GNUNET_RECLAIM_AttestationList *result;
359
360 result = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
361 for (ale = al->list_head; NULL != ale; ale = ale->next)
362 {
363 result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
364 GNUNET_assert (NULL != ale->attestation);
365 result_ale->attestation =
366 GNUNET_RECLAIM_attestation_new (ale->attestation->name,
367 ale->attestation->type,
368 ale->attestation->data,
369 ale->attestation->data_size);
370 result_ale->attestation->id = ale->attestation->id;
371 GNUNET_CONTAINER_DLL_insert (result->list_head,
372 result->list_tail,
373 result_ale);
374 }
375 return result;
376}
377
378
379/**
380 * Destroy attestation list
381 *
382 * @param attrs list to destroy
383 */
384void
385GNUNET_RECLAIM_attestation_list_destroy (
386 struct GNUNET_RECLAIM_AttestationList *al)
387{
388 struct GNUNET_RECLAIM_AttestationListEntry *ale;
389 struct GNUNET_RECLAIM_AttestationListEntry *tmp_ale;
390
391 for (ale = al->list_head; NULL != ale; ale = ale->next)
392 {
393 if (NULL != ale->attestation)
394 GNUNET_free (ale->attestation);
395 tmp_ale = ale;
396 ale = ale->next;
397 GNUNET_free (tmp_ale);
398 }
399 GNUNET_free (al);
400}
401
402
403/**
404 * Get required size for serialization buffer
405 *
406 * @param attr the attestation to serialize
407 * @return the required buffer size
408 */
409size_t
410GNUNET_RECLAIM_attestation_serialize_get_size (
411 const struct GNUNET_RECLAIM_Attestation *attestation)
412{
413 return sizeof(struct Attestation) + strlen (attestation->name)
414 + attestation->data_size;
415}
416
417
418/**
419 * Serialize an attestation
420 *
421 * @param attr the attestation to serialize
422 * @param result the serialized attestation
423 * @return length of serialized data
424 */
425size_t
426GNUNET_RECLAIM_attestation_serialize (
427 const struct GNUNET_RECLAIM_Attestation *attestation,
428 char *result)
429{
430 size_t data_len_ser;
431 size_t name_len;
432 struct Attestation *atts;
433 char *write_ptr;
434
435 atts = (struct Attestation *) result;
436 atts->attestation_type = htons (attestation->type);
437 atts->attestation_flag = htonl (attestation->flag);
438 atts->attestation_id = attestation->id;
439 name_len = strlen (attestation->name);
440 atts->name_len = htons (name_len);
441 write_ptr = (char *) &atts[1];
442 GNUNET_memcpy (write_ptr, attestation->name, name_len);
443 write_ptr += name_len;
444 // TODO plugin-ize
445 // data_len_ser = plugin->serialize_attribute_value (attr,
446 // &attr_ser[1]);
447 data_len_ser = attestation->data_size;
448 GNUNET_memcpy (write_ptr, attestation->data, attestation->data_size);
449 atts->data_size = htons (data_len_ser);
450
451 return sizeof(struct Attestation) + strlen (attestation->name)
452 + attestation->data_size;
453}
454
455
456/**
457 * Deserialize an attestation
458 *
459 * @param data the serialized attestation
460 * @param data_size the length of the serialized data
461 *
462 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
463 */
464struct GNUNET_RECLAIM_Attestation *
465GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size)
466{
467 struct GNUNET_RECLAIM_Attestation *attestation;
468 struct Attestation *atts;
469 size_t data_len;
470 size_t name_len;
471 char *write_ptr;
472
473 if (data_size < sizeof(struct Attestation))
474 return NULL;
475
476 atts = (struct Attestation *) data;
477 data_len = ntohs (atts->data_size);
478 name_len = ntohs (atts->name_len);
479 if (data_size < sizeof(struct Attestation) + data_len + name_len)
480 {
481 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
482 "Buffer too small to deserialize\n");
483 return NULL;
484 }
485 attestation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
486 + data_len + name_len + 1);
487 attestation->type = ntohs (atts->attestation_type);
488 attestation->flag = ntohl (atts->attestation_flag);
489 attestation->id = atts->attestation_id;
490 attestation->data_size = data_len;
491
492 write_ptr = (char *) &attestation[1];
493 GNUNET_memcpy (write_ptr, &atts[1], name_len);
494 write_ptr[name_len] = '\0';
495 attestation->name = write_ptr;
496
497 write_ptr += name_len + 1;
498 GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
499 attestation->data_size);
500 attestation->data = write_ptr;
501 return attestation;
502}
diff --git a/src/reclaim-attribute/reclaim_attestation.h b/src/reclaim-attribute/reclaim_attestation.h
new file mode 100644
index 000000000..5747d8896
--- /dev/null
+++ b/src/reclaim-attribute/reclaim_attestation.h
@@ -0,0 +1,64 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 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/**
21 * @author Martin Schanzenbach
22 * @file reclaim-attribute/reclaim_attestation.h
23 * @brief GNUnet reclaim identity attribute attestations
24 *
25 */
26#ifndef RECLAIM_ATTESTATION_H
27#define RECLAIM_ATTESTATION_H
28
29#include "gnunet_reclaim_service.h"
30
31/**
32 * Serialized attestation claim
33 */
34struct Attestation
35{
36 /**
37 * Attestation type
38 */
39 uint32_t attestation_type;
40
41 /**
42 * Attestation flag
43 */
44 uint32_t attestation_flag;
45
46 /**
47 * Attestation ID
48 */
49 struct GNUNET_RECLAIM_Identifier attestation_id;
50
51 /**
52 * Name length
53 */
54 uint32_t name_len;
55
56 /**
57 * Data size
58 */
59 uint32_t data_size;
60
61 // followed by data_size Attestation value data
62};
63
64#endif
diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c
index 07d8200c6..936f9cb75 100644
--- a/src/reclaim-attribute/reclaim_attribute.c
+++ b/src/reclaim-attribute/reclaim_attribute.c
@@ -25,7 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_reclaim_attribute_plugin.h" 28#include "gnunet_reclaim_plugin.h"
29#include "reclaim_attribute.h" 29#include "reclaim_attribute.h"
30 30
31 31
@@ -42,7 +42,7 @@ struct Plugin
42 /** 42 /**
43 * Plugin API 43 * Plugin API
44 */ 44 */
45 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; 45 struct GNUNET_RECLAIM_AttributePluginFunctions *api;
46}; 46};
47 47
48 48
@@ -74,7 +74,7 @@ static int initialized;
74static void 74static void
75add_plugin (void *cls, const char *library_name, void *lib_ret) 75add_plugin (void *cls, const char *library_name, void *lib_ret)
76{ 76{
77 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret; 77 struct GNUNET_RECLAIM_AttributePluginFunctions *api = lib_ret;
78 struct Plugin *plugin; 78 struct Plugin *plugin;
79 79
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -110,7 +110,7 @@ init ()
110 * @return corresponding number, UINT32_MAX on error 110 * @return corresponding number, UINT32_MAX on error
111 */ 111 */
112uint32_t 112uint32_t
113GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename) 113GNUNET_RECLAIM_attribute_typename_to_number (const char *typename)
114{ 114{
115 unsigned int i; 115 unsigned int i;
116 struct Plugin *plugin; 116 struct Plugin *plugin;
@@ -135,7 +135,7 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename)
135 * @return corresponding typestring, NULL on error 135 * @return corresponding typestring, NULL on error
136 */ 136 */
137const char * 137const char *
138GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type) 138GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type)
139{ 139{
140 unsigned int i; 140 unsigned int i;
141 struct Plugin *plugin; 141 struct Plugin *plugin;
@@ -164,7 +164,7 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
164 * @return #GNUNET_OK on success 164 * @return #GNUNET_OK on success
165 */ 165 */
166int 166int
167GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, 167GNUNET_RECLAIM_attribute_string_to_value (uint32_t type,
168 const char *s, 168 const char *s,
169 void **data, 169 void **data,
170 size_t *data_size) 170 size_t *data_size)
@@ -196,7 +196,7 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
196 * @return NULL on error, otherwise human-readable representation of the claim 196 * @return NULL on error, otherwise human-readable representation of the claim
197 */ 197 */
198char * 198char *
199GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, 199GNUNET_RECLAIM_attribute_value_to_string (uint32_t type,
200 const void *data, 200 const void *data,
201 size_t data_size) 201 size_t data_size)
202{ 202{
@@ -217,140 +217,34 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
217 return NULL; 217 return NULL;
218} 218}
219 219
220/**
221 * Convert an attestation type name to the corresponding number
222 *
223 * @param typename name to convert
224 * @return corresponding number, UINT32_MAX on error
225 */
226uint32_t
227GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename)
228{
229 unsigned int i;
230 struct Plugin *plugin;
231 uint32_t ret;
232 init ();
233 for (i = 0; i < num_plugins; i++)
234 {
235 plugin = attr_plugins[i];
236 if (UINT32_MAX !=
237 (ret = plugin->api->typename_to_number_attest (plugin->api->cls,
238 typename)))
239 return ret;
240 }
241 return UINT32_MAX;
242}
243
244/**
245 * Convert an attestation type number to the corresponding attestation type string
246 *
247 * @param type number of a type
248 * @return corresponding typestring, NULL on error
249 */
250const char *
251GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type)
252{
253 unsigned int i;
254 struct Plugin *plugin;
255 const char *ret;
256
257 init ();
258 for (i = 0; i < num_plugins; i++)
259 {
260 plugin = attr_plugins[i];
261 if (NULL !=
262 (ret = plugin->api->number_to_typename_attest (plugin->api->cls, type)))
263 return ret;
264 }
265 return NULL;
266}
267/**
268 * Convert human-readable version of a 'claim' of an attestation to the binary
269 * representation
270 *
271 * @param type type of the claim
272 * @param s human-readable string
273 * @param data set to value in binary encoding (will be allocated)
274 * @param data_size set to number of bytes in @a data
275 * @return #GNUNET_OK on success
276 */
277int
278GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type,
279 const char *s,
280 void **data,
281 size_t *data_size)
282{
283 unsigned int i;
284 struct Plugin *plugin;
285
286 init ();
287 for (i = 0; i < num_plugins; i++)
288 {
289 plugin = attr_plugins[i];
290 if (GNUNET_OK == plugin->api->string_to_value_attest (plugin->api->cls,
291 type,
292 s,
293 data,
294 data_size))
295 return GNUNET_OK;
296 }
297 return GNUNET_SYSERR;
298}
299
300
301/**
302 * Convert the 'claim' of an attestation to a string
303 *
304 * @param type the type of attestation
305 * @param data claim in binary encoding
306 * @param data_size number of bytes in @a data
307 * @return NULL on error, otherwise human-readable representation of the claim
308 */
309char *
310GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type,
311 const void *data,
312 size_t data_size)
313{
314 unsigned int i;
315 struct Plugin *plugin;
316 char *ret;
317
318 init ();
319 for (i = 0; i < num_plugins; i++)
320 {
321 plugin = attr_plugins[i];
322 if (NULL != (ret = plugin->api->value_to_string_attest (plugin->api->cls,
323 type,
324 data,
325 data_size)))
326 return ret;
327 }
328 return NULL;
329}
330 220
331/** 221/**
332 * Create a new attribute. 222 * Create a new attribute.
333 * 223 *
334 * @param attr_name the attribute name 224 * @param attr_name the attribute name
225 * @param attestation attestation ID of the attribute (maybe NULL)
335 * @param type the attribute type 226 * @param type the attribute type
336 * @param data the attribute value 227 * @param data the attribute value
337 * @param data_size the attribute value size 228 * @param data_size the attribute value size
338 * @return the new attribute 229 * @return the new attribute
339 */ 230 */
340struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 231struct GNUNET_RECLAIM_Attribute *
341GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, 232GNUNET_RECLAIM_attribute_new (const char *attr_name,
342 uint32_t type, 233 const struct GNUNET_RECLAIM_Identifier *attestation,
343 const void *data, 234 uint32_t type,
344 size_t data_size) 235 const void *data,
236 size_t data_size)
345{ 237{
346 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 238 struct GNUNET_RECLAIM_Attribute *attr;
347 char *write_ptr; 239 char *write_ptr;
348 char *attr_name_tmp = GNUNET_strdup (attr_name); 240 char *attr_name_tmp = GNUNET_strdup (attr_name);
349 241
350 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp); 242 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
351 243
352 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) 244 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
353 + strlen (attr_name_tmp) + 1 + data_size); 245 + strlen (attr_name_tmp) + 1 + data_size);
246 if (NULL != attestation)
247 attr->attestation = *attestation;
354 attr->type = type; 248 attr->type = type;
355 attr->data_size = data_size; 249 attr->data_size = data_size;
356 attr->flag = 0; 250 attr->flag = 0;
@@ -364,76 +258,6 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
364 return attr; 258 return attr;
365} 259}
366 260
367/**
368 * Create a new attestation.
369 *
370 * @param attr_name the attestation name
371 * @param type the attestation type
372 * @param data the attestation value
373 * @param data_size the attestation value size
374 * @return the new attestation
375 */
376struct GNUNET_RECLAIM_ATTESTATION_Claim *
377GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name,
378 uint32_t type,
379 const void *data,
380 size_t data_size)
381{
382 struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
383 char *write_ptr;
384 char *attr_name_tmp = GNUNET_strdup (attr_name);
385
386 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
387
388 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
389 + strlen (attr_name_tmp) + 1 + data_size);
390 attr->type = type;
391 attr->data_size = data_size;
392 attr->flag = 0;
393 write_ptr = (char *) &attr[1];
394 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
395 attr->name = write_ptr;
396 write_ptr += strlen (attr->name) + 1;
397 GNUNET_memcpy (write_ptr, data, data_size);
398 attr->data = write_ptr;
399 GNUNET_free (attr_name_tmp);
400 return attr;
401}
402
403/**
404 * Create a new attestation reference.
405 *
406 * @param attr_name the referenced claim name
407 * @param ref_value the claim name in the attestation
408 * @return the new reference
409 */
410struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
411GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
412 const char *ref_value)
413{
414 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
415 char *write_ptr;
416 char *attr_name_tmp = GNUNET_strdup (attr_name);
417 char *ref_value_tmp = GNUNET_strdup (ref_value);
418
419 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
420 GNUNET_STRINGS_utf8_tolower (ref_value, ref_value_tmp);
421
422 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE)
423 + strlen (attr_name_tmp) + strlen (ref_value_tmp) + 2);
424
425 write_ptr = (char *) &attr[1];
426 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
427 attr->name = write_ptr;
428
429 write_ptr += strlen (attr_name) + 1;
430 GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1);
431 attr->reference_value = write_ptr;
432
433 GNUNET_free (attr_name_tmp);
434 GNUNET_free (ref_value_tmp);
435 return attr;
436}
437 261
438/** 262/**
439 * Add a new attribute to a claim list 263 * Add a new attribute to a claim list
@@ -444,21 +268,23 @@ GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
444 * @param data_size claim payload size 268 * @param data_size claim payload size
445 */ 269 */
446void 270void
447GNUNET_RECLAIM_ATTRIBUTE_list_add ( 271GNUNET_RECLAIM_attribute_list_add (
448 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list, 272 struct GNUNET_RECLAIM_AttributeList *al,
449 const char *attr_name, 273 const char *attr_name,
274 const struct GNUNET_RECLAIM_Identifier *attestation,
450 uint32_t type, 275 uint32_t type,
451 const void *data, 276 const void *data,
452 size_t data_size) 277 size_t data_size)
453{ 278{
454 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 279 struct GNUNET_RECLAIM_AttributeListEntry *ale;
455 280
456 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 281 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
457 le->claim = 282 ale->attribute =
458 GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); 283 GNUNET_RECLAIM_attribute_new (attr_name, attestation,
459 GNUNET_CONTAINER_DLL_insert (claim_list->list_head, 284 type, data, data_size);
460 claim_list->list_tail, 285 GNUNET_CONTAINER_DLL_insert (al->list_head,
461 le); 286 al->list_tail,
287 ale);
462} 288}
463 289
464 290
@@ -469,36 +295,17 @@ GNUNET_RECLAIM_ATTRIBUTE_list_add (
469 * @return the required buffer size 295 * @return the required buffer size
470 */ 296 */
471size_t 297size_t
472GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( 298GNUNET_RECLAIM_attribute_list_serialize_get_size (
473 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 299 const struct GNUNET_RECLAIM_AttributeList *al)
474{ 300{
475 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 301 struct GNUNET_RECLAIM_AttributeListEntry *ale;
476 size_t len = 0; 302 size_t len = 0;
477 303
478 for (le = attrs->list_head; NULL != le; le = le->next) 304 for (ale = al->list_head; NULL != ale; ale = ale->next)
479 { 305 {
480 if (NULL != le->claim) 306 GNUNET_assert (NULL != ale->attribute);
481 { 307 len += GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute);
482 len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType); 308 len += sizeof(struct GNUNET_RECLAIM_AttributeListEntry);
483 len += GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
484 }
485 else if (NULL != le->attest )
486 {
487 len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
488 len += GNUNET_RECLAIM_ATTESTATION_serialize_get_size (le->attest);
489 }
490 else if (NULL != le->reference)
491 {
492 len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
493 len += GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (le->reference);
494 }
495 else
496 {
497 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
498 "Unserialized Claim List Entry Type for size not known.\n");
499 break;
500 }
501 len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
502 } 309 }
503 return len; 310 return len;
504} 311}
@@ -512,58 +319,22 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
512 * @return length of serialized data 319 * @return length of serialized data
513 */ 320 */
514size_t 321size_t
515GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( 322GNUNET_RECLAIM_attribute_list_serialize (
516 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 323 const struct GNUNET_RECLAIM_AttributeList *al,
517 char *result) 324 char *result)
518{ 325{
519 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 326 struct GNUNET_RECLAIM_AttributeListEntry *ale;
520 size_t len; 327 size_t len;
521 size_t total_len; 328 size_t total_len;
522 char *write_ptr; 329 char *write_ptr;
523 write_ptr = result; 330 write_ptr = result;
524 total_len = 0; 331 total_len = 0;
525 for (le = attrs->list_head; NULL != le; le = le->next) 332 for (ale = al->list_head; NULL != ale; ale = ale->next)
526 { 333 {
527 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *list_type; 334 GNUNET_assert (NULL != ale->attribute);
528 if (NULL != le->claim) 335 len = GNUNET_RECLAIM_attribute_serialize (ale->attribute, write_ptr);
529 { 336 total_len += len;
530 list_type = (struct 337 write_ptr += len;
531 GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
532 list_type->type = htons (1);
533 total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
534 write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
535 len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
536 total_len += len;
537 write_ptr += len;
538 }
539 else if (NULL != le->attest )
540 {
541 list_type = (struct
542 GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
543 list_type->type = htons (2);
544 total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
545 write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
546 len = GNUNET_RECLAIM_ATTESTATION_serialize (le->attest, write_ptr);
547 total_len += len;
548 write_ptr += len;
549 }
550 else if (NULL != le->reference)
551 {
552 list_type = (struct
553 GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
554 list_type->type = htons (3);
555 total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
556 write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
557 len = GNUNET_RECLAIM_ATTESTATION_REF_serialize (le->reference, write_ptr);
558 total_len += len;
559 write_ptr += len;
560 }
561 else
562 {
563 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
564 "Unserialized Claim List Entry Type not known.\n");
565 continue;
566 }
567 } 338 }
568 return total_len; 339 return total_len;
569} 340}
@@ -576,85 +347,30 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
576 * @param data_size the length of the serialized data 347 * @param data_size the length of the serialized data
577 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller 348 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
578 */ 349 */
579struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 350struct GNUNET_RECLAIM_AttributeList *
580GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size) 351GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size)
581{ 352{
582 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 353 struct GNUNET_RECLAIM_AttributeList *al;
583 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 354 struct GNUNET_RECLAIM_AttributeListEntry *ale;
584 size_t attr_len; 355 size_t attr_len;
585 const char *read_ptr; 356 const char *read_ptr;
586 357
587 if ((data_size < sizeof(struct Attribute) + sizeof(struct 358 al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
588 GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) 359 if (data_size < sizeof(struct Attribute) + sizeof(struct
589 && (data_size < sizeof(struct 360 GNUNET_RECLAIM_AttributeListEntry))
590 Attestation) 361 return al;
591 + sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) &&
592 (data_size < sizeof(struct Attestation_Reference) + sizeof(struct
593 GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) )
594 return NULL;
595
596 attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
597 read_ptr = data; 362 read_ptr = data;
598 while (((data + data_size) - read_ptr) >= sizeof(struct Attribute)) 363 while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
599 { 364 {
600 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *list_type; 365 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
601 list_type = (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) read_ptr; 366 ale->attribute =
602 if (1 == ntohs (list_type->type)) 367 GNUNET_RECLAIM_attribute_deserialize (read_ptr,
603 { 368 data_size - (read_ptr - data));
604 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 369 GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
605 read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType); 370 attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute);
606 if (((data + data_size) - read_ptr) < sizeof(struct Attribute)) 371 read_ptr += attr_len;
607 break;
608 le->attest = NULL;
609 le->reference = NULL;
610 le->claim =
611 GNUNET_RECLAIM_ATTRIBUTE_deserialize (read_ptr,
612 data_size - (read_ptr - data));
613 GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
614 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
615 read_ptr += attr_len;
616 }
617 else if (2 == ntohs (list_type->type))
618 {
619 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
620 read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
621 if (((data + data_size) - read_ptr) < sizeof(struct Attestation))
622 break;
623 le->claim = NULL;
624 le->reference = NULL;
625 le->attest =
626 GNUNET_RECLAIM_ATTESTATION_deserialize (read_ptr,
627 data_size - (read_ptr - data));
628 GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
629 attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (le->attest);
630 read_ptr += attr_len;
631 }
632 else if (3 == ntohs (list_type->type))
633 {
634 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
635 read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
636 if (((data + data_size) - read_ptr) < sizeof(struct
637 Attestation_Reference))
638 break;
639 le->claim = NULL;
640 le->attest = NULL;
641 le->reference =
642 GNUNET_RECLAIM_ATTESTATION_REF_deserialize (read_ptr,
643 data_size - (read_ptr
644 - data));
645 GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
646 attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
647 le->reference);
648 read_ptr += attr_len;
649 }
650 else
651 {
652 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
653 "Serialized Claim List Entry Type not known.\n");
654 break;
655 }
656 } 372 }
657 return attrs; 373 return al;
658} 374}
659 375
660 376
@@ -663,57 +379,33 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size)
663 * @param attrs claim list to copy 379 * @param attrs claim list to copy
664 * @return copied claim list 380 * @return copied claim list
665 */ 381 */
666struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 382struct GNUNET_RECLAIM_AttributeList *
667GNUNET_RECLAIM_ATTRIBUTE_list_dup ( 383GNUNET_RECLAIM_attribute_list_dup (
668 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 384 const struct GNUNET_RECLAIM_AttributeList *al)
669{ 385{
670 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 386 struct GNUNET_RECLAIM_AttributeListEntry *ale;
671 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le; 387 struct GNUNET_RECLAIM_AttributeListEntry *result_ale;
672 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result; 388 struct GNUNET_RECLAIM_AttributeList *result;
673 389
674 result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 390 result = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
675 if (NULL == attrs->list_head) 391 for (ale = al->list_head; NULL != ale; ale = ale->next)
676 { 392 {
677 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Duplicating empty List\n"); 393 result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
678 } 394 GNUNET_assert (NULL != ale->attribute);
679 for (le = attrs->list_head; NULL != le; le = le->next)
680 {
681 result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
682 result_le->claim = NULL;
683 result_le->attest = NULL;
684 result_le->reference = NULL;
685 if (NULL != le->claim)
686 {
687 result_le->claim =
688 GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name,
689 le->claim->type,
690 le->claim->data,
691 le->claim->data_size);
692
693 result_le->claim->id = le->claim->id;
694 result_le->claim->flag = le->claim->flag;
695 }
696 if ( NULL != le->attest)
697 {
698 result_le->attest = GNUNET_RECLAIM_ATTESTATION_claim_new (
699 le->attest->name,
700 le->attest->type,
701 le->attest->data,
702 le->attest->
703 data_size);
704 result_le->attest->id = le->attest->id;
705 }
706 if (NULL !=le->reference)
707 { 395 {
708 result_le->reference = GNUNET_RECLAIM_ATTESTATION_reference_new ( 396 result_ale->attribute =
709 le->reference->name, 397 GNUNET_RECLAIM_attribute_new (ale->attribute->name,
710 le->reference->reference_value); 398 &ale->attribute->attestation,
711 result_le->reference->id = le->reference->id; 399 ale->attribute->type,
712 result_le->reference->id_attest = le->reference->id_attest; 400 ale->attribute->data,
401 ale->attribute->data_size);
402
403 result_ale->attribute->id = ale->attribute->id;
404 result_ale->attribute->flag = ale->attribute->flag;
713 } 405 }
714 GNUNET_CONTAINER_DLL_insert (result->list_head, 406 GNUNET_CONTAINER_DLL_insert (result->list_head,
715 result->list_tail, 407 result->list_tail,
716 result_le); 408 result_ale);
717 } 409 }
718 return result; 410 return result;
719} 411}
@@ -725,45 +417,24 @@ GNUNET_RECLAIM_ATTRIBUTE_list_dup (
725 * @param attrs list to destroy 417 * @param attrs list to destroy
726 */ 418 */
727void 419void
728GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( 420GNUNET_RECLAIM_attribute_list_destroy (
729 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 421 struct GNUNET_RECLAIM_AttributeList *al)
730{ 422{
731 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 423 struct GNUNET_RECLAIM_AttributeListEntry *ale;
732 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le; 424 struct GNUNET_RECLAIM_AttributeListEntry *tmp_ale;
733 425
734 for (le = attrs->list_head; NULL != le; le = le->next) 426 for (ale = al->list_head; NULL != ale; ale = ale->next)
735 { 427 {
736 if (NULL != le->claim) 428 if (NULL != ale->attribute)
737 GNUNET_free (le->claim); 429 GNUNET_free (ale->attribute);
738 if (NULL != le->attest) 430 tmp_ale = ale;
739 GNUNET_free (le->attest); 431 ale = ale->next;
740 if (NULL != le->reference) 432 GNUNET_free (tmp_ale);
741 GNUNET_free (le->reference);
742 tmp_le = le;
743 le = le->next;
744 GNUNET_free (tmp_le);
745 } 433 }
746 GNUNET_free (attrs); 434 GNUNET_free (al);
747} 435}
748 436
749/** 437
750 * Count attestations in claim list
751 *
752 * @param attrs list
753 */
754int
755GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (
756 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
757{
758 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
759 int i = 0;
760 for (le = attrs->list_head; NULL != le; le = le->next)
761 {
762 if (NULL != le->attest)
763 i++;
764 }
765 return i;
766}
767/** 438/**
768 * Get required size for serialization buffer 439 * Get required size for serialization buffer
769 * 440 *
@@ -771,8 +442,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (
771 * @return the required buffer size 442 * @return the required buffer size
772 */ 443 */
773size_t 444size_t
774GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( 445GNUNET_RECLAIM_attribute_serialize_get_size (
775 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 446 const struct GNUNET_RECLAIM_Attribute *attr)
776{ 447{
777 return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size; 448 return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
778} 449}
@@ -786,8 +457,8 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
786 * @return length of serialized data 457 * @return length of serialized data
787 */ 458 */
788size_t 459size_t
789GNUNET_RECLAIM_ATTRIBUTE_serialize ( 460GNUNET_RECLAIM_attribute_serialize (
790 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 461 const struct GNUNET_RECLAIM_Attribute *attr,
791 char *result) 462 char *result)
792{ 463{
793 size_t data_len_ser; 464 size_t data_len_ser;
@@ -823,10 +494,10 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize (
823 * 494 *
824 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller 495 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
825 */ 496 */
826struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 497struct GNUNET_RECLAIM_Attribute *
827GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) 498GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size)
828{ 499{
829 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 500 struct GNUNET_RECLAIM_Attribute *attr;
830 struct Attribute *attr_ser; 501 struct Attribute *attr_ser;
831 size_t data_len; 502 size_t data_len;
832 size_t name_len; 503 size_t name_len;
@@ -844,7 +515,7 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
844 "Buffer too small to deserialize\n"); 515 "Buffer too small to deserialize\n");
845 return NULL; 516 return NULL;
846 } 517 }
847 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) 518 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
848 + data_len + name_len + 1); 519 + data_len + name_len + 1);
849 attr->type = ntohs (attr_ser->attribute_type); 520 attr->type = ntohs (attr_ser->attribute_type);
850 attr->flag = ntohl (attr_ser->attribute_flag); 521 attr->flag = ntohl (attr_ser->attribute_flag);
@@ -863,193 +534,4 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
863} 534}
864 535
865 536
866/**
867 * Get required size for serialization buffer
868 *
869 * @param attr the attestation to serialize
870 * @return the required buffer size
871 */
872size_t
873GNUNET_RECLAIM_ATTESTATION_serialize_get_size (
874 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
875{
876 return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
877}
878
879/**
880 * Serialize an attestation
881 *
882 * @param attr the attestation to serialize
883 * @param result the serialized attestation
884 * @return length of serialized data
885 */
886size_t
887GNUNET_RECLAIM_ATTESTATION_serialize (
888 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
889 char *result)
890{
891 size_t data_len_ser;
892 size_t name_len;
893 struct Attestation *attr_ser;
894 char *write_ptr;
895
896 attr_ser = (struct Attestation *) result;
897 attr_ser->attestation_type = htons (attr->type);
898 attr_ser->attestation_flag = htonl (attr->flag);
899 attr_ser->attestation_id = attr->id;
900 name_len = strlen (attr->name);
901 attr_ser->name_len = htons (name_len);
902 write_ptr = (char *) &attr_ser[1];
903 GNUNET_memcpy (write_ptr, attr->name, name_len);
904 write_ptr += name_len;
905 // TODO plugin-ize
906 // data_len_ser = plugin->serialize_attribute_value (attr,
907 // &attr_ser[1]);
908 data_len_ser = attr->data_size;
909 GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
910 attr_ser->data_size = htons (data_len_ser);
911
912 return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
913}
914
915/**
916 * Deserialize an attestation
917 *
918 * @param data the serialized attestation
919 * @param data_size the length of the serialized data
920 *
921 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
922 */
923struct GNUNET_RECLAIM_ATTESTATION_Claim *
924GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size)
925{
926 struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
927 struct Attestation *attr_ser;
928 size_t data_len;
929 size_t name_len;
930 char *write_ptr;
931
932 if (data_size < sizeof(struct Attestation))
933 return NULL;
934
935 attr_ser = (struct Attestation *) data;
936 data_len = ntohs (attr_ser->data_size);
937 name_len = ntohs (attr_ser->name_len);
938 if (data_size < sizeof(struct Attestation) + data_len + name_len)
939 {
940 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
941 "Buffer too small to deserialize\n");
942 return NULL;
943 }
944 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
945 + data_len + name_len + 1);
946 attr->type = ntohs (attr_ser->attestation_type);
947 attr->flag = ntohl (attr_ser->attestation_flag);
948 attr->id = attr_ser->attestation_id;
949 attr->data_size = data_len;
950
951 write_ptr = (char *) &attr[1];
952 GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
953 write_ptr[name_len] = '\0';
954 attr->name = write_ptr;
955
956 write_ptr += name_len + 1;
957 GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
958 attr->data = write_ptr;
959 return attr;
960}
961
962/**
963 * Get required size for serialization buffer
964 *
965 * @param attr the reference to serialize
966 * @return the required buffer size
967 */
968size_t
969GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
970 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
971{
972 return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
973 attr->reference_value);
974}
975
976
977/**
978 * Serialize a reference
979 *
980 * @param attr the reference to serialize
981 * @param result the serialized reference
982 * @return length of serialized data
983 */
984size_t
985GNUNET_RECLAIM_ATTESTATION_REF_serialize (
986 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
987 char *result)
988{
989 size_t name_len;
990 size_t refval_len;
991 struct Attestation_Reference *attr_ser;
992 char *write_ptr;
993 attr_ser = (struct Attestation_Reference *) result;
994 attr_ser->reference_id = attr->id;
995 attr_ser->attestation_id = attr->id_attest;
996 name_len = strlen (attr->name);
997 refval_len = strlen (attr->reference_value);
998 attr_ser->name_len = htons (name_len);
999 attr_ser->ref_value_len = htons (refval_len);
1000 write_ptr = (char *) &attr_ser[1];
1001 GNUNET_memcpy (write_ptr, attr->name, name_len);
1002 write_ptr += name_len;
1003 GNUNET_memcpy (write_ptr, attr->reference_value, refval_len);
1004
1005 return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
1006 attr->reference_value);
1007}
1008
1009
1010/**
1011 * Deserialize a reference
1012 *
1013 * @param data the serialized reference
1014 * @param data_size the length of the serialized data
1015 *
1016 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
1017 */
1018struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
1019GNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size)
1020{
1021 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
1022 struct Attestation_Reference *attr_ser;
1023 size_t name_len;
1024 size_t refval_len;
1025 char *write_ptr;
1026
1027 if (data_size < sizeof(struct Attestation_Reference))
1028 return NULL;
1029 attr_ser = (struct Attestation_Reference *) data;
1030 name_len = ntohs (attr_ser->name_len);
1031 refval_len = ntohs (attr_ser->ref_value_len);
1032 if (data_size < sizeof(struct Attestation_Reference) + refval_len + name_len)
1033 {
1034 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1035 "Buffer too small to deserialize\n");
1036 return NULL;
1037 }
1038 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE)
1039 + refval_len + name_len + 2);
1040
1041 attr->id = attr_ser->reference_id;
1042 attr->id_attest = attr_ser->attestation_id;
1043
1044 write_ptr = (char *) &attr[1];
1045 GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
1046 write_ptr[name_len] = '\0';
1047 attr->name = write_ptr;
1048
1049 write_ptr += name_len + 1;
1050 GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, refval_len);
1051 write_ptr[refval_len] = '\0';
1052 attr->reference_value = write_ptr;
1053 return attr;
1054}
1055/* end of reclaim_attribute.c */ 537/* end of reclaim_attribute.c */
diff --git a/src/reclaim-attribute/reclaim_attribute.h b/src/reclaim-attribute/reclaim_attribute.h
index 0746df48e..e54b210b9 100644
--- a/src/reclaim-attribute/reclaim_attribute.h
+++ b/src/reclaim-attribute/reclaim_attribute.h
@@ -49,6 +49,11 @@ struct Attribute
49 struct GNUNET_RECLAIM_Identifier attribute_id; 49 struct GNUNET_RECLAIM_Identifier attribute_id;
50 50
51 /** 51 /**
52 * Attestation ID
53 */
54 struct GNUNET_RECLAIM_Identifier attestation_id;
55
56 /**
52 * Name length 57 * Name length
53 */ 58 */
54 uint32_t name_len; 59 uint32_t name_len;
@@ -94,33 +99,4 @@ struct Attestation
94 // followed by data_size Attestation value data 99 // followed by data_size Attestation value data
95}; 100};
96 101
97/**
98 * Serialized attestation reference
99 */
100struct Attestation_Reference
101{
102 /**
103 * Reference ID
104 */
105 struct GNUNET_RECLAIM_Identifier reference_id;
106
107 /**
108 * The ID of the referenced attestation
109 */
110 struct GNUNET_RECLAIM_Identifier attestation_id;
111
112 /**
113 * Claim Name length
114 */
115 uint32_t name_len;
116
117 /**
118 * Length of the referenced value
119 */
120 uint32_t ref_value_len;
121
122
123 // followed by the name and referenced value
124};
125
126#endif 102#endif
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index c3d305eb5..b72336907 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -135,7 +135,7 @@ static struct GNUNET_RECLAIM_Ticket ticket;
135/** 135/**
136 * Attribute list 136 * Attribute list
137 */ 137 */
138static struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; 138static struct GNUNET_RECLAIM_AttributeList *attr_list;
139 139
140/** 140/**
141 * Attribute expiration interval 141 * Attribute expiration interval
@@ -155,7 +155,7 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task;
155/** 155/**
156 * Claim to store 156 * Claim to store
157 */ 157 */
158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 158struct GNUNET_RECLAIM_Attribute *claim;
159 159
160/** 160/**
161 * Claim to delete 161 * Claim to delete
@@ -165,7 +165,7 @@ static char *attr_delete;
165/** 165/**
166 * Claim object to delete 166 * Claim object to delete
167 */ 167 */
168static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete; 168static struct GNUNET_RECLAIM_Attribute *attr_to_delete;
169 169
170static void 170static void
171do_cleanup (void *cls) 171do_cleanup (void *cls)
@@ -226,9 +226,8 @@ store_attr_cont (void *cls, int32_t success, const char *emsg)
226static void 226static void
227process_attrs (void *cls, 227process_attrs (void *cls,
228 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 228 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
229 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 229 const struct GNUNET_RECLAIM_Attribute *attr,
230 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 230 const struct GNUNET_RECLAIM_Attestation *attest)
231 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
232{ 231{
233 char *value_str; 232 char *value_str;
234 char *id; 233 char *id;
@@ -245,18 +244,19 @@ process_attrs (void *cls,
245 ret = 1; 244 ret = 1;
246 return; 245 return;
247 } 246 }
248 value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 247 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
249 attr->data, 248 attr->data,
250 attr->data_size); 249 attr->data_size);
251 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 250 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
252 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 251 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
253 fprintf (stdout, 252 fprintf (stdout,
254 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", 253 "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
255 attr->name, 254 attr->name,
256 value_str, 255 value_str,
257 attr_type, 256 attr_type,
258 attr->flag, 257 attr->flag,
259 id); 258 id,
259 (NULL == attest) ? "" : "ATTESTED");
260 GNUNET_free (id); 260 GNUNET_free (id);
261} 261}
262 262
@@ -412,10 +412,10 @@ iter_finished (void *cls)
412 if (NULL == type_str) 412 if (NULL == type_str)
413 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; 413 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
414 else 414 else
415 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); 415 type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
416 416
417 GNUNET_assert (GNUNET_SYSERR != 417 GNUNET_assert (GNUNET_SYSERR !=
418 GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, 418 GNUNET_RECLAIM_attribute_string_to_value (type,
419 attr_value, 419 attr_value,
420 (void **) &data, 420 (void **) &data,
421 &data_size)); 421 &data_size));
@@ -428,7 +428,7 @@ iter_finished (void *cls)
428 else 428 else
429 { 429 {
430 claim = 430 claim =
431 GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); 431 GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
432 } 432 }
433 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, 433 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
434 pkey, 434 pkey,
@@ -447,11 +447,10 @@ iter_finished (void *cls)
447static void 447static void
448iter_cb (void *cls, 448iter_cb (void *cls,
449 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 449 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
450 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 450 const struct GNUNET_RECLAIM_Attribute *attr,
451 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 451 const struct GNUNET_RECLAIM_Attestation *attest)
452 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
453{ 452{
454 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 453 struct GNUNET_RECLAIM_AttributeListEntry *le;
455 char *attrs_tmp; 454 char *attrs_tmp;
456 char *attr_str; 455 char *attr_str;
457 char *label; 456 char *label;
@@ -462,10 +461,11 @@ iter_cb (void *cls,
462 { 461 {
463 if (0 == strcasecmp (attr_name, attr->name)) 462 if (0 == strcasecmp (attr_name, attr->name))
464 { 463 {
465 claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, 464 claim = GNUNET_RECLAIM_attribute_new (attr->name,
466 attr->type, 465 &attr->attestation,
467 attr->data, 466 attr->type,
468 attr->data_size); 467 attr->data,
468 attr->data_size);
469 } 469 }
470 } 470 }
471 else if (issue_attrs) 471 else if (issue_attrs)
@@ -479,13 +479,14 @@ iter_cb (void *cls,
479 attr_str = strtok (NULL, ","); 479 attr_str = strtok (NULL, ",");
480 continue; 480 continue;
481 } 481 }
482 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 482 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
483 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, 483 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
484 attr->type, 484 &attr->attestation,
485 attr->data, 485 attr->type,
486 attr->data_size); 486 attr->data,
487 le->claim->flag = attr->flag; 487 attr->data_size);
488 le->claim->id = attr->id; 488 le->attribute->flag = attr->flag;
489 le->attribute->id = attr->id;
489 GNUNET_CONTAINER_DLL_insert (attr_list->list_head, 490 GNUNET_CONTAINER_DLL_insert (attr_list->list_head,
490 attr_list->list_tail, 491 attr_list->list_tail,
491 le); 492 le);
@@ -498,20 +499,21 @@ iter_cb (void *cls,
498 label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 499 label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
499 if (0 == strcasecmp (attr_delete, label)) 500 if (0 == strcasecmp (attr_delete, label))
500 { 501 {
501 attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, 502 attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
502 attr->type, 503 &attr->attestation,
503 attr->data, 504 attr->type,
504 attr->data_size); 505 attr->data,
506 attr->data_size);
505 attr_to_delete->id = attr->id; 507 attr_to_delete->id = attr->id;
506 } 508 }
507 GNUNET_free (label); 509 GNUNET_free (label);
508 } 510 }
509 else if (list) 511 else if (list)
510 { 512 {
511 attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 513 attr_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
512 attr->data, 514 attr->data,
513 attr->data_size); 515 attr->data_size);
514 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 516 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
515 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 517 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
516 fprintf (stdout, 518 fprintf (stdout,
517 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", 519 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
@@ -568,7 +570,7 @@ start_process ()
568 &ticket, 570 &ticket,
569 sizeof(struct GNUNET_RECLAIM_Ticket)); 571 sizeof(struct GNUNET_RECLAIM_Ticket));
570 572
571 attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 573 attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
572 claim = NULL; 574 claim = NULL;
573 attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, 575 attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
574 pkey, 576 pkey,
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index a00bc5730..15f9a8385 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -263,18 +263,14 @@ struct AttributeDeleteHandle
263 /** 263 /**
264 * The attribute to delete 264 * The attribute to delete
265 */ 265 */
266 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 266 struct GNUNET_RECLAIM_Attribute *claim;
267 267
268 /** 268 /**
269 * The attestation to delete 269 * The attestation to delete
270 */ 270 */
271 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 271 struct GNUNET_RECLAIM_Attestation *attest;
272 272
273 /** 273 /**
274 * The reference to delete
275 */
276 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
277 /**
278 * Tickets to update 274 * Tickets to update
279 */ 275 */
280 struct TicketRecordsEntry *tickets_to_update_head; 276 struct TicketRecordsEntry *tickets_to_update_head;
@@ -334,17 +330,12 @@ struct AttributeStoreHandle
334 /** 330 /**
335 * The attribute to store 331 * The attribute to store
336 */ 332 */
337 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 333 struct GNUNET_RECLAIM_Attribute *claim;
338 334
339 /** 335 /**
340 * The attestation to store 336 * The attestation to store
341 */ 337 */
342 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 338 struct GNUNET_RECLAIM_Attestation *attest;
343
344 /**
345 * The reference to store
346 */
347 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
348 339
349 /** 340 /**
350 * The attribute expiration interval 341 * The attribute expiration interval
@@ -480,8 +471,6 @@ cleanup_adh (struct AttributeDeleteHandle *adh)
480 GNUNET_free (adh->claim); 471 GNUNET_free (adh->claim);
481 if (NULL != adh->attest) 472 if (NULL != adh->attest)
482 GNUNET_free (adh->attest); 473 GNUNET_free (adh->attest);
483 if (NULL != adh->reference)
484 GNUNET_free (adh->reference);
485 while (NULL != (le = adh->tickets_to_update_head)) 474 while (NULL != (le = adh->tickets_to_update_head))
486 { 475 {
487 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, 476 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
@@ -511,8 +500,6 @@ cleanup_as_handle (struct AttributeStoreHandle *ash)
511 GNUNET_free (ash->claim); 500 GNUNET_free (ash->claim);
512 if (NULL != ash->attest) 501 if (NULL != ash->attest)
513 GNUNET_free (ash->attest); 502 GNUNET_free (ash->attest);
514 if (NULL != ash->reference)
515 GNUNET_free (ash->reference);
516 GNUNET_free (ash); 503 GNUNET_free (ash);
517} 504}
518 505
@@ -718,13 +705,13 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
718{ 705{
719 struct TicketIssueOperation *tio; 706 struct TicketIssueOperation *tio;
720 struct IdpClient *idp = cls; 707 struct IdpClient *idp = cls;
721 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 708 struct GNUNET_RECLAIM_AttributeList *attrs;
722 size_t attrs_len; 709 size_t attrs_len;
723 710
724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); 711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
725 tio = GNUNET_new (struct TicketIssueOperation); 712 tio = GNUNET_new (struct TicketIssueOperation);
726 attrs_len = ntohs (im->attr_len); 713 attrs_len = ntohs (im->attr_len);
727 attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1], 714 attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1],
728 attrs_len); 715 attrs_len);
729 tio->r_id = ntohl (im->id); 716 tio->r_id = ntohl (im->id);
730 tio->client = idp; 717 tio->client = idp;
@@ -735,7 +722,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
735 &issue_ticket_result_cb, 722 &issue_ticket_result_cb,
736 tio); 723 tio);
737 GNUNET_SERVICE_client_continue (idp->client); 724 GNUNET_SERVICE_client_continue (idp->client);
738 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 725 GNUNET_RECLAIM_attribute_list_destroy (attrs);
739} 726}
740 727
741 728
@@ -828,7 +815,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
828static void 815static void
829consume_result_cb (void *cls, 816consume_result_cb (void *cls,
830 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 817 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
831 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 818 const struct GNUNET_RECLAIM_AttributeList *attrs,
832 int32_t success, 819 int32_t success,
833 const char *emsg) 820 const char *emsg)
834{ 821{
@@ -842,7 +829,7 @@ consume_result_cb (void *cls,
842 { 829 {
843 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); 830 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
844 } 831 }
845 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); 832 attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 833 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
847 "Sending CONSUME_TICKET_RESULT message\n"); 834 "Sending CONSUME_TICKET_RESULT message\n");
848 env = GNUNET_MQ_msg_extra (crm, 835 env = GNUNET_MQ_msg_extra (crm,
@@ -853,7 +840,7 @@ consume_result_cb (void *cls,
853 crm->identity = *identity; 840 crm->identity = *identity;
854 crm->result = htonl (success); 841 crm->result = htonl (success);
855 data_tmp = (char *) &crm[1]; 842 data_tmp = (char *) &crm[1];
856 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp); 843 GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
857 GNUNET_MQ_send (cop->client->mq, env); 844 GNUNET_MQ_send (cop->client->mq, env);
858 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, 845 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
859 cop->client->consume_op_tail, 846 cop->client->consume_op_tail,
@@ -965,20 +952,20 @@ attr_store_task (void *cls)
965 size_t buf_size; 952 size_t buf_size;
966 953
967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); 954 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
968 buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); 955 buf_size = GNUNET_RECLAIM_attribute_serialize_get_size (ash->claim);
969 buf = GNUNET_malloc (buf_size); 956 buf = GNUNET_malloc (buf_size);
970 // Give the ash a new id if unset 957 // Give the ash a new id if unset
971 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id)) 958 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id))
972 GNUNET_RECLAIM_id_generate (&ash->claim->id); 959 GNUNET_RECLAIM_id_generate (&ash->claim->id);
973 GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); 960 GNUNET_RECLAIM_attribute_serialize (ash->claim, buf);
974 label 961 label
975 = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, 962 = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id,
976 sizeof (ash->reference->id)); 963 sizeof (ash->claim->id));
977 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); 964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
978 965
979 rd[0].data_size = buf_size; 966 rd[0].data_size = buf_size;
980 rd[0].data = buf; 967 rd[0].data = buf;
981 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR; 968 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE;
982 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 969 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
983 rd[0].expiration_time = ash->exp.rel_value_us; 970 rd[0].expiration_time = ash->exp.rel_value_us;
984 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 971 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
@@ -1034,7 +1021,7 @@ handle_attribute_store_message (void *cls,
1034 data_len = ntohs (sam->attr_len); 1021 data_len = ntohs (sam->attr_len);
1035 1022
1036 ash = GNUNET_new (struct AttributeStoreHandle); 1023 ash = GNUNET_new (struct AttributeStoreHandle);
1037 ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1], 1024 ash->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1],
1038 data_len); 1025 data_len);
1039 1026
1040 ash->r_id = ntohl (sam->id); 1027 ash->r_id = ntohl (sam->id);
@@ -1088,32 +1075,6 @@ attest_store_cont (void *cls, int32_t success, const char *emsg)
1088 1075
1089 1076
1090/** 1077/**
1091 * Send a reference error response
1092 *
1093 * @param ash our attribute store handle
1094 * @param success the success status
1095 */
1096static void
1097send_ref_error (struct AttributeStoreHandle *ash)
1098{
1099 struct GNUNET_MQ_Envelope *env;
1100 struct SuccessResultMessage *acr_msg;
1101
1102 ash->ns_qe = NULL;
1103 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
1104 ash->client->store_op_tail,
1105 ash);
1106
1107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1108 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
1109 acr_msg->id = htonl (ash->r_id);
1110 acr_msg->op_result = htonl (GNUNET_SYSERR);
1111 GNUNET_MQ_send (ash->client->mq, env);
1112 cleanup_as_handle (ash);
1113}
1114
1115
1116/**
1117 * Error looking up potential attestation. Abort. 1078 * Error looking up potential attestation. Abort.
1118 * 1079 *
1119 * @param cls our attribute store handle 1080 * @param cls our attribute store handle
@@ -1131,7 +1092,7 @@ attest_error (void *cls)
1131 1092
1132 1093
1133/** 1094/**
1134* Check for existing record before storing reference 1095* Check for existing record before storing attestation
1135* 1096*
1136* @param cls our attribute store handle 1097* @param cls our attribute store handle
1137* @param zone zone we are iterating 1098* @param zone zone we are iterating
@@ -1149,56 +1110,27 @@ attest_add_cb (void *cls,
1149 struct AttributeStoreHandle *ash = cls; 1110 struct AttributeStoreHandle *ash = cls;
1150 char *buf; 1111 char *buf;
1151 size_t buf_size; 1112 size_t buf_size;
1152 buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest); 1113 buf_size = GNUNET_RECLAIM_attestation_serialize_get_size (ash->attest);
1153 buf = GNUNET_malloc (buf_size); 1114 buf = GNUNET_malloc (buf_size);
1154 GNUNET_RECLAIM_ATTESTATION_serialize (ash->attest, buf); 1115 GNUNET_RECLAIM_attestation_serialize (ash->attest, buf);
1155 if (0 == rd_count) 1116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1156 { 1117 "Storing new Attestation\n");
1157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1118 struct GNUNET_GNSRECORD_Data rd_new[1];
1158 "Storing new Attestation\n");
1159 struct GNUNET_GNSRECORD_Data rd_new[1];
1160 rd_new[0].data_size = buf_size;
1161 rd_new[0].data = buf;
1162 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR;
1163 rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1164 rd_new[0].expiration_time = ash->exp.rel_value_us;
1165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1166 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1167 &ash->identity,
1168 label,
1169 1,
1170 rd_new,
1171 &attest_store_cont,
1172 ash);
1173 GNUNET_free (buf);
1174 return;
1175 }
1176 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
1177 {
1178 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1179 "Existing Attestation location is not an Attestation\n");
1180 send_ref_error (ash);
1181 return;
1182 }
1183 struct GNUNET_GNSRECORD_Data rd_new[rd_count];
1184 for (int i = 0; i<rd_count; i++)
1185 {
1186 rd_new[i] = rd[i];
1187 }
1188 rd_new[0].data_size = buf_size; 1119 rd_new[0].data_size = buf_size;
1189 rd_new[0].data = buf; 1120 rd_new[0].data = buf;
1190 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR; 1121 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION;
1191 rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1122 rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1192 rd_new[0].expiration_time = ash->exp.rel_value_us; 1123 rd_new[0].expiration_time = ash->exp.rel_value_us;
1193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); 1124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1194 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 1125 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1195 &ash->identity, 1126 &ash->identity,
1196 label, 1127 label,
1197 rd_count, 1128 1,
1198 rd_new, 1129 rd_new,
1199 &attest_store_cont, 1130 &attest_store_cont,
1200 ash); 1131 ash);
1201 GNUNET_free (buf); 1132 GNUNET_free (buf);
1133 return;
1202} 1134}
1203 1135
1204 1136
@@ -1273,7 +1205,7 @@ handle_attestation_store_message (void *cls,
1273 data_len = ntohs (sam->attr_len); 1205 data_len = ntohs (sam->attr_len);
1274 1206
1275 ash = GNUNET_new (struct AttributeStoreHandle); 1207 ash = GNUNET_new (struct AttributeStoreHandle);
1276 ash->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &sam[1], 1208 ash->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &sam[1],
1277 data_len); 1209 data_len);
1278 1210
1279 ash->r_id = ntohl (sam->id); 1211 ash->r_id = ntohl (sam->id);
@@ -1289,250 +1221,6 @@ handle_attestation_store_message (void *cls,
1289 1221
1290 1222
1291/** 1223/**
1292 * Error looking up potential reference value. Abort.
1293 *
1294 * @param cls our attribute store handle
1295 */
1296static void
1297ref_error (void *cls)
1298{
1299 struct AttributeStoreHandle *ash = cls;
1300 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1301 "Failed to find Attestation entry for Attestation reference\n");
1302 cleanup_as_handle (ash);
1303 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1304 return;
1305}
1306
1307
1308/**
1309 * Error looking up potential reference value. Abort.
1310 *
1311 * @param cls our attribute delete handle
1312 */
1313static void
1314ref_del_error (void *cls)
1315{
1316 struct AttributeDeleteHandle *adh = cls;
1317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1318 "Failed to find Attestation entry for Attestation reference\n");
1319 cleanup_adh (adh);
1320 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1321 return;
1322}
1323
1324
1325/**
1326* Reference store result handler
1327*
1328* @param cls our attribute store handle
1329* @param success GNUNET_OK if successful
1330* @param emsg error message (NULL if success=GNUNET_OK)
1331*/
1332static void
1333reference_store_cont (void *cls, int32_t success, const char *emsg)
1334{
1335 struct AttributeStoreHandle *ash = cls;
1336 struct GNUNET_MQ_Envelope *env;
1337 struct SuccessResultMessage *acr_msg;
1338
1339 ash->ns_qe = NULL;
1340 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
1341 ash->client->store_op_tail,
1342 ash);
1343
1344 if (GNUNET_SYSERR == success)
1345 {
1346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1347 "Failed to store reference %s\n",
1348 emsg);
1349 cleanup_as_handle (ash);
1350 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1351 return;
1352 }
1353
1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1355 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
1356 acr_msg->id = htonl (ash->r_id);
1357 acr_msg->op_result = htonl (GNUNET_OK);
1358 GNUNET_MQ_send (ash->client->mq, env);
1359 cleanup_as_handle (ash);
1360}
1361
1362
1363/**
1364* Check for existing record before storing reference
1365*
1366* @param cls our attribute store handle
1367* @param zone zone we are iterating
1368* @param label label of the records
1369* @param rd_count record count
1370* @param rd records
1371*/
1372static void
1373ref_add_cb (void *cls,
1374 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1375 const char *label,
1376 unsigned int rd_count,
1377 const struct GNUNET_GNSRECORD_Data *rd)
1378{
1379 struct AttributeStoreHandle *ash = cls;
1380 char *buf;
1381 size_t buf_size;
1382 buf_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (ash->reference);
1383 buf = GNUNET_malloc (buf_size);
1384 GNUNET_RECLAIM_ATTESTATION_REF_serialize (ash->reference, buf);
1385 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
1386 char *data_tmp;
1387 if (0 == rd_count)
1388 {
1389 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1390 "Failed to find Attestation entry for Attestation reference\n");
1391 send_ref_error (ash);
1392 return;
1393 }
1394 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
1395 {
1396 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1397 "Intended Reference storage location is not an attestation\n");
1398 send_ref_error (ash);
1399 return;
1400 }
1401 struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
1402 int i;
1403 for (i = 0; i<rd_count; i++)
1404 {
1405 data_tmp = GNUNET_malloc (rd[i].data_size);
1406 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1407 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons (
1408 rd[i].data_size));
1409 rd_new[i] = rd[i];
1410 if ((strcmp (ash->reference->name,ref->name) == 0) &&
1411 (strcmp (ash->reference->reference_value,ref->reference_value)==0) )
1412 {
1413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1414 "Reference already stored\n");
1415 reference_store_cont (ash,GNUNET_OK, NULL);
1416 return;
1417 }
1418 }
1419 rd_new[rd_count].data_size = buf_size;
1420 rd_new[rd_count].data = buf;
1421 rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE;
1422 rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1423 rd_new[rd_count].expiration_time = ash->exp.rel_value_us;
1424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1425 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1426 &ash->identity,
1427 label,
1428 rd_count + 1,
1429 rd_new,
1430 &reference_store_cont,
1431 ash);
1432 GNUNET_free (buf);
1433}
1434
1435
1436/**
1437 * Add a new reference
1438 *
1439 * @param cls the AttributeStoreHandle
1440 */
1441static void
1442reference_store_task (void *cls)
1443{
1444 struct AttributeStoreHandle *ash = cls;
1445 char *label;
1446
1447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n");
1448
1449 // Give the ash a new id if unset
1450 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id))
1451 {
1452 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id_attest))
1453 {
1454 GNUNET_RECLAIM_id_generate (&ash->reference->id);
1455 }
1456 else
1457 {
1458 ash->reference->id = ash->reference->id_attest;
1459 }
1460 }
1461
1462 label = GNUNET_STRINGS_data_to_string_alloc (&ash->reference->id,
1463 sizeof (ash->reference->id));
1464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1465 "Looking up existing data under label %s\n", label);
1466// Test for the content of the existing ID
1467
1468 ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
1469 &ash->identity,
1470 label,
1471 &ref_error,
1472 ash,
1473 &ref_add_cb,
1474 ash);
1475 GNUNET_free (label);
1476}
1477
1478
1479/**
1480 * Check an attestation reference store message
1481 *
1482 * @param cls unused
1483 * @param sam the message to check
1484 */
1485static int
1486check_reference_store_message (void *cls,
1487 const struct
1488 AttributeStoreMessage *sam)
1489{
1490 uint16_t size;
1491
1492 size = ntohs (sam->header.size);
1493 if (size <= sizeof(struct AttributeStoreMessage))
1494 {
1495 GNUNET_break (0);
1496 return GNUNET_SYSERR;
1497 }
1498 return GNUNET_OK;
1499}
1500
1501
1502/**
1503 * Handle an attestation reference store message
1504 *
1505 * @param cls our client
1506 * @param sam the message to handle
1507 */
1508static void
1509handle_reference_store_message (void *cls,
1510 const struct AttributeStoreMessage *sam)
1511{
1512 struct AttributeStoreHandle *ash;
1513 struct IdpClient *idp = cls;
1514 size_t data_len;
1515
1516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_STORE message\n");
1517
1518 data_len = ntohs (sam->attr_len);
1519 ash = GNUNET_new (struct AttributeStoreHandle);
1520 ash->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &sam[1],
1521 data_len);
1522 ash->r_id = ntohl (sam->id);
1523 ash->identity = sam->identity;
1524 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1525 GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey);
1526
1527
1528 GNUNET_SERVICE_client_continue (idp->client);
1529 ash->client = idp;
1530 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1531 GNUNET_SCHEDULER_add_now (&reference_store_task, ash);
1532}
1533
1534
1535/**
1536 * Send a deletion success response 1224 * Send a deletion success response
1537 * 1225 *
1538 * @param adh our attribute deletion handle 1226 * @param adh our attribute deletion handle
@@ -1578,7 +1266,7 @@ ticket_iter (void *cls,
1578 int has_changed = GNUNET_NO; 1266 int has_changed = GNUNET_NO;
1579 for (int i = 0; i < rd_count; i++) 1267 for (int i = 0; i < rd_count; i++)
1580 { 1268 {
1581 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1269 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
1582 continue; 1270 continue;
1583 if (adh->claim != NULL) 1271 if (adh->claim != NULL)
1584 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, 1272 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
@@ -1588,12 +1276,8 @@ ticket_iter (void *cls,
1588 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, 1276 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
1589 &adh->attest->id)) 1277 &adh->attest->id))
1590 continue; 1278 continue;
1591 if (adh->reference != NULL)
1592 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
1593 &adh->reference->id))
1594 continue;
1595 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1279 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1596 "Attribute or Attestation/Reference to delete found (%s)\n", 1280 "Attribute or Attestation to delete found (%s)\n",
1597 adh->label); 1281 adh->label);
1598 has_changed = GNUNET_YES; 1282 has_changed = GNUNET_YES;
1599 break; 1283 break;
@@ -1684,20 +1368,15 @@ update_tickets (void *cls)
1684 for (int i = 0; i < le->rd_count; i++) 1368 for (int i = 0; i < le->rd_count; i++)
1685 { 1369 {
1686 if (adh->claim != NULL) 1370 if (adh->claim != NULL)
1687 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) 1371 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1688 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1372 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1689 &adh->claim->id))) 1373 &adh->claim->id)))
1690 continue; 1374 continue;
1691 if (adh->attest != NULL) 1375 if (adh->attest != NULL)
1692 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) 1376 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1693 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1377 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1694 &adh->attest->id))) 1378 &adh->attest->id)))
1695 continue; 1379 continue;
1696 if (adh->reference != NULL)
1697 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
1698 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1699 &adh->reference->id)))
1700 continue;
1701 rd_new[j] = rd[i]; 1380 rd_new[j] = rd[i];
1702 j++; 1381 j++;
1703 } 1382 }
@@ -1837,9 +1516,8 @@ handle_attribute_delete_message (void *cls,
1837 data_len = ntohs (dam->attr_len); 1516 data_len = ntohs (dam->attr_len);
1838 1517
1839 adh = GNUNET_new (struct AttributeDeleteHandle); 1518 adh = GNUNET_new (struct AttributeDeleteHandle);
1840 adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], 1519 adh->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1],
1841 data_len); 1520 data_len);
1842 adh->reference = NULL;
1843 adh->attest = NULL; 1521 adh->attest = NULL;
1844 1522
1845 adh->r_id = ntohl (dam->id); 1523 adh->r_id = ntohl (dam->id);
@@ -1928,9 +1606,8 @@ handle_attestation_delete_message (void *cls,
1928 data_len = ntohs (dam->attr_len); 1606 data_len = ntohs (dam->attr_len);
1929 1607
1930 adh = GNUNET_new (struct AttributeDeleteHandle); 1608 adh = GNUNET_new (struct AttributeDeleteHandle);
1931 adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1], 1609 adh->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &dam[1],
1932 data_len); 1610 data_len);
1933 adh->reference = NULL;
1934 adh->claim = NULL; 1611 adh->claim = NULL;
1935 1612
1936 adh->r_id = ntohl (dam->id); 1613 adh->r_id = ntohl (dam->id);
@@ -1951,169 +1628,6 @@ handle_attestation_delete_message (void *cls,
1951} 1628}
1952 1629
1953 1630
1954/**
1955* Reference deleted callback
1956*
1957* @param cls our handle
1958* @param success success status
1959* @param emsg error message (NULL if success=GNUNET_OK)
1960*/
1961static void
1962reference_delete_cont (void *cls, int32_t success, const char *emsg)
1963{
1964 struct AttributeDeleteHandle *adh = cls;
1965
1966 adh->ns_qe = NULL;
1967 if (GNUNET_SYSERR == success)
1968 {
1969 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1970 "Error deleting reference %s\n",
1971 adh->label);
1972 send_delete_response (adh, GNUNET_SYSERR);
1973 cleanup_adh (adh);
1974 return;
1975 }
1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1977 // GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
1978 send_delete_response (adh, GNUNET_OK);
1979 cleanup_adh (adh);
1980 return;
1981}
1982
1983
1984static void
1985ref_del_cb (void *cls,
1986 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1987 const char *label,
1988 unsigned int rd_count,
1989 const struct GNUNET_GNSRECORD_Data *rd)
1990{
1991
1992 struct AttributeDeleteHandle *adh = cls;
1993 char *data_tmp;
1994 struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1];
1995 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
1996 size_t attr_len;
1997
1998 if (0 == rd_count)
1999 {
2000 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2001 "Failed to find Attestation entry for Attestation reference\n");
2002 cleanup_adh (adh);
2003 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
2004 return;
2005 }
2006 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
2007 {
2008 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2009 "Intended Reference location is not an attestation\n");
2010 cleanup_adh (adh);
2011 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
2012 return;
2013 }
2014 rd_new[0] = rd[0];
2015 int i;
2016 int j = 1;
2017 for (i = 1; i<rd_count; i++)
2018 {
2019 data_tmp = GNUNET_malloc (rd[i].data_size);
2020 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2021 attr_len = htons (rd[i].data_size);
2022 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len);
2023 if (NULL == ref)
2024 {
2025 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2026 "Unable to parse attestation reference from %s\n",
2027 data_tmp);
2028 rd_new[j] = rd[i];
2029 j += 1;
2030 continue;
2031 }
2032 if ((strcmp (adh->reference->name,ref->name) == 0) &&
2033 (strcmp (adh->reference->reference_value,ref->reference_value)==0) )
2034 {
2035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2036 "Found reference to delete.\n");
2037 }
2038 else
2039 {
2040 rd_new[j] = rd[i];
2041 j += 1;
2042 }
2043 GNUNET_free (data_tmp);
2044 }
2045 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
2046 &adh->identity,
2047 label,
2048 j,
2049 rd_new,
2050 &reference_delete_cont,
2051 adh);
2052}
2053
2054
2055/**
2056 * Check an attestation reference delete message
2057 *
2058 * @param cls unused
2059 * @param sam the message to check
2060 */
2061static int
2062check_reference_delete_message (void *cls,
2063 const struct AttributeDeleteMessage *dam)
2064{
2065 uint16_t size;
2066
2067 size = ntohs (dam->header.size);
2068 if (size <= sizeof(struct AttributeDeleteMessage))
2069 {
2070 GNUNET_break (0);
2071 return GNUNET_SYSERR;
2072 }
2073 return GNUNET_OK;
2074}
2075
2076
2077/**
2078 * Handle reference deletion
2079 *
2080 * @param cls our client
2081 * @param dam deletion message
2082 */
2083static void
2084handle_reference_delete_message (void *cls,
2085 const struct AttributeDeleteMessage *dam)
2086{
2087 struct AttributeDeleteHandle *adh;
2088 struct IdpClient *idp = cls;
2089 size_t data_len;
2090
2091 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n");
2092 data_len = ntohs (dam->attr_len);
2093 adh = GNUNET_new (struct AttributeDeleteHandle);
2094 adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1],
2095 data_len);
2096 adh->attest = NULL;
2097 adh->claim = NULL;
2098
2099 adh->r_id = ntohl (dam->id);
2100 adh->identity = dam->identity;
2101 adh->label
2102 = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id,
2103 sizeof(adh->reference->id));
2104 GNUNET_SERVICE_client_continue (idp->client);
2105 adh->client = idp;
2106 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
2107 adh->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
2108 &adh->identity,
2109 adh->label,
2110 &ref_del_error,
2111 adh,
2112 &ref_del_cb,
2113 adh);
2114}
2115
2116
2117/************************************************* 1631/*************************************************
2118* Attrubute iteration 1632* Attrubute iteration
2119*************************************************/ 1633*************************************************/
@@ -2159,7 +1673,7 @@ attr_iter_error (void *cls)
2159 1673
2160 1674
2161/** 1675/**
2162 * Got record. Return if it is an attribute or attestation/reference. 1676 * Got record. Return if it is an attribute or attestation.
2163 * 1677 *
2164 * @param cls our attribute iterator 1678 * @param cls our attribute iterator
2165 * @param zone zone we are iterating 1679 * @param zone zone we are iterating
@@ -2185,14 +1699,14 @@ attr_iter_cb (void *cls,
2185 } 1699 }
2186 if (rd_count > 1) 1700 if (rd_count > 1)
2187 { 1701 {
2188 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[0].record_type) 1702 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[0].record_type)
2189 { 1703 {
2190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2191 "Found Ticket. Ignoring.\n"); 1705 "Found Ticket. Ignoring.\n");
2192 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); 1706 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
2193 return; 1707 return;
2194 } 1708 }
2195 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) 1709 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[0].record_type)
2196 { 1710 {
2197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1711 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2198 "Non-Attestation record with multiple entries found: %u\n", 1712 "Non-Attestation record with multiple entries found: %u\n",
@@ -2204,15 +1718,14 @@ attr_iter_cb (void *cls,
2204 1718
2205 for (int i = 0; i<rd_count; i++) 1719 for (int i = 0; i<rd_count; i++)
2206 { 1720 {
2207 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) && 1721 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type) &&
2208 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) && 1722 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[i].record_type))
2209 (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type))
2210 { 1723 {
2211 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); 1724 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
2212 return; 1725 return;
2213 } 1726 }
2214 1727 // FIXME Send attribute TOGETHER with respective attestation if applicable
2215 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 1728 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
2216 { 1729 {
2217 struct AttributeResultMessage *arm; 1730 struct AttributeResultMessage *arm;
2218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", 1731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
@@ -2231,7 +1744,7 @@ attr_iter_cb (void *cls,
2231 } 1744 }
2232 else 1745 else
2233 { 1746 {
2234 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 1747 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
2235 { 1748 {
2236 struct AttributeResultMessage *arm; 1749 struct AttributeResultMessage *arm;
2237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", 1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
@@ -2248,26 +1761,6 @@ attr_iter_cb (void *cls,
2248 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); 1761 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2249 GNUNET_MQ_send (ai->client->mq, env); 1762 GNUNET_MQ_send (ai->client->mq, env);
2250 } 1763 }
2251 else
2252 {
2253 struct ReferenceResultMessage *rrm;
2254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
2255 label);
2256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2257 "Sending REFERENCE_RESULT message\n");
2258 env = GNUNET_MQ_msg_extra (rrm,
2259 rd[i].data_size + rd[0].data_size,
2260 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT);
2261 rrm->id = htonl (ai->request_id);
2262 rrm->attest_len = htons (rd[0].data_size);
2263 rrm->ref_len = htons (rd[i].data_size);
2264 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity);
2265 data_tmp = (char *) &rrm[1];
2266 GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
2267 data_tmp += rd[0].data_size;
2268 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2269 GNUNET_MQ_send (ai->client->mq, env);
2270 }
2271 } 1764 }
2272 } 1765 }
2273} 1766}
@@ -2610,19 +2103,10 @@ GNUNET_SERVICE_MAIN (
2610 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, 2103 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE,
2611 struct AttributeDeleteMessage, 2104 struct AttributeDeleteMessage,
2612 NULL), 2105 NULL),
2613 GNUNET_MQ_hd_var_size (reference_store_message, 2106 GNUNET_MQ_hd_fixed_size (iteration_start,
2614 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, 2107 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
2615 struct AttributeStoreMessage, 2108 struct AttributeIterationStartMessage,
2616 NULL), 2109 NULL),
2617 GNUNET_MQ_hd_var_size (reference_delete_message,
2618 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE,
2619 struct AttributeDeleteMessage,
2620 NULL),
2621 GNUNET_MQ_hd_fixed_size (
2622 iteration_start,
2623 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
2624 struct AttributeIterationStartMessage,
2625 NULL),
2626 GNUNET_MQ_hd_fixed_size (iteration_next, 2110 GNUNET_MQ_hd_fixed_size (iteration_next,
2627 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, 2111 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT,
2628 struct AttributeIterationNextMessage, 2112 struct AttributeIterationNextMessage,
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index bdb9e6dd9..019ce51b0 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -59,7 +59,7 @@ struct TicketReference
59 /** 59 /**
60 * Attributes 60 * Attributes
61 */ 61 */
62 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 62 struct GNUNET_RECLAIM_AttributeList *attrs;
63 63
64 /** 64 /**
65 * Tickets 65 * Tickets
@@ -111,7 +111,12 @@ struct RECLAIM_TICKETS_ConsumeHandle
111 /** 111 /**
112 * Attributes 112 * Attributes
113 */ 113 */
114 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 114 struct GNUNET_RECLAIM_AttributeList *attrs;
115
116 /**
117 * Attestations
118 */
119 struct GNUNET_RECLAIM_AttestationList *attests;
115 120
116 /** 121 /**
117 * Lookup time 122 * Lookup time
@@ -165,7 +170,7 @@ struct TicketIssueHandle
165 /** 170 /**
166 * Attributes to issue 171 * Attributes to issue
167 */ 172 */
168 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 173 struct GNUNET_RECLAIM_AttributeList *attrs;
169 174
170 /** 175 /**
171 * Issuer Key 176 * Issuer Key
@@ -431,7 +436,7 @@ process_tickets (void *cls)
431 } 436 }
432 for (int i = 0; i < le->rd_count; i++) 437 for (int i = 0; i < le->rd_count; i++)
433 { 438 {
434 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 439 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
435 continue; 440 continue;
436 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 441 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
437 { 442 {
@@ -493,7 +498,7 @@ rvk_ticket_update (void *cls,
493 /** Let everything point to the old record **/ 498 /** Let everything point to the old record **/
494 for (int i = 0; i < rd_count; i++) 499 for (int i = 0; i < rd_count; i++)
495 { 500 {
496 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 501 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
497 continue; 502 continue;
498 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 503 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
499 { 504 {
@@ -685,80 +690,55 @@ rvk_move_attr_cb (void *cls,
685 // new_rd = *rd; 690 // new_rd = *rd;
686 for (int i = 0; i < rd_count; i++) 691 for (int i = 0; i < rd_count; i++)
687 { 692 {
688 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 693 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
689 { 694 {
690 /** find a new place for this attribute **/ 695 /** find a new place for this attribute **/
691 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 696 struct GNUNET_RECLAIM_Attribute *claim;
692 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, 697 claim = GNUNET_RECLAIM_attribute_deserialize (rd[i].data,
693 rd[i].data_size); 698 rd[i].data_size);
694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
695 "Attribute to update: Name=%s\n", 700 "Attribute to update: Name=%s\n",
696 claim->name); 701 claim->name);
697 claim->id = rvk->move_attr->new_id; 702 claim->id = rvk->move_attr->new_id;
698 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); 703 new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize_get_size (claim);
699 attr_data = GNUNET_malloc (rd[i].data_size); 704 attr_data = GNUNET_malloc (rd[i].data_size);
700 new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, 705 new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize (claim,
701 attr_data); 706 attr_data);
702 new_rd[i].data = attr_data; 707 new_rd[i].data = attr_data;
703 new_rd[i].record_type = rd[i].record_type; 708 new_rd[i].record_type = rd[i].record_type;
704 new_rd[i].flags = rd[i].flags; 709 new_rd[i].flags = rd[i].flags;
705 new_rd[i].expiration_time = rd[i].expiration_time; 710 new_rd[i].expiration_time = rd[i].expiration_time;
706 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 711 new_label =
707 sizeof (rvk->move_attr-> 712 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
708 new_id)); 713 sizeof (rvk->move_attr->new_id));
709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
710 GNUNET_free (claim); 715 GNUNET_free (claim);
711 } 716 }
712 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 717 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
713 { 718 {
714 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; 719 struct GNUNET_RECLAIM_Attestation *attest;
715 attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, 720 attest = GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
716 rd[i].data_size); 721 rd[i].data_size);
717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
718 "Attestation to update: Name=%s\n", 723 "Attestation to update: Name=%s\n",
719 attest->name); 724 attest->name);
720 attest->id = rvk->move_attr->new_id; 725 attest->id = rvk->move_attr->new_id;
721 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( 726 new_rd[i].data_size =
722 attest); 727 GNUNET_RECLAIM_attestation_serialize_get_size (attest);
723 attr_data = GNUNET_malloc (rd[i].data_size); 728 attr_data = GNUNET_malloc (rd[i].data_size);
724 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest, 729 new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest,
725 attr_data); 730 attr_data);
726 new_rd[i].data = attr_data; 731 new_rd[i].data = attr_data;
727 new_rd[i].record_type = rd[i].record_type; 732 new_rd[i].record_type = rd[i].record_type;
728 new_rd[i].flags = rd[i].flags; 733 new_rd[i].flags = rd[i].flags;
729 new_rd[i].expiration_time = rd[i].expiration_time; 734 new_rd[i].expiration_time = rd[i].expiration_time;
730 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 735 new_label =
731 sizeof (rvk->move_attr-> 736 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
732 new_id)); 737 sizeof (rvk->move_attr->new_id));
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", 738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n",
734 new_label); 739 new_label);
735 GNUNET_free (attest); 740 GNUNET_free (attest);
736 } 741 }
737 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
738 {
739 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
740 reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
741 rd[i].data_size);
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743 "Reference to update: Name=%s\n",
744 reference->name);
745 reference->id = rvk->move_attr->new_id;
746 reference->id_attest = rvk->move_attr->new_id;
747 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
748 reference);
749 attr_data = GNUNET_malloc (rd[i].data_size);
750 new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference,
751 attr_data);
752 new_rd[i].data = attr_data;
753 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
754 sizeof (rvk->move_attr->
755 new_id));
756 new_rd[i].record_type = rd[i].record_type;
757 new_rd[i].flags = rd[i].flags;
758 new_rd[i].expiration_time = rd[i].expiration_time;
759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference %s\n", new_label);
760 GNUNET_free (reference);
761 }
762 } 742 }
763 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 743 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
764 &rvk->identity, 744 &rvk->identity,
@@ -880,7 +860,7 @@ revoke_attrs_cb (void *cls,
880 */ 860 */
881 for (int i = 0; i < rd_count; i++) 861 for (int i = 0; i < rd_count; i++)
882 { 862 {
883 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 863 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
884 continue; 864 continue;
885 le = GNUNET_new (struct RevokedAttributeEntry); 865 le = GNUNET_new (struct RevokedAttributeEntry);
886 le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data); 866 le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
@@ -999,7 +979,9 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
999 } 979 }
1000 980
1001 if (NULL != cth->attrs) 981 if (NULL != cth->attrs)
1002 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs); 982 GNUNET_RECLAIM_attribute_list_destroy (cth->attrs);
983 if (NULL != cth->attests)
984 GNUNET_RECLAIM_attestation_list_destroy (cth->attests);
1003 GNUNET_free (cth); 985 GNUNET_free (cth);
1004} 986}
1005 987
@@ -1018,7 +1000,7 @@ process_parallel_lookup_result (void *cls,
1018{ 1000{
1019 struct ParallelLookup *parallel_lookup = cls; 1001 struct ParallelLookup *parallel_lookup = cls;
1020 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; 1002 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1021 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; 1003 struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1022 1004
1023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1024 "Parallel lookup finished (count=%u)\n", 1006 "Parallel lookup finished (count=%u)\n",
@@ -1044,62 +1026,34 @@ process_parallel_lookup_result (void *cls,
1044 // REMARK: It is possible now to find rd_count > 1 1026 // REMARK: It is possible now to find rd_count > 1
1045 for (int i = 0; i < rd_count; i++) 1027 for (int i = 0; i < rd_count; i++)
1046 { 1028 {
1047 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type) 1029 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
1048 { 1030 {
1049 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1031 attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1050 attr_le->claim = 1032 attr_le->attribute =
1051 GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size); 1033 GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size);
1052 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, 1034 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1053 cth->attrs->list_tail, 1035 cth->attrs->list_tail,
1054 attr_le); 1036 attr_le);
1055 attr_le->reference = NULL;
1056 attr_le->attest = NULL;
1057 } 1037 }
1058 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) 1038 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
1059 { 1039 {
1060 /**Ignore all plain attestations 1040 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1061 *attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1041 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1062 *attr_le->attest = 1042 ale->attestation =
1063 * GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, rd[i].data_size); 1043 GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
1064 *GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, 1044 rd[i].data_size);
1065 * cth->attrs->list_tail, 1045 GNUNET_CONTAINER_DLL_insert (cth->attests->list_head,
1066 * attr_le); 1046 cth->attests->list_tail,
1067 */ 1047 ale);
1068 continue;
1069 } 1048 }
1070 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type) 1049 else
1071 { 1050 {
1072 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le2; 1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1073 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1052 "Parallel Lookup of Reference without Attestation");
1074 attr_le2 = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1053 continue;
1075 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[0].record_type) 1054 }
1076 {
1077 attr_le->attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[0].data,
1078 rd[0].
1079 data_size);
1080 attr_le2->reference =
1081 GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
1082 rd[i].data_size);
1083 attr_le->claim = NULL;
1084 attr_le->reference = NULL;
1085 attr_le2->claim = NULL;
1086 attr_le2->attest = NULL;
1087 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1088 cth->attrs->list_tail,
1089 attr_le);
1090 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1091 cth->attrs->list_tail,
1092 attr_le2);
1093 }
1094 else
1095 {
1096 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1097 "Parallel Lookup of Reference without Attestation");
1098 continue;
1099 }
1100 1055
1101 1056
1102 }
1103 } 1057 }
1104 if (NULL != cth->parallel_lookups_head) 1058 if (NULL != cth->parallel_lookups_head)
1105 return; // Wait for more 1059 return; // Wait for more
@@ -1170,7 +1124,7 @@ lookup_authz_cb (void *cls,
1170 1124
1171 for (int i = 0; i < rd_count; i++) 1125 for (int i = 0; i < rd_count; i++)
1172 { 1126 {
1173 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1127 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
1174 continue; 1128 continue;
1175 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 1129 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
@@ -1234,7 +1188,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1234 1188
1235 cth->identity = *id; 1189 cth->identity = *id;
1236 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); 1190 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1237 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1191 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1238 cth->ticket = *ticket; 1192 cth->ticket = *ticket;
1239 cth->cb = cb; 1193 cth->cb = cb;
1240 cth->cb_cls = cb_cls; 1194 cth->cb_cls = cb_cls;
@@ -1249,7 +1203,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1249 GNUNET_GNS_lookup (gns, 1203 GNUNET_GNS_lookup (gns,
1250 label, 1204 label,
1251 &cth->ticket.identity, 1205 &cth->ticket.identity,
1252 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, 1206 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF,
1253 GNUNET_GNS_LO_DEFAULT, 1207 GNUNET_GNS_LO_DEFAULT,
1254 &lookup_authz_cb, 1208 &lookup_authz_cb,
1255 cth); 1209 cth);
@@ -1325,73 +1279,39 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1325static void 1279static void
1326issue_ticket (struct TicketIssueHandle *ih) 1280issue_ticket (struct TicketIssueHandle *ih)
1327{ 1281{
1328 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1282 struct GNUNET_RECLAIM_AttributeListEntry *le;
1329 struct GNUNET_GNSRECORD_Data *attrs_record; 1283 struct GNUNET_GNSRECORD_Data *attrs_record;
1330 char *label; 1284 char *label;
1331 size_t list_len = 1; 1285 size_t list_len = 1;
1332 int i; 1286 int i;
1333 char *attest_string;
1334 1287
1335 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1288 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1289 {
1336 list_len++; 1290 list_len++;
1291 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1292 list_len++;
1293 }
1337 1294
1338 attrs_record = 1295 attrs_record =
1339 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1296 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1340 i = 0; 1297 i = 0;
1341 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1298 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1342 { 1299 {
1343 if (NULL != le->claim) 1300 attrs_record[i].data = &le->attribute->id;
1344 { 1301 attrs_record[i].data_size = sizeof(le->attribute->id);
1345 attrs_record[i].data = &le->claim->id;
1346 attrs_record[i].data_size = sizeof(le->claim->id);
1347 }
1348 else if (NULL != le->attest)
1349 {
1350 // REMARK: Since we only store IDs, the references are irrelevant
1351 int j = 0;
1352 GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1353 while (j<i)
1354 {
1355 if (0 == strcmp (attest_string,GNUNET_STRINGS_data_to_string_alloc (
1356 attrs_record[j].data, attrs_record[j].data_size)))
1357 break;
1358 j++;
1359 }
1360 if (j < i)
1361 {
1362 list_len--;
1363 continue;
1364 }
1365 attrs_record[i].data = &le->attest->id;
1366 attrs_record[i].data_size = sizeof(le->attest->id);
1367 }
1368 else if (NULL != le->reference)
1369 {
1370 list_len--;
1371 continue;
1372 /*
1373 int j = 0;
1374 GNUNET_asprintf (&attest_string,"%d",le->attest->id);
1375 while (j<i)
1376 {
1377 if (strcmp(attest_string, GNUNET_STRINGS_data_to_string_alloc (
1378 attrs_record[j].data, attrs_record[j].data_size)))
1379 break;
1380 j++;
1381 }
1382 if (j < i)
1383 continue;
1384 attrs_record[i].data = &le->reference->id;
1385 attrs_record[i].data_size = sizeof(le->reference->id);
1386 */
1387 }
1388 /**
1389 * FIXME: Should this be the attribute expiration time or ticket
1390 * refresh interval? Probably min(attrs.expiration)
1391 */
1392 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1302 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1393 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; 1303 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
1394 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1304 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1305 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1306 {
1307 i++;
1308 attrs_record[i].data = &le->attribute->attestation;
1309 attrs_record[i].data_size = sizeof(le->attribute->attestation);
1310 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1311 attrs_record[i].record_type =
1312 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
1313 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1314 }
1395 i++; 1315 i++;
1396 } 1316 }
1397 attrs_record[i].data = &ih->ticket; 1317 attrs_record[i].data = &ih->ticket;
@@ -1464,14 +1384,20 @@ filter_tickets_cb (void *cls,
1464 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1384 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1465 1385
1466 // figure out the number of requested attributes 1386 // figure out the number of requested attributes
1467 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1387 struct GNUNET_RECLAIM_AttributeListEntry *le;
1468 unsigned int attr_cnt = 0; 1388 unsigned int attr_cnt = 0;
1389 unsigned int attest_cnt = 0;
1469 1390
1470 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1391 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1392 {
1471 attr_cnt++; 1393 attr_cnt++;
1394 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1395 attest_cnt++;
1396 }
1472 1397
1473 // ticket search 1398 // ticket search
1474 unsigned int found_attrs_cnt = 0; 1399 unsigned int found_attrs_cnt = 0;
1400 unsigned int found_attests_cnt = 0;
1475 1401
1476 for (int i = 0; i < rd_count; i++) 1402 for (int i = 0; i < rd_count; i++)
1477 { 1403 {
@@ -1491,31 +1417,20 @@ filter_tickets_cb (void *cls,
1491 } 1417 }
1492 1418
1493 // cmp requested attributes with ticket attributes 1419 // cmp requested attributes with ticket attributes
1494 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1420 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1421 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
1495 continue; 1422 continue;
1496 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1423 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1497 { 1424 {
1498 // cmp attr_ref id with requested attr id 1425 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1499 if (NULL !=le->claim) 1426 &le->attribute->id))
1500 { 1427 found_attrs_cnt++;
1501 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(le->claim->id))) 1428 }
1502 found_attrs_cnt++; 1429 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1503 } 1430 {
1504 else if (NULL !=le->attest) 1431 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1505 { 1432 &le->attribute->attestation))
1506 if (0 == memcmp (rd[i].data, 1433 found_attests_cnt++;
1507 &le->attest->id,
1508 sizeof(le->attest->id)))
1509 found_attrs_cnt++;
1510 }
1511 else if (NULL != le->reference)
1512 {
1513 if (0 == memcmp (rd[i].data,
1514 &le->reference->id,
1515 sizeof(le->reference->id)))
1516 found_attrs_cnt++;
1517 }
1518
1519 } 1434 }
1520 } 1435 }
1521 1436
@@ -1523,7 +1438,9 @@ filter_tickets_cb (void *cls,
1523 * If we found a matching ticket, return that to the caller and 1438 * If we found a matching ticket, return that to the caller and
1524 * we are done. 1439 * we are done.
1525 */ 1440 */
1526 if ((attr_cnt == found_attrs_cnt) && (NULL != ticket)) 1441 if ((attr_cnt == found_attrs_cnt) &&
1442 (attest_cnt == found_attests_cnt) &&
1443 (NULL != ticket))
1527 { 1444 {
1528 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); 1445 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
1529 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); 1446 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
@@ -1567,7 +1484,7 @@ filter_tickets_finished_cb (void *cls)
1567 */ 1484 */
1568void 1485void
1569RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1486RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1570 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1487 const struct GNUNET_RECLAIM_AttributeList *attrs,
1571 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 1488 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
1572 RECLAIM_TICKETS_TicketResult cb, 1489 RECLAIM_TICKETS_TicketResult cb,
1573 void *cb_cls) 1490 void *cb_cls)
@@ -1577,7 +1494,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1577 tih = GNUNET_new (struct TicketIssueHandle); 1494 tih = GNUNET_new (struct TicketIssueHandle);
1578 tih->cb = cb; 1495 tih->cb = cb;
1579 tih->cb_cls = cb_cls; 1496 tih->cb_cls = cb_cls;
1580 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs); 1497 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs);
1581 tih->identity = *identity; 1498 tih->identity = *identity;
1582 tih->ticket.audience = *audience; 1499 tih->ticket.audience = *audience;
1583 1500
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index c75cefc03..e8299718c 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -136,7 +136,7 @@ typedef void (*RECLAIM_TICKETS_TicketResult) (
136typedef void (*RECLAIM_TICKETS_ConsumeCallback) ( 136typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
137 void *cls, 137 void *cls,
138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
139 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l, 139 const struct GNUNET_RECLAIM_AttributeList *l,
140 int32_t success, 140 int32_t success,
141 const char *emsg); 141 const char *emsg);
142 142
@@ -217,7 +217,7 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
217 */ 217 */
218void 218void
219RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 219RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
220 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 220 const struct GNUNET_RECLAIM_AttributeList *attrs,
221 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 221 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
222 RECLAIM_TICKETS_TicketResult cb, 222 RECLAIM_TICKETS_TicketResult cb,
223 void *cb_cls); 223 void *cb_cls);
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c
index 6ac60a704..4c08430e7 100644
--- a/src/reclaim/json_reclaim.c
+++ b/src/reclaim/json_reclaim.c
@@ -43,11 +43,12 @@
43static int 43static int
44parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 44parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
45{ 45{
46 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 46 struct GNUNET_RECLAIM_Attribute *attr;
47 const char *name_str = NULL; 47 const char *name_str = NULL;
48 const char *val_str = NULL; 48 const char *val_str = NULL;
49 const char *type_str = NULL; 49 const char *type_str = NULL;
50 const char *id_str = NULL; 50 const char *id_str = NULL;
51 const char *attest_str = NULL;
51 const char *flag_str = NULL; 52 const char *flag_str = NULL;
52 char *data; 53 char *data;
53 int unpack_state; 54 int unpack_state;
@@ -64,11 +65,13 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
64 } 65 }
65 // interpret single attribute 66 // interpret single attribute
66 unpack_state = json_unpack (root, 67 unpack_state = json_unpack (root,
67 "{s:s, s?s, s:s, s:s, s?s!}", 68 "{s:s, s?s, s?s, s:s, s:s, s?s!}",
68 "name", 69 "name",
69 &name_str, 70 &name_str,
70 "id", 71 "id",
71 &id_str, 72 &id_str,
73 "attestation",
74 &attest_str,
72 "type", 75 "type",
73 &type_str, 76 &type_str,
74 "value", 77 "value",
@@ -82,9 +85,9 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
82 "Error json object has a wrong format!\n"); 85 "Error json object has a wrong format!\n");
83 return GNUNET_SYSERR; 86 return GNUNET_SYSERR;
84 } 87 }
85 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); 88 type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
86 if (GNUNET_SYSERR == 89 if (GNUNET_SYSERR ==
87 (GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, 90 (GNUNET_RECLAIM_attribute_string_to_value (type,
88 val_str, 91 val_str,
89 (void **) &data, 92 (void **) &data,
90 &data_size))) 93 &data_size)))
@@ -92,7 +95,15 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n"); 95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n");
93 return GNUNET_SYSERR; 96 return GNUNET_SYSERR;
94 } 97 }
95 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size); 98 attr = GNUNET_RECLAIM_attribute_new (name_str, NULL,
99 type, data, data_size);
100 if ((NULL != attest_str) && (0 != strlen (attest_str)))
101 {
102 GNUNET_STRINGS_string_to_data (attest_str,
103 strlen (attest_str),
104 &attr->attestation,
105 sizeof(attr->attestation));
106 }
96 if ((NULL == id_str) || (0 == strlen (id_str))) 107 if ((NULL == id_str) || (0 == strlen (id_str)))
97 memset (&attr->id, 0, sizeof (attr->id)); 108 memset (&attr->id, 0, sizeof (attr->id));
98 else 109 else
@@ -101,7 +112,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
101 &attr->id, 112 &attr->id,
102 sizeof(attr->id)); 113 sizeof(attr->id));
103 114
104 *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr; 115 *(struct GNUNET_RECLAIM_Attribute **) spec->ptr = attr;
105 return GNUNET_OK; 116 return GNUNET_OK;
106} 117}
107 118
@@ -115,9 +126,9 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
115static void 126static void
116clean_attr (void *cls, struct GNUNET_JSON_Specification *spec) 127clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
117{ 128{
118 struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr; 129 struct GNUNET_RECLAIM_Attribute **attr;
119 130
120 attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr; 131 attr = (struct GNUNET_RECLAIM_Attribute **) spec->ptr;
121 if (NULL != *attr) 132 if (NULL != *attr)
122 { 133 {
123 GNUNET_free (*attr); 134 GNUNET_free (*attr);
@@ -129,11 +140,11 @@ clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
129/** 140/**
130 * JSON Specification for Reclaim claims. 141 * JSON Specification for Reclaim claims.
131 * 142 *
132 * @param ticket struct of GNUNET_RECLAIM_ATTRIBUTE_Claim to fill 143 * @param ticket struct of GNUNET_RECLAIM_Attribute to fill
133 * @return JSON Specification 144 * @return JSON Specification
134 */ 145 */
135struct GNUNET_JSON_Specification 146struct GNUNET_JSON_Specification
136GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) 147GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr)
137{ 148{
138 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr, 149 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
139 .cleaner = &clean_attr, 150 .cleaner = &clean_attr,
@@ -279,7 +290,7 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
279static int 290static int
280parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 291parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
281{ 292{
282 struct GNUNET_RECLAIM_ATTESTATION_Claim *attr; 293 struct GNUNET_RECLAIM_Attestation *attr;
283 const char *name_str = NULL; 294 const char *name_str = NULL;
284 const char *val_str = NULL; 295 const char *val_str = NULL;
285 const char *type_str = NULL; 296 const char *type_str = NULL;
@@ -315,9 +326,9 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
315 "Error json object has a wrong format!\n"); 326 "Error json object has a wrong format!\n");
316 return GNUNET_SYSERR; 327 return GNUNET_SYSERR;
317 } 328 }
318 type = GNUNET_RECLAIM_ATTESTATION_typename_to_number (type_str); 329 type = GNUNET_RECLAIM_attestation_typename_to_number (type_str);
319 if (GNUNET_SYSERR == 330 if (GNUNET_SYSERR ==
320 (GNUNET_RECLAIM_ATTESTATION_string_to_value (type, 331 (GNUNET_RECLAIM_attestation_string_to_value (type,
321 val_str, 332 val_str,
322 (void **) &data, 333 (void **) &data,
323 &data_size))) 334 &data_size)))
@@ -325,7 +336,7 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attestation value invalid!\n"); 336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attestation value invalid!\n");
326 return GNUNET_SYSERR; 337 return GNUNET_SYSERR;
327 } 338 }
328 attr = GNUNET_RECLAIM_ATTESTATION_claim_new (name_str, type, data, data_size); 339 attr = GNUNET_RECLAIM_attestation_new (name_str, type, data, data_size);
329 if ((NULL == id_str) || (0 == strlen (id_str))) 340 if ((NULL == id_str) || (0 == strlen (id_str)))
330 memset (&attr->id, 0, sizeof (attr->id)); 341 memset (&attr->id, 0, sizeof (attr->id));
331 else 342 else
@@ -334,7 +345,7 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
334 &attr->id, 345 &attr->id,
335 sizeof(attr->id)); 346 sizeof(attr->id));
336 347
337 *(struct GNUNET_RECLAIM_ATTESTATION_Claim **) spec->ptr = attr; 348 *(struct GNUNET_RECLAIM_Attestation **) spec->ptr = attr;
338 return GNUNET_OK; 349 return GNUNET_OK;
339} 350}
340 351
@@ -347,9 +358,9 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
347static void 358static void
348clean_attest (void *cls, struct GNUNET_JSON_Specification *spec) 359clean_attest (void *cls, struct GNUNET_JSON_Specification *spec)
349{ 360{
350 struct GNUNET_RECLAIM_ATTESTATION_Claim **attr; 361 struct GNUNET_RECLAIM_Attestation **attr;
351 362
352 attr = (struct GNUNET_RECLAIM_ATTESTATION_Claim **) spec->ptr; 363 attr = (struct GNUNET_RECLAIM_Attestation **) spec->ptr;
353 if (NULL != *attr) 364 if (NULL != *attr)
354 { 365 {
355 GNUNET_free (*attr); 366 GNUNET_free (*attr);
@@ -364,7 +375,7 @@ clean_attest (void *cls, struct GNUNET_JSON_Specification *spec)
364 */ 375 */
365struct GNUNET_JSON_Specification 376struct GNUNET_JSON_Specification
366GNUNET_RECLAIM_JSON_spec_claim_attest (struct 377GNUNET_RECLAIM_JSON_spec_claim_attest (struct
367 GNUNET_RECLAIM_ATTESTATION_Claim **attr) 378 GNUNET_RECLAIM_Attestation **attr)
368{ 379{
369 struct GNUNET_JSON_Specification ret = { .parser = &parse_attest, 380 struct GNUNET_JSON_Specification ret = { .parser = &parse_attest,
370 .cleaner = &clean_attest, 381 .cleaner = &clean_attest,
@@ -378,105 +389,3 @@ GNUNET_RECLAIM_JSON_spec_claim_attest (struct
378 return ret; 389 return ret;
379} 390}
380 391
381/**
382 * Parse given JSON object to an attestation claim
383 *
384 * @param cls closure, NULL
385 * @param root the json object representing data
386 * @param spec where to write the data
387 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
388 */
389static int
390parse_attest_ref (void *cls, json_t *root, struct
391 GNUNET_JSON_Specification *spec)
392{
393 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
394 const char *name_str = NULL;
395 const char *ref_val_str = NULL;
396 const char *ref_id_str = NULL;
397 const char *id_str = NULL;
398 int unpack_state;
399
400 GNUNET_assert (NULL != root);
401
402 if (! json_is_object (root))
403 {
404 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
405 "Error json is not array nor object!\n");
406 return GNUNET_SYSERR;
407 }
408 // interpret single reference
409 unpack_state = json_unpack (root,
410 "{s:s, s?s, s:s, s:s!}",
411 "name",
412 &name_str,
413 "id",
414 &id_str,
415 "ref_id",
416 &ref_id_str,
417 "ref_value",
418 &ref_val_str);
419 if ((0 != unpack_state) || (NULL == name_str) || (NULL == ref_val_str) ||
420 (NULL == ref_id_str))
421 {
422 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
423 "Error json object has a wrong format!\n");
424 return GNUNET_SYSERR;
425 }
426
427 attr = GNUNET_RECLAIM_ATTESTATION_reference_new (name_str, ref_val_str);
428 memset (&attr->id, 0, sizeof (attr->id));
429
430 if ((NULL == ref_id_str) || (0 == strlen (ref_id_str)))
431 memset (&attr->id_attest, 0, sizeof (attr->id_attest));
432 else
433 GNUNET_STRINGS_string_to_data (ref_id_str,
434 strlen (ref_id_str),
435 &attr->id_attest,
436 sizeof(attr->id_attest));
437
438 *(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **) spec->ptr = attr;
439 return GNUNET_OK;
440}
441
442/**
443 * Cleanup data left from parsing RSA public key.
444 *
445 * @param cls closure, NULL
446 * @param[out] spec where to free the data
447 */
448static void
449clean_attest_ref (void *cls, struct GNUNET_JSON_Specification *spec)
450{
451 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr;
452
453 attr = (struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **) spec->ptr;
454 if (NULL != *attr)
455 {
456 GNUNET_free (*attr);
457 *attr = NULL;
458 }
459}
460
461/**
462 * JSON Specification for Reclaim attestation references.
463 *
464 * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_REFERENCE to fill
465 * @return JSON Specification
466 */
467struct GNUNET_JSON_Specification
468GNUNET_RECLAIM_JSON_spec_claim_attest_ref (struct
469 GNUNET_RECLAIM_ATTESTATION_REFERENCE
470 **attr)
471{
472 struct GNUNET_JSON_Specification ret = { .parser = &parse_attest_ref,
473 .cleaner = &clean_attest_ref,
474 .cls = NULL,
475 .field = NULL,
476 .ptr = attr,
477 .ptr_size = 0,
478 .size_ptr = NULL };
479
480 *attr = NULL;
481 return ret;
482}
diff --git a/src/reclaim/json_reclaim.h b/src/reclaim/json_reclaim.h
index 9e6479e5e..5aaf81b93 100644
--- a/src/reclaim/json_reclaim.h
+++ b/src/reclaim/json_reclaim.h
@@ -36,7 +36,7 @@
36 * @return JSON Specification 36 * @return JSON Specification
37 */ 37 */
38struct GNUNET_JSON_Specification 38struct GNUNET_JSON_Specification
39GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr); 39GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr);
40 40
41/** 41/**
42 * JSON Specification for Reclaim tickets. 42 * JSON Specification for Reclaim tickets.
@@ -50,18 +50,10 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket);
50/** 50/**
51 * JSON Specification for Reclaim attestation claims. 51 * JSON Specification for Reclaim attestation claims.
52 * 52 *
53 * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_Claim to fill 53 * @param ticket struct of GNUNET_RECLAIM_Attestation to fill
54 * @return JSON Specification 54 * @return JSON Specification
55 */ 55 */
56struct GNUNET_JSON_Specification 56struct GNUNET_JSON_Specification
57GNUNET_RECLAIM_JSON_spec_claim_attest (struct 57GNUNET_RECLAIM_JSON_spec_claim_attest (struct
58 GNUNET_RECLAIM_ATTESTATION_Claim **attr); 58 GNUNET_RECLAIM_Attestation **attr);
59 59
60 /**
61 * JSON Specification for Reclaim attestation references.
62 *
63 * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_REFERENCE to fill
64 * @return JSON Specification
65 */
66 struct GNUNET_JSON_Specification
67 GNUNET_RECLAIM_JSON_spec_claim_attest_ref(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr);
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index 1d23003ab..487aa5695 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -60,6 +60,11 @@ struct OIDC_Parameters
60 * The length of the attributes list 60 * The length of the attributes list
61 */ 61 */
62 uint32_t attr_list_len GNUNET_PACKED; 62 uint32_t attr_list_len GNUNET_PACKED;
63
64 /**
65 * The length of the attestation list
66 */
67 uint32_t attest_list_len GNUNET_PACKED;
63}; 68};
64 69
65GNUNET_NETWORK_STRUCT_END 70GNUNET_NETWORK_STRUCT_END
@@ -118,12 +123,14 @@ fix_base64 (char *str)
118char * 123char *
119OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 124OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
120 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 125 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
121 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 126 struct GNUNET_RECLAIM_AttributeList *attrs,
127 struct GNUNET_RECLAIM_AttestationList *attests,
122 const struct GNUNET_TIME_Relative *expiration_time, 128 const struct GNUNET_TIME_Relative *expiration_time,
123 const char *nonce, 129 const char *nonce,
124 const char *secret_key) 130 const char *secret_key)
125{ 131{
126 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 132 struct GNUNET_RECLAIM_AttributeListEntry *le;
133 struct GNUNET_RECLAIM_AttestationListEntry *ale;
127 struct GNUNET_HashCode signature; 134 struct GNUNET_HashCode signature;
128 struct GNUNET_TIME_Absolute exp_time; 135 struct GNUNET_TIME_Absolute exp_time;
129 struct GNUNET_TIME_Absolute time_now; 136 struct GNUNET_TIME_Absolute time_now;
@@ -146,7 +153,12 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
146 json_t *aggr_names; 153 json_t *aggr_names;
147 json_t *aggr_sources; 154 json_t *aggr_sources;
148 json_t *aggr_sources_jwt; 155 json_t *aggr_sources_jwt;
149 struct GNUNET_RECLAIM_Identifier attest_arr[GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (attrs)]; 156 int num_attestations = 0;
157 for (le = attrs->list_head; NULL != le; le = le->next)
158 {
159 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
160 num_attestations++;
161 }
150 162
151 // iat REQUIRED time now 163 // iat REQUIRED time now
152 time_now = GNUNET_TIME_absolute_get (); 164 time_now = GNUNET_TIME_absolute_get ();
@@ -191,97 +203,73 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
191 // nonce 203 // nonce
192 if (NULL != nonce) 204 if (NULL != nonce)
193 json_object_set_new (body, "nonce", json_string (nonce)); 205 json_object_set_new (body, "nonce", json_string (nonce));
194 int i = 0;
195 attest_val_str = NULL; 206 attest_val_str = NULL;
196 aggr_names_str = NULL; 207 aggr_names_str = NULL;
197 aggr_sources_str = NULL; 208 aggr_sources_str = NULL;
198 aggr_sources_jwt_str = NULL; 209 aggr_sources_jwt_str = NULL;
199 source_name = NULL; 210 source_name = NULL;
211 int i = 0;
212 for (ale = attests->list_head; NULL != ale; ale = ale->next)
213 {
214 // New Attestation
215 GNUNET_asprintf (&source_name,
216 "src%d",
217 i);
218 aggr_sources_jwt = json_object ();
219 attest_val_str =
220 GNUNET_RECLAIM_attestation_value_to_string (ale->attestation->type,
221 ale->attestation->data,
222 ale->attestation->data_size);
223 json_object_set_new (aggr_sources_jwt, "JWT",
224 json_string (attest_val_str) );
225 aggr_sources_jwt_str = json_dumps (aggr_sources_jwt, JSON_INDENT (0)
226 | JSON_COMPACT);
227 json_object_set_new (aggr_sources, source_name,json_string (
228 aggr_sources_jwt_str));
229 i++;
230 }
231
200 for (le = attrs->list_head; NULL != le; le = le->next) 232 for (le = attrs->list_head; NULL != le; le = le->next)
201 { 233 {
202 234
203 if (le->claim != NULL) 235 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
204 { 236 {
205 237
206 attr_val_str = 238 attr_val_str =
207 GNUNET_RECLAIM_ATTRIBUTE_value_to_string (le->claim->type, 239 GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type,
208 le->claim->data, 240 le->attribute->data,
209 le->claim->data_size); 241 le->attribute->data_size);
210 json_object_set_new (body, le->claim->name, json_string (attr_val_str)); 242 json_object_set_new (body, le->attribute->name,
243 json_string (attr_val_str));
211 GNUNET_free (attr_val_str); 244 GNUNET_free (attr_val_str);
212 } 245 }
213 else if (NULL != le->reference) 246 else
214 { 247 {
215 // Check if attest is there 248 // Check if attest is there
216 int j = 0; 249 int j = 0;
217 while (j<i) 250 for (ale = attests->list_head; NULL != ale; ale = ale->next)
218 { 251 {
219 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j], 252 if (GNUNET_YES ==
220 &le->reference->id_attest)) 253 GNUNET_RECLAIM_id_is_equal (&ale->attestation->id,
254 &le->attribute->attestation))
221 break; 255 break;
222 j++; 256 j++;
223 } 257 }
224 if (j==i) 258 GNUNET_assert (NULL != ale);
225 { 259 // Attestation is existing, hence take the respective source str
226 // Attest not yet existent. Append to the end of the list 260 GNUNET_asprintf (&source_name,
227 GNUNET_CONTAINER_DLL_remove (attrs->list_head, attrs->list_tail, le); 261 "src%d",
228 GNUNET_CONTAINER_DLL_insert_tail (attrs->list_head, attrs->list_tail, 262 j);
229 le); 263 json_object_set_new (aggr_names, le->attribute->data,
230 continue; 264 json_string (source_name));
231 }
232 else
233 {
234 // Attestation is existing, hence take the respective source str
235 GNUNET_asprintf (&source_name,
236 "src%d",
237 j);
238 json_object_set_new (aggr_names, le->reference->name, json_string (
239 source_name));
240 }
241
242 }
243 else if (NULL != le->attest)
244 {
245 // We assume that at max 99 different attestations
246 int j = 0;
247 while (j<i)
248 {
249 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j],
250 &le->attest->id))
251 break;
252 j++;
253 }
254 if (j==i)
255 {
256 // New Attestation
257 attest_arr[i] = le->attest->id;
258 GNUNET_asprintf (&source_name,
259 "src%d",
260 i);
261 aggr_sources_jwt = json_object ();
262 attest_val_str = GNUNET_RECLAIM_ATTESTATION_value_to_string (
263 le->attest->type, le->attest->data, le->attest->data_size);
264 json_object_set_new (aggr_sources_jwt, "JWT",json_string (
265 attest_val_str) );
266 aggr_sources_jwt_str = json_dumps (aggr_sources_jwt, JSON_INDENT (0)
267 | JSON_COMPACT);
268 json_object_set_new (aggr_sources, source_name,json_string (
269 aggr_sources_jwt_str));
270 i++;
271 }
272 else
273 {
274 // Attestation already existent. Ignore
275 continue;
276 }
277
278 } 265 }
279 } 266 }
267
280 if (NULL != attest_val_str) 268 if (NULL != attest_val_str)
281 GNUNET_free (attest_val_str); 269 GNUNET_free (attest_val_str);
282 if (NULL != source_name) 270 if (NULL != source_name)
283 GNUNET_free (source_name); 271 GNUNET_free (source_name);
284 if (0!=i) 272 if (0 != i)
285 { 273 {
286 aggr_names_str = json_dumps (aggr_names, JSON_INDENT (0) | JSON_COMPACT); 274 aggr_names_str = json_dumps (aggr_names, JSON_INDENT (0) | JSON_COMPACT);
287 aggr_sources_str = json_dumps (aggr_sources, JSON_INDENT (0) 275 aggr_sources_str = json_dumps (aggr_sources, JSON_INDENT (0)
@@ -574,7 +562,8 @@ encrypt_payload (const struct GNUNET_CRYPTO_EcdsaPublicKey *ecdsa_pub,
574char * 562char *
575OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 563OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
576 const struct GNUNET_RECLAIM_Ticket *ticket, 564 const struct GNUNET_RECLAIM_Ticket *ticket,
577 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 565 struct GNUNET_RECLAIM_AttributeList *attrs,
566 struct GNUNET_RECLAIM_AttestationList *attests,
578 const char *nonce_str, 567 const char *nonce_str,
579 const char *code_challenge) 568 const char *code_challenge)
580{ 569{
@@ -587,6 +576,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
587 size_t payload_len; 576 size_t payload_len;
588 size_t code_payload_len; 577 size_t code_payload_len;
589 size_t attr_list_len = 0; 578 size_t attr_list_len = 0;
579 size_t attests_list_len = 0;
590 size_t code_challenge_len = 0; 580 size_t code_challenge_len = 0;
591 uint32_t nonce; 581 uint32_t nonce;
592 uint32_t nonce_tmp; 582 uint32_t nonce_tmp;
@@ -625,7 +615,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
625 if (NULL != attrs) 615 if (NULL != attrs)
626 { 616 {
627 // Get length 617 // Get length
628 attr_list_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); 618 attr_list_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
629 params.attr_list_len = htonl (attr_list_len); 619 params.attr_list_len = htonl (attr_list_len);
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
631 "Length of serialized attributes: %lu\n", 621 "Length of serialized attributes: %lu\n",
@@ -633,6 +623,19 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
633 // Get serialized attributes 623 // Get serialized attributes
634 payload_len += attr_list_len; 624 payload_len += attr_list_len;
635 } 625 }
626 if (NULL != attests)
627 {
628 // Get length
629 attests_list_len =
630 GNUNET_RECLAIM_attestation_list_serialize_get_size (attests);
631 params.attest_list_len = htonl (attests_list_len);
632 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
633 "Length of serialized attestations: %lu\n",
634 attests_list_len);
635 // Get serialized attributes
636 payload_len += attests_list_len;
637 }
638
636 // Get plaintext length 639 // Get plaintext length
637 payload = GNUNET_malloc (payload_len); 640 payload = GNUNET_malloc (payload_len);
638 memcpy (payload, &params, sizeof(params)); 641 memcpy (payload, &params, sizeof(params));
@@ -643,7 +646,10 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
643 tmp += code_challenge_len; 646 tmp += code_challenge_len;
644 } 647 }
645 if (0 < attr_list_len) 648 if (0 < attr_list_len)
646 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, tmp); 649 GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp);
650 if (0 < attests_list_len)
651 GNUNET_RECLAIM_attestation_list_serialize (attests, tmp);
652
647 /** END **/ 653 /** END **/
648 654
649 /** ENCRYPT **/ 655 /** ENCRYPT **/
@@ -711,7 +717,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv,
711 const char *code, 717 const char *code,
712 const char *code_verifier, 718 const char *code_verifier,
713 struct GNUNET_RECLAIM_Ticket *ticket, 719 struct GNUNET_RECLAIM_Ticket *ticket,
714 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs, 720 struct GNUNET_RECLAIM_AttributeList **attrs,
721 struct GNUNET_RECLAIM_AttestationList **attests,
715 char **nonce_str) 722 char **nonce_str)
716{ 723{
717 char *code_payload; 724 char *code_payload;
@@ -829,7 +836,7 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv,
829 // Attributes 836 // Attributes
830 attrs_ser = ((char *) &params[1]) + code_challenge_len; 837 attrs_ser = ((char *) &params[1]) + code_challenge_len;
831 attrs_ser_len = ntohl (params->attr_list_len); 838 attrs_ser_len = ntohl (params->attr_list_len);
832 *attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (attrs_ser, attrs_ser_len); 839 *attrs = GNUNET_RECLAIM_attribute_list_deserialize (attrs_ser, attrs_ser_len);
833 840
834 *nonce_str = NULL; 841 *nonce_str = NULL;
835 if (nonce != 0) 842 if (nonce != 0)
diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h
index a7072755b..2c533357e 100644
--- a/src/reclaim/oidc_helper.h
+++ b/src/reclaim/oidc_helper.h
@@ -51,7 +51,8 @@
51char* 51char*
52OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 52OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
53 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 53 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
54 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 54 struct GNUNET_RECLAIM_AttributeList *attrs,
55 struct GNUNET_RECLAIM_AttestationList *attests,
55 const struct GNUNET_TIME_Relative *expiration_time, 56 const struct GNUNET_TIME_Relative *expiration_time,
56 const char *nonce, 57 const char *nonce,
57 const char *secret_key); 58 const char *secret_key);
@@ -70,7 +71,8 @@ OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
70char* 71char*
71OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 72OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
72 const struct GNUNET_RECLAIM_Ticket *ticket, 73 const struct GNUNET_RECLAIM_Ticket *ticket,
73 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 74 struct GNUNET_RECLAIM_AttributeList *attrs,
75 struct GNUNET_RECLAIM_AttestationList *attests,
74 const char *nonce, 76 const char *nonce,
75 const char *code_challenge); 77 const char *code_challenge);
76 78
@@ -92,7 +94,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv,
92 const char *code, 94 const char *code,
93 const char *code_verifier, 95 const char *code_verifier,
94 struct GNUNET_RECLAIM_Ticket *ticket, 96 struct GNUNET_RECLAIM_Ticket *ticket,
95 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs, 97 struct GNUNET_RECLAIM_AttributeList **attrs,
98 struct GNUNET_RECLAIM_AttestationList **attests,
96 char **nonce); 99 char **nonce);
97 100
98/** 101/**
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index f7145a272..b91e123a3 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -44,18 +44,15 @@ value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
44{ 44{
45 switch (type) 45 switch (type)
46 { 46 {
47 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
48 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
49
50 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 47 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
51 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 48 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
52 return GNUNET_strndup (data, data_size); 49 return GNUNET_strndup (data, data_size);
53 50 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
54 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 51 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
55 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 52 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
56 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 53 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
57 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR: 54 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION:
58 case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE: 55 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF:
59 return GNUNET_STRINGS_data_to_string_alloc (data, data_size); 56 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
60 57
61 default: 58 default:
@@ -83,20 +80,17 @@ string_to_value (void *cls, uint32_t type, const char *s, void **data,
83 return GNUNET_SYSERR; 80 return GNUNET_SYSERR;
84 switch (type) 81 switch (type)
85 { 82 {
86 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
87 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
88
89 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 83 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
90 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 84 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
91 *data = GNUNET_strdup (s); 85 *data = GNUNET_strdup (s);
92 *data_size = strlen (s); 86 *data_size = strlen (s);
93 return GNUNET_OK; 87 return GNUNET_OK;
94 88 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
95 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 89 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
96 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 90 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
97 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 91 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
98 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR: 92 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION:
99 case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE: 93 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF:
100 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); 94 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
101 95
102 default: 96 default:
@@ -114,14 +108,14 @@ static struct
114 const char *name; 108 const char *name;
115 uint32_t number; 109 uint32_t number;
116} name_map[] = { 110} name_map[] = {
117 { "RECLAIM_ATTR", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR }, 111 { "RECLAIM_ATTRIBUTE", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE },
118 { "RECLAIM_ATTR_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF }, 112 { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF },
119 { "RECLAIM_ATTEST", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR }, 113 { "RECLAIM_ATTESTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION },
114 { "RECLAIM_ATTESTATION_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF },
120 { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER }, 115 { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER },
121 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, 116 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT },
122 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, 117 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT },
123 { "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET }, 118 { "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET },
124 { "RECLAIM_REFERENCE", GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE },
125 { NULL, UINT32_MAX } 119 { NULL, UINT32_MAX }
126}; 120};
127 121
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 741094f21..610f93dbe 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -428,7 +428,13 @@ struct RequestHandle
428 /** 428 /**
429 * Attribute claim list 429 * Attribute claim list
430 */ 430 */
431 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; 431 struct GNUNET_RECLAIM_AttributeList *attr_list;
432
433 /**
434 * Attestation list
435 */
436 struct GNUNET_RECLAIM_AttestationList *attests_list;
437
432 438
433 /** 439 /**
434 * IDENTITY Operation 440 * IDENTITY Operation
@@ -523,8 +529,7 @@ struct RequestHandle
523static void 529static void
524cleanup_handle (struct RequestHandle *handle) 530cleanup_handle (struct RequestHandle *handle)
525{ 531{
526 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry; 532 struct GNUNET_RECLAIM_AttributeListEntry *claim_entry;
527 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
528 struct EgoEntry *ego_entry; 533 struct EgoEntry *ego_entry;
529 struct EgoEntry *ego_tmp; 534 struct EgoEntry *ego_tmp;
530 535
@@ -564,22 +569,9 @@ cleanup_handle (struct RequestHandle *handle)
564 json_decref (handle->oidc->response); 569 json_decref (handle->oidc->response);
565 GNUNET_free (handle->oidc); 570 GNUNET_free (handle->oidc);
566 } 571 }
567 if (NULL != handle->attr_list) 572 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
568 { 573 GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list);
569 for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) 574
570 {
571 claim_tmp = claim_entry;
572 claim_entry = claim_entry->next;
573 if (NULL != claim_tmp->claim)
574 GNUNET_free (claim_tmp->claim);
575 if (NULL != claim_tmp->attest)
576 GNUNET_free (claim_tmp->attest);
577 if (NULL != claim_tmp->reference)
578 GNUNET_free (claim_tmp->reference);
579 GNUNET_free (claim_tmp);
580 }
581 GNUNET_free (handle->attr_list);
582 }
583 for (ego_entry = handle->ego_head; NULL != ego_entry;) 575 for (ego_entry = handle->ego_head; NULL != ego_entry;)
584 { 576 {
585 ego_tmp = ego_entry; 577 ego_tmp = ego_entry;
@@ -934,6 +926,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
934 code_string = OIDC_build_authz_code (&handle->priv_key, 926 code_string = OIDC_build_authz_code (&handle->priv_key,
935 &handle->ticket, 927 &handle->ticket,
936 handle->attr_list, 928 handle->attr_list,
929 handle->attests_list,
937 handle->oidc->nonce, 930 handle->oidc->nonce,
938 handle->oidc->code_challenge); 931 handle->oidc->code_challenge);
939 if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) && 932 if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) &&
@@ -991,107 +984,61 @@ oidc_collect_finished_cb (void *cls)
991 984
992 985
993/** 986/**
994 * Collects all attributes/references for an ego if in scope parameter 987 * Collects all attributes for an ego if in scope parameter
995 */ 988 */
996static void 989static void
997oidc_attr_collect (void *cls, 990oidc_attr_collect (void *cls,
998 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 991 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
999 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 992 const struct GNUNET_RECLAIM_Attribute *attr,
1000 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 993 const struct GNUNET_RECLAIM_Attestation *attest)
1001 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
1002{ 994{
1003 struct RequestHandle *handle = cls; 995 struct RequestHandle *handle = cls;
1004 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 996 struct GNUNET_RECLAIM_AttributeListEntry *le;
1005 char *scope_variables; 997 char *scope_variables;
1006 char *scope_variable; 998 char *scope_variable;
1007 char delimiter[] = " "; 999 char delimiter[] = " ";
1008 1000
1009 if ((NULL == attr) && (NULL == reference)) 1001 scope_variables = GNUNET_strdup (handle->oidc->scope);
1002 scope_variable = strtok (scope_variables, delimiter);
1003 while (NULL != scope_variable)
1010 { 1004 {
1011 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1005 if (0 == strcmp (attr->name, scope_variable))
1012 return; 1006 break;
1007 scope_variable = strtok (NULL, delimiter);
1013 } 1008 }
1014 if (NULL != reference) 1009 if (NULL == scope_variable)
1015 { 1010 {
1016 if ((NULL == reference->name) || (NULL == reference->reference_value)) 1011 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1017 {
1018 return;
1019 }
1020 scope_variables = GNUNET_strdup (handle->oidc->scope);
1021 scope_variable = strtok (scope_variables, delimiter);
1022 while (NULL != scope_variable)
1023 {
1024 if (0 == strcmp (reference->name, scope_variable))
1025 break;
1026 scope_variable = strtok (NULL, delimiter);
1027 }
1028 if (NULL == scope_variable)
1029 {
1030 GNUNET_free (scope_variables);
1031 return;
1032 }
1033 GNUNET_free (scope_variables); 1012 GNUNET_free (scope_variables);
1034 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le2; 1013 // We can ignore this
1035 le2 = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1014 return;
1036 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 1015 }
1037 le->claim = NULL; 1016 GNUNET_free (scope_variables);
1038 le->reference = NULL; 1017 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1039 le->attest = GNUNET_RECLAIM_ATTESTATION_claim_new (attest->name, 1018 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
1019 &attr->attestation,
1020 attr->type,
1021 attr->data,
1022 attr->data_size);
1023 le->attribute->id = attr->id;
1024 le->attribute->flag = attr->flag;
1025 le->attribute->attestation = attr->attestation;
1026 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1027 handle->attr_list->list_tail,
1028 le);
1029 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
1030 {
1031 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1032 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1033 ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name,
1040 attest->type, 1034 attest->type,
1041 attest->data, 1035 attest->data,
1042 attest->data_size); 1036 attest->data_size);
1043 le->attest->id = attest->id; 1037 GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head,
1044 le2->attest = NULL; 1038 handle->attests_list->list_tail,
1045 le2->claim = NULL; 1039 ale);
1046 le2->reference = GNUNET_RECLAIM_ATTESTATION_reference_new (reference->name,
1047 reference->
1048 reference_value);
1049 le2->reference->id = reference->id;
1050 le2->reference->id_attest = reference->id_attest;
1051 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1052 handle->attr_list->list_tail,
1053 le);
1054 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1055 handle->attr_list->list_tail,
1056 le2);
1057 }
1058 else if (NULL != attr)
1059 {
1060 if ((NULL == attr->name) || (NULL == attr->data))
1061 {
1062 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1063 return;
1064 }
1065 scope_variables = GNUNET_strdup (handle->oidc->scope);
1066 scope_variable = strtok (scope_variables, delimiter);
1067 while (NULL != scope_variable)
1068 {
1069 if (0 == strcmp (attr->name, scope_variable))
1070 break;
1071 scope_variable = strtok (NULL, delimiter);
1072 }
1073 if (NULL == scope_variable)
1074 {
1075 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1076 GNUNET_free (scope_variables);
1077 return;
1078 }
1079 GNUNET_free (scope_variables);
1080 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
1081 le->reference = NULL;
1082 le->attest = NULL;
1083 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
1084 attr->type,
1085 attr->data,
1086 attr->data_size);
1087 le->claim->id = attr->id;
1088 le->claim->flag = attr->flag;
1089
1090 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1091 handle->attr_list->list_tail,
1092 le);
1093 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1094 } 1040 }
1041 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1095} 1042}
1096 1043
1097 1044
@@ -1149,7 +1096,7 @@ code_redirect (void *cls)
1149 *GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego); 1096 *GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego);
1150 handle->idp = GNUNET_RECLAIM_connect (cfg); 1097 handle->idp = GNUNET_RECLAIM_connect (cfg);
1151 handle->attr_list = 1098 handle->attr_list =
1152 GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1099 GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1153 handle->attr_it = 1100 handle->attr_it =
1154 GNUNET_RECLAIM_get_attributes_start (handle->idp, 1101 GNUNET_RECLAIM_get_attributes_start (handle->idp,
1155 &handle->priv_key, 1102 &handle->priv_key,
@@ -1784,7 +1731,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1784 struct RequestHandle *handle = cls; 1731 struct RequestHandle *handle = cls;
1785 const struct EgoEntry *ego_entry; 1732 const struct EgoEntry *ego_entry;
1786 struct GNUNET_TIME_Relative expiration_time; 1733 struct GNUNET_TIME_Relative expiration_time;
1787 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *cl; 1734 struct GNUNET_RECLAIM_AttributeList *cl;
1735 struct GNUNET_RECLAIM_AttestationList *al;
1788 struct GNUNET_RECLAIM_Ticket ticket; 1736 struct GNUNET_RECLAIM_Ticket ticket;
1789 struct GNUNET_CRYPTO_EcdsaPublicKey cid; 1737 struct GNUNET_CRYPTO_EcdsaPublicKey cid;
1790 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 1738 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
@@ -1872,7 +1820,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1872 1820
1873 // decode code 1821 // decode code
1874 if (GNUNET_OK != OIDC_parse_authz_code (privkey, code, code_verifier, &ticket, 1822 if (GNUNET_OK != OIDC_parse_authz_code (privkey, code, code_verifier, &ticket,
1875 &cl, &nonce)) 1823 &cl, &al, &nonce))
1876 { 1824 {
1877 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST); 1825 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST);
1878 handle->edesc = GNUNET_strdup ("invalid code"); 1826 handle->edesc = GNUNET_strdup ("invalid code");
@@ -1912,6 +1860,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1912 id_token = OIDC_id_token_new (&ticket.audience, 1860 id_token = OIDC_id_token_new (&ticket.audience,
1913 &ticket.identity, 1861 &ticket.identity,
1914 cl, 1862 cl,
1863 al,
1915 &expiration_time, 1864 &expiration_time,
1916 (NULL != nonce) ? nonce : NULL, 1865 (NULL != nonce) ? nonce : NULL,
1917 jwt_secret); 1866 jwt_secret);
@@ -1927,7 +1876,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1927 MHD_add_response_header (resp, "Pragma", "no-cache"); 1876 MHD_add_response_header (resp, "Pragma", "no-cache");
1928 MHD_add_response_header (resp, "Content-Type", "application/json"); 1877 MHD_add_response_header (resp, "Content-Type", "application/json");
1929 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 1878 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1930 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cl); 1879 GNUNET_RECLAIM_attribute_list_destroy (cl);
1880 GNUNET_RECLAIM_attestation_list_destroy (al);
1931 GNUNET_free (access_token); 1881 GNUNET_free (access_token);
1932 GNUNET_free (json_response); 1882 GNUNET_free (json_response);
1933 GNUNET_free (id_token); 1883 GNUNET_free (id_token);
@@ -1936,14 +1886,13 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1936 1886
1937 1887
1938/** 1888/**
1939 * Collects claims and stores them in handle 1889 * Collects claims and stores them in handle
1940 */ 1890 */
1941static void 1891static void
1942consume_ticket (void *cls, 1892consume_ticket (void *cls,
1943 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1893 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1944 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1894 const struct GNUNET_RECLAIM_Attribute *attr,
1945 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 1895 const struct GNUNET_RECLAIM_Attestation *attest)
1946 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
1947{ 1896{
1948 struct RequestHandle *handle = cls; 1897 struct RequestHandle *handle = cls;
1949 if (NULL == identity) 1898 if (NULL == identity)
@@ -1951,82 +1900,76 @@ consume_ticket (void *cls,
1951 GNUNET_SCHEDULER_add_now (&return_userinfo_response, handle); 1900 GNUNET_SCHEDULER_add_now (&return_userinfo_response, handle);
1952 return; 1901 return;
1953 } 1902 }
1954 if (NULL != attr) 1903 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
1955 { 1904 {
1956 char *tmp_value; 1905 char *tmp_value;
1957 json_t *value; 1906 json_t *value;
1958 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 1907 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1959 attr->data, 1908 attr->data,
1960 attr->data_size); 1909 attr->data_size);
1961 value = json_string (tmp_value); 1910 value = json_string (tmp_value);
1962 json_object_set_new (handle->oidc->response, attr->name, value); 1911 json_object_set_new (handle->oidc->response, attr->name, value);
1963 GNUNET_free (tmp_value); 1912 GNUNET_free (tmp_value);
1913 return;
1964 } 1914 }
1965 else if ((NULL != attest) && (NULL != reference)) 1915 json_t *claim_sources;
1966 { 1916 json_t *claim_sources_jwt;
1967 json_t *claim_sources; 1917 json_t *claim_names;
1968 json_t *claim_sources_jwt; 1918 char *attest_val_str;
1969 json_t *claim_names; 1919 claim_sources = json_object_get (handle->oidc->response,"_claim_sources");
1970 char *attest_val_str; 1920 claim_names = json_object_get (handle->oidc->response,"_claim_names");
1971 claim_sources=json_object_get(handle->oidc->response,"_claim_sources"); 1921 attest_val_str =
1972 claim_names=json_object_get(handle->oidc->response,"_claim_names"); 1922 GNUNET_RECLAIM_attestation_value_to_string (attest->type,
1973 attest_val_str = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type, 1923 attest->data,
1974 attest->data, 1924 attest->data_size);
1975 attest-> 1925 if ((NULL == claim_sources) && (NULL == claim_names) )
1976 data_size); 1926 {
1977 if ((NULL == claim_sources) && (NULL == claim_names) ) 1927 claim_sources = json_object ();
1978 { 1928 claim_names = json_object ();
1979 claim_sources = json_object (); 1929 }
1980 claim_names = json_object (); 1930 char *source_name;
1981 } 1931 int i = 0;
1982 char *source_name; 1932 GNUNET_asprintf (&source_name, "src%d", i);
1983 int i = 0; 1933 while (NULL != (claim_sources_jwt = json_object_get (claim_sources,
1984 GNUNET_asprintf (&source_name,"src%d",i); 1934 source_name)))
1985 while (NULL != (claim_sources_jwt = json_object_get (claim_sources, 1935 {
1986 source_name))) 1936 if (0 == strcmp (json_string_value (json_object_get (claim_sources_jwt,
1937 "JWT")),
1938 attest_val_str))
1987 { 1939 {
1988 if (0 == strcmp (json_string_value (json_object_get (claim_sources_jwt, 1940 // Adapt only the claim names
1989 "JWT")), 1941 json_object_set_new (claim_names, attr->data,
1990 attest_val_str)) 1942 json_string (source_name));
1991 { 1943 json_object_set (handle->oidc->response,
1992 // Adapt only the claim names 1944 "_claim_names", claim_names);
1993 json_object_set_new (claim_names, reference->name, json_string ( 1945 break;
1994 source_name));
1995 json_object_set (handle->oidc->response, "_claim_names",claim_names);
1996 handle->oidc->response = json_deep_copy(handle->oidc->response);
1997 break;
1998 }
1999 i++;
2000 GNUNET_asprintf (&source_name,"src%d",i);
2001 }
2002
2003 // Create new one
2004 if (NULL == claim_sources_jwt)
2005 {
2006 claim_sources_jwt = json_object ();
2007 // Set the JWT for names
2008 json_object_set_new (claim_names, reference->name, json_string (
2009 source_name));
2010 // Set the JWT for the inner source
2011 json_object_set_new (claim_sources_jwt, "JWT", json_string (
2012 attest_val_str));
2013 // Set the JWT for the source
2014 json_object_set_new (claim_sources, source_name,claim_sources_jwt);
2015 // Set as claims
2016 json_object_set (handle->oidc->response, "_claim_names", claim_names);
2017 json_object_set (handle->oidc->response, "_claim_sources",claim_sources);
2018 handle->oidc->response = json_deep_copy(handle->oidc->response);
2019 } 1946 }
2020 1947 i++;
2021 json_decref (claim_sources); 1948 GNUNET_free (source_name);
2022 json_decref (claim_names); 1949 GNUNET_asprintf (&source_name, "src%d", i);
2023 json_decref (claim_sources_jwt); 1950 }
2024 GNUNET_free (attest_val_str); 1951
2025 } 1952 // Create new one
2026 else 1953 if (NULL == claim_sources_jwt)
2027 { 1954 {
2028 // REMARK: We should not find any claim, one of attest/ref is NULL 1955 claim_sources_jwt = json_object ();
2029 } 1956 // Set the JWT for names
1957 json_object_set_new (claim_names, attr->data,
1958 json_string (source_name));
1959 // Set the JWT for the inner source
1960 json_object_set_new (claim_sources_jwt, "JWT",
1961 json_string (attest_val_str));
1962 // Set the JWT for the source
1963 json_object_set_new (claim_sources, source_name, claim_sources_jwt);
1964 // Set as claims
1965 json_object_set (handle->oidc->response, "_claim_names", claim_names);
1966 json_object_set (handle->oidc->response, "_claim_sources",claim_sources);
1967 }
1968
1969 json_decref (claim_sources);
1970 json_decref (claim_names);
1971 json_decref (claim_sources_jwt);
1972 GNUNET_free (attest_val_str);
2030} 1973}
2031 1974
2032 1975
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 9a6af6bcf..fcb34e11a 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -48,9 +48,9 @@
48#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes" 48#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes"
49 49
50/** 50/**
51 * Attestation namespace 51 * Attestation namespace
52 */ 52 */
53#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE "/reclaim/attestation" 53#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION "/reclaim/attestation"
54 54
55/** 55/**
56 * Ticket namespace 56 * Ticket namespace
@@ -167,7 +167,7 @@ struct RequestHandle
167 /** 167 /**
168 * Attribute claim list 168 * Attribute claim list
169 */ 169 */
170 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; 170 struct GNUNET_RECLAIM_AttributeList *attr_list;
171 171
172 /** 172 /**
173 * IDENTITY Operation 173 * IDENTITY Operation
@@ -190,6 +190,12 @@ struct RequestHandle
190 struct GNUNET_RECLAIM_AttributeIterator *attr_it; 190 struct GNUNET_RECLAIM_AttributeIterator *attr_it;
191 191
192 /** 192 /**
193 * Attribute iterator
194 */
195 struct GNUNET_RECLAIM_AttestationIterator *attest_it;
196
197
198 /**
193 * Ticket iterator 199 * Ticket iterator
194 */ 200 */
195 struct GNUNET_RECLAIM_TicketIterator *ticket_it; 201 struct GNUNET_RECLAIM_TicketIterator *ticket_it;
@@ -247,8 +253,6 @@ struct RequestHandle
247static void 253static void
248cleanup_handle (struct RequestHandle *handle) 254cleanup_handle (struct RequestHandle *handle)
249{ 255{
250 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
251 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
252 struct EgoEntry *ego_entry; 256 struct EgoEntry *ego_entry;
253 struct EgoEntry *ego_tmp; 257 struct EgoEntry *ego_tmp;
254 258
@@ -261,6 +265,8 @@ cleanup_handle (struct RequestHandle *handle)
261 GNUNET_IDENTITY_disconnect (handle->identity_handle); 265 GNUNET_IDENTITY_disconnect (handle->identity_handle);
262 if (NULL != handle->attr_it) 266 if (NULL != handle->attr_it)
263 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); 267 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
268 if (NULL != handle->attest_it)
269 GNUNET_RECLAIM_get_attestations_stop (handle->attest_it);
264 if (NULL != handle->ticket_it) 270 if (NULL != handle->ticket_it)
265 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); 271 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
266 if (NULL != handle->idp) 272 if (NULL != handle->idp)
@@ -269,19 +275,7 @@ cleanup_handle (struct RequestHandle *handle)
269 GNUNET_free (handle->url); 275 GNUNET_free (handle->url);
270 if (NULL != handle->emsg) 276 if (NULL != handle->emsg)
271 GNUNET_free (handle->emsg); 277 GNUNET_free (handle->emsg);
272 if (NULL != handle->attr_list) 278 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
273 {
274 for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
275 {
276 claim_tmp = claim_entry;
277 claim_entry = claim_entry->next;
278 GNUNET_free (claim_tmp->claim);
279 GNUNET_free (claim_tmp->attest);
280 GNUNET_free (claim_tmp->reference);
281 GNUNET_free (claim_tmp);
282 }
283 GNUNET_free (handle->attr_list);
284 }
285 for (ego_entry = handle->ego_head; NULL != ego_entry;) 279 for (ego_entry = handle->ego_head; NULL != ego_entry;)
286 { 280 {
287 ego_tmp = ego_entry; 281 ego_tmp = ego_entry;
@@ -366,6 +360,7 @@ finished_cont (void *cls, int32_t success, const char *emsg)
366 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); 360 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
367} 361}
368 362
363
369static void 364static void
370delete_finished_cb (void *cls, int32_t success, const char *emsg) 365delete_finished_cb (void *cls, int32_t success, const char *emsg)
371{ 366{
@@ -382,6 +377,7 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg)
382 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); 377 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
383} 378}
384 379
380
385/** 381/**
386 * Return attributes for identity 382 * Return attributes for identity
387 * 383 *
@@ -456,85 +452,6 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
456 452
457 453
458static void 454static void
459add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle,
460 const char *url,
461 void *cls)
462{
463 struct RequestHandle *handle = cls;
464 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
465 const char *identity;
466 struct EgoEntry *ego_entry;
467 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attribute;
468 struct GNUNET_TIME_Relative exp;
469 char term_data[handle->rest_handle->data_size + 1];
470 json_t *data_json;
471 json_error_t err;
472 struct GNUNET_JSON_Specification attrspec[] =
473 { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attribute),
474 GNUNET_JSON_spec_end () };
475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
476 "Adding an attestation reference for %s.\n",
477 handle->url);
478 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
479 "reference/") + 1 >= strlen (
480 handle->url))
481 {
482 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
483 GNUNET_SCHEDULER_add_now (&do_error, handle);
484 return;
485 }
486 identity = handle->url + strlen (
487 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
488 + 1;
489 for (ego_entry = handle->ego_head; NULL != ego_entry;
490 ego_entry = ego_entry->next)
491 if (0 == strcmp (identity, ego_entry->identifier))
492 break;
493 if (NULL == ego_entry)
494 {
495 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
496 return;
497 }
498 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
499 if (0 >= handle->rest_handle->data_size)
500 {
501 GNUNET_SCHEDULER_add_now (&do_error, handle);
502 return;
503 }
504
505 term_data[handle->rest_handle->data_size] = '\0';
506 GNUNET_memcpy (term_data,
507 handle->rest_handle->data,
508 handle->rest_handle->data_size);
509 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
510 GNUNET_assert (GNUNET_OK ==
511 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
512 json_decref (data_json);
513 if (NULL == attribute)
514 {
515 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
516 "Unable to parse attestation reference from %s\n",
517 term_data);
518 GNUNET_SCHEDULER_add_now (&do_error, handle);
519 return;
520 }
521 /**
522 * New ID for attribute
523 */
524 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
525 attribute->id = attribute->id_attest;
526 handle->idp = GNUNET_RECLAIM_connect (cfg);
527 exp = GNUNET_TIME_UNIT_HOURS;
528 handle->idp_op = GNUNET_RECLAIM_attestation_reference_store (handle->idp,
529 identity_priv,
530 attribute,
531 &exp,
532 &finished_cont,
533 handle);
534 GNUNET_JSON_parse_free (attrspec);
535}
536
537static void
538parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 455parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
539 const char *url, 456 const char *url,
540 void *cls) 457 void *cls)
@@ -576,16 +493,16 @@ parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
576 } 493 }
577 if (0 == strcmp (type_str, "JWT")) 494 if (0 == strcmp (type_str, "JWT"))
578 { 495 {
579 // The value is a JWT 496 // The value is a JWT
580 char *decoded_jwt; 497 char *decoded_jwt;
581 char delim[] = "."; 498 char delim[] = ".";
582 char *jwt_body = strtok (val_str, delim); 499 char *jwt_body = strtok (val_str, delim);
583 jwt_body = strtok (NULL, delim); 500 jwt_body = strtok (NULL, delim);
584 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), 501 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
585 (void **) &decoded_jwt); 502 (void **) &decoded_jwt);
586 resp = GNUNET_REST_create_response (decoded_jwt); 503 resp = GNUNET_REST_create_response (decoded_jwt);
587 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 504 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
588 GNUNET_free (decoded_jwt); 505 GNUNET_free (decoded_jwt);
589 } 506 }
590 else 507 else
591 { 508 {
@@ -598,42 +515,31 @@ parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
598 json_decref (data_json); 515 json_decref (data_json);
599} 516}
600 517
518
601static void 519static void
602add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 520add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
603 const char *url, 521 const char *url,
604 void *cls) 522 void *cls)
605{ 523{
606 struct RequestHandle *handle = cls; 524 struct RequestHandle *handle = cls;
607 /* Check for substring "reference" */ 525 /* Check for substring "parse"
608 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen ( 526 * FIXME UGLY! */
527 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) < strlen (
609 handle->url)) 528 handle->url))
610 { 529 {
611 if ( strncmp ("reference/", (handle->url + strlen ( 530 if (strncmp ("parse", (handle->url + strlen (
612 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) 531 GNUNET_REST_API_NS_RECLAIM_ATTESTATION)
613 + 1), strlen ( 532 + 1), strlen (
614 "reference/")) == 0) 533 "parse")) == 0)
615 { 534 {
616 add_attestation_ref_cont (con_handle,url,cls); 535 parse_attestation_cont (con_handle,url,cls);
617 return; 536 return;
618 } 537 }
619 } 538 }
620 /* Check for substring "parse" */
621 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
622 handle->url))
623 {
624 if ( strncmp ("parse", (handle->url + strlen (
625 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
626 + 1), strlen (
627 "parse")) == 0)
628 {
629 parse_attestation_cont (con_handle,url,cls);
630 return;
631 }
632 }
633 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; 539 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
634 const char *identity; 540 const char *identity;
635 struct EgoEntry *ego_entry; 541 struct EgoEntry *ego_entry;
636 struct GNUNET_RECLAIM_ATTESTATION_Claim *attribute; 542 struct GNUNET_RECLAIM_Attestation *attribute;
637 struct GNUNET_TIME_Relative exp; 543 struct GNUNET_TIME_Relative exp;
638 char term_data[handle->rest_handle->data_size + 1]; 544 char term_data[handle->rest_handle->data_size + 1];
639 json_t *data_json; 545 json_t *data_json;
@@ -645,7 +551,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
646 "Adding an attestation for %s.\n", 552 "Adding an attestation for %s.\n",
647 handle->url); 553 handle->url);
648 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen ( 554 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
649 handle->url)) 555 handle->url))
650 { 556 {
651 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 557 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -653,7 +559,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
653 return; 559 return;
654 } 560 }
655 identity = handle->url + strlen ( 561 identity = handle->url + strlen (
656 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1; 562 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1;
657 563
658 for (ego_entry = handle->ego_head; NULL != ego_entry; 564 for (ego_entry = handle->ego_head; NULL != ego_entry;
659 ego_entry = ego_entry->next) 565 ego_entry = ego_entry->next)
@@ -705,104 +611,6 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
705 GNUNET_JSON_parse_free (attrspec); 611 GNUNET_JSON_parse_free (attrspec);
706} 612}
707 613
708/**
709 * Collect all references for an ego
710 *
711 */
712static void
713ref_collect (void *cls,
714 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
715 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
716 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
717 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
718{
719 struct RequestHandle *handle = cls;
720 json_t *attr_obj;
721 char *id_str;
722 char *id_attest_str;
723
724 if (NULL == reference)
725 {
726 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
727 return;
728 }
729
730 if ((NULL == reference->name) || (NULL == reference->reference_value))
731 {
732 return;
733 }
734
735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference: %s\n",
736 reference->name);
737 attr_obj = json_object ();
738 json_object_set_new (attr_obj, "name", json_string (reference->name));
739 json_object_set_new (attr_obj, "ref_value", json_string (
740 reference->reference_value));
741 id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id,
742 sizeof(reference->id));
743 id_attest_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id_attest,
744 sizeof(reference->id_attest));
745 json_object_set_new (attr_obj, "id", json_string (id_str));
746 json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str));
747 json_array_append (handle->resp_object, attr_obj);
748 json_decref (attr_obj);
749}
750
751/**
752 * Lists references for identity request
753 *
754 * @param con_handle the connection handle
755 * @param url the url
756 * @param cls the RequestHandle
757 */
758static void
759list_reference_cont (struct GNUNET_REST_RequestHandle *con_handle,
760 const char *url,
761 void *cls)
762{
763 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
764 struct RequestHandle *handle = cls;
765 struct EgoEntry *ego_entry;
766 char *identity;
767
768 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
769 "Getting references for %s.\n",
770 handle->url);
771 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
772 "reference/") + 1 >= strlen (
773 handle->url))
774 {
775 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
776 GNUNET_SCHEDULER_add_now (&do_error, handle);
777 return;
778 }
779 identity = handle->url + strlen (
780 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
781 + 1;
782 for (ego_entry = handle->ego_head; NULL != ego_entry;
783 ego_entry = ego_entry->next)
784 if (0 == strcmp (identity, ego_entry->identifier))
785 break;
786 handle->resp_object = json_array ();
787
788 if (NULL == ego_entry)
789 {
790 // Done
791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
792 GNUNET_SCHEDULER_add_now (&return_response, handle);
793 return;
794 }
795 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
796 handle->idp = GNUNET_RECLAIM_connect (cfg);
797 handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
798 priv_key,
799 &collect_error_cb,
800 handle,
801 &ref_collect,
802 handle,
803 &collect_finished_cb,
804 handle);
805}
806 614
807/** 615/**
808 * Collect all attestations for an ego 616 * Collect all attestations for an ego
@@ -811,9 +619,7 @@ list_reference_cont (struct GNUNET_REST_RequestHandle *con_handle,
811static void 619static void
812attest_collect (void *cls, 620attest_collect (void *cls,
813 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 621 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
814 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 622 const struct GNUNET_RECLAIM_Attestation *attest)
815 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
816 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
817{ 623{
818 struct RequestHandle *handle = cls; 624 struct RequestHandle *handle = cls;
819 json_t *attr_obj; 625 json_t *attr_obj;
@@ -822,12 +628,6 @@ attest_collect (void *cls,
822 char *id_str; 628 char *id_str;
823 629
824 630
825 if (NULL != reference)
826 {
827 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
828 "Attestation Collection with Reference\n");
829 return;
830 }
831 if (NULL == attest) 631 if (NULL == attest)
832 { 632 {
833 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -847,15 +647,16 @@ attest_collect (void *cls,
847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n", 647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n",
848 attest->name); 648 attest->name);
849 649
850 tmp_value = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type, 650 tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
851 attest->data, 651 attest->data,
852 attest->data_size); 652 attest->data_size);
853 attr_obj = json_object (); 653 attr_obj = json_object ();
854 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 654 json_object_set_new (attr_obj, "value", json_string (tmp_value));
855 json_object_set_new (attr_obj, "name", json_string (attest->name)); 655 json_object_set_new (attr_obj, "name", json_string (attest->name));
856 type = GNUNET_RECLAIM_ATTESTATION_number_to_typename (attest->type); 656 type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
857 json_object_set_new (attr_obj, "type", json_string (type)); 657 json_object_set_new (attr_obj, "type", json_string (type));
858 id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id)); 658 id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id,
659 sizeof(attest->id));
859 json_object_set_new (attr_obj, "id", json_string (id_str)); 660 json_object_set_new (attr_obj, "id", json_string (id_str));
860 json_array_append (handle->resp_object, attr_obj); 661 json_array_append (handle->resp_object, attr_obj);
861 json_decref (attr_obj); 662 json_decref (attr_obj);
@@ -877,19 +678,6 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
877 void *cls) 678 void *cls)
878{ 679{
879 struct RequestHandle *handle = cls; 680 struct RequestHandle *handle = cls;
880 /* Check for substring "reference" */
881 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
882 handle->url))
883 {
884 if ( strncmp ("reference/", (handle->url + strlen (
885 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
886 + 1), strlen (
887 "reference/")) == 0)
888 {
889 list_reference_cont (con_handle,url,cls);
890 return;
891 }
892 }
893 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 681 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
894 struct EgoEntry *ego_entry; 682 struct EgoEntry *ego_entry;
895 char *identity; 683 char *identity;
@@ -897,7 +685,7 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
897 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
898 "Getting attestations for %s.\n", 686 "Getting attestations for %s.\n",
899 handle->url); 687 handle->url);
900 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen ( 688 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
901 handle->url)) 689 handle->url))
902 { 690 {
903 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 691 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -905,7 +693,7 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
905 return; 693 return;
906 } 694 }
907 identity = handle->url + strlen ( 695 identity = handle->url + strlen (
908 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1; 696 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1;
909 697
910 for (ego_entry = handle->ego_head; NULL != ego_entry; 698 for (ego_entry = handle->ego_head; NULL != ego_entry;
911 ego_entry = ego_entry->next) 699 ego_entry = ego_entry->next)
@@ -923,109 +711,14 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
923 } 711 }
924 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 712 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
925 handle->idp = GNUNET_RECLAIM_connect (cfg); 713 handle->idp = GNUNET_RECLAIM_connect (cfg);
926 handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp, 714 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp,
927 priv_key, 715 priv_key,
928 &collect_error_cb, 716 &collect_error_cb,
929 handle, 717 handle,
930 &attest_collect, 718 &attest_collect,
931 handle, 719 handle,
932 &collect_finished_cb, 720 &collect_finished_cb,
933 handle); 721 handle);
934}
935
936/**
937 * Deletes reference from an identity
938 *
939 * @param con_handle the connection handle
940 * @param url the url
941 * @param cls the RequestHandle
942 */
943static void
944delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle,
945 const char *url,
946 void *cls)
947{
948 struct RequestHandle *handle = cls;
949 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
950 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
951 struct EgoEntry *ego_entry;
952 char *identity;
953 char *identity_id_str;
954 char *id;
955 char term_data[handle->rest_handle->data_size + 1];
956 json_t *data_json;
957 json_error_t err;
958
959 struct GNUNET_JSON_Specification attrspec[] =
960 { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attr),
961 GNUNET_JSON_spec_end () };
962 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
963 "Deleting attestation reference.\n");
964 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
965 "reference/") + 1 >= strlen (
966 handle->url))
967 {
968 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
969 GNUNET_SCHEDULER_add_now (&do_error, handle);
970 return;
971 }
972 identity_id_str = strdup (handle->url + strlen (
973 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
974 + strlen ("reference/")
975 + 1);
976 identity = strtok (identity_id_str, "/");
977 id = strtok (NULL, "/");
978
979 if ((NULL == identity) || (NULL == id))
980 {
981 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
982 GNUNET_SCHEDULER_add_now (&do_error, handle);
983 return;
984 }
985 for (ego_entry = handle->ego_head; NULL != ego_entry;
986 ego_entry = ego_entry->next)
987 if (0 == strcmp (identity, ego_entry->identifier))
988 break;
989 handle->resp_object = json_array ();
990 if (NULL == ego_entry)
991 {
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
993 GNUNET_SCHEDULER_add_now (&return_response, handle);
994 return;
995 }
996 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
997 if (0 >= handle->rest_handle->data_size)
998 {
999 GNUNET_SCHEDULER_add_now (&do_error, handle);
1000 return;
1001 }
1002
1003 term_data[handle->rest_handle->data_size] = '\0';
1004 GNUNET_memcpy (term_data,
1005 handle->rest_handle->data,
1006 handle->rest_handle->data_size);
1007 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1008 GNUNET_assert (GNUNET_OK ==
1009 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
1010 json_decref (data_json);
1011 if (NULL == attr)
1012 {
1013 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1014 "Unable to parse attestation reference from %s\n",
1015 term_data);
1016 GNUNET_SCHEDULER_add_now (&do_error, handle);
1017 return;
1018 }
1019 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(attr->id));
1020
1021 handle->idp = GNUNET_RECLAIM_connect (cfg);
1022 handle->idp_op = GNUNET_RECLAIM_attestation_reference_delete (handle->idp,
1023 priv_key,
1024 attr,
1025 &
1026 delete_finished_cb,
1027 handle);
1028 GNUNET_JSON_parse_free (attrspec);
1029} 722}
1030 723
1031 724
@@ -1042,28 +735,15 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
1042 void *cls) 735 void *cls)
1043{ 736{
1044 struct RequestHandle *handle = cls; 737 struct RequestHandle *handle = cls;
1045 /* Check for substring "reference" */
1046 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
1047 handle->url))
1048 {
1049 if ( strncmp ("reference", (handle->url + strlen (
1050 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
1051 + 1), strlen (
1052 "reference")) == 0)
1053 {
1054 delete_attestation_ref_cont (con_handle,url,cls);
1055 return;
1056 }
1057 }
1058 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 738 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1059 struct GNUNET_RECLAIM_ATTESTATION_Claim attr; 739 struct GNUNET_RECLAIM_Attestation attr;
1060 struct EgoEntry *ego_entry; 740 struct EgoEntry *ego_entry;
1061 char *identity_id_str; 741 char *identity_id_str;
1062 char *identity; 742 char *identity;
1063 char *id; 743 char *id;
1064 744
1065 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n"); 745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
1066 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen ( 746 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
1067 handle->url)) 747 handle->url))
1068 { 748 {
1069 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 749 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -1072,7 +752,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
1072 } 752 }
1073 identity_id_str = 753 identity_id_str =
1074 strdup (handle->url + strlen ( 754 strdup (handle->url + strlen (
1075 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1); 755 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1);
1076 identity = strtok (identity_id_str, "/"); 756 identity = strtok (identity_id_str, "/");
1077 id = strtok (NULL, "/"); 757 id = strtok (NULL, "/");
1078 if ((NULL == identity) || (NULL == id)) 758 if ((NULL == identity) || (NULL == id))
@@ -1098,7 +778,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
1098 } 778 }
1099 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 779 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1100 handle->idp = GNUNET_RECLAIM_connect (cfg); 780 handle->idp = GNUNET_RECLAIM_connect (cfg);
1101 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)); 781 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attestation));
1102 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); 782 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1103 attr.name = ""; 783 attr.name = "";
1104 handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp, 784 handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp,
@@ -1109,6 +789,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
1109 GNUNET_free (identity_id_str); 789 GNUNET_free (identity_id_str);
1110} 790}
1111 791
792
1112/** 793/**
1113 * List tickets for identity request 794 * List tickets for identity request
1114 * 795 *
@@ -1173,7 +854,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1173 const char *identity; 854 const char *identity;
1174 struct RequestHandle *handle = cls; 855 struct RequestHandle *handle = cls;
1175 struct EgoEntry *ego_entry; 856 struct EgoEntry *ego_entry;
1176 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attribute; 857 struct GNUNET_RECLAIM_Attribute *attribute;
1177 struct GNUNET_TIME_Relative exp; 858 struct GNUNET_TIME_Relative exp;
1178 char term_data[handle->rest_handle->data_size + 1]; 859 char term_data[handle->rest_handle->data_size + 1];
1179 json_t *data_json; 860 json_t *data_json;
@@ -1242,20 +923,21 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1242 GNUNET_JSON_parse_free (attrspec); 923 GNUNET_JSON_parse_free (attrspec);
1243} 924}
1244 925
926
1245/** 927/**
1246 * Parse a JWT and return the respective claim value as Attribute 928 * Parse a JWT and return the respective claim value as Attribute
1247 * 929 *
1248 * @param attest the jwt attestation 930 * @param attest the jwt attestation
1249 * @param claim the name of the claim in the JWT 931 * @param claim the name of the claim in the JWT
1250 * 932 *
1251 * @return a GNUNET_RECLAIM_ATTRIBUTE_Claim, containing the new value 933 * @return a GNUNET_RECLAIM_Attribute, containing the new value
1252 */ 934 */
1253struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 935struct GNUNET_RECLAIM_Attribute *
1254parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 936parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
1255 const char *claim) 937 const char *claim)
1256{ 938{
1257 char *jwt_string; 939 char *jwt_string;
1258 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 940 struct GNUNET_RECLAIM_Attribute *attr;
1259 char delim[] = "."; 941 char delim[] = ".";
1260 const char *type_str = NULL; 942 const char *type_str = NULL;
1261 const char *val_str = NULL; 943 const char *val_str = NULL;
@@ -1267,7 +949,7 @@ parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1267 json_t *json_val; 949 json_t *json_val;
1268 json_error_t *json_err = NULL; 950 json_error_t *json_err = NULL;
1269 951
1270 jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type, 952 jwt_string = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
1271 attest->data, 953 attest->data,
1272 attest->data_size); 954 attest->data_size);
1273 char *jwt_body = strtok (jwt_string, delim); 955 char *jwt_body = strtok (jwt_string, delim);
@@ -1284,24 +966,26 @@ parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1284 } 966 }
1285 } 967 }
1286 type_str = "String"; 968 type_str = "String";
1287 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); 969 type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
1288 if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,val_str, 970 if (GNUNET_SYSERR == GNUNET_RECLAIM_attribute_string_to_value (type,val_str,
1289 (void **) &data, 971 (void **) &data,
1290 &data_size))) 972 &data_size))
1291 { 973 {
1292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1293 "Attribute value from JWT Parser invalid!\n"); 975 "Attribute value from JWT Parser invalid!\n");
1294 GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, 976 GNUNET_RECLAIM_attribute_string_to_value (type,
1295 "Error: Referenced Claim Name not Found", 977 "Error: Referenced Claim Name not Found",
1296 (void **) &data, 978 (void **) &data,
1297 &data_size); 979 &data_size);
1298 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size); 980 attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
981 type, data, data_size);
1299 attr->id = attest->id; 982 attr->id = attest->id;
1300 attr->flag = 1; 983 attr->flag = 1;
1301 } 984 }
1302 else 985 else
1303 { 986 {
1304 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size); 987 attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
988 type, data, data_size);
1305 attr->id = attest->id; 989 attr->id = attest->id;
1306 attr->flag = 1; 990 attr->flag = 1;
1307 } 991 }
@@ -1316,53 +1000,34 @@ parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1316static void 1000static void
1317attr_collect (void *cls, 1001attr_collect (void *cls,
1318 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1002 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1319 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1003 const struct GNUNET_RECLAIM_Attribute *attr,
1320 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 1004 const struct GNUNET_RECLAIM_Attestation *attest)
1321 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
1322{ 1005{
1323 struct RequestHandle *handle = cls; 1006 struct RequestHandle *handle = cls;
1324 json_t *attr_obj; 1007 json_t *attr_obj;
1325 const char *type; 1008 const char *type;
1326 char *id_str; 1009 char *id_str;
1327 1010
1328 if ((NULL == attr) && (NULL == reference)) 1011 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
1329 { 1012 {
1330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1013 struct GNUNET_RECLAIM_Attribute *attr2;
1331 "Attribute Collection with empty Attribute/Reference\n"); 1014 attr2 = parse_jwt (attest, attr->data);
1332 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1333 return;
1334 }
1335
1336 if (NULL == attr)
1337 {
1338
1339 if ((NULL == reference->name) || (NULL == reference->reference_value))
1340 {
1341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1342 "Attribute Collection with empty Reference Name/Value\n");
1343 return;
1344 }
1345 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2;
1346 attr2 = parse_jwt (attest, reference->reference_value);
1347 if (NULL == attr2) 1015 if (NULL == attr2)
1348 { 1016 {
1349 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1350 "Attribute Collection with unparsed Attestation\n"); 1018 "Attribute Collection with unparsed Attestation\n");
1351 return; 1019 return;
1352 } 1020 }
1353 attr2->name = reference->name; 1021 attr2->name = attr->name;
1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n",
1355 reference->name);
1356 char *tmp_value; 1022 char *tmp_value;
1357 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr2->type, 1023 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr2->type,
1358 attr2->data, 1024 attr2->data,
1359 attr2->data_size); 1025 attr2->data_size);
1360 attr_obj = json_object (); 1026 attr_obj = json_object ();
1361
1362 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 1027 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1363 json_object_set_new (attr_obj, "name", json_string (attr2->name)); 1028 json_object_set_new (attr_obj, "name", json_string (attr2->name));
1364 json_object_set_new (attr_obj, "flag", json_string ("1")); 1029 json_object_set_new (attr_obj, "flag", json_string ("1"));
1365 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr2->type); 1030 type = GNUNET_RECLAIM_attribute_number_to_typename (attr2->type);
1366 json_object_set_new (attr_obj, "type", json_string (type)); 1031 json_object_set_new (attr_obj, "type", json_string (type));
1367 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id, 1032 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id,
1368 sizeof(attr2->id)); 1033 sizeof(attr2->id));
@@ -1373,18 +1038,11 @@ attr_collect (void *cls,
1373 } 1038 }
1374 else 1039 else
1375 { 1040 {
1376 if ((NULL == attr->name) || (NULL == attr->data))
1377 {
1378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1379 "Attribute Collection with empty Attribute Name/Value\n");
1380 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1381 return;
1382 }
1383 char *tmp_value; 1041 char *tmp_value;
1384 char *flag_str; 1042 char *flag_str;
1385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); 1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1386 1044
1387 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 1045 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1388 attr->data, 1046 attr->data,
1389 attr->data_size); 1047 attr->data_size);
1390 1048
@@ -1393,7 +1051,7 @@ attr_collect (void *cls,
1393 json_object_set_new (attr_obj, "name", json_string (attr->name)); 1051 json_object_set_new (attr_obj, "name", json_string (attr->name));
1394 GNUNET_asprintf (&flag_str,"%d",attr->flag); 1052 GNUNET_asprintf (&flag_str,"%d",attr->flag);
1395 json_object_set_new (attr_obj, "flag", json_string (flag_str)); 1053 json_object_set_new (attr_obj, "flag", json_string (flag_str));
1396 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 1054 type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
1397 json_object_set_new (attr_obj, "type", json_string (type)); 1055 json_object_set_new (attr_obj, "type", json_string (type));
1398 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, 1056 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
1399 sizeof(attr->id)); 1057 sizeof(attr->id));
@@ -1405,6 +1063,7 @@ attr_collect (void *cls,
1405 } 1063 }
1406} 1064}
1407 1065
1066
1408/** 1067/**
1409 * List attributes for identity request 1068 * List attributes for identity request
1410 * 1069 *
@@ -1474,7 +1133,7 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1474{ 1133{
1475 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 1134 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1476 struct RequestHandle *handle = cls; 1135 struct RequestHandle *handle = cls;
1477 struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr; 1136 struct GNUNET_RECLAIM_Attribute attr;
1478 struct EgoEntry *ego_entry; 1137 struct EgoEntry *ego_entry;
1479 char *identity_id_str; 1138 char *identity_id_str;
1480 char *identity; 1139 char *identity;
@@ -1514,7 +1173,7 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1514 } 1173 }
1515 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 1174 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1516 handle->idp = GNUNET_RECLAIM_connect (cfg); 1175 handle->idp = GNUNET_RECLAIM_connect (cfg);
1517 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); 1176 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1518 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); 1177 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1519 attr.name = ""; 1178 attr.name = "";
1520 handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp, 1179 handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
@@ -1603,9 +1262,8 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
1603static void 1262static void
1604consume_cont (void *cls, 1263consume_cont (void *cls,
1605 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1264 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1606 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1265 const struct GNUNET_RECLAIM_Attribute *attr,
1607 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 1266 const struct GNUNET_RECLAIM_Attestation *attest)
1608 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
1609{ 1267{
1610 struct RequestHandle *handle = cls; 1268 struct RequestHandle *handle = cls;
1611 char *val_str; 1269 char *val_str;
@@ -1618,7 +1276,7 @@ consume_cont (void *cls,
1618 } 1276 }
1619 1277
1620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); 1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1621 val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 1279 val_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1622 attr->data, 1280 attr->data,
1623 attr->data_size); 1281 attr->data_size);
1624 if (NULL == val_str) 1282 if (NULL == val_str)
@@ -1749,13 +1407,13 @@ init_cont (struct RequestHandle *handle)
1749 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, 1407 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
1750 &delete_attribute_cont }, 1408 &delete_attribute_cont },
1751 { MHD_HTTP_METHOD_GET, 1409 { MHD_HTTP_METHOD_GET,
1752 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, 1410 GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
1753 &list_attestation_cont }, 1411 &list_attestation_cont },
1754 { MHD_HTTP_METHOD_POST, 1412 { MHD_HTTP_METHOD_POST,
1755 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, 1413 GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
1756 &add_attestation_cont }, 1414 &add_attestation_cont },
1757 { MHD_HTTP_METHOD_DELETE, 1415 { MHD_HTTP_METHOD_DELETE,
1758 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, 1416 GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
1759 &delete_attestation_cont }, 1417 &delete_attestation_cont },
1760 { MHD_HTTP_METHOD_GET, 1418 { MHD_HTTP_METHOD_GET,
1761 GNUNET_REST_API_NS_IDENTITY_TICKETS, 1419 GNUNET_REST_API_NS_IDENTITY_TICKETS,
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index ff953a096..3da49fe7a 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -139,6 +139,11 @@ struct AttributeResultMessage
139 uint16_t attr_len GNUNET_PACKED; 139 uint16_t attr_len GNUNET_PACKED;
140 140
141 /** 141 /**
142 * Length of serialized attestation data
143 */
144 uint16_t attestation_len GNUNET_PACKED;
145
146 /**
142 * always zero (for alignment) 147 * always zero (for alignment)
143 */ 148 */
144 uint16_t reserved GNUNET_PACKED; 149 uint16_t reserved GNUNET_PACKED;
@@ -154,6 +159,42 @@ struct AttributeResultMessage
154}; 159};
155 160
156/** 161/**
162 * Attestation is returned from the idp.
163 */
164struct AttestationResultMessage
165{
166 /**
167 * Message header
168 */
169 struct GNUNET_MessageHeader header;
170
171 /**
172 * Unique identifier for this request (for key collisions).
173 */
174 uint32_t id GNUNET_PACKED;
175
176 /**
177 * Length of serialized attribute data
178 */
179 uint16_t attestation_len GNUNET_PACKED;
180
181 /**
182 * always zero (for alignment)
183 */
184 uint16_t reserved GNUNET_PACKED;
185
186 /**
187 * The public key of the identity.
188 */
189 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
190
191 /* followed by:
192 * serialized attestation data
193 */
194};
195
196
197/**
157 * Reference plus Attestation is returned from the idp. 198 * Reference plus Attestation is returned from the idp.
158 */ 199 */
159struct ReferenceResultMessage 200struct ReferenceResultMessage
@@ -463,6 +504,11 @@ struct ConsumeTicketResultMessage
463 uint16_t attrs_len GNUNET_PACKED; 504 uint16_t attrs_len GNUNET_PACKED;
464 505
465 /** 506 /**
507 * Length of attestation data
508 */
509 uint16_t attestations_len;
510
511 /**
466 * always zero (for alignment) 512 * always zero (for alignment)
467 */ 513 */
468 uint16_t reserved GNUNET_PACKED; 514 uint16_t reserved GNUNET_PACKED;
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 5a3bee218..0fcf95ee3 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -72,6 +72,11 @@ struct GNUNET_RECLAIM_Operation
72 GNUNET_RECLAIM_AttributeResult ar_cb; 72 GNUNET_RECLAIM_AttributeResult ar_cb;
73 73
74 /** 74 /**
75 * Attestation result callback
76 */
77 GNUNET_RECLAIM_AttestationResult at_cb;
78
79 /**
75 * Revocation result callback 80 * Revocation result callback
76 */ 81 */
77 GNUNET_RECLAIM_ContinuationWithStatus rvk_cb; 82 GNUNET_RECLAIM_ContinuationWithStatus rvk_cb;
@@ -228,6 +233,73 @@ struct GNUNET_RECLAIM_AttributeIterator
228 uint32_t r_id; 233 uint32_t r_id;
229}; 234};
230 235
236/**
237 * Handle for a attestation iterator operation
238 */
239struct GNUNET_RECLAIM_AttestationIterator
240{
241 /**
242 * Kept in a DLL.
243 */
244 struct GNUNET_RECLAIM_AttestationIterator *next;
245
246 /**
247 * Kept in a DLL.
248 */
249 struct GNUNET_RECLAIM_AttestationIterator *prev;
250
251 /**
252 * Main handle to access the service.
253 */
254 struct GNUNET_RECLAIM_Handle *h;
255
256 /**
257 * Function to call on completion.
258 */
259 GNUNET_SCHEDULER_TaskCallback finish_cb;
260
261 /**
262 * Closure for @e finish_cb.
263 */
264 void *finish_cb_cls;
265
266 /**
267 * The continuation to call with the results
268 */
269 GNUNET_RECLAIM_AttestationResult proc;
270
271 /**
272 * Closure for @e proc.
273 */
274 void *proc_cls;
275
276 /**
277 * Function to call on errors.
278 */
279 GNUNET_SCHEDULER_TaskCallback error_cb;
280
281 /**
282 * Closure for @e error_cb.
283 */
284 void *error_cb_cls;
285
286 /**
287 * Envelope of the message to send to the service, if not yet
288 * sent.
289 */
290 struct GNUNET_MQ_Envelope *env;
291
292 /**
293 * Private key of the zone.
294 */
295 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
296
297 /**
298 * The operation id this zone iteration operation has
299 */
300 uint32_t r_id;
301};
302
231 303
232/** 304/**
233 * Handle to the service. 305 * Handle to the service.
@@ -272,6 +344,16 @@ struct GNUNET_RECLAIM_Handle
272 /** 344 /**
273 * Head of active iterations 345 * Head of active iterations
274 */ 346 */
347 struct GNUNET_RECLAIM_AttestationIterator *ait_head;
348
349 /**
350 * Tail of active iterations
351 */
352 struct GNUNET_RECLAIM_AttestationIterator *ait_tail;
353
354 /**
355 * Head of active iterations
356 */
275 struct GNUNET_RECLAIM_TicketIterator *ticket_it_head; 357 struct GNUNET_RECLAIM_TicketIterator *ticket_it_head;
276 358
277 /** 359 /**
@@ -372,6 +454,23 @@ free_it (struct GNUNET_RECLAIM_AttributeIterator *it)
372 454
373 455
374/** 456/**
457 * Free @a it.
458 *
459 * @param ait entry to free
460 */
461static void
462free_ait (struct GNUNET_RECLAIM_AttestationIterator *ait)
463{
464 struct GNUNET_RECLAIM_Handle *h = ait->h;
465
466 GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait);
467 if (NULL != ait->env)
468 GNUNET_MQ_discard (ait->env);
469 GNUNET_free (ait);
470}
471
472
473/**
375 * Free @a op 474 * Free @a op
376 * 475 *
377 * @param op the operation to free 476 * @param op the operation to free
@@ -483,9 +582,12 @@ handle_consume_ticket_result (void *cls,
483 struct GNUNET_RECLAIM_Handle *h = cls; 582 struct GNUNET_RECLAIM_Handle *h = cls;
484 struct GNUNET_RECLAIM_Operation *op; 583 struct GNUNET_RECLAIM_Operation *op;
485 size_t attrs_len; 584 size_t attrs_len;
585 size_t attests_len;
486 uint32_t r_id = ntohl (msg->id); 586 uint32_t r_id = ntohl (msg->id);
587 char *read_ptr;
487 588
488 attrs_len = ntohs (msg->attrs_len); 589 attrs_len = ntohs (msg->attrs_len);
590 attests_len = ntohs (msg->attestations_len);
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); 591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
490 592
491 593
@@ -496,42 +598,53 @@ handle_consume_ticket_result (void *cls,
496 return; 598 return;
497 599
498 { 600 {
499 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 601 struct GNUNET_RECLAIM_AttributeList *attrs;
500 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 602 struct GNUNET_RECLAIM_AttributeListEntry *le;
501 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le2; 603 struct GNUNET_RECLAIM_AttestationList *attests;
604 struct GNUNET_RECLAIM_AttestationListEntry *ale;
502 attrs = 605 attrs =
503 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len); 606 GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
607 read_ptr = ((char *) &msg[1]) + attrs_len;
608 attests =
609 GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len);
504 if (NULL != op->ar_cb) 610 if (NULL != op->ar_cb)
505 { 611 {
506 if (NULL == attrs) 612 if (NULL == attrs)
507 { 613 {
508 op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL); 614 op->ar_cb (op->cls, &msg->identity, NULL, NULL);
509 } 615 }
510 else 616 else
511 { 617 {
512 for (le = attrs->list_head; NULL != le; le = le->next) 618 for (le = attrs->list_head; NULL != le; le = le->next)
513 { 619 {
514 if ((le->reference != NULL) && (le->attest == NULL)) 620 if (GNUNET_NO ==
621 GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
515 { 622 {
516 for (le2 = attrs->list_head; NULL != le2; le2 = le2->next) 623 for (ale = attests->list_head; NULL != ale; ale = ale->next)
517 { 624 {
518 if ((le2->attest != NULL) && 625 if (GNUNET_YES ==
519 (0 == memcmp (&le2->attest->id, 626 GNUNET_RECLAIM_id_is_equal (&le->attribute->id,
520 &le->reference->id_attest, 627 &ale->attestation->id))
521 sizeof (le2->attest->id))))
522 { 628 {
523 op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest, 629 op->ar_cb (op->cls, &msg->identity,
524 le->reference); 630 le->attribute, ale->attestation);
525 break; 631 break;
526 } 632 }
527 633
528 } 634 }
529 } 635 }
636 else // No attestations
637 {
638 op->ar_cb (op->cls, &msg->identity,
639 le->attribute, NULL);
640 }
530 } 641 }
531 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 642 GNUNET_RECLAIM_attribute_list_destroy (attrs);
643 GNUNET_RECLAIM_attestation_list_destroy (attests);
532 attrs = NULL; 644 attrs = NULL;
645 attests = NULL;
533 } 646 }
534 op->ar_cb (op->cls, NULL, NULL, NULL, NULL); 647 op->ar_cb (op->cls, NULL, NULL, NULL);
535 } 648 }
536 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 649 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
537 free_op (op); 650 free_op (op);
@@ -582,9 +695,11 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
582 struct GNUNET_RECLAIM_AttributeIterator *it; 695 struct GNUNET_RECLAIM_AttributeIterator *it;
583 struct GNUNET_RECLAIM_Operation *op; 696 struct GNUNET_RECLAIM_Operation *op;
584 size_t attr_len; 697 size_t attr_len;
698 size_t attest_len;
585 uint32_t r_id = ntohl (msg->id); 699 uint32_t r_id = ntohl (msg->id);
586 700
587 attr_len = ntohs (msg->attr_len); 701 attr_len = ntohs (msg->attr_len);
702 attest_len = ntohs (msg->attestation_len);
588 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); 703 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
589 704
590 705
@@ -615,7 +730,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
615 if (NULL != op) 730 if (NULL != op)
616 { 731 {
617 if (NULL != op->ar_cb) 732 if (NULL != op->ar_cb)
618 op->ar_cb (op->cls, NULL, NULL, NULL, NULL); 733 op->ar_cb (op->cls, NULL, NULL, NULL);
619 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 734 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
620 free_op (op); 735 free_op (op);
621 } 736 }
@@ -623,17 +738,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
623 } 738 }
624 739
625 { 740 {
626 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 741 struct GNUNET_RECLAIM_Attribute *attr;
627 attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len); 742 struct GNUNET_RECLAIM_Attestation *attest;
743 char *read_ptr;
744 attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len);
745 read_ptr = ((char *) &msg[1]) + attr_len;
746 attest = GNUNET_RECLAIM_attestation_deserialize (read_ptr, attest_len);
628 if (NULL != it) 747 if (NULL != it)
629 { 748 {
630 if (NULL != it->proc) 749 if (NULL != it->proc)
631 it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL); 750 it->proc (it->proc_cls, &msg->identity, attr, attest);
632 } 751 }
633 else if (NULL != op) 752 else if (NULL != op)
634 { 753 {
635 if (NULL != op->ar_cb) 754 if (NULL != op->ar_cb)
636 op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL); 755 op->ar_cb (op->cls, &msg->identity, attr, attest);
637 } 756 }
638 GNUNET_free (attr); 757 GNUNET_free (attr);
639 return; 758 return;
@@ -644,21 +763,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
644 763
645/** 764/**
646 * Handle an incoming message of type 765 * Handle an incoming message of type
647 * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 766 * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT
648 * 767 *
649 * @param cls 768 * @param cls
650 * @param msg the message we received 769 * @param msg the message we received
651 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 770 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
652 */ 771 */
653static int 772static int
654check_attestation_result (void *cls, const struct AttributeResultMessage *msg) 773check_attestation_result (void *cls, const struct AttestationResultMessage *msg)
655{ 774{
656 size_t msg_len; 775 size_t msg_len;
657 size_t attr_len; 776 size_t attr_len;
658 777
659 msg_len = ntohs (msg->header.size); 778 msg_len = ntohs (msg->header.size);
660 attr_len = ntohs (msg->attr_len); 779 attr_len = ntohs (msg->attestation_len);
661 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) 780 if (msg_len != sizeof(struct AttestationResultMessage) + attr_len)
662 { 781 {
663 GNUNET_break (0); 782 GNUNET_break (0);
664 return GNUNET_SYSERR; 783 return GNUNET_SYSERR;
@@ -669,26 +788,27 @@ check_attestation_result (void *cls, const struct AttributeResultMessage *msg)
669 788
670/** 789/**
671 * Handle an incoming message of type 790 * Handle an incoming message of type
672 * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 791 * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT
673 * 792 *
674 * @param cls 793 * @param cls
675 * @param msg the message we received 794 * @param msg the message we received
676 */ 795 */
677static void 796static void
678handle_attestation_result (void *cls, const struct AttributeResultMessage *msg) 797handle_attestation_result (void *cls, const struct
798 AttestationResultMessage *msg)
679{ 799{
680 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; 800 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
681 struct GNUNET_RECLAIM_Handle *h = cls; 801 struct GNUNET_RECLAIM_Handle *h = cls;
682 struct GNUNET_RECLAIM_AttributeIterator *it; 802 struct GNUNET_RECLAIM_AttestationIterator *it;
683 struct GNUNET_RECLAIM_Operation *op; 803 struct GNUNET_RECLAIM_Operation *op;
684 size_t attr_len; 804 size_t att_len;
685 uint32_t r_id = ntohl (msg->id); 805 uint32_t r_id = ntohl (msg->id);
686 806
687 attr_len = ntohs (msg->attr_len); 807 att_len = ntohs (msg->attestation_len);
688 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); 808 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n");
689 809
690 810
691 for (it = h->it_head; NULL != it; it = it->next) 811 for (it = h->ait_head; NULL != it; it = it->next)
692 if (it->r_id == r_id) 812 if (it->r_id == r_id)
693 break; 813 break;
694 for (op = h->op_head; NULL != op; op = op->next) 814 for (op = h->op_head; NULL != op; op = op->next)
@@ -710,12 +830,12 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
710 { 830 {
711 if (NULL != it->finish_cb) 831 if (NULL != it->finish_cb)
712 it->finish_cb (it->finish_cb_cls); 832 it->finish_cb (it->finish_cb_cls);
713 free_it (it); 833 free_ait (it);
714 } 834 }
715 if (NULL != op) 835 if (NULL != op)
716 { 836 {
717 if (NULL != op->ar_cb) 837 if (NULL != op->at_cb)
718 op->ar_cb (op->cls, NULL, NULL, NULL, NULL); 838 op->at_cb (op->cls, NULL, NULL);
719 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 839 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
720 free_op (op); 840 free_op (op);
721 } 841 }
@@ -723,126 +843,19 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
723 } 843 }
724 844
725 { 845 {
726 struct GNUNET_RECLAIM_ATTESTATION_Claim *attr; 846 struct GNUNET_RECLAIM_Attestation *att;
727 attr = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], attr_len); 847 att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len);
728 if (NULL != it) 848 if (NULL != it)
729 { 849 {
730 if (NULL != it->proc) 850 if (NULL != it->proc)
731 it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL); 851 it->proc (it->proc_cls, &msg->identity, att);
732 } 852 }
733 else if (NULL != op) 853 else if (NULL != op)
734 { 854 {
735 if (NULL != op->ar_cb) 855 if (NULL != op->at_cb)
736 op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL); 856 op->at_cb (op->cls, &msg->identity, att);
737 } 857 }
738 GNUNET_free (attr); 858 GNUNET_free (att);
739 return;
740 }
741 GNUNET_assert (0);
742}
743
744
745/**
746 * Handle an incoming message of type
747 * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
748 *
749 * @param cls
750 * @param msg the message we received
751 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
752 */
753static int
754check_reference_result (void *cls, const struct ReferenceResultMessage *msg)
755{
756 size_t msg_len;
757 size_t attr_len;
758 size_t ref_len;
759
760 msg_len = ntohs (msg->header.size);
761 attr_len = ntohs (msg->attest_len);
762 ref_len = ntohs (msg->ref_len);
763 if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len)
764 {
765 GNUNET_break (0);
766 return GNUNET_SYSERR;
767 }
768 return GNUNET_OK;
769}
770
771
772/**
773* Handle an incoming message of type
774* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
775*
776* @param cls
777* @param msg the message we received
778*/
779static void
780handle_reference_result (void *cls, const struct ReferenceResultMessage *msg)
781{
782 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
783 struct GNUNET_RECLAIM_Handle *h = cls;
784 struct GNUNET_RECLAIM_AttributeIterator *it;
785 struct GNUNET_RECLAIM_Operation *op;
786 size_t attest_len;
787 size_t ref_len;
788 uint32_t r_id = ntohl (msg->id);
789 attest_len = ntohs (msg->attest_len);
790 ref_len = ntohs (msg->ref_len);
791 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
792 for (it = h->it_head; NULL != it; it = it->next)
793 if (it->r_id == r_id)
794 break;
795 for (op = h->op_head; NULL != op; op = op->next)
796 if (op->r_id == r_id)
797 break;
798 if ((NULL == it) && (NULL == op))
799 return;
800
801 if ((0 ==
802 (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
803 {
804 if ((NULL == it) && (NULL == op))
805 {
806 GNUNET_break (0);
807 force_reconnect (h);
808 return;
809 }
810 if (NULL != it)
811 {
812 if (NULL != it->finish_cb)
813 it->finish_cb (it->finish_cb_cls);
814 free_it (it);
815 }
816 if (NULL != op)
817 {
818 if (NULL != op->ar_cb)
819 op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
820 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
821 free_op (op);
822 }
823 return;
824 }
825
826 {
827 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
828 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
829 attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
830 attest_len);
831 ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1]
832 + attest_len,
833 ref_len);
834 if (NULL != it)
835 {
836 if (NULL != it->proc)
837 it->proc (it->proc_cls, &msg->identity, NULL, attest, ref);
838 }
839 else if (NULL != op)
840 {
841 if (NULL != op->ar_cb)
842 op->ar_cb (op->cls, &msg->identity, NULL, attest, ref);
843 }
844 GNUNET_free (ref);
845 GNUNET_free (attest);
846 return; 859 return;
847 } 860 }
848 GNUNET_assert (0); 861 GNUNET_assert (0);
@@ -969,11 +982,7 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
969 h), 982 h),
970 GNUNET_MQ_hd_var_size (attestation_result, 983 GNUNET_MQ_hd_var_size (attestation_result,
971 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, 984 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT,
972 struct AttributeResultMessage, 985 struct AttestationResultMessage,
973 h),
974 GNUNET_MQ_hd_var_size (reference_result,
975 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
976 struct ReferenceResultMessage,
977 h), 986 h),
978 GNUNET_MQ_hd_fixed_size (ticket_result, 987 GNUNET_MQ_hd_fixed_size (ticket_result,
979 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 988 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
@@ -1083,7 +1092,7 @@ struct GNUNET_RECLAIM_Operation *
1083GNUNET_RECLAIM_attribute_store ( 1092GNUNET_RECLAIM_attribute_store (
1084 struct GNUNET_RECLAIM_Handle *h, 1093 struct GNUNET_RECLAIM_Handle *h,
1085 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1094 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1086 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1095 const struct GNUNET_RECLAIM_Attribute *attr,
1087 const struct GNUNET_TIME_Relative *exp_interval, 1096 const struct GNUNET_TIME_Relative *exp_interval,
1088 GNUNET_RECLAIM_ContinuationWithStatus cont, 1097 GNUNET_RECLAIM_ContinuationWithStatus cont,
1089 void *cont_cls) 1098 void *cont_cls)
@@ -1098,7 +1107,7 @@ GNUNET_RECLAIM_attribute_store (
1098 op->cls = cont_cls; 1107 op->cls = cont_cls;
1099 op->r_id = h->r_id_gen++; 1108 op->r_id = h->r_id_gen++;
1100 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1109 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1101 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); 1110 attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr);
1102 op->env = GNUNET_MQ_msg_extra (sam, 1111 op->env = GNUNET_MQ_msg_extra (sam,
1103 attr_len, 1112 attr_len,
1104 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); 1113 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE);
@@ -1106,7 +1115,7 @@ GNUNET_RECLAIM_attribute_store (
1106 sam->id = htonl (op->r_id); 1115 sam->id = htonl (op->r_id);
1107 sam->exp = GNUNET_htonll (exp_interval->rel_value_us); 1116 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1108 1117
1109 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]); 1118 GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]);
1110 1119
1111 sam->attr_len = htons (attr_len); 1120 sam->attr_len = htons (attr_len);
1112 if (NULL != h->mq) 1121 if (NULL != h->mq)
@@ -1130,7 +1139,7 @@ struct GNUNET_RECLAIM_Operation *
1130GNUNET_RECLAIM_attribute_delete ( 1139GNUNET_RECLAIM_attribute_delete (
1131 struct GNUNET_RECLAIM_Handle *h, 1140 struct GNUNET_RECLAIM_Handle *h,
1132 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1141 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1133 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1142 const struct GNUNET_RECLAIM_Attribute *attr,
1134 GNUNET_RECLAIM_ContinuationWithStatus cont, 1143 GNUNET_RECLAIM_ContinuationWithStatus cont,
1135 void *cont_cls) 1144 void *cont_cls)
1136{ 1145{
@@ -1144,13 +1153,13 @@ GNUNET_RECLAIM_attribute_delete (
1144 op->cls = cont_cls; 1153 op->cls = cont_cls;
1145 op->r_id = h->r_id_gen++; 1154 op->r_id = h->r_id_gen++;
1146 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1155 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1147 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); 1156 attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr);
1148 op->env = GNUNET_MQ_msg_extra (dam, 1157 op->env = GNUNET_MQ_msg_extra (dam,
1149 attr_len, 1158 attr_len,
1150 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); 1159 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE);
1151 dam->identity = *pkey; 1160 dam->identity = *pkey;
1152 dam->id = htonl (op->r_id); 1161 dam->id = htonl (op->r_id);
1153 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]); 1162 GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]);
1154 1163
1155 dam->attr_len = htons (attr_len); 1164 dam->attr_len = htons (attr_len);
1156 if (NULL != h->mq) 1165 if (NULL != h->mq)
@@ -1175,7 +1184,7 @@ struct GNUNET_RECLAIM_Operation *
1175GNUNET_RECLAIM_attestation_store ( 1184GNUNET_RECLAIM_attestation_store (
1176 struct GNUNET_RECLAIM_Handle *h, 1185 struct GNUNET_RECLAIM_Handle *h,
1177 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1186 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1178 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, 1187 const struct GNUNET_RECLAIM_Attestation *attr,
1179 const struct GNUNET_TIME_Relative *exp_interval, 1188 const struct GNUNET_TIME_Relative *exp_interval,
1180 GNUNET_RECLAIM_ContinuationWithStatus cont, 1189 GNUNET_RECLAIM_ContinuationWithStatus cont,
1181 void *cont_cls) 1190 void *cont_cls)
@@ -1190,7 +1199,7 @@ GNUNET_RECLAIM_attestation_store (
1190 op->cls = cont_cls; 1199 op->cls = cont_cls;
1191 op->r_id = h->r_id_gen++; 1200 op->r_id = h->r_id_gen++;
1192 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1201 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1193 attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr); 1202 attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr);
1194 op->env = GNUNET_MQ_msg_extra (sam, 1203 op->env = GNUNET_MQ_msg_extra (sam,
1195 attr_len, 1204 attr_len,
1196 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE); 1205 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE);
@@ -1198,7 +1207,7 @@ GNUNET_RECLAIM_attestation_store (
1198 sam->id = htonl (op->r_id); 1207 sam->id = htonl (op->r_id);
1199 sam->exp = GNUNET_htonll (exp_interval->rel_value_us); 1208 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1200 1209
1201 GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &sam[1]); 1210 GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]);
1202 1211
1203 sam->attr_len = htons (attr_len); 1212 sam->attr_len = htons (attr_len);
1204 if (NULL != h->mq) 1213 if (NULL != h->mq)
@@ -1222,7 +1231,7 @@ struct GNUNET_RECLAIM_Operation *
1222GNUNET_RECLAIM_attestation_delete ( 1231GNUNET_RECLAIM_attestation_delete (
1223 struct GNUNET_RECLAIM_Handle *h, 1232 struct GNUNET_RECLAIM_Handle *h,
1224 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1233 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1225 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, 1234 const struct GNUNET_RECLAIM_Attestation *attr,
1226 GNUNET_RECLAIM_ContinuationWithStatus cont, 1235 GNUNET_RECLAIM_ContinuationWithStatus cont,
1227 void *cont_cls) 1236 void *cont_cls)
1228{ 1237{
@@ -1236,105 +1245,13 @@ GNUNET_RECLAIM_attestation_delete (
1236 op->cls = cont_cls; 1245 op->cls = cont_cls;
1237 op->r_id = h->r_id_gen++; 1246 op->r_id = h->r_id_gen++;
1238 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1247 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1239 attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr); 1248 attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr);
1240 op->env = GNUNET_MQ_msg_extra (dam, 1249 op->env = GNUNET_MQ_msg_extra (dam,
1241 attr_len, 1250 attr_len,
1242 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE); 1251 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE);
1243 dam->identity = *pkey; 1252 dam->identity = *pkey;
1244 dam->id = htonl (op->r_id); 1253 dam->id = htonl (op->r_id);
1245 GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &dam[1]); 1254 GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]);
1246
1247 dam->attr_len = htons (attr_len);
1248 if (NULL != h->mq)
1249 GNUNET_MQ_send_copy (h->mq, op->env);
1250 return op;
1251}
1252
1253
1254/**
1255 * Store an attestation reference. If the reference is already present,
1256 * it is replaced with the new reference.
1257 *
1258 * @param h handle to the re:claimID service
1259 * @param pkey private key of the identity
1260 * @param attr the reference value
1261 * @param exp_interval the relative expiration interval for the reference
1262 * @param cont continuation to call when done
1263 * @param cont_cls closure for @a cont
1264 * @return handle to abort the request
1265 */
1266struct GNUNET_RECLAIM_Operation *
1267GNUNET_RECLAIM_attestation_reference_store (
1268 struct GNUNET_RECLAIM_Handle *h,
1269 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1270 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
1271 const struct GNUNET_TIME_Relative *exp_interval,
1272 GNUNET_RECLAIM_ContinuationWithStatus cont,
1273 void *cont_cls)
1274{
1275 struct GNUNET_RECLAIM_Operation *op;
1276 struct AttributeStoreMessage *sam;
1277 size_t attr_len;
1278 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1279 op->h = h;
1280 op->as_cb = cont;
1281 op->cls = cont_cls;
1282 op->r_id = h->r_id_gen++;
1283 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1284 attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr);
1285 op->env = GNUNET_MQ_msg_extra (sam,
1286 attr_len,
1287 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE);
1288 sam->identity = *pkey;
1289 sam->id = htonl (op->r_id);
1290 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1291
1292 GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &sam[1]);
1293
1294 sam->attr_len = htons (attr_len);
1295 if (NULL != h->mq)
1296 GNUNET_MQ_send_copy (h->mq, op->env);
1297 return op;
1298}
1299
1300
1301/**
1302 * Delete an attestation reference. Tickets used to share this reference are updated
1303 * accordingly.
1304 *
1305 * @param h handle to the re:claimID service
1306 * @param pkey Private key of the identity to delete the reference from
1307 * @param attr The reference
1308 * @param cont Continuation to call when done
1309 * @param cont_cls Closure for @a cont
1310 * @return handle Used to to abort the request
1311 */
1312struct GNUNET_RECLAIM_Operation *
1313GNUNET_RECLAIM_attestation_reference_delete (
1314 struct GNUNET_RECLAIM_Handle *h,
1315 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1316 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
1317 GNUNET_RECLAIM_ContinuationWithStatus cont,
1318 void *cont_cls)
1319{
1320
1321 struct GNUNET_RECLAIM_Operation *op;
1322 struct AttributeDeleteMessage *dam;
1323 size_t attr_len;
1324
1325 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1326 op->h = h;
1327 op->as_cb = cont;
1328 op->cls = cont_cls;
1329 op->r_id = h->r_id_gen++;
1330 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1331 attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr);
1332 op->env = GNUNET_MQ_msg_extra (dam,
1333 attr_len,
1334 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE);
1335 dam->identity = *pkey;
1336 dam->id = htonl (op->r_id);
1337 GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &dam[1]);
1338 1255
1339 dam->attr_len = htons (attr_len); 1256 dam->attr_len = htons (attr_len);
1340 if (NULL != h->mq) 1257 if (NULL != h->mq)
@@ -1470,7 +1387,7 @@ GNUNET_RECLAIM_ticket_issue (
1470 struct GNUNET_RECLAIM_Handle *h, 1387 struct GNUNET_RECLAIM_Handle *h,
1471 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1388 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1472 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1389 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1473 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1390 const struct GNUNET_RECLAIM_AttributeList *attrs,
1474 GNUNET_RECLAIM_TicketCallback cb, 1391 GNUNET_RECLAIM_TicketCallback cb,
1475 void *cb_cls) 1392 void *cb_cls)
1476{ 1393{
@@ -1485,7 +1402,7 @@ GNUNET_RECLAIM_ticket_issue (
1485 op->cls = cb_cls; 1402 op->cls = cb_cls;
1486 op->r_id = h->r_id_gen++; 1403 op->r_id = h->r_id_gen++;
1487 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1404 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1488 attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); 1405 attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
1489 op->env = GNUNET_MQ_msg_extra (tim, 1406 op->env = GNUNET_MQ_msg_extra (tim,
1490 attr_len, 1407 attr_len,
1491 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); 1408 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
@@ -1493,7 +1410,7 @@ GNUNET_RECLAIM_ticket_issue (
1493 tim->rp = *rp; 1410 tim->rp = *rp;
1494 tim->id = htonl (op->r_id); 1411 tim->id = htonl (op->r_id);
1495 1412
1496 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]); 1413 GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]);
1497 1414
1498 tim->attr_len = htons (attr_len); 1415 tim->attr_len = htons (attr_len);
1499 if (NULL != h->mq) 1416 if (NULL != h->mq)