diff options
Diffstat (limited to 'src/include/gnunet_reclaim_lib.h')
-rw-r--r-- | src/include/gnunet_reclaim_lib.h | 412 |
1 files changed, 326 insertions, 86 deletions
diff --git a/src/include/gnunet_reclaim_lib.h b/src/include/gnunet_reclaim_lib.h index 4f2d6dba5..bbf1c3ad3 100644 --- a/src/include/gnunet_reclaim_lib.h +++ b/src/include/gnunet_reclaim_lib.h | |||
@@ -39,32 +39,41 @@ extern "C" { | |||
39 | 39 | ||
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | 41 | ||
42 | enum GNUNET_RECLAIM_AttributeType { | ||
43 | /** | ||
44 | * No value attribute. | ||
45 | */ | ||
46 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE = 0, | ||
42 | 47 | ||
43 | /** | 48 | /** |
44 | * No value attribute. | 49 | * String attribute. |
45 | */ | 50 | */ |
46 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 0 | 51 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING = 1 |
52 | }; | ||
47 | 53 | ||
48 | /** | 54 | enum GNUNET_RECLAIM_CredentialType { |
49 | * String attribute. | 55 | /** |
50 | */ | 56 | * No value credential. |
51 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 | 57 | */ |
58 | GNUNET_RECLAIM_CREDENTIAL_TYPE_NONE = 0, | ||
52 | 59 | ||
53 | /** | 60 | /** |
54 | * No value attestation. | 61 | * A JSON Web Token credential. |
55 | */ | 62 | */ |
56 | #define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE 10 | 63 | GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT = 1, |
57 | 64 | ||
58 | /** | 65 | /** |
59 | * A JSON Web Token attestation. | 66 | * libpabc credential |
60 | */ | 67 | */ |
61 | #define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT 11 | 68 | GNUNET_RECLAIM_CREDENTIAL_TYPE_PABC = 2 |
69 | }; | ||
62 | 70 | ||
63 | /** | 71 | /** |
64 | * We want an ID to be a 256-bit symmetric key | 72 | * We want an ID to be a 256-bit symmetric key |
65 | */ | 73 | */ |
66 | #define GNUNET_RECLAIM_ID_LENGTH (256 / 8) | 74 | #define GNUNET_RECLAIM_ID_LENGTH (256 / 8) |
67 | 75 | ||
76 | GNUNET_NETWORK_STRUCT_BEGIN | ||
68 | /** | 77 | /** |
69 | * A reclaim identifier | 78 | * A reclaim identifier |
70 | * FIXME maybe put this in a different namespace | 79 | * FIXME maybe put this in a different namespace |
@@ -74,6 +83,8 @@ struct GNUNET_RECLAIM_Identifier | |||
74 | char id[GNUNET_RECLAIM_ID_LENGTH]; | 83 | char id[GNUNET_RECLAIM_ID_LENGTH]; |
75 | }; | 84 | }; |
76 | 85 | ||
86 | GNUNET_NETWORK_STRUCT_END | ||
87 | |||
77 | static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; | 88 | static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO; |
78 | 89 | ||
79 | #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \ | 90 | #define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \ |
@@ -104,9 +115,10 @@ struct GNUNET_RECLAIM_Attribute | |||
104 | struct GNUNET_RECLAIM_Identifier id; | 115 | struct GNUNET_RECLAIM_Identifier id; |
105 | 116 | ||
106 | /** | 117 | /** |
107 | * Referenced ID of Attestation (may be 0 if self-attested) | 118 | * Referenced ID of credential |
119 | * (may be GNUNET_RECLAIM_ID_ZERO if self-creded) | ||
108 | */ | 120 | */ |
109 | struct GNUNET_RECLAIM_Identifier attestation; | 121 | struct GNUNET_RECLAIM_Identifier credential; |
110 | 122 | ||
111 | /** | 123 | /** |
112 | * Type of Claim | 124 | * Type of Claim |
@@ -138,9 +150,9 @@ struct GNUNET_RECLAIM_Attribute | |||
138 | }; | 150 | }; |
139 | 151 | ||
140 | /** | 152 | /** |
141 | * An attestation. | 153 | * A credential. |
142 | */ | 154 | */ |
143 | struct GNUNET_RECLAIM_Attestation | 155 | struct GNUNET_RECLAIM_Credential |
144 | { | 156 | { |
145 | /** | 157 | /** |
146 | * ID | 158 | * ID |
@@ -158,7 +170,7 @@ struct GNUNET_RECLAIM_Attestation | |||
158 | uint32_t flag; | 170 | uint32_t flag; |
159 | 171 | ||
160 | /** | 172 | /** |
161 | * The name of the attribute. Note "name" must never be individually | 173 | * The name of the credential. Note: must never be individually |
162 | * free'd | 174 | * free'd |
163 | */ | 175 | */ |
164 | const char *name; | 176 | const char *name; |
@@ -169,7 +181,36 @@ struct GNUNET_RECLAIM_Attestation | |||
169 | size_t data_size; | 181 | size_t data_size; |
170 | 182 | ||
171 | /** | 183 | /** |
172 | * Binary value stored as attribute value. Note: "data" must never | 184 | * Binary value stored as credential value. Note: "data" must never |
185 | * be individually 'malloc'ed, but instead always points into some | ||
186 | * existing data area. | ||
187 | */ | ||
188 | const void *data; | ||
189 | }; | ||
190 | |||
191 | |||
192 | /** | ||
193 | * A credential presentation. | ||
194 | */ | ||
195 | struct GNUNET_RECLAIM_Presentation | ||
196 | { | ||
197 | /** | ||
198 | * The credential id of which this is a presentation. | ||
199 | */ | ||
200 | struct GNUNET_RECLAIM_Identifier credential_id; | ||
201 | |||
202 | /** | ||
203 | * Type/Format of Claim | ||
204 | */ | ||
205 | uint32_t type; | ||
206 | |||
207 | /** | ||
208 | * Number of bytes in @e data. | ||
209 | */ | ||
210 | size_t data_size; | ||
211 | |||
212 | /** | ||
213 | * Binary value stored as presentation value. Note: "data" must never | ||
173 | * be individually 'malloc'ed, but instead always points into some | 214 | * be individually 'malloc'ed, but instead always points into some |
174 | * existing data area. | 215 | * existing data area. |
175 | */ | 216 | */ |
@@ -177,6 +218,7 @@ struct GNUNET_RECLAIM_Attestation | |||
177 | }; | 218 | }; |
178 | 219 | ||
179 | 220 | ||
221 | |||
180 | /** | 222 | /** |
181 | * A list of GNUNET_RECLAIM_Attribute structures. | 223 | * A list of GNUNET_RECLAIM_Attribute structures. |
182 | */ | 224 | */ |
@@ -214,56 +256,94 @@ struct GNUNET_RECLAIM_AttributeListEntry | |||
214 | }; | 256 | }; |
215 | 257 | ||
216 | /** | 258 | /** |
217 | * A list of GNUNET_RECLAIM_Attestation structures. | 259 | * A list of GNUNET_RECLAIM_Credential structures. |
260 | */ | ||
261 | struct GNUNET_RECLAIM_CredentialList | ||
262 | { | ||
263 | /** | ||
264 | * List head | ||
265 | */ | ||
266 | struct GNUNET_RECLAIM_CredentialListEntry *list_head; | ||
267 | |||
268 | /** | ||
269 | * List tail | ||
270 | */ | ||
271 | struct GNUNET_RECLAIM_CredentialListEntry *list_tail; | ||
272 | }; | ||
273 | |||
274 | |||
275 | struct GNUNET_RECLAIM_CredentialListEntry | ||
276 | { | ||
277 | /** | ||
278 | * DLL | ||
279 | */ | ||
280 | struct GNUNET_RECLAIM_CredentialListEntry *prev; | ||
281 | |||
282 | /** | ||
283 | * DLL | ||
284 | */ | ||
285 | struct GNUNET_RECLAIM_CredentialListEntry *next; | ||
286 | |||
287 | /** | ||
288 | * The credential | ||
289 | */ | ||
290 | struct GNUNET_RECLAIM_Credential *credential; | ||
291 | |||
292 | }; | ||
293 | |||
294 | |||
295 | /** | ||
296 | * A list of GNUNET_RECLAIM_Presentation structures. | ||
218 | */ | 297 | */ |
219 | struct GNUNET_RECLAIM_AttestationList | 298 | struct GNUNET_RECLAIM_PresentationList |
220 | { | 299 | { |
221 | /** | 300 | /** |
222 | * List head | 301 | * List head |
223 | */ | 302 | */ |
224 | struct GNUNET_RECLAIM_AttestationListEntry *list_head; | 303 | struct GNUNET_RECLAIM_PresentationListEntry *list_head; |
225 | 304 | ||
226 | /** | 305 | /** |
227 | * List tail | 306 | * List tail |
228 | */ | 307 | */ |
229 | struct GNUNET_RECLAIM_AttestationListEntry *list_tail; | 308 | struct GNUNET_RECLAIM_PresentationListEntry *list_tail; |
230 | }; | 309 | }; |
231 | 310 | ||
232 | 311 | ||
233 | struct GNUNET_RECLAIM_AttestationListEntry | 312 | struct GNUNET_RECLAIM_PresentationListEntry |
234 | { | 313 | { |
235 | /** | 314 | /** |
236 | * DLL | 315 | * DLL |
237 | */ | 316 | */ |
238 | struct GNUNET_RECLAIM_AttestationListEntry *prev; | 317 | struct GNUNET_RECLAIM_PresentationListEntry *prev; |
239 | 318 | ||
240 | /** | 319 | /** |
241 | * DLL | 320 | * DLL |
242 | */ | 321 | */ |
243 | struct GNUNET_RECLAIM_AttestationListEntry *next; | 322 | struct GNUNET_RECLAIM_PresentationListEntry *next; |
244 | 323 | ||
245 | /** | 324 | /** |
246 | * The attestation | 325 | * The credential |
247 | */ | 326 | */ |
248 | struct GNUNET_RECLAIM_Attestation *attestation; | 327 | struct GNUNET_RECLAIM_Presentation *presentation; |
249 | 328 | ||
250 | }; | 329 | }; |
251 | 330 | ||
252 | 331 | ||
332 | |||
253 | /** | 333 | /** |
254 | * Create a new attribute claim. | 334 | * Create a new attribute claim. |
255 | * | 335 | * |
256 | * @param attr_name the attribute name | 336 | * @param attr_name the attribute name |
257 | * @param attestation ID of the attestation (may be NULL) | 337 | * @param credential ID of the credential (may be NULL) |
258 | * @param type the attribute type | 338 | * @param type the attribute type |
259 | * @param data the attribute value. Must be the mapped name if attestation not NULL | 339 | * @param data the attribute value. Must be #attr_name if credential not NULL |
260 | * @param data_size the attribute value size | 340 | * @param data_size the attribute value size |
261 | * @return the new attribute | 341 | * @return the new attribute |
262 | */ | 342 | */ |
263 | struct GNUNET_RECLAIM_Attribute * | 343 | struct GNUNET_RECLAIM_Attribute * |
264 | GNUNET_RECLAIM_attribute_new (const char *attr_name, | 344 | GNUNET_RECLAIM_attribute_new (const char *attr_name, |
265 | const struct | 345 | const struct |
266 | GNUNET_RECLAIM_Identifier *attestation, | 346 | GNUNET_RECLAIM_Identifier *credential, |
267 | uint32_t type, | 347 | uint32_t type, |
268 | const void *data, | 348 | const void *data, |
269 | size_t data_size); | 349 | size_t data_size); |
@@ -295,7 +375,7 @@ GNUNET_RECLAIM_attribute_list_destroy ( | |||
295 | * | 375 | * |
296 | * @param attrs the attribute list to add to | 376 | * @param attrs the attribute list to add to |
297 | * @param attr_name the name of the new attribute claim | 377 | * @param attr_name the name of the new attribute claim |
298 | * @param attestation attestation ID (may be NULL) | 378 | * @param credential credential ID (may be NULL) |
299 | * @param type the type of the claim | 379 | * @param type the type of the claim |
300 | * @param data claim payload | 380 | * @param data claim payload |
301 | * @param data_size claim payload size | 381 | * @param data_size claim payload size |
@@ -304,7 +384,7 @@ void | |||
304 | GNUNET_RECLAIM_attribute_list_add ( | 384 | GNUNET_RECLAIM_attribute_list_add ( |
305 | struct GNUNET_RECLAIM_AttributeList *attrs, | 385 | struct GNUNET_RECLAIM_AttributeList *attrs, |
306 | const char *attr_name, | 386 | const char *attr_name, |
307 | const struct GNUNET_RECLAIM_Identifier *attestation, | 387 | const struct GNUNET_RECLAIM_Identifier *credential, |
308 | uint32_t type, | 388 | uint32_t type, |
309 | const void *data, | 389 | const void *data, |
310 | size_t data_size); | 390 | size_t data_size); |
@@ -361,11 +441,13 @@ GNUNET_RECLAIM_attribute_serialize (const struct GNUNET_RECLAIM_Attribute *attr, | |||
361 | * | 441 | * |
362 | * @param data the serialized attribute | 442 | * @param data the serialized attribute |
363 | * @param data_size the length of the serialized data | 443 | * @param data_size the length of the serialized data |
444 | * @param attr deserialized attribute. Will be allocated. Must be free'd | ||
364 | * | 445 | * |
365 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 446 | * @return number of bytes read or -1 for error |
366 | */ | 447 | */ |
367 | struct GNUNET_RECLAIM_Attribute * | 448 | ssize_t |
368 | GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size); | 449 | GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, |
450 | struct GNUNET_RECLAIM_Attribute **attr); | ||
369 | 451 | ||
370 | 452 | ||
371 | /** | 453 | /** |
@@ -434,8 +516,8 @@ GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type); | |||
434 | * @return the required buffer size | 516 | * @return the required buffer size |
435 | */ | 517 | */ |
436 | size_t | 518 | size_t |
437 | GNUNET_RECLAIM_attestation_list_serialize_get_size ( | 519 | GNUNET_RECLAIM_credential_list_serialize_get_size ( |
438 | const struct GNUNET_RECLAIM_AttestationList *attestations); | 520 | const struct GNUNET_RECLAIM_CredentialList *credentials); |
439 | 521 | ||
440 | 522 | ||
441 | /** | 523 | /** |
@@ -444,8 +526,8 @@ GNUNET_RECLAIM_attestation_list_serialize_get_size ( | |||
444 | * @param attrs list to destroy | 526 | * @param attrs list to destroy |
445 | */ | 527 | */ |
446 | void | 528 | void |
447 | GNUNET_RECLAIM_attestation_list_destroy ( | 529 | GNUNET_RECLAIM_credential_list_destroy ( |
448 | struct GNUNET_RECLAIM_AttestationList *attestations); | 530 | struct GNUNET_RECLAIM_CredentialList *credentials); |
449 | 531 | ||
450 | 532 | ||
451 | /** | 533 | /** |
@@ -457,8 +539,8 @@ GNUNET_RECLAIM_attestation_list_destroy ( | |||
457 | * @param data_size claim payload size | 539 | * @param data_size claim payload size |
458 | */ | 540 | */ |
459 | void | 541 | void |
460 | GNUNET_RECLAIM_attestation_list_add ( | 542 | GNUNET_RECLAIM_credential_list_add ( |
461 | struct GNUNET_RECLAIM_AttestationList *attrs, | 543 | struct GNUNET_RECLAIM_CredentialList *attrs, |
462 | const char *att_name, | 544 | const char *att_name, |
463 | uint32_t type, | 545 | uint32_t type, |
464 | const void *data, | 546 | const void *data, |
@@ -473,8 +555,8 @@ GNUNET_RECLAIM_attestation_list_add ( | |||
473 | * @return length of serialized data | 555 | * @return length of serialized data |
474 | */ | 556 | */ |
475 | size_t | 557 | size_t |
476 | GNUNET_RECLAIM_attestation_list_serialize ( | 558 | GNUNET_RECLAIM_credential_list_serialize ( |
477 | const struct GNUNET_RECLAIM_AttestationList *attrs, | 559 | const struct GNUNET_RECLAIM_CredentialList *attrs, |
478 | char *result); | 560 | char *result); |
479 | 561 | ||
480 | 562 | ||
@@ -485,75 +567,75 @@ GNUNET_RECLAIM_attestation_list_serialize ( | |||
485 | * @param data_size the length of the serialized data | 567 | * @param data_size the length of the serialized data |
486 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 568 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
487 | */ | 569 | */ |
488 | struct GNUNET_RECLAIM_AttestationList * | 570 | struct GNUNET_RECLAIM_CredentialList * |
489 | GNUNET_RECLAIM_attestation_list_deserialize (const char *data, | 571 | GNUNET_RECLAIM_credential_list_deserialize (const char *data, |
490 | size_t data_size); | 572 | size_t data_size); |
491 | 573 | ||
492 | 574 | ||
493 | /** | 575 | /** |
494 | * @param attestation the attestation to serialize | 576 | * @param credential the credential to serialize |
495 | * @return the required buffer size | 577 | * @return the required buffer size |
496 | */ | 578 | */ |
497 | size_t | 579 | size_t |
498 | GNUNET_RECLAIM_attestation_serialize_get_size ( | 580 | GNUNET_RECLAIM_credential_serialize_get_size ( |
499 | const struct GNUNET_RECLAIM_Attestation *attestation); | 581 | const struct GNUNET_RECLAIM_Credential *credential); |
500 | 582 | ||
501 | 583 | ||
502 | /** | 584 | /** |
503 | * Serialize an attestation | 585 | * Serialize an credential |
504 | * | 586 | * |
505 | * @param attestation the attestation to serialize | 587 | * @param credential the credential to serialize |
506 | * @param result the serialized attestation | 588 | * @param result the serialized credential |
507 | * @return length of serialized data | 589 | * @return length of serialized data |
508 | */ | 590 | */ |
509 | size_t | 591 | size_t |
510 | GNUNET_RECLAIM_attestation_serialize ( | 592 | GNUNET_RECLAIM_credential_serialize ( |
511 | const struct GNUNET_RECLAIM_Attestation *attestation, | 593 | const struct GNUNET_RECLAIM_Credential *credential, |
512 | char *result); | 594 | char *result); |
513 | 595 | ||
514 | 596 | ||
515 | /** | 597 | /** |
516 | * Deserialize an attestation | 598 | * Deserialize an credential |
517 | * | 599 | * |
518 | * @param data the serialized attestation | 600 | * @param data the serialized credential |
519 | * @param data_size the length of the serialized data | 601 | * @param data_size the length of the serialized data |
520 | * | 602 | * |
521 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 603 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
522 | */ | 604 | */ |
523 | struct GNUNET_RECLAIM_Attestation * | 605 | struct GNUNET_RECLAIM_Credential * |
524 | GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size); | 606 | GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size); |
525 | 607 | ||
526 | 608 | ||
527 | /** | 609 | /** |
528 | * Create a new attestation. | 610 | * Create a new credential. |
529 | * | 611 | * |
530 | * @param name the attestation name | 612 | * @param name the credential name |
531 | * @param type the attestation type | 613 | * @param type the credential type |
532 | * @param data the attestation value | 614 | * @param data the credential value |
533 | * @param data_size the attestation value size | 615 | * @param data_size the credential value size |
534 | * @return the new attestation | 616 | * @return the new credential |
535 | */ | 617 | */ |
536 | struct GNUNET_RECLAIM_Attestation * | 618 | struct GNUNET_RECLAIM_Credential * |
537 | GNUNET_RECLAIM_attestation_new (const char *name, | 619 | GNUNET_RECLAIM_credential_new (const char *name, |
538 | uint32_t type, | 620 | uint32_t type, |
539 | const void *data, | 621 | const void *data, |
540 | size_t data_size); | 622 | size_t data_size); |
541 | 623 | ||
542 | /** | 624 | /** |
543 | * Convert the 'claim' of an attestation to a string | 625 | * Convert the 'claim' of an credential to a string |
544 | * | 626 | * |
545 | * @param type the type of attestation | 627 | * @param type the type of credential |
546 | * @param data claim in binary encoding | 628 | * @param data claim in binary encoding |
547 | * @param data_size number of bytes in @a data | 629 | * @param data_size number of bytes in @a data |
548 | * @return NULL on error, otherwise human-readable representation of the claim | 630 | * @return NULL on error, otherwise human-readable representation of the claim |
549 | */ | 631 | */ |
550 | char * | 632 | char * |
551 | GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, | 633 | GNUNET_RECLAIM_credential_value_to_string (uint32_t type, |
552 | const void *data, | 634 | const void *data, |
553 | size_t data_size); | 635 | size_t data_size); |
554 | 636 | ||
555 | /** | 637 | /** |
556 | * Convert human-readable version of a 'claim' of an attestation to the binary | 638 | * Convert human-readable version of a 'claim' of an credential to the binary |
557 | * representation | 639 | * representation |
558 | * | 640 | * |
559 | * @param type type of the claim | 641 | * @param type type of the claim |
@@ -563,48 +645,206 @@ GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, | |||
563 | * @return #GNUNET_OK on success | 645 | * @return #GNUNET_OK on success |
564 | */ | 646 | */ |
565 | int | 647 | int |
566 | GNUNET_RECLAIM_attestation_string_to_value (uint32_t type, | 648 | GNUNET_RECLAIM_credential_string_to_value (uint32_t type, |
567 | const char *s, | 649 | const char *s, |
568 | void **data, | 650 | void **data, |
569 | size_t *data_size); | 651 | size_t *data_size); |
570 | 652 | ||
571 | /** | 653 | /** |
572 | * Convert an attestation type number to the corresponding attestation type string | 654 | * Convert an credential type number to the corresponding credential type string |
573 | * | 655 | * |
574 | * @param type number of a type | 656 | * @param type number of a type |
575 | * @return corresponding typestring, NULL on error | 657 | * @return corresponding typestring, NULL on error |
576 | */ | 658 | */ |
577 | const char * | 659 | const char * |
578 | GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type); | 660 | GNUNET_RECLAIM_credential_number_to_typename (uint32_t type); |
579 | 661 | ||
580 | /** | 662 | /** |
581 | * Convert an attestation type name to the corresponding number | 663 | * Convert an credential type name to the corresponding number |
582 | * | 664 | * |
583 | * @param typename name to convert | 665 | * @param typename name to convert |
584 | * @return corresponding number, UINT32_MAX on error | 666 | * @return corresponding number, UINT32_MAX on error |
585 | */ | 667 | */ |
586 | uint32_t | 668 | uint32_t |
587 | GNUNET_RECLAIM_attestation_typename_to_number (const char *typename); | 669 | GNUNET_RECLAIM_credential_typename_to_number (const char *typename); |
588 | 670 | ||
589 | /** | 671 | /** |
590 | * Convert an attestation type name to the corresponding number | 672 | * Convert an credential type name to the corresponding number |
591 | * | 673 | * |
592 | * @param typename name to convert | 674 | * @param typename name to convert |
593 | * @return corresponding number, UINT32_MAX on error | 675 | * @return corresponding number, UINT32_MAX on error |
594 | */ | 676 | */ |
595 | struct GNUNET_RECLAIM_AttributeList* | 677 | struct GNUNET_RECLAIM_AttributeList* |
596 | GNUNET_RECLAIM_attestation_get_attributes (const struct | 678 | GNUNET_RECLAIM_credential_get_attributes (const struct |
597 | GNUNET_RECLAIM_Attestation *attest); | 679 | GNUNET_RECLAIM_Credential *cred); |
680 | |||
681 | char* | ||
682 | GNUNET_RECLAIM_credential_get_issuer (const struct | ||
683 | GNUNET_RECLAIM_Credential *cred); | ||
684 | |||
685 | int | ||
686 | GNUNET_RECLAIM_credential_get_expiration (const struct | ||
687 | GNUNET_RECLAIM_Credential *cred, | ||
688 | struct GNUNET_TIME_Absolute *exp); | ||
689 | |||
690 | /** | ||
691 | * Get required size for serialization buffer | ||
692 | * | ||
693 | * @param presentations the presentation list to serialize | ||
694 | * @return the required buffer size | ||
695 | */ | ||
696 | size_t | ||
697 | GNUNET_RECLAIM_presentation_list_serialize_get_size ( | ||
698 | const struct GNUNET_RECLAIM_PresentationList *presentations); | ||
699 | |||
700 | |||
701 | /** | ||
702 | * Destroy presentations list | ||
703 | * | ||
704 | * @param presentations list to destroy | ||
705 | */ | ||
706 | void | ||
707 | GNUNET_RECLAIM_presentation_list_destroy ( | ||
708 | struct GNUNET_RECLAIM_PresentationList *presentations); | ||
709 | |||
710 | |||
711 | /** | ||
712 | * Serialize a presentation list | ||
713 | * | ||
714 | * @param presentations the attribute list to serialize | ||
715 | * @param result the serialized list | ||
716 | * @return length of serialized data | ||
717 | */ | ||
718 | size_t | ||
719 | GNUNET_RECLAIM_presentation_list_serialize ( | ||
720 | const struct GNUNET_RECLAIM_PresentationList *presentations, | ||
721 | char *result); | ||
722 | |||
723 | |||
724 | /** | ||
725 | * Deserialize a presentation list | ||
726 | * | ||
727 | * @param data the serialized list | ||
728 | * @param data_size the length of the serialized data | ||
729 | * @return a GNUNET_RECLAIM_PresentationList, must be free'd by caller | ||
730 | */ | ||
731 | struct GNUNET_RECLAIM_PresentationList * | ||
732 | GNUNET_RECLAIM_presentation_list_deserialize (const char *data, | ||
733 | size_t data_size); | ||
734 | |||
735 | |||
736 | /** | ||
737 | * @param presentation the presentation to serialize | ||
738 | * @return the required buffer size | ||
739 | */ | ||
740 | size_t | ||
741 | GNUNET_RECLAIM_presentation_serialize_get_size ( | ||
742 | const struct GNUNET_RECLAIM_Presentation *presentation); | ||
743 | |||
744 | |||
745 | /** | ||
746 | * Serialize a presentation. | ||
747 | * | ||
748 | * @param presentation the presentation to serialize | ||
749 | * @param result the serialized presentation | ||
750 | * @return length of serialized data | ||
751 | */ | ||
752 | size_t | ||
753 | GNUNET_RECLAIM_presentation_serialize ( | ||
754 | const struct GNUNET_RECLAIM_Presentation *presentation, | ||
755 | char *result); | ||
756 | |||
757 | |||
758 | /** | ||
759 | * Deserialize a presentation | ||
760 | * | ||
761 | * @param data the serialized presentation | ||
762 | * @param data_size the length of the serialized data | ||
763 | * | ||
764 | * @return a GNUNET_RECLAIM_Presentation, must be free'd by caller | ||
765 | */ | ||
766 | struct GNUNET_RECLAIM_Presentation * | ||
767 | GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size); | ||
768 | |||
769 | |||
770 | /** | ||
771 | * Convert the 'claim' of a presentation to a string | ||
772 | * | ||
773 | * @param type the type of presentation | ||
774 | * @param data presentation in binary encoding | ||
775 | * @param data_size number of bytes in @a data | ||
776 | * @return NULL on error, otherwise human-readable representation of the claim | ||
777 | */ | ||
778 | char * | ||
779 | GNUNET_RECLAIM_presentation_value_to_string (uint32_t type, | ||
780 | const void *data, | ||
781 | size_t data_size); | ||
782 | |||
783 | struct GNUNET_RECLAIM_Presentation * | ||
784 | GNUNET_RECLAIM_presentation_new (uint32_t type, | ||
785 | const void *data, | ||
786 | size_t data_size); | ||
787 | |||
788 | /** | ||
789 | * Convert human-readable version of a 'claim' of a presentation to the binary | ||
790 | * representation | ||
791 | * | ||
792 | * @param type type of the presentation | ||
793 | * @param s human-readable string | ||
794 | * @param data set to value in binary encoding (will be allocated) | ||
795 | * @param data_size set to number of bytes in @a data | ||
796 | * @return #GNUNET_OK on success | ||
797 | */ | ||
798 | int | ||
799 | GNUNET_RECLAIM_presentation_string_to_value (uint32_t type, | ||
800 | const char *s, | ||
801 | void **data, | ||
802 | size_t *data_size); | ||
803 | |||
804 | /** | ||
805 | * Convert a presentation type number to the corresponding credential type | ||
806 | * string. | ||
807 | * | ||
808 | * @param type number of a type | ||
809 | * @return corresponding typestring, NULL on error | ||
810 | */ | ||
811 | const char * | ||
812 | GNUNET_RECLAIM_presentation_number_to_typename (uint32_t type); | ||
813 | |||
814 | struct GNUNET_RECLAIM_AttributeList* | ||
815 | GNUNET_RECLAIM_presentation_get_attributes (const struct | ||
816 | GNUNET_RECLAIM_Presentation *cred); | ||
598 | 817 | ||
599 | char* | 818 | char* |
600 | GNUNET_RECLAIM_attestation_get_issuer (const struct | 819 | GNUNET_RECLAIM_presentation_get_issuer (const struct |
601 | GNUNET_RECLAIM_Attestation *attest); | 820 | GNUNET_RECLAIM_Presentation *cred); |
602 | 821 | ||
603 | int | 822 | int |
604 | GNUNET_RECLAIM_attestation_get_expiration (const struct | 823 | GNUNET_RECLAIM_presentation_get_expiration (const struct |
605 | GNUNET_RECLAIM_Attestation *attest, | 824 | GNUNET_RECLAIM_Presentation *cred, |
606 | struct GNUNET_TIME_Absolute *exp); | 825 | struct GNUNET_TIME_Absolute *exp); |
607 | 826 | ||
827 | |||
828 | |||
829 | /** | ||
830 | * Create a presentation from a credential and a lift of (selected) | ||
831 | * attributes in the credential. | ||
832 | * FIXME not yet implemented | ||
833 | * | ||
834 | * @param cred the credential to use | ||
835 | * @param attrs the attributes to present from the credential | ||
836 | * @param presentation the credential presentation presenting the attributes according | ||
837 | * to the presentation mechanism of the credential | ||
838 | * or NULL on error. | ||
839 | * @return GNUNET_OK on success. | ||
840 | */ | ||
841 | int | ||
842 | GNUNET_RECLAIM_credential_get_presentation ( | ||
843 | const struct GNUNET_RECLAIM_Credential *cred, | ||
844 | const struct GNUNET_RECLAIM_AttributeList *attrs, | ||
845 | struct GNUNET_RECLAIM_Presentation **presentation); | ||
846 | |||
847 | |||
608 | #if 0 /* keep Emacsens' auto-indent happy */ | 848 | #if 0 /* keep Emacsens' auto-indent happy */ |
609 | { | 849 | { |
610 | #endif | 850 | #endif |