aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-08-28 12:27:32 +0200
committerjospaeth <spaethj@in.tum.de>2020-08-28 12:27:32 +0200
commit5f7d255ae5221c447367c4ac7a157ddcd27bcd57 (patch)
tree22fae70a54ad97c15a59f62e4c8bb9498a0d2e53 /src/reclaim
parent62d6be2695969cd430351b503b033057a1b50f47 (diff)
parentbbf9540c93da3c6b950920ee7eaae479c95403c5 (diff)
downloadgnunet-5f7d255ae5221c447367c4ac7a157ddcd27bcd57.tar.gz
gnunet-5f7d255ae5221c447367c4ac7a157ddcd27bcd57.zip
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/Makefile.am18
-rw-r--r--src/reclaim/gnunet-reclaim.c221
-rw-r--r--src/reclaim/gnunet-service-reclaim.c299
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c335
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h7
-rw-r--r--src/reclaim/json_reclaim.c68
-rw-r--r--src/reclaim/json_reclaim.h11
-rw-r--r--src/reclaim/oidc_helper.c118
-rw-r--r--src/reclaim/oidc_helper.h23
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c12
-rw-r--r--src/reclaim/plugin_reclaim_credential_jwt.c (renamed from src/reclaim/plugin_reclaim_attestation_jwt.c)206
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c156
-rw-r--r--src/reclaim/plugin_rest_reclaim.c146
-rw-r--r--src/reclaim/reclaim.h35
-rw-r--r--src/reclaim/reclaim_api.c219
-rw-r--r--src/reclaim/reclaim_attestation.c570
-rw-r--r--src/reclaim/reclaim_attribute.c18
-rw-r--r--src/reclaim/reclaim_attribute.h37
-rw-r--r--src/reclaim/reclaim_credential.c1037
-rw-r--r--src/reclaim/reclaim_credential.h (renamed from src/reclaim/reclaim_attestation.h)61
20 files changed, 2194 insertions, 1403 deletions
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am
index 9b75c11aa..a58127abf 100644
--- a/src/reclaim/Makefile.am
+++ b/src/reclaim/Makefile.am
@@ -13,8 +13,8 @@ REST_PLUGIN = \
13 libgnunet_plugin_rest_openid_connect.la \ 13 libgnunet_plugin_rest_openid_connect.la \
14 libgnunet_plugin_rest_reclaim.la 14 libgnunet_plugin_rest_reclaim.la
15 15
16ATTESTATION_PLUGIN = \ 16CREDENTIAL_PLUGIN = \
17 libgnunet_plugin_reclaim_attestation_jwt.la 17 libgnunet_plugin_reclaim_credential_jwt.la
18 18
19EXTRA_DIST = \ 19EXTRA_DIST = \
20 reclaim.conf \ 20 reclaim.conf \
@@ -34,7 +34,7 @@ lib_LTLIBRARIES = \
34plugin_LTLIBRARIES = \ 34plugin_LTLIBRARIES = \
35 libgnunet_plugin_gnsrecord_reclaim.la \ 35 libgnunet_plugin_gnsrecord_reclaim.la \
36 libgnunet_plugin_reclaim_attribute_basic.la \ 36 libgnunet_plugin_reclaim_attribute_basic.la \
37 $(ATTESTATION_PLUGIN) \ 37 $(CREDENTIAL_PLUGIN) \
38 $(REST_PLUGIN) 38 $(REST_PLUGIN)
39 39
40bin_PROGRAMS = \ 40bin_PROGRAMS = \
@@ -115,8 +115,8 @@ libgnunetreclaim_la_SOURCES = \
115 reclaim.h \ 115 reclaim.h \
116 reclaim_attribute.c \ 116 reclaim_attribute.c \
117 reclaim_attribute.h \ 117 reclaim_attribute.h \
118 reclaim_attestation.c \ 118 reclaim_credential.c \
119 reclaim_attestation.h 119 reclaim_credential.h
120libgnunetreclaim_la_LIBADD = \ 120libgnunetreclaim_la_LIBADD = \
121 $(top_builddir)/src/util/libgnunetutil.la \ 121 $(top_builddir)/src/util/libgnunetutil.la \
122 $(GN_LIBINTL) $(XLIB) 122 $(GN_LIBINTL) $(XLIB)
@@ -133,14 +133,14 @@ libgnunet_plugin_reclaim_attribute_basic_la_LIBADD = \
133libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \ 133libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \
134 $(GN_PLUGIN_LDFLAGS) 134 $(GN_PLUGIN_LDFLAGS)
135 135
136libgnunet_plugin_reclaim_attestation_jwt_la_SOURCES = \ 136libgnunet_plugin_reclaim_credential_jwt_la_SOURCES = \
137 plugin_reclaim_attestation_jwt.c 137 plugin_reclaim_credential_jwt.c
138libgnunet_plugin_reclaim_attestation_jwt_la_LIBADD = \ 138libgnunet_plugin_reclaim_credential_jwt_la_LIBADD = \
139 $(top_builddir)/src/util/libgnunetutil.la \ 139 $(top_builddir)/src/util/libgnunetutil.la \
140 libgnunetreclaim.la \ 140 libgnunetreclaim.la \
141 -ljansson\ 141 -ljansson\
142 $(LTLIBINTL) 142 $(LTLIBINTL)
143libgnunet_plugin_reclaim_attestation_jwt_la_LDFLAGS = \ 143libgnunet_plugin_reclaim_credential_jwt_la_LDFLAGS = \
144 $(GN_PLUGIN_LDFLAGS) 144 $(GN_PLUGIN_LDFLAGS)
145 145
146gnunet_reclaim_SOURCES = \ 146gnunet_reclaim_SOURCES = \
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 6bef5b6fe..ab281a645 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -43,29 +43,34 @@ static int ret;
43static int list; 43static int list;
44 44
45/** 45/**
46 * List attestations flag 46 * List credentials flag
47 */ 47 */
48static int list_attestations; 48static int list_credentials;
49 49
50/** 50/**
51 * Attestation ID string 51 * Credential ID string
52 */ 52 */
53static char *attestation_id; 53static char *credential_id;
54 54
55/** 55/**
56 * Attestation ID 56 * Credential ID
57 */ 57 */
58static struct GNUNET_RECLAIM_Identifier attestation; 58static struct GNUNET_RECLAIM_Identifier credential;
59 59
60/** 60/**
61 * Attestation name 61 * Credential name
62 */ 62 */
63static char *attestation_name; 63static char *credential_name;
64 64
65/** 65/**
66 * Attestation exists 66 * Credential type
67 */ 67 */
68static int attestation_exists; 68static char *credential_type;
69
70/**
71 * Credential exists
72 */
73static int credential_exists;
69 74
70/** 75/**
71 * Relying party 76 * Relying party
@@ -133,9 +138,9 @@ static struct GNUNET_RECLAIM_Operation *reclaim_op;
133static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; 138static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator;
134 139
135/** 140/**
136 * Attestation iterator 141 * Credential iterator
137 */ 142 */
138static struct GNUNET_RECLAIM_AttestationIterator *attest_iterator; 143static struct GNUNET_RECLAIM_CredentialIterator *cred_iterator;
139 144
140 145
141/** 146/**
@@ -143,10 +148,6 @@ static struct GNUNET_RECLAIM_AttestationIterator *attest_iterator;
143 */ 148 */
144static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator; 149static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator;
145 150
146/**
147 * Master ABE key
148 */
149static struct GNUNET_CRYPTO_AbeMasterKey *abe_key;
150 151
151/** 152/**
152 * ego private key 153 * ego private key
@@ -208,25 +209,27 @@ do_cleanup (void *cls)
208 GNUNET_RECLAIM_cancel (reclaim_op); 209 GNUNET_RECLAIM_cancel (reclaim_op);
209 if (NULL != attr_iterator) 210 if (NULL != attr_iterator)
210 GNUNET_RECLAIM_get_attributes_stop (attr_iterator); 211 GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
211 if (NULL != attest_iterator) 212 if (NULL != cred_iterator)
212 GNUNET_RECLAIM_get_attestations_stop (attest_iterator); 213 GNUNET_RECLAIM_get_credentials_stop (cred_iterator);
213 if (NULL != ticket_iterator) 214 if (NULL != ticket_iterator)
214 GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator); 215 GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
215 if (NULL != reclaim_handle) 216 if (NULL != reclaim_handle)
216 GNUNET_RECLAIM_disconnect (reclaim_handle); 217 GNUNET_RECLAIM_disconnect (reclaim_handle);
217 if (NULL != identity_handle) 218 if (NULL != identity_handle)
218 GNUNET_IDENTITY_disconnect (identity_handle); 219 GNUNET_IDENTITY_disconnect (identity_handle);
219 if (NULL != abe_key)
220 GNUNET_free (abe_key);
221 if (NULL != attr_list) 220 if (NULL != attr_list)
222 GNUNET_free (attr_list); 221 GNUNET_free (attr_list);
223 if (NULL != attr_to_delete) 222 if (NULL != attr_to_delete)
224 GNUNET_free (attr_to_delete); 223 GNUNET_free (attr_to_delete);
224 if (NULL == credential_type)
225 GNUNET_free (credential_type);
225} 226}
226 227
227 228
228static void 229static void
229ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 230ticket_issue_cb (void *cls,
231 const struct GNUNET_RECLAIM_Ticket *ticket,
232 const struct GNUNET_RECLAIM_PresentationList *presentations)
230{ 233{
231 char *ticket_str; 234 char *ticket_str;
232 235
@@ -260,7 +263,7 @@ static void
260process_attrs (void *cls, 263process_attrs (void *cls,
261 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 264 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
262 const struct GNUNET_RECLAIM_Attribute *attr, 265 const struct GNUNET_RECLAIM_Attribute *attr,
263 const struct GNUNET_RECLAIM_Attestation *attest) 266 const struct GNUNET_RECLAIM_Presentation *presentation)
264{ 267{
265 char *value_str; 268 char *value_str;
266 char *id; 269 char *id;
@@ -280,7 +283,7 @@ process_attrs (void *cls,
280 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); 283 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
281 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 284 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
282 value_str = NULL; 285 value_str = NULL;
283 if (NULL == attest) 286 if (NULL == presentation)
284 { 287 {
285 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type, 288 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
286 attr->data, 289 attr->data,
@@ -290,7 +293,7 @@ process_attrs (void *cls,
290 { 293 {
291 struct GNUNET_RECLAIM_AttributeListEntry *ale; 294 struct GNUNET_RECLAIM_AttributeListEntry *ale;
292 struct GNUNET_RECLAIM_AttributeList *al 295 struct GNUNET_RECLAIM_AttributeList *al
293 = GNUNET_RECLAIM_attestation_get_attributes (attest); 296 = GNUNET_RECLAIM_presentation_get_attributes (presentation);
294 297
295 for (ale = al->list_head; NULL != ale; ale = ale->next) 298 for (ale = al->list_head; NULL != ale; ale = ale->next)
296 { 299 {
@@ -298,10 +301,8 @@ process_attrs (void *cls,
298 continue; 301 continue;
299 value_str 302 value_str
300 = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type, 303 = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
301 ale->attribute-> 304 ale->attribute->data,
302 data, 305 ale->attribute->data_size);
303 ale->attribute->
304 data_size);
305 break; 306 break;
306 } 307 }
307 } 308 }
@@ -312,7 +313,7 @@ process_attrs (void *cls,
312 attr_type, 313 attr_type,
313 attr->flag, 314 attr->flag,
314 id, 315 id,
315 (NULL == attest) ? "" : "(ATTESTED)"); 316 (NULL == presentation) ? "" : "(ATTESTED)");
316 GNUNET_free (value_str); 317 GNUNET_free (value_str);
317 GNUNET_free (id); 318 GNUNET_free (id);
318} 319}
@@ -362,7 +363,7 @@ static void
362iter_error (void *cls) 363iter_error (void *cls)
363{ 364{
364 attr_iterator = NULL; 365 attr_iterator = NULL;
365 attest_iterator = NULL; 366 cred_iterator = NULL;
366 fprintf (stderr, "Failed\n"); 367 fprintf (stderr, "Failed\n");
367 368
368 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 369 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -457,6 +458,7 @@ iter_finished (void *cls)
457 if (NULL == attr_to_delete) 458 if (NULL == attr_to_delete)
458 { 459 {
459 fprintf (stdout, "No such attribute ``%s''\n", attr_delete); 460 fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
461 GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
460 return; 462 return;
461 } 463 }
462 reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle, 464 reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
@@ -489,9 +491,9 @@ iter_finished (void *cls)
489 claim = 491 claim =
490 GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size); 492 GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
491 } 493 }
492 if (NULL != attestation_id) 494 if (NULL != credential_id)
493 { 495 {
494 claim->attestation = attestation; 496 claim->credential = credential;
495 } 497 }
496 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, 498 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
497 pkey, 499 pkey,
@@ -524,7 +526,7 @@ iter_cb (void *cls,
524 if (0 == strcasecmp (attr_name, attr->name)) 526 if (0 == strcasecmp (attr_name, attr->name))
525 { 527 {
526 claim = GNUNET_RECLAIM_attribute_new (attr->name, 528 claim = GNUNET_RECLAIM_attribute_new (attr->name,
527 &attr->attestation, 529 &attr->credential,
528 attr->type, 530 attr->type,
529 attr->data, 531 attr->data,
530 attr->data_size); 532 attr->data_size);
@@ -543,7 +545,7 @@ iter_cb (void *cls,
543 } 545 }
544 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 546 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
545 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, 547 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
546 &attr->attestation, 548 &attr->credential,
547 attr->type, 549 attr->type,
548 attr->data, 550 attr->data,
549 attr->data_size); 551 attr->data_size);
@@ -562,7 +564,7 @@ iter_cb (void *cls,
562 if (0 == strcasecmp (attr_delete, label)) 564 if (0 == strcasecmp (attr_delete, label))
563 { 565 {
564 attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name, 566 attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
565 &attr->attestation, 567 &attr->credential,
566 attr->type, 568 attr->type,
567 attr->data, 569 attr->data,
568 attr->data_size); 570 attr->data_size);
@@ -577,7 +579,7 @@ iter_cb (void *cls,
577 attr->data_size); 579 attr->data_size);
578 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); 580 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
579 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 581 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
580 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) 582 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->credential))
581 { 583 {
582 fprintf (stdout, 584 fprintf (stdout,
583 "%s: ``%s'' (%s); ID: %s\n", 585 "%s: ``%s'' (%s); ID: %s\n",
@@ -588,17 +590,17 @@ iter_cb (void *cls,
588 } 590 }
589 else 591 else
590 { 592 {
591 char *attest_id = 593 char *cred_id =
592 GNUNET_STRINGS_data_to_string_alloc (&attr->attestation, 594 GNUNET_STRINGS_data_to_string_alloc (&attr->credential,
593 sizeof(attr->attestation)); 595 sizeof(attr->credential));
594 fprintf (stdout, 596 fprintf (stdout,
595 "%s: <``%s'' in attestation %s> (%s); ID: %s\n", 597 "%s: ``%s'' in credential presentation `%s' (%s); ID: %s\n",
596 attr->name, 598 attr->name,
597 attr_str, 599 attr_str,
598 attest_id, 600 cred_id,
599 attr_type, 601 attr_type,
600 id); 602 id);
601 GNUNET_free (attest_id); 603 GNUNET_free (cred_id);
602 604
603 } 605 }
604 GNUNET_free (id); 606 GNUNET_free (id);
@@ -608,29 +610,31 @@ iter_cb (void *cls,
608 610
609 611
610static void 612static void
611attest_iter_finished (void *cls) 613cred_iter_finished (void *cls)
612{ 614{
613 attest_iterator = NULL; 615 cred_iterator = NULL;
614 616
615 // Add new attestation 617 // Add new credential
616 if ((NULL != attestation_name) && 618 if ((NULL != credential_name) &&
617 (NULL != attr_value)) 619 (NULL != attr_value))
618 { 620 {
619 struct GNUNET_RECLAIM_Attestation *attestation = 621 enum GNUNET_RECLAIM_CredentialType ctype =
620 GNUNET_RECLAIM_attestation_new (attestation_name, 622 GNUNET_RECLAIM_credential_typename_to_number (credential_type);
621 GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, // FIXME hardcoded 623 struct GNUNET_RECLAIM_Credential *credential =
622 attr_value, 624 GNUNET_RECLAIM_credential_new (credential_name,
623 strlen (attr_value)); 625 ctype,
624 reclaim_op = GNUNET_RECLAIM_attestation_store (reclaim_handle, 626 attr_value,
625 pkey, 627 strlen (attr_value));
626 attestation, 628 reclaim_op = GNUNET_RECLAIM_credential_store (reclaim_handle,
627 &exp_interval, 629 pkey,
628 store_cont, 630 credential,
629 NULL); 631 &exp_interval,
632 store_cont,
633 NULL);
630 return; 634 return;
631 635
632 } 636 }
633 if (list_attestations) 637 if (list_credentials)
634 { 638 {
635 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 639 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
636 return; 640 return;
@@ -648,34 +652,34 @@ attest_iter_finished (void *cls)
648 652
649 653
650static void 654static void
651attest_iter_cb (void *cls, 655cred_iter_cb (void *cls,
652 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 656 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
653 const struct GNUNET_RECLAIM_Attestation *attest) 657 const struct GNUNET_RECLAIM_Credential *cred)
654{ 658{
655 char *attest_str; 659 char *cred_str;
656 char *attr_str; 660 char *attr_str;
657 char *id; 661 char *id;
658 const char *attest_type; 662 const char *cred_type;
659 struct GNUNET_RECLAIM_AttributeListEntry *ale; 663 struct GNUNET_RECLAIM_AttributeListEntry *ale;
660 664
661 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attestation, 665 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&credential,
662 &attest->id)) 666 &cred->id))
663 attestation_exists = GNUNET_YES; 667 credential_exists = GNUNET_YES;
664 if (list_attestations) 668 if (list_credentials)
665 { 669 {
666 attest_str = GNUNET_RECLAIM_attestation_value_to_string (attest->type, 670 cred_str = GNUNET_RECLAIM_credential_value_to_string (cred->type,
667 attest->data, 671 cred->data,
668 attest->data_size); 672 cred->data_size);
669 attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type); 673 cred_type = GNUNET_RECLAIM_credential_number_to_typename (cred->type);
670 id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id)); 674 id = GNUNET_STRINGS_data_to_string_alloc (&cred->id, sizeof(cred->id));
671 fprintf (stdout, 675 fprintf (stdout,
672 "%s: ``%s'' (%s); ID: %s\n", 676 "%s: ``%s'' (%s); ID: %s\n",
673 attest->name, 677 cred->name,
674 attest_str, 678 cred_str,
675 attest_type, 679 cred_type,
676 id); 680 id);
677 struct GNUNET_RECLAIM_AttributeList *attrs = 681 struct GNUNET_RECLAIM_AttributeList *attrs =
678 GNUNET_RECLAIM_attestation_get_attributes (attest); 682 GNUNET_RECLAIM_credential_get_attributes (cred);
679 if (NULL != attrs) 683 if (NULL != attrs)
680 { 684 {
681 fprintf (stdout, 685 fprintf (stdout,
@@ -684,11 +688,8 @@ attest_iter_cb (void *cls,
684 { 688 {
685 attr_str = GNUNET_RECLAIM_attribute_value_to_string ( 689 attr_str = GNUNET_RECLAIM_attribute_value_to_string (
686 ale->attribute->type, 690 ale->attribute->type,
687 ale->attribute-> 691 ale->attribute->data,
688 data, 692 ale->attribute->data_size);
689 ale->attribute->
690 data_size);
691
692 fprintf (stdout, 693 fprintf (stdout,
693 "\t %s: %s\n", ale->attribute->name, attr_str); 694 "\t %s: %s\n", ale->attribute->name, attr_str);
694 GNUNET_free (attr_str); 695 GNUNET_free (attr_str);
@@ -697,7 +698,7 @@ attest_iter_cb (void *cls,
697 } 698 }
698 GNUNET_free (id); 699 GNUNET_free (id);
699 } 700 }
700 GNUNET_RECLAIM_get_attestations_next (attest_iterator); 701 GNUNET_RECLAIM_get_credentials_next (cred_iterator);
701} 702}
702 703
703 704
@@ -710,12 +711,14 @@ start_process ()
710 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 711 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
711 return; 712 return;
712 } 713 }
713 attestation = GNUNET_RECLAIM_ID_ZERO; 714 if (NULL == credential_type)
714 if (NULL != attestation_id) 715 credential_type = GNUNET_strdup ("JWT");
715 GNUNET_STRINGS_string_to_data (attestation_id, 716 credential = GNUNET_RECLAIM_ID_ZERO;
716 strlen (attestation_id), 717 if (NULL != credential_id)
717 &attestation, sizeof(attestation)); 718 GNUNET_STRINGS_string_to_data (credential_id,
718 attestation_exists = GNUNET_NO; 719 strlen (credential_id),
720 &credential, sizeof(credential));
721 credential_exists = GNUNET_NO;
719 if (list_tickets) 722 if (list_tickets)
720 { 723 {
721 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle, 724 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
@@ -750,15 +753,14 @@ start_process ()
750 753
751 attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 754 attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
752 claim = NULL; 755 claim = NULL;
753 attest_iterator = GNUNET_RECLAIM_get_attestations_start (reclaim_handle, 756 cred_iterator = GNUNET_RECLAIM_get_credentials_start (reclaim_handle,
754 pkey, 757 pkey,
755 &iter_error, 758 &iter_error,
756 NULL, 759 NULL,
757 &attest_iter_cb, 760 &cred_iter_cb,
758 NULL, 761 NULL,
759 & 762 &cred_iter_finished,
760 attest_iter_finished, 763 NULL);
761 NULL);
762 764
763} 765}
764 766
@@ -856,20 +858,20 @@ main (int argc, char *const argv[])
856 gettext_noop ("List attributes for EGO"), 858 gettext_noop ("List attributes for EGO"),
857 &list), 859 &list),
858 GNUNET_GETOPT_option_flag ('A', 860 GNUNET_GETOPT_option_flag ('A',
859 "attestations", 861 "credentials",
860 gettext_noop ("List attestations for EGO"), 862 gettext_noop ("List credentials for EGO"),
861 &list_attestations), 863 &list_credentials),
862 GNUNET_GETOPT_option_string ('I', 864 GNUNET_GETOPT_option_string ('I',
863 "Attestation ID", 865 "Credential ID",
864 "ATTESTATION_ID", 866 "CREDENTIAL_ID",
865 gettext_noop ( 867 gettext_noop (
866 "Attestation to use for attribute"), 868 "Credential to use for attribute"),
867 &attestation_id), 869 &credential_id),
868 GNUNET_GETOPT_option_string ('N', 870 GNUNET_GETOPT_option_string ('N',
869 "attestation-name", 871 "credential-name",
870 "NAME", 872 "NAME",
871 gettext_noop ("Attestation name"), 873 gettext_noop ("Credential name"),
872 &attestation_name), 874 &credential_name),
873 GNUNET_GETOPT_option_string ('i', 875 GNUNET_GETOPT_option_string ('i',
874 "issue", 876 "issue",
875 "A1,A2,...", 877 "A1,A2,...",
@@ -891,6 +893,11 @@ main (int argc, char *const argv[])
891 "TYPE", 893 "TYPE",
892 gettext_noop ("Type of attribute"), 894 gettext_noop ("Type of attribute"),
893 &type_str), 895 &type_str),
896 GNUNET_GETOPT_option_string ('u',
897 "credential-type",
898 "TYPE",
899 gettext_noop ("Type of credential"),
900 &credential_type),
894 GNUNET_GETOPT_option_flag ('T', 901 GNUNET_GETOPT_option_flag ('T',
895 "tickets", 902 "tickets",
896 gettext_noop ("List tickets of ego"), 903 gettext_noop ("List tickets of ego"),
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 84afd482e..d2cdc62a2 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -170,17 +170,17 @@ struct IdpClient
170 170
171 /** 171 /**
172 * Head of the DLL of 172 * Head of the DLL of
173 * Attribute iteration operations in 173 * Credential iteration operations in
174 * progress initiated by this client 174 * progress initiated by this client
175 */ 175 */
176 struct Iterator *attest_iter_head; 176 struct Iterator *cred_iter_head;
177 177
178 /** 178 /**
179 * Tail of the DLL of 179 * Tail of the DLL of
180 * Attribute iteration operations 180 * Credential iteration operations
181 * in progress initiated by this client 181 * in progress initiated by this client
182 */ 182 */
183 struct Iterator *attest_iter_tail; 183 struct Iterator *cred_iter_tail;
184 184
185 /** 185 /**
186 * Head of DLL of ticket iteration ops 186 * Head of DLL of ticket iteration ops
@@ -285,9 +285,9 @@ struct AttributeDeleteHandle
285 struct GNUNET_RECLAIM_Attribute *claim; 285 struct GNUNET_RECLAIM_Attribute *claim;
286 286
287 /** 287 /**
288 * The attestation to delete 288 * The credential to delete
289 */ 289 */
290 struct GNUNET_RECLAIM_Attestation *attest; 290 struct GNUNET_RECLAIM_Credential *credential;
291 291
292 /** 292 /**
293 * Tickets to update 293 * Tickets to update
@@ -352,9 +352,9 @@ struct AttributeStoreHandle
352 struct GNUNET_RECLAIM_Attribute *claim; 352 struct GNUNET_RECLAIM_Attribute *claim;
353 353
354 /** 354 /**
355 * The attestation to store 355 * The credential to store
356 */ 356 */
357 struct GNUNET_RECLAIM_Attestation *attest; 357 struct GNUNET_RECLAIM_Credential *credential;
358 358
359 /** 359 /**
360 * The attribute expiration interval 360 * The attribute expiration interval
@@ -488,8 +488,8 @@ cleanup_adh (struct AttributeDeleteHandle *adh)
488 GNUNET_free (adh->label); 488 GNUNET_free (adh->label);
489 if (NULL != adh->claim) 489 if (NULL != adh->claim)
490 GNUNET_free (adh->claim); 490 GNUNET_free (adh->claim);
491 if (NULL != adh->attest) 491 if (NULL != adh->credential)
492 GNUNET_free (adh->attest); 492 GNUNET_free (adh->credential);
493 while (NULL != (le = adh->tickets_to_update_head)) 493 while (NULL != (le = adh->tickets_to_update_head))
494 { 494 {
495 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, 495 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
@@ -517,8 +517,8 @@ cleanup_as_handle (struct AttributeStoreHandle *ash)
517 GNUNET_NAMESTORE_cancel (ash->ns_qe); 517 GNUNET_NAMESTORE_cancel (ash->ns_qe);
518 if (NULL != ash->claim) 518 if (NULL != ash->claim)
519 GNUNET_free (ash->claim); 519 GNUNET_free (ash->claim);
520 if (NULL != ash->attest) 520 if (NULL != ash->credential)
521 GNUNET_free (ash->attest); 521 GNUNET_free (ash->credential);
522 GNUNET_free (ash); 522 GNUNET_free (ash);
523} 523}
524 524
@@ -569,9 +569,9 @@ cleanup_client (struct IdpClient *idp)
569 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); 569 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
570 GNUNET_free (ai); 570 GNUNET_free (ai);
571 } 571 }
572 while (NULL != (ai = idp->attest_iter_head)) 572 while (NULL != (ai = idp->cred_iter_head))
573 { 573 {
574 GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail, 574 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
575 ai); 575 ai);
576 GNUNET_free (ai); 576 GNUNET_free (ai);
577 } 577 }
@@ -646,19 +646,33 @@ static void
646send_ticket_result (const struct IdpClient *client, 646send_ticket_result (const struct IdpClient *client,
647 uint32_t r_id, 647 uint32_t r_id,
648 const struct GNUNET_RECLAIM_Ticket *ticket, 648 const struct GNUNET_RECLAIM_Ticket *ticket,
649 const struct GNUNET_RECLAIM_PresentationList *presentations,
649 uint32_t success) 650 uint32_t success)
650{ 651{
651 struct TicketResultMessage *irm; 652 struct TicketResultMessage *irm;
652 struct GNUNET_MQ_Envelope *env; 653 struct GNUNET_MQ_Envelope *env;
654 size_t pres_len = 0;
653 655
654 env = GNUNET_MQ_msg (irm, 656 if (NULL != presentations)
655 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 657 {
658 pres_len =
659 GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations);
660 }
661 env = GNUNET_MQ_msg_extra (irm,
662 pres_len,
663 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
656 if (NULL != ticket) 664 if (NULL != ticket)
657 { 665 {
658 irm->ticket = *ticket; 666 irm->ticket = *ticket;
659 } 667 }
660 // TODO add success member 668 // TODO add success member
661 irm->id = htonl (r_id); 669 irm->id = htonl (r_id);
670 irm->presentations_len = htons (pres_len);
671 if (NULL != presentations)
672 {
673 GNUNET_RECLAIM_presentation_list_serialize (presentations,
674 (char*) &irm[1]);
675 }
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); 676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
663 GNUNET_MQ_send (client->mq, env); 677 GNUNET_MQ_send (client->mq, env);
664} 678}
@@ -669,12 +683,14 @@ send_ticket_result (const struct IdpClient *client,
669 * 683 *
670 * @param cls out ticket issue operation handle 684 * @param cls out ticket issue operation handle
671 * @param ticket the issued ticket 685 * @param ticket the issued ticket
686 * @param presentations newly created credential presentations (NULL on error)
672 * @param success issue success status (GNUNET_OK if successful) 687 * @param success issue success status (GNUNET_OK if successful)
673 * @param emsg error message (NULL of success is GNUNET_OK) 688 * @param emsg error message (NULL of success is GNUNET_OK)
674 */ 689 */
675static void 690static void
676issue_ticket_result_cb (void *cls, 691issue_ticket_result_cb (void *cls,
677 struct GNUNET_RECLAIM_Ticket *ticket, 692 struct GNUNET_RECLAIM_Ticket *ticket,
693 struct GNUNET_RECLAIM_PresentationList *presentations,
678 int32_t success, 694 int32_t success,
679 const char *emsg) 695 const char *emsg)
680{ 696{
@@ -682,7 +698,7 @@ issue_ticket_result_cb (void *cls,
682 698
683 if (GNUNET_OK != success) 699 if (GNUNET_OK != success)
684 { 700 {
685 send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR); 701 send_ticket_result (tio->client, tio->r_id, NULL, NULL, GNUNET_SYSERR);
686 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, 702 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
687 tio->client->issue_op_tail, 703 tio->client->issue_op_tail,
688 tio); 704 tio);
@@ -690,7 +706,8 @@ issue_ticket_result_cb (void *cls,
690 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg); 706 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
691 return; 707 return;
692 } 708 }
693 send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR); 709 send_ticket_result (tio->client, tio->r_id,
710 ticket, presentations, GNUNET_SYSERR);
694 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, 711 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
695 tio->client->issue_op_tail, 712 tio->client->issue_op_tail,
696 tio); 713 tio);
@@ -847,7 +864,7 @@ static void
847consume_result_cb (void *cls, 864consume_result_cb (void *cls,
848 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 865 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
849 const struct GNUNET_RECLAIM_AttributeList *attrs, 866 const struct GNUNET_RECLAIM_AttributeList *attrs,
850 const struct GNUNET_RECLAIM_AttestationList *attests, 867 const struct GNUNET_RECLAIM_PresentationList *presentations,
851 int32_t success, 868 int32_t success,
852 const char *emsg) 869 const char *emsg)
853{ 870{
@@ -856,28 +873,28 @@ consume_result_cb (void *cls,
856 struct GNUNET_MQ_Envelope *env; 873 struct GNUNET_MQ_Envelope *env;
857 char *data_tmp; 874 char *data_tmp;
858 size_t attrs_len = 0; 875 size_t attrs_len = 0;
859 size_t attests_len = 0; 876 size_t pres_len = 0;
860 877
861 if (GNUNET_OK != success) 878 if (GNUNET_OK != success)
862 { 879 {
863 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); 880 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
864 } 881 }
865 attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); 882 attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
866 attests_len = GNUNET_RECLAIM_attestation_list_serialize_get_size (attests); 883 pres_len = GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations);
867 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
868 "Sending CONSUME_TICKET_RESULT message\n"); 885 "Sending CONSUME_TICKET_RESULT message\n");
869 env = GNUNET_MQ_msg_extra (crm, 886 env = GNUNET_MQ_msg_extra (crm,
870 attrs_len + attests_len, 887 attrs_len + pres_len,
871 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 888 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
872 crm->id = htonl (cop->r_id); 889 crm->id = htonl (cop->r_id);
873 crm->attrs_len = htons (attrs_len); 890 crm->attrs_len = htons (attrs_len);
874 crm->attestations_len = htons (attests_len); 891 crm->presentations_len = htons (pres_len);
875 crm->identity = *identity; 892 crm->identity = *identity;
876 crm->result = htonl (success); 893 crm->result = htonl (success);
877 data_tmp = (char *) &crm[1]; 894 data_tmp = (char *) &crm[1];
878 GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); 895 GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
879 data_tmp += attrs_len; 896 data_tmp += attrs_len;
880 GNUNET_RECLAIM_attestation_list_serialize (attests, data_tmp); 897 GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
881 GNUNET_MQ_send (cop->client->mq, env); 898 GNUNET_MQ_send (cop->client->mq, env);
882 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, 899 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
883 cop->client->consume_op_tail, 900 cop->client->consume_op_tail,
@@ -1075,14 +1092,14 @@ handle_attribute_store_message (void *cls,
1075 1092
1076 1093
1077/** 1094/**
1078 * Attestation store result handler 1095 * Credential store result handler
1079 * 1096 *
1080 * @param cls our attribute store handle 1097 * @param cls our attribute store handle
1081 * @param success GNUNET_OK if successful 1098 * @param success GNUNET_OK if successful
1082 * @param emsg error message (NULL if success=GNUNET_OK) 1099 * @param emsg error message (NULL if success=GNUNET_OK)
1083 */ 1100 */
1084static void 1101static void
1085attest_store_cont (void *cls, int32_t success, const char *emsg) 1102cred_store_cont (void *cls, int32_t success, const char *emsg)
1086{ 1103{
1087 struct AttributeStoreHandle *ash = cls; 1104 struct AttributeStoreHandle *ash = cls;
1088 struct GNUNET_MQ_Envelope *env; 1105 struct GNUNET_MQ_Envelope *env;
@@ -1096,7 +1113,7 @@ attest_store_cont (void *cls, int32_t success, const char *emsg)
1096 if (GNUNET_SYSERR == success) 1113 if (GNUNET_SYSERR == success)
1097 { 1114 {
1098 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1099 "Failed to store attestation %s\n", 1116 "Failed to store credential: %s\n",
1100 emsg); 1117 emsg);
1101 cleanup_as_handle (ash); 1118 cleanup_as_handle (ash);
1102 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 1119 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
@@ -1113,16 +1130,16 @@ attest_store_cont (void *cls, int32_t success, const char *emsg)
1113 1130
1114 1131
1115/** 1132/**
1116 * Error looking up potential attestation. Abort. 1133 * Error looking up potential credential. Abort.
1117 * 1134 *
1118 * @param cls our attribute store handle 1135 * @param cls our attribute store handle
1119 */ 1136 */
1120static void 1137static void
1121attest_error (void *cls) 1138cred_error (void *cls)
1122{ 1139{
1123 struct AttributeStoreHandle *ash = cls; 1140 struct AttributeStoreHandle *ash = cls;
1124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1125 "Failed to check for existing Attestation\n"); 1142 "Failed to check for existing credential.\n");
1126 cleanup_as_handle (ash); 1143 cleanup_as_handle (ash);
1127 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 1144 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1128 return; 1145 return;
@@ -1130,7 +1147,7 @@ attest_error (void *cls)
1130 1147
1131 1148
1132/** 1149/**
1133* Check for existing record before storing attestation 1150* Check for existing record before storing credential
1134* 1151*
1135* @param cls our attribute store handle 1152* @param cls our attribute store handle
1136* @param zone zone we are iterating 1153* @param zone zone we are iterating
@@ -1139,33 +1156,34 @@ attest_error (void *cls)
1139* @param rd records 1156* @param rd records
1140*/ 1157*/
1141static void 1158static void
1142attest_add_cb (void *cls, 1159cred_add_cb (void *cls,
1143 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1160 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1144 const char *label, 1161 const char *label,
1145 unsigned int rd_count, 1162 unsigned int rd_count,
1146 const struct GNUNET_GNSRECORD_Data *rd) 1163 const struct GNUNET_GNSRECORD_Data *rd)
1147{ 1164{
1148 struct AttributeStoreHandle *ash = cls; 1165 struct AttributeStoreHandle *ash = cls;
1166 struct GNUNET_GNSRECORD_Data rd_new[1];
1149 char *buf; 1167 char *buf;
1150 size_t buf_size; 1168 size_t buf_size;
1151 buf_size = GNUNET_RECLAIM_attestation_serialize_get_size (ash->attest); 1169
1170 buf_size = GNUNET_RECLAIM_credential_serialize_get_size (ash->credential);
1152 buf = GNUNET_malloc (buf_size); 1171 buf = GNUNET_malloc (buf_size);
1153 GNUNET_RECLAIM_attestation_serialize (ash->attest, buf); 1172 GNUNET_RECLAIM_credential_serialize (ash->credential, buf);
1154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1155 "Storing new Attestation\n"); 1174 "Storing new credential under `%s'.\n",
1156 struct GNUNET_GNSRECORD_Data rd_new[1]; 1175 label);
1157 rd_new[0].data_size = buf_size; 1176 rd_new[0].data_size = buf_size;
1158 rd_new[0].data = buf; 1177 rd_new[0].data = buf;
1159 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION; 1178 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL;
1160 rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1179 rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1161 rd_new[0].expiration_time = ash->exp.rel_value_us; 1180 rd_new[0].expiration_time = ash->exp.rel_value_us;
1162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1163 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 1181 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1164 &ash->identity, 1182 &ash->identity,
1165 label, 1183 label,
1166 1, 1184 1,
1167 rd_new, 1185 rd_new,
1168 &attest_store_cont, 1186 &cred_store_cont,
1169 ash); 1187 ash);
1170 GNUNET_free (buf); 1188 GNUNET_free (buf);
1171 return; 1189 return;
@@ -1173,44 +1191,43 @@ attest_add_cb (void *cls,
1173 1191
1174 1192
1175/** 1193/**
1176 * Add a new attestation 1194 * Add a new credential
1177 * 1195 *
1178 * @param cls the AttributeStoreHandle 1196 * @param cls the AttributeStoreHandle
1179 */ 1197 */
1180static void 1198static void
1181attest_store_task (void *cls) 1199cred_store_task (void *cls)
1182{ 1200{
1183 struct AttributeStoreHandle *ash = cls; 1201 struct AttributeStoreHandle *ash = cls;
1184 char *label; 1202 char *label;
1185 1203
1186 // Give the ash a new id if unset 1204 // Give the ash a new id if unset
1187 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->attest->id)) 1205 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->credential->id))
1188 GNUNET_RECLAIM_id_generate (&ash->attest->id); 1206 GNUNET_RECLAIM_id_generate (&ash->credential->id);
1189 label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, 1207 label = GNUNET_STRINGS_data_to_string_alloc (&ash->credential->id,
1190 sizeof (ash->attest->id)); 1208 sizeof (ash->credential->id));
1191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1192 "Looking up existing data under label %s\n", label); 1210 "Looking up existing data under label `%s'\n", label);
1193// Test for the content of the existing ID
1194 ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, 1211 ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
1195 &ash->identity, 1212 &ash->identity,
1196 label, 1213 label,
1197 &attest_error, 1214 &cred_error,
1198 ash, 1215 ash,
1199 &attest_add_cb, 1216 &cred_add_cb,
1200 ash); 1217 ash);
1201 GNUNET_free (label); 1218 GNUNET_free (label);
1202} 1219}
1203 1220
1204 1221
1205/** 1222/**
1206 * Check an attestation store message 1223 * Check an credential store message
1207 * 1224 *
1208 * @param cls unused 1225 * @param cls unused
1209 * @param sam the message to check 1226 * @param sam the message to check
1210 */ 1227 */
1211static int 1228static int
1212check_attestation_store_message (void *cls, 1229check_credential_store_message (void *cls,
1213 const struct AttributeStoreMessage *sam) 1230 const struct AttributeStoreMessage *sam)
1214{ 1231{
1215 uint16_t size; 1232 uint16_t size;
1216 1233
@@ -1225,26 +1242,26 @@ check_attestation_store_message (void *cls,
1225 1242
1226 1243
1227/** 1244/**
1228* Handle an attestation store message 1245* Handle a credential store message
1229* 1246*
1230* @param cls our client 1247* @param cls our client
1231* @param sam the message to handle 1248* @param sam the message to handle
1232*/ 1249*/
1233static void 1250static void
1234handle_attestation_store_message (void *cls, 1251handle_credential_store_message (void *cls,
1235 const struct AttributeStoreMessage *sam) 1252 const struct AttributeStoreMessage *sam)
1236{ 1253{
1237 struct AttributeStoreHandle *ash; 1254 struct AttributeStoreHandle *ash;
1238 struct IdpClient *idp = cls; 1255 struct IdpClient *idp = cls;
1239 size_t data_len; 1256 size_t data_len;
1240 1257
1241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_STORE message\n"); 1258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1242 1259
1243 data_len = ntohs (sam->attr_len); 1260 data_len = ntohs (sam->attr_len);
1244 1261
1245 ash = GNUNET_new (struct AttributeStoreHandle); 1262 ash = GNUNET_new (struct AttributeStoreHandle);
1246 ash->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &sam[1], 1263 ash->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &sam[1],
1247 data_len); 1264 data_len);
1248 1265
1249 ash->r_id = ntohl (sam->id); 1266 ash->r_id = ntohl (sam->id);
1250 ash->identity = sam->identity; 1267 ash->identity = sam->identity;
@@ -1254,7 +1271,7 @@ handle_attestation_store_message (void *cls,
1254 GNUNET_SERVICE_client_continue (idp->client); 1271 GNUNET_SERVICE_client_continue (idp->client);
1255 ash->client = idp; 1272 ash->client = idp;
1256 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); 1273 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1257 GNUNET_SCHEDULER_add_now (&attest_store_task, ash); 1274 GNUNET_SCHEDULER_add_now (&cred_store_task, ash);
1258} 1275}
1259 1276
1260 1277
@@ -1310,12 +1327,12 @@ ticket_iter (void *cls,
1310 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, 1327 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
1311 &adh->claim->id)) 1328 &adh->claim->id))
1312 continue; 1329 continue;
1313 if (adh->attest != NULL) 1330 if (adh->credential != NULL)
1314 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, 1331 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
1315 &adh->attest->id)) 1332 &adh->credential->id))
1316 continue; 1333 continue;
1317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1334 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1318 "Attribute or Attestation to delete found (%s)\n", 1335 "Attribute to delete found (%s)\n",
1319 adh->label); 1336 adh->label);
1320 has_changed = GNUNET_YES; 1337 has_changed = GNUNET_YES;
1321 break; 1338 break;
@@ -1410,10 +1427,10 @@ update_tickets (void *cls)
1410 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1427 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1411 &adh->claim->id))) 1428 &adh->claim->id)))
1412 continue; 1429 continue;
1413 if (adh->attest != NULL) 1430 if (adh->credential != NULL)
1414 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) 1431 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1415 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1432 && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1416 &adh->attest->id))) 1433 &adh->credential->id)))
1417 continue; 1434 continue;
1418 rd_new[j] = rd[i]; 1435 rd_new[j] = rd[i];
1419 j++; 1436 j++;
@@ -1557,7 +1574,7 @@ handle_attribute_delete_message (void *cls,
1557 GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1], 1574 GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1],
1558 data_len, 1575 data_len,
1559 &adh->claim); 1576 &adh->claim);
1560 adh->attest = NULL; 1577 adh->credential = NULL;
1561 1578
1562 adh->r_id = ntohl (dam->id); 1579 adh->r_id = ntohl (dam->id);
1563 adh->identity = dam->identity; 1580 adh->identity = dam->identity;
@@ -1578,14 +1595,14 @@ handle_attribute_delete_message (void *cls,
1578 1595
1579 1596
1580/** 1597/**
1581 * Attestation deleted callback 1598 * Credential deleted callback
1582 * 1599 *
1583 * @param cls our handle 1600 * @param cls our handle
1584 * @param success success status 1601 * @param success success status
1585 * @param emsg error message (NULL if success=GNUNET_OK) 1602 * @param emsg error message (NULL if success=GNUNET_OK)
1586 */ 1603 */
1587static void 1604static void
1588attest_delete_cont (void *cls, int32_t success, const char *emsg) 1605cred_delete_cont (void *cls, int32_t success, const char *emsg)
1589{ 1606{
1590 struct AttributeDeleteHandle *adh = cls; 1607 struct AttributeDeleteHandle *adh = cls;
1591 1608
@@ -1593,7 +1610,7 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg)
1593 if (GNUNET_SYSERR == success) 1610 if (GNUNET_SYSERR == success)
1594 { 1611 {
1595 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1612 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1596 "Error deleting attestation %s\n", 1613 "Error deleting credential `%s'\n",
1597 adh->label); 1614 adh->label);
1598 send_delete_response (adh, GNUNET_SYSERR); 1615 send_delete_response (adh, GNUNET_SYSERR);
1599 cleanup_adh (adh); 1616 cleanup_adh (adh);
@@ -1605,14 +1622,14 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg)
1605 1622
1606 1623
1607/** 1624/**
1608 * Check attestation delete message format 1625 * Check credential delete message format
1609 * 1626 *
1610 * @cls unused 1627 * @cls unused
1611 * @dam message to check 1628 * @dam message to check
1612 */ 1629 */
1613static int 1630static int
1614check_attestation_delete_message (void *cls, 1631check_credential_delete_message (void *cls,
1615 const struct AttributeDeleteMessage *dam) 1632 const struct AttributeDeleteMessage *dam)
1616{ 1633{
1617 uint16_t size; 1634 uint16_t size;
1618 1635
@@ -1627,33 +1644,33 @@ check_attestation_delete_message (void *cls,
1627 1644
1628 1645
1629/** 1646/**
1630 * Handle attestation deletion 1647 * Handle credential deletion
1631 * 1648 *
1632 * @param cls our client 1649 * @param cls our client
1633 * @param dam deletion message 1650 * @param dam deletion message
1634 */ 1651 */
1635static void 1652static void
1636handle_attestation_delete_message (void *cls, 1653handle_credential_delete_message (void *cls,
1637 const struct AttributeDeleteMessage *dam) 1654 const struct AttributeDeleteMessage *dam)
1638{ 1655{
1639 struct AttributeDeleteHandle *adh; 1656 struct AttributeDeleteHandle *adh;
1640 struct IdpClient *idp = cls; 1657 struct IdpClient *idp = cls;
1641 size_t data_len; 1658 size_t data_len;
1642 1659
1643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_DELETE message\n"); 1660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1644 1661
1645 data_len = ntohs (dam->attr_len); 1662 data_len = ntohs (dam->attr_len);
1646 1663
1647 adh = GNUNET_new (struct AttributeDeleteHandle); 1664 adh = GNUNET_new (struct AttributeDeleteHandle);
1648 adh->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &dam[1], 1665 adh->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &dam[1],
1649 data_len); 1666 data_len);
1650 adh->claim = NULL; 1667 adh->claim = NULL;
1651 1668
1652 adh->r_id = ntohl (dam->id); 1669 adh->r_id = ntohl (dam->id);
1653 adh->identity = dam->identity; 1670 adh->identity = dam->identity;
1654 adh->label 1671 adh->label
1655 = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, 1672 = GNUNET_STRINGS_data_to_string_alloc (&adh->credential->id,
1656 sizeof(adh->attest->id)); 1673 sizeof(adh->credential->id));
1657 GNUNET_SERVICE_client_continue (idp->client); 1674 GNUNET_SERVICE_client_continue (idp->client);
1658 adh->client = idp; 1675 adh->client = idp;
1659 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); 1676 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
@@ -1662,7 +1679,7 @@ handle_attestation_delete_message (void *cls,
1662 adh->label, 1679 adh->label,
1663 0, 1680 0,
1664 NULL, 1681 NULL,
1665 &attest_delete_cont, 1682 &cred_delete_cont,
1666 adh); 1683 adh);
1667} 1684}
1668 1685
@@ -1712,7 +1729,7 @@ attr_iter_error (void *cls)
1712 1729
1713 1730
1714/** 1731/**
1715 * Got record. Return if it is an attribute or attestation. 1732 * Got record. Return if it is an attribute.
1716 * 1733 *
1717 * @param cls our attribute iterator 1734 * @param cls our attribute iterator
1718 * @param zone zone we are iterating 1735 * @param zone zone we are iterating
@@ -1852,51 +1869,51 @@ handle_iteration_next (void *cls,
1852 1869
1853 1870
1854/************************************************* 1871/*************************************************
1855* Attestation iteration 1872* Credential iteration
1856*************************************************/ 1873*************************************************/
1857 1874
1858 1875
1859/** 1876/**
1860 * Done iterating over attestations 1877 * Done iterating over credentials
1861 * 1878 *
1862 * @param cls our iterator handle 1879 * @param cls our iterator handle
1863 */ 1880 */
1864static void 1881static void
1865attest_iter_finished (void *cls) 1882cred_iter_finished (void *cls)
1866{ 1883{
1867 struct Iterator *ai = cls; 1884 struct Iterator *ai = cls;
1868 struct GNUNET_MQ_Envelope *env; 1885 struct GNUNET_MQ_Envelope *env;
1869 struct AttestationResultMessage *arm; 1886 struct CredentialResultMessage *arm;
1870 1887
1871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTESTATION_RESULT message\n"); 1888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
1872 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); 1889 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
1873 arm->id = htonl (ai->request_id); 1890 arm->id = htonl (ai->request_id);
1874 arm->attestation_len = htons (0); 1891 arm->credential_len = htons (0);
1875 GNUNET_MQ_send (ai->client->mq, env); 1892 GNUNET_MQ_send (ai->client->mq, env);
1876 GNUNET_CONTAINER_DLL_remove (ai->client->attest_iter_head, 1893 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
1877 ai->client->attest_iter_tail, 1894 ai->client->cred_iter_tail,
1878 ai); 1895 ai);
1879 GNUNET_free (ai); 1896 GNUNET_free (ai);
1880} 1897}
1881 1898
1882 1899
1883/** 1900/**
1884 * Error iterating over attestations. Abort. 1901 * Error iterating over credentials. Abort.
1885 * 1902 *
1886 * @param cls our attribute iteration handle 1903 * @param cls our attribute iteration handle
1887 */ 1904 */
1888static void 1905static void
1889attest_iter_error (void *cls) 1906cred_iter_error (void *cls)
1890{ 1907{
1891 struct Iterator *ai = cls; 1908 struct Iterator *ai = cls;
1892 1909
1893 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attestations\n"); 1910 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
1894 attest_iter_finished (ai); 1911 cred_iter_finished (ai);
1895} 1912}
1896 1913
1897 1914
1898/** 1915/**
1899 * Got record. Return attestation. 1916 * Got record. Return credential.
1900 * 1917 *
1901 * @param cls our attribute iterator 1918 * @param cls our attribute iterator
1902 * @param zone zone we are iterating 1919 * @param zone zone we are iterating
@@ -1905,32 +1922,32 @@ attest_iter_error (void *cls)
1905 * @param rd records 1922 * @param rd records
1906 */ 1923 */
1907static void 1924static void
1908attest_iter_cb (void *cls, 1925cred_iter_cb (void *cls,
1909 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1926 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1910 const char *label, 1927 const char *label,
1911 unsigned int rd_count, 1928 unsigned int rd_count,
1912 const struct GNUNET_GNSRECORD_Data *rd) 1929 const struct GNUNET_GNSRECORD_Data *rd)
1913{ 1930{
1914 struct Iterator *ai = cls; 1931 struct Iterator *ai = cls;
1915 struct GNUNET_MQ_Envelope *env; 1932 struct GNUNET_MQ_Envelope *env;
1916 struct AttestationResultMessage *arm; 1933 struct CredentialResultMessage *arm;
1917 char *data_tmp; 1934 char *data_tmp;
1918 1935
1919 if ((rd_count != 1) || 1936 if ((rd_count != 1) ||
1920 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) 1937 (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL != rd->record_type))
1921 { 1938 {
1922 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); 1939 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1923 return; 1940 return;
1924 } 1941 }
1925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", 1942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
1926 label); 1943 label);
1927 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1944 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1928 "Sending ATTESTATION_RESULT message\n"); 1945 "Sending CREDENTIAL_RESULT message\n");
1929 env = GNUNET_MQ_msg_extra (arm, 1946 env = GNUNET_MQ_msg_extra (arm,
1930 rd->data_size, 1947 rd->data_size,
1931 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); 1948 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
1932 arm->id = htonl (ai->request_id); 1949 arm->id = htonl (ai->request_id);
1933 arm->attestation_len = htons (rd->data_size); 1950 arm->credential_len = htons (rd->data_size);
1934 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); 1951 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1935 data_tmp = (char *) &arm[1]; 1952 data_tmp = (char *) &arm[1];
1936 GNUNET_memcpy (data_tmp, rd->data, rd->data_size); 1953 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
@@ -1946,29 +1963,29 @@ attest_iter_cb (void *cls,
1946 * @param ais_msg the iteration message to start 1963 * @param ais_msg the iteration message to start
1947 */ 1964 */
1948static void 1965static void
1949handle_attestation_iteration_start (void *cls, 1966handle_credential_iteration_start (void *cls,
1950 const struct 1967 const struct
1951 AttestationIterationStartMessage *ais_msg) 1968 CredentialIterationStartMessage *ais_msg)
1952{ 1969{
1953 struct IdpClient *idp = cls; 1970 struct IdpClient *idp = cls;
1954 struct Iterator *ai; 1971 struct Iterator *ai;
1955 1972
1956 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1957 "Received ATTESTATION_ITERATION_START message\n"); 1974 "Received CREDENTIAL_ITERATION_START message\n");
1958 ai = GNUNET_new (struct Iterator); 1975 ai = GNUNET_new (struct Iterator);
1959 ai->request_id = ntohl (ais_msg->id); 1976 ai->request_id = ntohl (ais_msg->id);
1960 ai->client = idp; 1977 ai->client = idp;
1961 ai->identity = ais_msg->identity; 1978 ai->identity = ais_msg->identity;
1962 1979
1963 GNUNET_CONTAINER_DLL_insert (idp->attest_iter_head, idp->attest_iter_tail, 1980 GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
1964 ai); 1981 ai);
1965 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, 1982 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
1966 &ai->identity, 1983 &ai->identity,
1967 &attest_iter_error, 1984 &cred_iter_error,
1968 ai, 1985 ai,
1969 &attest_iter_cb, 1986 &cred_iter_cb,
1970 ai, 1987 ai,
1971 &attest_iter_finished, 1988 &cred_iter_finished,
1972 ai); 1989 ai);
1973 GNUNET_SERVICE_client_continue (idp->client); 1990 GNUNET_SERVICE_client_continue (idp->client);
1974} 1991}
@@ -1981,9 +1998,9 @@ handle_attestation_iteration_start (void *cls,
1981 * @param ais_msg the stop message 1998 * @param ais_msg the stop message
1982 */ 1999 */
1983static void 2000static void
1984handle_attestation_iteration_stop (void *cls, 2001handle_credential_iteration_stop (void *cls,
1985 const struct 2002 const struct
1986 AttestationIterationStopMessage *ais_msg) 2003 CredentialIterationStopMessage *ais_msg)
1987{ 2004{
1988 struct IdpClient *idp = cls; 2005 struct IdpClient *idp = cls;
1989 struct Iterator *ai; 2006 struct Iterator *ai;
@@ -1991,9 +2008,9 @@ handle_attestation_iteration_stop (void *cls,
1991 2008
1992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2009 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1993 "Received `%s' message\n", 2010 "Received `%s' message\n",
1994 "ATTESTATION_ITERATION_STOP"); 2011 "CREDENTIAL_ITERATION_STOP");
1995 rid = ntohl (ais_msg->id); 2012 rid = ntohl (ais_msg->id);
1996 for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) 2013 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
1997 if (ai->request_id == rid) 2014 if (ai->request_id == rid)
1998 break; 2015 break;
1999 if (NULL == ai) 2016 if (NULL == ai)
@@ -2002,7 +2019,7 @@ handle_attestation_iteration_stop (void *cls,
2002 GNUNET_SERVICE_client_drop (idp->client); 2019 GNUNET_SERVICE_client_drop (idp->client);
2003 return; 2020 return;
2004 } 2021 }
2005 GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail, 2022 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2006 ai); 2023 ai);
2007 GNUNET_free (ai); 2024 GNUNET_free (ai);
2008 GNUNET_SERVICE_client_continue (idp->client); 2025 GNUNET_SERVICE_client_continue (idp->client);
@@ -2010,24 +2027,24 @@ handle_attestation_iteration_stop (void *cls,
2010 2027
2011 2028
2012/** 2029/**
2013 * Client requests next attestation from iterator 2030 * Client requests next credential from iterator
2014 * 2031 *
2015 * @param cls the client 2032 * @param cls the client
2016 * @param ais_msg the message 2033 * @param ais_msg the message
2017 */ 2034 */
2018static void 2035static void
2019handle_attestation_iteration_next (void *cls, 2036handle_credential_iteration_next (void *cls,
2020 const struct 2037 const struct
2021 AttestationIterationNextMessage *ais_msg) 2038 CredentialIterationNextMessage *ais_msg)
2022{ 2039{
2023 struct IdpClient *idp = cls; 2040 struct IdpClient *idp = cls;
2024 struct Iterator *ai; 2041 struct Iterator *ai;
2025 uint32_t rid; 2042 uint32_t rid;
2026 2043
2027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2028 "Received ATTESTATION_ITERATION_NEXT message\n"); 2045 "Received CREDENTIAL_ITERATION_NEXT message\n");
2029 rid = ntohl (ais_msg->id); 2046 rid = ntohl (ais_msg->id);
2030 for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) 2047 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2031 if (ai->request_id == rid) 2048 if (ai->request_id == rid)
2032 break; 2049 break;
2033 if (NULL == ai) 2050 if (NULL == ai)
@@ -2269,16 +2286,16 @@ GNUNET_SERVICE_MAIN (
2269 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, 2286 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE,
2270 struct AttributeStoreMessage, 2287 struct AttributeStoreMessage,
2271 NULL), 2288 NULL),
2272 GNUNET_MQ_hd_var_size (attestation_store_message, 2289 GNUNET_MQ_hd_var_size (credential_store_message,
2273 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE, 2290 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE,
2274 struct AttributeStoreMessage, 2291 struct AttributeStoreMessage,
2275 NULL), 2292 NULL),
2276 GNUNET_MQ_hd_var_size (attribute_delete_message, 2293 GNUNET_MQ_hd_var_size (attribute_delete_message,
2277 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, 2294 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE,
2278 struct AttributeDeleteMessage, 2295 struct AttributeDeleteMessage,
2279 NULL), 2296 NULL),
2280 GNUNET_MQ_hd_var_size (attestation_delete_message, 2297 GNUNET_MQ_hd_var_size (credential_delete_message,
2281 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, 2298 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE,
2282 struct AttributeDeleteMessage, 2299 struct AttributeDeleteMessage,
2283 NULL), 2300 NULL),
2284 GNUNET_MQ_hd_fixed_size (iteration_start, 2301 GNUNET_MQ_hd_fixed_size (iteration_start,
@@ -2293,17 +2310,17 @@ GNUNET_SERVICE_MAIN (
2293 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, 2310 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP,
2294 struct AttributeIterationStopMessage, 2311 struct AttributeIterationStopMessage,
2295 NULL), 2312 NULL),
2296 GNUNET_MQ_hd_fixed_size (attestation_iteration_start, 2313 GNUNET_MQ_hd_fixed_size (credential_iteration_start,
2297 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START, 2314 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START,
2298 struct AttestationIterationStartMessage, 2315 struct CredentialIterationStartMessage,
2299 NULL), 2316 NULL),
2300 GNUNET_MQ_hd_fixed_size (attestation_iteration_next, 2317 GNUNET_MQ_hd_fixed_size (credential_iteration_next,
2301 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT, 2318 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT,
2302 struct AttestationIterationNextMessage, 2319 struct CredentialIterationNextMessage,
2303 NULL), 2320 NULL),
2304 GNUNET_MQ_hd_fixed_size (attestation_iteration_stop, 2321 GNUNET_MQ_hd_fixed_size (credential_iteration_stop,
2305 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP, 2322 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP,
2306 struct AttestationIterationStopMessage, 2323 struct CredentialIterationStopMessage,
2307 NULL), 2324 NULL),
2308 2325
2309 GNUNET_MQ_hd_var_size (issue_ticket_message, 2326 GNUNET_MQ_hd_var_size (issue_ticket_message,
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index af01d8ec7..4dd8100f9 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -114,9 +114,9 @@ struct RECLAIM_TICKETS_ConsumeHandle
114 struct GNUNET_RECLAIM_AttributeList *attrs; 114 struct GNUNET_RECLAIM_AttributeList *attrs;
115 115
116 /** 116 /**
117 * Attestations 117 * Presentations
118 */ 118 */
119 struct GNUNET_RECLAIM_AttestationList *attests; 119 struct GNUNET_RECLAIM_PresentationList *presentations;
120 120
121 /** 121 /**
122 * Lookup time 122 * Lookup time
@@ -173,6 +173,11 @@ struct TicketIssueHandle
173 struct GNUNET_RECLAIM_AttributeList *attrs; 173 struct GNUNET_RECLAIM_AttributeList *attrs;
174 174
175 /** 175 /**
176 * Presentations to add
177 */
178 struct GNUNET_RECLAIM_PresentationList *presentations;
179
180 /**
176 * Issuer Key 181 * Issuer Key
177 */ 182 */
178 struct GNUNET_CRYPTO_EcdsaPrivateKey identity; 183 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
@@ -715,20 +720,20 @@ rvk_move_attr_cb (void *cls,
715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
716 GNUNET_free (claim); 721 GNUNET_free (claim);
717 } 722 }
718 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type) 723 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
719 { 724 {
720 struct GNUNET_RECLAIM_Attestation *attest; 725 struct GNUNET_RECLAIM_Credential *credential;
721 attest = GNUNET_RECLAIM_attestation_deserialize (rd[i].data, 726 credential = GNUNET_RECLAIM_credential_deserialize (rd[i].data,
722 rd[i].data_size); 727 rd[i].data_size);
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 728 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
724 "Attestation to update: Name=%s\n", 729 "Credential to update: Name=%s\n",
725 attest->name); 730 credential->name);
726 attest->id = rvk->move_attr->new_id; 731 credential->id = rvk->move_attr->new_id;
727 new_rd[i].data_size = 732 new_rd[i].data_size =
728 GNUNET_RECLAIM_attestation_serialize_get_size (attest); 733 GNUNET_RECLAIM_credential_serialize_get_size (credential);
729 attr_data = GNUNET_malloc (rd[i].data_size); 734 attr_data = GNUNET_malloc (rd[i].data_size);
730 new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest, 735 new_rd[i].data_size = GNUNET_RECLAIM_credential_serialize (credential,
731 attr_data); 736 attr_data);
732 new_rd[i].data = attr_data; 737 new_rd[i].data = attr_data;
733 new_rd[i].record_type = rd[i].record_type; 738 new_rd[i].record_type = rd[i].record_type;
734 new_rd[i].flags = rd[i].flags; 739 new_rd[i].flags = rd[i].flags;
@@ -736,9 +741,9 @@ rvk_move_attr_cb (void *cls,
736 new_label = 741 new_label =
737 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 742 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
738 sizeof (rvk->move_attr->new_id)); 743 sizeof (rvk->move_attr->new_id));
739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", 744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n",
740 new_label); 745 new_label);
741 GNUNET_free (attest); 746 GNUNET_free (credential);
742 } 747 }
743 } 748 }
744 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 749 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
@@ -981,8 +986,8 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
981 986
982 if (NULL != cth->attrs) 987 if (NULL != cth->attrs)
983 GNUNET_RECLAIM_attribute_list_destroy (cth->attrs); 988 GNUNET_RECLAIM_attribute_list_destroy (cth->attrs);
984 if (NULL != cth->attests) 989 if (NULL != cth->presentations)
985 GNUNET_RECLAIM_attestation_list_destroy (cth->attests); 990 GNUNET_RECLAIM_presentation_list_destroy (cth->presentations);
986 GNUNET_free (cth); 991 GNUNET_free (cth);
987} 992}
988 993
@@ -1027,40 +1032,20 @@ process_parallel_lookup_result (void *cls,
1027 // REMARK: It is possible now to find rd_count > 1 1032 // REMARK: It is possible now to find rd_count > 1
1028 for (int i = 0; i < rd_count; i++) 1033 for (int i = 0; i < rd_count; i++)
1029 { 1034 {
1030 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type) 1035 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
1031 {
1032 attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1033 GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size,
1034 &attr_le->attribute);
1035 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1036 cth->attrs->list_tail,
1037 attr_le);
1038 }
1039 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
1040 {
1041 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1042 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1043 ale->attestation =
1044 GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
1045 rd[i].data_size);
1046 GNUNET_CONTAINER_DLL_insert (cth->attests->list_head,
1047 cth->attests->list_tail,
1048 ale);
1049 }
1050 else
1051 {
1052 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1053 "Parallel Lookup of Reference without Attestation");
1054 continue; 1036 continue;
1055 } 1037 attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1056 1038 GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size,
1057 1039 &attr_le->attribute);
1040 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
1041 cth->attrs->list_tail,
1042 attr_le);
1058 } 1043 }
1059 if (NULL != cth->parallel_lookups_head) 1044 if (NULL != cth->parallel_lookups_head)
1060 return; // Wait for more 1045 return; // Wait for more
1061 /* Else we are done */ 1046 /* Else we are done */
1062 cth->cb (cth->cb_cls, &cth->ticket.identity, 1047 cth->cb (cth->cb_cls, &cth->ticket.identity,
1063 cth->attrs, cth->attests, GNUNET_OK, NULL); 1048 cth->attrs, cth->presentations, GNUNET_OK, NULL);
1064 cleanup_cth (cth); 1049 cleanup_cth (cth);
1065} 1050}
1066 1051
@@ -1110,6 +1095,7 @@ lookup_authz_cb (void *cls,
1110 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; 1095 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1111 struct ParallelLookup *parallel_lookup; 1096 struct ParallelLookup *parallel_lookup;
1112 char *lbl; 1097 char *lbl;
1098 struct GNUNET_RECLAIM_PresentationListEntry *ale;
1113 1099
1114 cth->lookup_request = NULL; 1100 cth->lookup_request = NULL;
1115 1101
@@ -1126,26 +1112,44 @@ lookup_authz_cb (void *cls,
1126 1112
1127 for (int i = 0; i < rd_count; i++) 1113 for (int i = 0; i < rd_count; i++)
1128 { 1114 {
1129 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) && 1115 /**
1130 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type)) 1116 * Check if record is a credential presentation or an attribute
1131 continue; 1117 * reference.
1132 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 1118 */
1133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl); 1119 switch (rd[i].record_type)
1134 parallel_lookup = GNUNET_new (struct ParallelLookup); 1120 {
1135 parallel_lookup->handle = cth; 1121 case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
1136 parallel_lookup->label = lbl; 1122 ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
1137 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); 1123 ale->presentation =
1138 parallel_lookup->lookup_request = 1124 GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1139 GNUNET_GNS_lookup (gns, 1125 rd[i].data_size);
1140 lbl, 1126 GNUNET_CONTAINER_DLL_insert (cth->presentations->list_head,
1141 &cth->ticket.identity, 1127 cth->presentations->list_tail,
1142 GNUNET_GNSRECORD_TYPE_ANY, 1128 ale);
1143 GNUNET_GNS_LO_DEFAULT, 1129 break;
1144 &process_parallel_lookup_result, 1130 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
1145 parallel_lookup); 1131 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1146 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, 1132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1147 cth->parallel_lookups_tail, 1133 parallel_lookup = GNUNET_new (struct ParallelLookup);
1148 parallel_lookup); 1134 parallel_lookup->handle = cth;
1135 parallel_lookup->label = lbl;
1136 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1137 parallel_lookup->lookup_request =
1138 GNUNET_GNS_lookup (gns,
1139 lbl,
1140 &cth->ticket.identity,
1141 GNUNET_GNSRECORD_TYPE_ANY,
1142 GNUNET_GNS_LO_DEFAULT,
1143 &process_parallel_lookup_result,
1144 parallel_lookup);
1145 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head,
1146 cth->parallel_lookups_tail,
1147 parallel_lookup);
1148 break;
1149 default:
1150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1151 "Ignoring unknown record type %d", rd[i].record_type);
1152 }
1149 } 1153 }
1150 /** 1154 /**
1151 * We started lookups. Add a timeout task. 1155 * We started lookups. Add a timeout task.
@@ -1163,7 +1167,7 @@ lookup_authz_cb (void *cls,
1163 * No references found, return empty attribute list 1167 * No references found, return empty attribute list
1164 */ 1168 */
1165 cth->cb (cth->cb_cls, &cth->ticket.identity, 1169 cth->cb (cth->cb_cls, &cth->ticket.identity,
1166 cth->attrs, cth->attests, GNUNET_OK, NULL); 1170 cth->attrs, NULL, GNUNET_OK, NULL);
1167 cleanup_cth (cth); 1171 cleanup_cth (cth);
1168} 1172}
1169 1173
@@ -1193,7 +1197,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1193 cth->identity = *id; 1197 cth->identity = *id;
1194 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); 1198 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1195 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 1199 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1196 cth->attests = GNUNET_new (struct GNUNET_RECLAIM_AttestationList); 1200 cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1197 cth->ticket = *ticket; 1201 cth->ticket = *ticket;
1198 cth->cb = cb; 1202 cth->cb = cb;
1199 cth->cb_cls = cb_cls; 1203 cth->cb_cls = cb_cls;
@@ -1231,8 +1235,8 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
1231 1235
1232 1236
1233/******************************* 1237/*******************************
1234* Ticket issue 1238 * Ticket issue
1235*******************************/ 1239 *******************************/
1236 1240
1237/** 1241/**
1238 * Cleanup ticket consume handle 1242 * Cleanup ticket consume handle
@@ -1265,11 +1269,15 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1265 { 1269 {
1266 handle->cb (handle->cb_cls, 1270 handle->cb (handle->cb_cls,
1267 &handle->ticket, 1271 &handle->ticket,
1272 NULL,
1268 GNUNET_SYSERR, 1273 GNUNET_SYSERR,
1269 "Error storing AuthZ ticket in GNS"); 1274 "Error storing AuthZ ticket in GNS");
1270 return; 1275 return;
1271 } 1276 }
1272 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); 1277 handle->cb (handle->cb_cls,
1278 &handle->ticket,
1279 handle->presentations,
1280 GNUNET_OK, NULL);
1273 cleanup_issue_handle (handle); 1281 cleanup_issue_handle (handle);
1274} 1282}
1275 1283
@@ -1285,15 +1293,17 @@ static void
1285issue_ticket (struct TicketIssueHandle *ih) 1293issue_ticket (struct TicketIssueHandle *ih)
1286{ 1294{
1287 struct GNUNET_RECLAIM_AttributeListEntry *le; 1295 struct GNUNET_RECLAIM_AttributeListEntry *le;
1296 struct GNUNET_RECLAIM_PresentationListEntry *ple;
1288 struct GNUNET_GNSRECORD_Data *attrs_record; 1297 struct GNUNET_GNSRECORD_Data *attrs_record;
1289 char *label; 1298 char *label;
1290 int i; 1299 int i;
1300 int j;
1291 int attrs_count = 0; 1301 int attrs_count = 0;
1292 1302
1293 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1303 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1294 attrs_count++; 1304 attrs_count++;
1295 1305
1296 // Worst case we have one attestation per attribute 1306 // Worst case we have one presentation per attribute
1297 attrs_record = 1307 attrs_record =
1298 GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data)); 1308 GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1299 i = 0; 1309 i = 0;
@@ -1308,28 +1318,67 @@ issue_ticket (struct TicketIssueHandle *ih)
1308 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF; 1318 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
1309 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1319 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1310 i++; 1320 i++;
1311 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 1321 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
1312 { 1322 {
1313 int j; 1323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1324 "Attribute is backed by credential. Adding...\n");
1325 struct GNUNET_RECLAIM_Presentation *pres = NULL;
1314 for (j = 0; j < i; j++) 1326 for (j = 0; j < i; j++)
1315 { 1327 {
1316 if (attrs_record[j].record_type 1328 if (attrs_record[j].record_type
1317 != GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF) 1329 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION)
1318 continue; 1330 continue;
1319 if (0 == memcmp (attrs_record[j].data, 1331 pres = GNUNET_RECLAIM_presentation_deserialize (attrs_record[j].data,
1320 &le->attribute->attestation, 1332 attrs_record[j].
1321 sizeof (le->attribute->attestation))) 1333 data_size);
1334 if (NULL == pres)
1335 {
1336 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1337 "Failed to deserialize presentation\n");
1338 continue;
1339 }
1340 if (0 == memcmp (&pres->credential_id,
1341 &le->attribute->credential,
1342 sizeof (le->attribute->credential)))
1322 break; 1343 break;
1344 GNUNET_free (pres);
1345 pres = NULL;
1346 }
1347 if (NULL != pres)
1348 {
1349 GNUNET_free (pres);
1350 continue; // Skip as we have already added this credential presentation.
1351 }
1352 for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next)
1353 {
1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1355 "Checking presentation....\n");
1356
1357 if (0 != memcmp (&le->attribute->credential,
1358 &ple->presentation->credential_id,
1359 sizeof (le->attribute->credential)))
1360 {
1361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1362 "Presentation does not match credential ID.\n");
1363 continue;
1364 }
1365 char *pres_buf;
1366 size_t pres_size;
1367 pres_size =
1368 GNUNET_RECLAIM_presentation_serialize_get_size (ple->presentation);
1369 pres_buf = GNUNET_malloc (pres_size);
1370 GNUNET_RECLAIM_presentation_serialize (ple->presentation,
1371 pres_buf);
1372 attrs_record[i].data = pres_buf;
1373 attrs_record[i].data_size = pres_size;
1374 attrs_record[i].expiration_time =
1375 ticket_refresh_interval.rel_value_us;
1376 attrs_record[i].record_type =
1377 GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION;
1378 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1379 i++;
1380 break;
1323 } 1381 }
1324 if (j < i)
1325 continue; // Skip as we have already added this attestation.
1326 attrs_record[i].data = &le->attribute->attestation;
1327 attrs_record[i].data_size = sizeof(le->attribute->attestation);
1328 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1329 attrs_record[i].record_type =
1330 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
1331 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1332 i++;
1333 } 1382 }
1334 } 1383 }
1335 attrs_record[i].data = &ih->ticket; 1384 attrs_record[i].data = &ih->ticket;
@@ -1351,14 +1400,23 @@ issue_ticket (struct TicketIssueHandle *ih)
1351 attrs_record, 1400 attrs_record,
1352 &store_ticket_issue_cont, 1401 &store_ticket_issue_cont,
1353 ih); 1402 ih);
1403 for (j = 0; j > i; j++)
1404 {
1405 if (attrs_record[j].record_type
1406 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION)
1407 continue;
1408 // Yes, we are allowed to do this because we allocated it above
1409 char *ptr = (char*) attrs_record[j].data;
1410 GNUNET_free (ptr);
1411 }
1354 GNUNET_free (attrs_record); 1412 GNUNET_free (attrs_record);
1355 GNUNET_free (label); 1413 GNUNET_free (label);
1356} 1414}
1357 1415
1358 1416
1359/************************************************* 1417/*************************************************
1360* Ticket iteration (finding a specific ticket) 1418 * Ticket iteration (finding a specific ticket)
1361*************************************************/ 1419 *************************************************/
1362 1420
1363 1421
1364/** 1422/**
@@ -1374,6 +1432,7 @@ filter_tickets_error_cb (void *cls)
1374 tih->ns_it = NULL; 1432 tih->ns_it = NULL;
1375 tih->cb (tih->cb_cls, 1433 tih->cb (tih->cb_cls,
1376 &tih->ticket, 1434 &tih->ticket,
1435 NULL,
1377 GNUNET_SYSERR, 1436 GNUNET_SYSERR,
1378 "Error storing AuthZ ticket in GNS"); 1437 "Error storing AuthZ ticket in GNS");
1379 cleanup_issue_handle (tih); 1438 cleanup_issue_handle (tih);
@@ -1401,22 +1460,25 @@ filter_tickets_cb (void *cls,
1401{ 1460{
1402 struct TicketIssueHandle *tih = cls; 1461 struct TicketIssueHandle *tih = cls;
1403 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1462 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1404 1463 struct GNUNET_RECLAIM_Presentation *pres;
1405 // figure out the number of requested attributes 1464 struct GNUNET_RECLAIM_PresentationList *ticket_presentations;
1465 struct GNUNET_RECLAIM_Credential *cred;
1466 struct GNUNET_RECLAIM_PresentationListEntry *ple;
1406 struct GNUNET_RECLAIM_AttributeListEntry *le; 1467 struct GNUNET_RECLAIM_AttributeListEntry *le;
1407 unsigned int attr_cnt = 0; 1468 unsigned int attr_cnt = 0;
1408 unsigned int attest_cnt = 0; 1469 unsigned int pres_cnt = 0;
1409 1470
1410 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1471 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1411 { 1472 {
1412 attr_cnt++; 1473 attr_cnt++;
1413 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 1474 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
1414 attest_cnt++; 1475 pres_cnt++;
1415 } 1476 }
1416 1477
1417 // ticket search 1478 // ticket search
1418 unsigned int found_attrs_cnt = 0; 1479 unsigned int found_attrs_cnt = 0;
1419 unsigned int found_attests_cnt = 0; 1480 unsigned int found_pres_cnt = 0;
1481 ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1420 1482
1421 for (int i = 0; i < rd_count; i++) 1483 for (int i = 0; i < rd_count; i++)
1422 { 1484 {
@@ -1436,20 +1498,75 @@ filter_tickets_cb (void *cls,
1436 } 1498 }
1437 1499
1438 // cmp requested attributes with ticket attributes 1500 // cmp requested attributes with ticket attributes
1439 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) && 1501 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1440 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type)) 1502 {
1441 continue; 1503 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1442 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1504 {
1505 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
1506 &le->attribute->id))
1507 found_attrs_cnt++;
1508 }
1509 }
1510 if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
1443 { 1511 {
1444 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1512 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1445 &le->attribute->id)) 1513 "Found credential...\n");
1446 found_attrs_cnt++; 1514
1515 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1516 {
1517 cred = GNUNET_RECLAIM_credential_deserialize (rd[i].data,
1518 rd[i].data_size);
1519 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id,
1520 &le->attribute->credential))
1521 {
1522 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1523 "No match.\n");
1524 GNUNET_free (cred);
1525 continue;
1526 }
1527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1528 "Match, creating presentation...\n");
1529 if (GNUNET_OK != GNUNET_RECLAIM_credential_get_presentation (
1530 cred,
1531 tih->attrs,
1532 &pres))
1533 {
1534 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1535 "Unable to retrieve presentation from credential\n");
1536 GNUNET_free (cred);
1537 continue;
1538 }
1539 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
1540 ple->presentation = pres;
1541 GNUNET_CONTAINER_DLL_insert (tih->presentations->list_head,
1542 tih->presentations->list_tail,
1543 ple);
1544 GNUNET_free (cred);
1545 }
1447 } 1546 }
1448 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1547 if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type)
1449 { 1548 {
1450 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, 1549 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1451 &le->attribute->attestation)) 1550 {
1452 found_attests_cnt++; 1551 pres = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1552 rd[i].data_size);
1553 if (NULL == pres)
1554 {
1555 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1556 "Failed to deserialize presentation\n");
1557 continue;
1558 }
1559 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&pres->credential_id,
1560 &le->attribute->credential))
1561 {
1562 found_pres_cnt++;
1563 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
1564 ple->presentation = pres;
1565 GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head,
1566 ticket_presentations->list_tail,
1567 ple);
1568 }
1569 }
1453 } 1570 }
1454 } 1571 }
1455 1572
@@ -1458,11 +1575,12 @@ filter_tickets_cb (void *cls,
1458 * we are done. 1575 * we are done.
1459 */ 1576 */
1460 if ((attr_cnt == found_attrs_cnt) && 1577 if ((attr_cnt == found_attrs_cnt) &&
1461 (attest_cnt == found_attests_cnt) && 1578 (pres_cnt == found_pres_cnt) &&
1462 (NULL != ticket)) 1579 (NULL != ticket))
1463 { 1580 {
1464 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); 1581 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
1465 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); 1582 tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL);
1583 GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1466 cleanup_issue_handle (tih); 1584 cleanup_issue_handle (tih);
1467 return; 1585 return;
1468 } 1586 }
@@ -1514,6 +1632,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1514 tih->cb = cb; 1632 tih->cb = cb;
1515 tih->cb_cls = cb_cls; 1633 tih->cb_cls = cb_cls;
1516 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs); 1634 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs);
1635 tih->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1517 tih->identity = *identity; 1636 tih->identity = *identity;
1518 tih->ticket.audience = *audience; 1637 tih->ticket.audience = *audience;
1519 1638
@@ -1531,8 +1650,8 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1531 1650
1532 1651
1533/************************************ 1652/************************************
1534* Ticket iteration 1653 * Ticket iteration
1535************************************/ 1654 ************************************/
1536 1655
1537/** 1656/**
1538 * Cleanup ticket iterator 1657 * Cleanup ticket iterator
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index 1c7214d42..0dd790fc7 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -113,6 +113,7 @@ typedef void (*RECLAIM_TICKETS_TicketIter) (
113 * 113 *
114 * @param cls closure 114 * @param cls closure
115 * @param ticket the ticket 115 * @param ticket the ticket
116 * @param presentations new presentations for ticket (NULL on error)
116 * @param success #GNUNET_SYSERR on failure (including timeout/queue 117 * @param success #GNUNET_SYSERR on failure (including timeout/queue
117 * drop/failure to validate) #GNUNET_OK on success 118 * drop/failure to validate) #GNUNET_OK on success
118 * @param emsg NULL on success, otherwise an error message 119 * @param emsg NULL on success, otherwise an error message
@@ -120,6 +121,7 @@ typedef void (*RECLAIM_TICKETS_TicketIter) (
120typedef void (*RECLAIM_TICKETS_TicketResult) ( 121typedef void (*RECLAIM_TICKETS_TicketResult) (
121 void *cls, 122 void *cls,
122 struct GNUNET_RECLAIM_Ticket *ticket, 123 struct GNUNET_RECLAIM_Ticket *ticket,
124 struct GNUNET_RECLAIM_PresentationList *presentations,
123 int32_t success, 125 int32_t success,
124 const char *emsg); 126 const char *emsg);
125 127
@@ -129,7 +131,8 @@ typedef void (*RECLAIM_TICKETS_TicketResult) (
129 * 131 *
130 * @param cls closure 132 * @param cls closure
131 * @param identity the issuer of the ticket/attributes 133 * @param identity the issuer of the ticket/attributes
132 * @param l attribute list retrieved through ticket 134 * @param attributes attribute list retrieved through ticket
135 * @param presentations attribute presentations (may be NULL)
133 * @param success GNUNET_OK on success 136 * @param success GNUNET_OK on success
134 * @param emsg error message (NULL on success) 137 * @param emsg error message (NULL on success)
135 */ 138 */
@@ -137,7 +140,7 @@ typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
137 void *cls, 140 void *cls,
138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 141 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
139 const struct GNUNET_RECLAIM_AttributeList *attributes, 142 const struct GNUNET_RECLAIM_AttributeList *attributes,
140 const struct GNUNET_RECLAIM_AttestationList *attestations, 143 const struct GNUNET_RECLAIM_PresentationList *presentations,
141 int32_t success, 144 int32_t success,
142 const char *emsg); 145 const char *emsg);
143 146
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c
index c470ea567..8a3479b8a 100644
--- a/src/reclaim/json_reclaim.c
+++ b/src/reclaim/json_reclaim.c
@@ -46,7 +46,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
46 const char *val_str = NULL; 46 const char *val_str = NULL;
47 const char *type_str = NULL; 47 const char *type_str = NULL;
48 const char *id_str = NULL; 48 const char *id_str = NULL;
49 const char *attest_str = NULL; 49 const char *cred_str = NULL;
50 const char *flag_str = NULL; 50 const char *flag_str = NULL;
51 char *data; 51 char *data;
52 int unpack_state; 52 int unpack_state;
@@ -68,8 +68,8 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
68 &name_str, 68 &name_str,
69 "id", 69 "id",
70 &id_str, 70 &id_str,
71 "attestation", 71 "credential",
72 &attest_str, 72 &cred_str,
73 "type", 73 "type",
74 &type_str, 74 &type_str,
75 "value", 75 "value",
@@ -95,12 +95,12 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
95 } 95 }
96 attr = GNUNET_RECLAIM_attribute_new (name_str, NULL, 96 attr = GNUNET_RECLAIM_attribute_new (name_str, NULL,
97 type, data, data_size); 97 type, data, data_size);
98 if ((NULL != attest_str) && (0 != strlen (attest_str))) 98 if ((NULL != cred_str) && (0 != strlen (cred_str)))
99 { 99 {
100 GNUNET_STRINGS_string_to_data (attest_str, 100 GNUNET_STRINGS_string_to_data (cred_str,
101 strlen (attest_str), 101 strlen (cred_str),
102 &attr->attestation, 102 &attr->credential,
103 sizeof(attr->attestation)); 103 sizeof(attr->credential));
104 } 104 }
105 if ((NULL == id_str) || (0 == strlen (id_str))) 105 if ((NULL == id_str) || (0 == strlen (id_str)))
106 memset (&attr->id, 0, sizeof (attr->id)); 106 memset (&attr->id, 0, sizeof (attr->id));
@@ -142,7 +142,7 @@ clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
142 * @return JSON Specification 142 * @return JSON Specification
143 */ 143 */
144struct GNUNET_JSON_Specification 144struct GNUNET_JSON_Specification
145GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr) 145GNUNET_RECLAIM_JSON_spec_attribute (struct GNUNET_RECLAIM_Attribute **attr)
146{ 146{
147 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr, 147 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
148 .cleaner = &clean_attr, 148 .cleaner = &clean_attr,
@@ -279,7 +279,7 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
279 279
280 280
281/** 281/**
282 * Parse given JSON object to an attestation claim 282 * Parse given JSON object to a credential claim
283 * 283 *
284 * @param cls closure, NULL 284 * @param cls closure, NULL
285 * @param root the json object representing data 285 * @param root the json object representing data
@@ -287,9 +287,9 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
287 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error 287 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
288 */ 288 */
289static int 289static int
290parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 290parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
291{ 291{
292 struct GNUNET_RECLAIM_Attestation *attr; 292 struct GNUNET_RECLAIM_Credential *cred;
293 const char *name_str = NULL; 293 const char *name_str = NULL;
294 const char *val_str = NULL; 294 const char *val_str = NULL;
295 const char *type_str = NULL; 295 const char *type_str = NULL;
@@ -325,26 +325,26 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
325 "Error json object has a wrong format!\n"); 325 "Error json object has a wrong format!\n");
326 return GNUNET_SYSERR; 326 return GNUNET_SYSERR;
327 } 327 }
328 type = GNUNET_RECLAIM_attestation_typename_to_number (type_str); 328 type = GNUNET_RECLAIM_credential_typename_to_number (type_str);
329 if (GNUNET_SYSERR == 329 if (GNUNET_SYSERR ==
330 (GNUNET_RECLAIM_attestation_string_to_value (type, 330 (GNUNET_RECLAIM_credential_string_to_value (type,
331 val_str, 331 val_str,
332 (void **) &data, 332 (void **) &data,
333 &data_size))) 333 &data_size)))
334 { 334 {
335 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attestation value invalid!\n"); 335 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Credential value invalid!\n");
336 return GNUNET_SYSERR; 336 return GNUNET_SYSERR;
337 } 337 }
338 attr = GNUNET_RECLAIM_attestation_new (name_str, type, data, data_size); 338 cred = GNUNET_RECLAIM_credential_new (name_str, type, data, data_size);
339 if ((NULL == id_str) || (0 == strlen (id_str))) 339 if ((NULL == id_str) || (0 == strlen (id_str)))
340 memset (&attr->id, 0, sizeof (attr->id)); 340 memset (&cred->id, 0, sizeof (cred->id));
341 else 341 else
342 GNUNET_STRINGS_string_to_data (id_str, 342 GNUNET_STRINGS_string_to_data (id_str,
343 strlen (id_str), 343 strlen (id_str),
344 &attr->id, 344 &cred->id,
345 sizeof(attr->id)); 345 sizeof(cred->id));
346 346
347 *(struct GNUNET_RECLAIM_Attestation **) spec->ptr = attr; 347 *(struct GNUNET_RECLAIM_Credential **) spec->ptr = cred;
348 return GNUNET_OK; 348 return GNUNET_OK;
349} 349}
350 350
@@ -356,11 +356,11 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
356 * @param[out] spec where to free the data 356 * @param[out] spec where to free the data
357 */ 357 */
358static void 358static void
359clean_attest (void *cls, struct GNUNET_JSON_Specification *spec) 359clean_credential (void *cls, struct GNUNET_JSON_Specification *spec)
360{ 360{
361 struct GNUNET_RECLAIM_Attestation **attr; 361 struct GNUNET_RECLAIM_Credential **attr;
362 362
363 attr = (struct GNUNET_RECLAIM_Attestation **) spec->ptr; 363 attr = (struct GNUNET_RECLAIM_Credential **) spec->ptr;
364 if (NULL != *attr) 364 if (NULL != *attr)
365 { 365 {
366 GNUNET_free (*attr); 366 GNUNET_free (*attr);
@@ -370,23 +370,23 @@ clean_attest (void *cls, struct GNUNET_JSON_Specification *spec)
370 370
371 371
372/** 372/**
373 * JSON Specification for Reclaim attestation claims. 373 * JSON Specification for credential claims.
374 * 374 *
375 * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_Claim to fill 375 * @param attr struct of GNUNET_RECLAIM_Credential to fill
376 * @return JSON Specification 376 * @return JSON Specification
377 */ 377 */
378struct GNUNET_JSON_Specification 378struct GNUNET_JSON_Specification
379GNUNET_RECLAIM_JSON_spec_claim_attest (struct 379GNUNET_RECLAIM_JSON_spec_credential (struct
380 GNUNET_RECLAIM_Attestation **attr) 380 GNUNET_RECLAIM_Credential **cred)
381{ 381{
382 struct GNUNET_JSON_Specification ret = { .parser = &parse_attest, 382 struct GNUNET_JSON_Specification ret = { .parser = &parse_credential,
383 .cleaner = &clean_attest, 383 .cleaner = &clean_credential,
384 .cls = NULL, 384 .cls = NULL,
385 .field = NULL, 385 .field = NULL,
386 .ptr = attr, 386 .ptr = cred,
387 .ptr_size = 0, 387 .ptr_size = 0,
388 .size_ptr = NULL }; 388 .size_ptr = NULL };
389 389
390 *attr = NULL; 390 *cred = NULL;
391 return ret; 391 return ret;
392} 392}
diff --git a/src/reclaim/json_reclaim.h b/src/reclaim/json_reclaim.h
index c57971dcb..613ddf873 100644
--- a/src/reclaim/json_reclaim.h
+++ b/src/reclaim/json_reclaim.h
@@ -32,11 +32,11 @@
32/** 32/**
33 * JSON Specification for Reclaim claims. 33 * JSON Specification for Reclaim claims.
34 * 34 *
35 * @param ticket struct of GNUNET_RECLAIM_ATTRIBUTE_Claim to fill 35 * @param attr struct of GNUNET_RECLAIM_Attribute to fill
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 **attr); 39GNUNET_RECLAIM_JSON_spec_attribute (struct GNUNET_RECLAIM_Attribute **attr);
40 40
41/** 41/**
42 * JSON Specification for Reclaim tickets. 42 * JSON Specification for Reclaim tickets.
@@ -48,11 +48,10 @@ struct GNUNET_JSON_Specification
48GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket); 48GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket);
49 49
50/** 50/**
51 * JSON Specification for Reclaim attestation claims. 51 * JSON Specification for credentials.
52 * 52 *
53 * @param ticket struct of GNUNET_RECLAIM_Attestation to fill 53 * @param cred struct of GNUNET_RECLAIM_Credential 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_credential (struct GNUNET_RECLAIM_Credential **cred);
58 GNUNET_RECLAIM_Attestation **attr);
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index eab12db33..b307a358c 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -62,9 +62,9 @@ struct OIDC_Parameters
62 uint32_t attr_list_len GNUNET_PACKED; 62 uint32_t attr_list_len GNUNET_PACKED;
63 63
64 /** 64 /**
65 * The length of the attestation list 65 * The length of the presentation list
66 */ 66 */
67 uint32_t attest_list_len GNUNET_PACKED; 67 uint32_t pres_list_len GNUNET_PACKED;
68}; 68};
69 69
70GNUNET_NETWORK_STRUCT_END 70GNUNET_NETWORK_STRUCT_END
@@ -156,25 +156,25 @@ fix_base64 (char *str)
156 156
157static json_t* 157static json_t*
158generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 158generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
159 struct GNUNET_RECLAIM_AttributeList *attrs, 159 const struct GNUNET_RECLAIM_AttributeList *attrs,
160 struct GNUNET_RECLAIM_AttestationList *attests) 160 const struct GNUNET_RECLAIM_PresentationList *presentations)
161{ 161{
162 struct GNUNET_RECLAIM_AttributeListEntry *le; 162 struct GNUNET_RECLAIM_AttributeListEntry *le;
163 struct GNUNET_RECLAIM_AttestationListEntry *ale; 163 struct GNUNET_RECLAIM_PresentationListEntry *ple;
164 char *subject; 164 char *subject;
165 char *source_name; 165 char *source_name;
166 char *attr_val_str; 166 char *attr_val_str;
167 char *attest_val_str; 167 char *pres_val_str;
168 json_t *body; 168 json_t *body;
169 json_t *aggr_names; 169 json_t *aggr_names;
170 json_t *aggr_sources; 170 json_t *aggr_sources;
171 json_t *aggr_sources_jwt; 171 json_t *aggr_sources_jwt;
172 json_t *addr_claim = NULL; 172 json_t *addr_claim = NULL;
173 int num_attestations = 0; 173 int num_presentations = 0;
174 for (le = attrs->list_head; NULL != le; le = le->next) 174 for (le = attrs->list_head; NULL != le; le = le->next)
175 { 175 {
176 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 176 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
177 num_attestations++; 177 num_presentations++;
178 } 178 }
179 179
180 subject = 180 subject =
@@ -191,23 +191,25 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
191 json_object_set_new (body, "iss", json_string (SERVER_ADDRESS)); 191 json_object_set_new (body, "iss", json_string (SERVER_ADDRESS));
192 // sub REQUIRED public key identity, not exceed 255 ASCII length 192 // sub REQUIRED public key identity, not exceed 255 ASCII length
193 json_object_set_new (body, "sub", json_string (subject)); 193 json_object_set_new (body, "sub", json_string (subject));
194 attest_val_str = NULL; 194 pres_val_str = NULL;
195 source_name = NULL; 195 source_name = NULL;
196 int i = 0; 196 int i = 0;
197 for (ale = attests->list_head; NULL != ale; ale = ale->next) 197 for (ple = presentations->list_head; NULL != ple; ple = ple->next)
198 { 198 {
199 // New Attestation 199 // New presentation
200 GNUNET_asprintf (&source_name, 200 GNUNET_asprintf (&source_name,
201 "src%d", 201 "src%d",
202 i); 202 i);
203 aggr_sources_jwt = json_object (); 203 aggr_sources_jwt = json_object ();
204 attest_val_str = 204 pres_val_str =
205 GNUNET_RECLAIM_attestation_value_to_string (ale->attestation->type, 205 GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type,
206 ale->attestation->data, 206 ple->presentation->data,
207 ale->attestation->data_size); 207 ple->presentation->data_size);
208 json_object_set_new (aggr_sources_jwt, "JWT", 208 json_object_set_new (aggr_sources_jwt,
209 json_string (attest_val_str) ); 209 GNUNET_RECLAIM_presentation_number_to_typename (ple->presentation->type),
210 json_string (pres_val_str) );
210 json_object_set_new (aggr_sources, source_name, aggr_sources_jwt); 211 json_object_set_new (aggr_sources, source_name, aggr_sources_jwt);
212 GNUNET_free (pres_val_str);
211 GNUNET_free (source_name); 213 GNUNET_free (source_name);
212 source_name = NULL; 214 source_name = NULL;
213 i++; 215 i++;
@@ -216,7 +218,7 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
216 for (le = attrs->list_head; NULL != le; le = le->next) 218 for (le = attrs->list_head; NULL != le; le = le->next)
217 { 219 {
218 220
219 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 221 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
220 { 222 {
221 223
222 attr_val_str = 224 attr_val_str =
@@ -247,18 +249,24 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
247 } 249 }
248 else 250 else
249 { 251 {
250 // Check if attest is there 252 // Check if presentation is there
251 int j = 0; 253 int j = 0;
252 for (ale = attests->list_head; NULL != ale; ale = ale->next) 254 for (ple = presentations->list_head; NULL != ple; ple = ple->next)
253 { 255 {
254 if (GNUNET_YES == 256 if (GNUNET_YES ==
255 GNUNET_RECLAIM_id_is_equal (&ale->attestation->id, 257 GNUNET_RECLAIM_id_is_equal (&ple->presentation->credential_id,
256 &le->attribute->attestation)) 258 &le->attribute->credential))
257 break; 259 break;
258 j++; 260 j++;
259 } 261 }
260 GNUNET_assert (NULL != ale); 262 if (NULL == ple)
261 // Attestation is existing, hence take the respective source str 263 {
264 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
265 "Presentation for `%s' missing...\n",
266 le->attribute->name);
267 continue;
268 }
269 // Presentation exists, hence take the respective source str
262 GNUNET_asprintf (&source_name, 270 GNUNET_asprintf (&source_name,
263 "src%d", 271 "src%d",
264 j); 272 j);
@@ -269,9 +277,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
269 } 277 }
270 if (NULL != addr_claim) 278 if (NULL != addr_claim)
271 json_object_set_new (body, "address", addr_claim); 279 json_object_set_new (body, "address", addr_claim);
272
273 if (NULL != attest_val_str)
274 GNUNET_free (attest_val_str);
275 if (0 != i) 280 if (0 != i)
276 { 281 {
277 json_object_set_new (body, "_claim_names", aggr_names); 282 json_object_set_new (body, "_claim_names", aggr_names);
@@ -286,18 +291,18 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
286 * 291 *
287 * @param sub_key the subject (user) 292 * @param sub_key the subject (user)
288 * @param attrs user attribute list 293 * @param attrs user attribute list
289 * @param attests user attribute attestation list (may be empty) 294 * @param presentations credential presentation list (may be empty)
290 * @return Userinfo JSON 295 * @return Userinfo JSON
291 */ 296 */
292char * 297char *
293OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 298OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
294 struct GNUNET_RECLAIM_AttributeList *attrs, 299 const struct GNUNET_RECLAIM_AttributeList *attrs,
295 struct GNUNET_RECLAIM_AttestationList *attests) 300 const struct GNUNET_RECLAIM_PresentationList *presentations)
296{ 301{
297 char *body_str; 302 char *body_str;
298 json_t* body = generate_userinfo_json (sub_key, 303 json_t* body = generate_userinfo_json (sub_key,
299 attrs, 304 attrs,
300 attests); 305 presentations);
301 body_str = json_dumps (body, JSON_INDENT (0) | JSON_COMPACT); 306 body_str = json_dumps (body, JSON_INDENT (0) | JSON_COMPACT);
302 json_decref (body); 307 json_decref (body);
303 return body_str; 308 return body_str;
@@ -310,6 +315,7 @@ OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
310 * @param aud_key the public of the audience 315 * @param aud_key the public of the audience
311 * @param sub_key the public key of the subject 316 * @param sub_key the public key of the subject
312 * @param attrs the attribute list 317 * @param attrs the attribute list
318 * @param presentations credential presentation list (may be empty)
313 * @param expiration_time the validity of the token 319 * @param expiration_time the validity of the token
314 * @param secret_key the key used to sign the JWT 320 * @param secret_key the key used to sign the JWT
315 * @return a new base64-encoded JWT string. 321 * @return a new base64-encoded JWT string.
@@ -317,8 +323,8 @@ OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
317char * 323char *
318OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 324OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
319 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 325 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
320 struct GNUNET_RECLAIM_AttributeList *attrs, 326 const struct GNUNET_RECLAIM_AttributeList *attrs,
321 struct GNUNET_RECLAIM_AttestationList *attests, 327 const struct GNUNET_RECLAIM_PresentationList *presentations,
322 const struct GNUNET_TIME_Relative *expiration_time, 328 const struct GNUNET_TIME_Relative *expiration_time,
323 const char *nonce, 329 const char *nonce,
324 const char *secret_key) 330 const char *secret_key)
@@ -339,7 +345,7 @@ OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
339 345
340 body = generate_userinfo_json (sub_key, 346 body = generate_userinfo_json (sub_key,
341 attrs, 347 attrs,
342 attests); 348 presentations);
343 // iat REQUIRED time now 349 // iat REQUIRED time now
344 time_now = GNUNET_TIME_absolute_get (); 350 time_now = GNUNET_TIME_absolute_get ();
345 // exp REQUIRED time expired from config 351 // exp REQUIRED time expired from config
@@ -426,6 +432,7 @@ OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
426 * @param issuer the issuer of the ticket, used to sign the ticket and nonce 432 * @param issuer the issuer of the ticket, used to sign the ticket and nonce
427 * @param ticket the ticket to include in the code 433 * @param ticket the ticket to include in the code
428 * @param attrs list of attributes which are shared 434 * @param attrs list of attributes which are shared
435 * @param presentations credential presentation list (may be empty)
429 * @param nonce the nonce to include in the code 436 * @param nonce the nonce to include in the code
430 * @param code_challenge PKCE code challenge 437 * @param code_challenge PKCE code challenge
431 * @return a new authorization code (caller must free) 438 * @return a new authorization code (caller must free)
@@ -433,8 +440,8 @@ OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
433char * 440char *
434OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 441OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
435 const struct GNUNET_RECLAIM_Ticket *ticket, 442 const struct GNUNET_RECLAIM_Ticket *ticket,
436 struct GNUNET_RECLAIM_AttributeList *attrs, 443 const struct GNUNET_RECLAIM_AttributeList *attrs,
437 struct GNUNET_RECLAIM_AttestationList *attests, 444 const struct GNUNET_RECLAIM_PresentationList *presentations,
438 const char *nonce_str, 445 const char *nonce_str,
439 const char *code_challenge) 446 const char *code_challenge)
440{ 447{
@@ -447,7 +454,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
447 size_t payload_len; 454 size_t payload_len;
448 size_t code_payload_len; 455 size_t code_payload_len;
449 size_t attr_list_len = 0; 456 size_t attr_list_len = 0;
450 size_t attests_list_len = 0; 457 size_t pres_list_len = 0;
451 size_t code_challenge_len = 0; 458 size_t code_challenge_len = 0;
452 uint32_t nonce_len = 0; 459 uint32_t nonce_len = 0;
453 struct GNUNET_CRYPTO_EccSignaturePurpose *purpose; 460 struct GNUNET_CRYPTO_EccSignaturePurpose *purpose;
@@ -481,17 +488,17 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
481 // Get serialized attributes 488 // Get serialized attributes
482 payload_len += attr_list_len; 489 payload_len += attr_list_len;
483 } 490 }
484 if (NULL != attests) 491 if (NULL != presentations)
485 { 492 {
486 // Get length 493 // Get length
487 attests_list_len = 494 pres_list_len =
488 GNUNET_RECLAIM_attestation_list_serialize_get_size (attests); 495 GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations);
489 params.attest_list_len = htonl (attests_list_len); 496 params.pres_list_len = htonl (pres_list_len);
490 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
491 "Length of serialized attestations: %lu\n", 498 "Length of serialized presentations: %lu\n",
492 attests_list_len); 499 pres_list_len);
493 // Get serialized attributes 500 // Get serialized attributes
494 payload_len += attests_list_len; 501 payload_len += pres_list_len;
495 } 502 }
496 503
497 // Get plaintext length 504 // Get plaintext length
@@ -510,8 +517,8 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
510 } 517 }
511 if (0 < attr_list_len) 518 if (0 < attr_list_len)
512 GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp); 519 GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp);
513 if (0 < attests_list_len) 520 if (0 < pres_list_len)
514 GNUNET_RECLAIM_attestation_list_serialize (attests, tmp); 521 GNUNET_RECLAIM_presentation_list_serialize (presentations, tmp);
515 522
516 /** END **/ 523 /** END **/
517 524
@@ -564,7 +571,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
564 * if used in request. 571 * if used in request.
565 * @param ticket where to store the ticket 572 * @param ticket where to store the ticket
566 * @param attrs the attributes in the code 573 * @param attrs the attributes in the code
567 * @param attests the attestations in the code (if any) 574 * @param presentations credential presentation list
568 * @param nonce_str where to store the nonce (if contained) 575 * @param nonce_str where to store the nonce (if contained)
569 * @return GNUNET_OK if successful, else GNUNET_SYSERR 576 * @return GNUNET_OK if successful, else GNUNET_SYSERR
570 */ 577 */
@@ -574,14 +581,14 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
574 const char *code_verifier, 581 const char *code_verifier,
575 struct GNUNET_RECLAIM_Ticket *ticket, 582 struct GNUNET_RECLAIM_Ticket *ticket,
576 struct GNUNET_RECLAIM_AttributeList **attrs, 583 struct GNUNET_RECLAIM_AttributeList **attrs,
577 struct GNUNET_RECLAIM_AttestationList **attests, 584 struct GNUNET_RECLAIM_PresentationList **presentations,
578 char **nonce_str) 585 char **nonce_str)
579{ 586{
580 char *code_payload; 587 char *code_payload;
581 char *ptr; 588 char *ptr;
582 char *plaintext; 589 char *plaintext;
583 char *attrs_ser; 590 char *attrs_ser;
584 char *attests_ser; 591 char *presentations_ser;
585 char *expected_code_challenge; 592 char *expected_code_challenge;
586 char *code_challenge; 593 char *code_challenge;
587 char *code_verifier_hash; 594 char *code_verifier_hash;
@@ -589,7 +596,7 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
589 struct GNUNET_CRYPTO_EcdsaSignature *signature; 596 struct GNUNET_CRYPTO_EcdsaSignature *signature;
590 uint32_t code_challenge_len; 597 uint32_t code_challenge_len;
591 uint32_t attrs_ser_len; 598 uint32_t attrs_ser_len;
592 uint32_t attests_ser_len; 599 uint32_t pres_ser_len;
593 size_t plaintext_len; 600 size_t plaintext_len;
594 size_t code_payload_len; 601 size_t code_payload_len;
595 uint32_t nonce_len = 0; 602 uint32_t nonce_len = 0;
@@ -692,10 +699,11 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
692 attrs_ser = ((char *) &params[1]) + code_challenge_len + nonce_len; 699 attrs_ser = ((char *) &params[1]) + code_challenge_len + nonce_len;
693 attrs_ser_len = ntohl (params->attr_list_len); 700 attrs_ser_len = ntohl (params->attr_list_len);
694 *attrs = GNUNET_RECLAIM_attribute_list_deserialize (attrs_ser, attrs_ser_len); 701 *attrs = GNUNET_RECLAIM_attribute_list_deserialize (attrs_ser, attrs_ser_len);
695 attests_ser = ((char*) attrs_ser) + attrs_ser_len; 702 presentations_ser = ((char*) attrs_ser) + attrs_ser_len;
696 attests_ser_len = ntohl (params->attest_list_len); 703 pres_ser_len = ntohl (params->pres_list_len);
697 *attests = GNUNET_RECLAIM_attestation_list_deserialize (attests_ser, 704 *presentations =
698 attests_ser_len); 705 GNUNET_RECLAIM_presentation_list_deserialize (presentations_ser,
706 pres_ser_len);
699 707
700 GNUNET_free (code_payload); 708 GNUNET_free (code_payload);
701 return GNUNET_OK; 709 return GNUNET_OK;
diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h
index e713dab62..10a6f3d1f 100644
--- a/src/reclaim/oidc_helper.h
+++ b/src/reclaim/oidc_helper.h
@@ -44,6 +44,7 @@
44 * @param aud_key the public of the audience 44 * @param aud_key the public of the audience
45 * @param sub_key the public key of the subject 45 * @param sub_key the public key of the subject
46 * @param attrs the attribute list 46 * @param attrs the attribute list
47 * @param presentations credential presentation list (may be empty)
47 * @param expiration_time the validity of the token 48 * @param expiration_time the validity of the token
48 * @param secret_key the key used to sign the JWT 49 * @param secret_key the key used to sign the JWT
49 * @return a new base64-encoded JWT string. 50 * @return a new base64-encoded JWT string.
@@ -51,8 +52,8 @@
51char* 52char*
52OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 53OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
53 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 54 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
54 struct GNUNET_RECLAIM_AttributeList *attrs, 55 const struct GNUNET_RECLAIM_AttributeList *attrs,
55 struct GNUNET_RECLAIM_AttestationList *attests, 56 const struct GNUNET_RECLAIM_PresentationList *presentations,
56 const struct GNUNET_TIME_Relative *expiration_time, 57 const struct GNUNET_TIME_Relative *expiration_time,
57 const char *nonce, 58 const char *nonce,
58 const char *secret_key); 59 const char *secret_key);
@@ -64,6 +65,7 @@ OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
64 * @param issuer the issuer of the ticket, used to sign the ticket and nonce 65 * @param issuer the issuer of the ticket, used to sign the ticket and nonce
65 * @param ticket the ticket to include in the code 66 * @param ticket the ticket to include in the code
66 * @param attrs list of attributes to share 67 * @param attrs list of attributes to share
68 * @param presentations credential presentation list
67 * @param nonce the nonce to include in the code 69 * @param nonce the nonce to include in the code
68 * @param code_challenge PKCE code challenge 70 * @param code_challenge PKCE code challenge
69 * @return a new authorization code (caller must free) 71 * @return a new authorization code (caller must free)
@@ -71,8 +73,8 @@ OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
71char* 73char*
72OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 74OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
73 const struct GNUNET_RECLAIM_Ticket *ticket, 75 const struct GNUNET_RECLAIM_Ticket *ticket,
74 struct GNUNET_RECLAIM_AttributeList *attrs, 76 const struct GNUNET_RECLAIM_AttributeList *attrs,
75 struct GNUNET_RECLAIM_AttestationList *attests, 77 const struct GNUNET_RECLAIM_PresentationList *presentations,
76 const char *nonce, 78 const char *nonce,
77 const char *code_challenge); 79 const char *code_challenge);
78 80
@@ -86,6 +88,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
86 * @param code_verfier PKCE code verifier 88 * @param code_verfier PKCE code verifier
87 * @param ticket where to store the ticket 89 * @param ticket where to store the ticket
88 * @param attrs the attributes found in the code 90 * @param attrs the attributes found in the code
91 * @param presentations credential presentation list
89 * @param nonce where to store the nonce 92 * @param nonce where to store the nonce
90 * @return GNUNET_OK if successful, else GNUNET_SYSERR 93 * @return GNUNET_OK if successful, else GNUNET_SYSERR
91 */ 94 */
@@ -95,7 +98,7 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *ecdsa_pub,
95 const char *code_verifier, 98 const char *code_verifier,
96 struct GNUNET_RECLAIM_Ticket *ticket, 99 struct GNUNET_RECLAIM_Ticket *ticket,
97 struct GNUNET_RECLAIM_AttributeList **attrs, 100 struct GNUNET_RECLAIM_AttributeList **attrs,
98 struct GNUNET_RECLAIM_AttestationList **attests, 101 struct GNUNET_RECLAIM_PresentationList **presentations,
99 char **nonce); 102 char **nonce);
100 103
101/** 104/**
@@ -136,8 +139,8 @@ OIDC_access_token_parse (const char* token,
136 * @return GNUNET_YES if attribute is implcitly requested 139 * @return GNUNET_YES if attribute is implcitly requested
137 */ 140 */
138enum GNUNET_GenericReturnValue 141enum GNUNET_GenericReturnValue
139OIDC_check_scopes_for_claim_request (const char*scopes, 142OIDC_check_scopes_for_claim_request (const char *scopes,
140 const char*attr); 143 const char *attr);
141 144
142 145
143/** 146/**
@@ -145,12 +148,12 @@ OIDC_check_scopes_for_claim_request (const char*scopes,
145 * 148 *
146 * @param sub_key the subject (user) 149 * @param sub_key the subject (user)
147 * @param attrs user attribute list 150 * @param attrs user attribute list
148 * @param attests user attribute attestation list (may be empty) 151 * @param presentations credential presentation list
149 * @return Userinfo JSON 152 * @return Userinfo JSON
150 */ 153 */
151char * 154char *
152OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 155OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
153 struct GNUNET_RECLAIM_AttributeList *attrs, 156 const struct GNUNET_RECLAIM_AttributeList *attrs,
154 struct GNUNET_RECLAIM_AttestationList *attests); 157 const struct GNUNET_RECLAIM_PresentationList *presentations);
155 158
156#endif 159#endif
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index b91e123a3..60c49fd6a 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -51,8 +51,8 @@ value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
51 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: 51 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
52 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 52 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
53 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 53 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
54 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION: 54 case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL:
55 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF: 55 case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
56 return GNUNET_STRINGS_data_to_string_alloc (data, data_size); 56 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
57 57
58 default: 58 default:
@@ -89,8 +89,8 @@ string_to_value (void *cls, uint32_t type, const char *s, void **data,
89 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: 89 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
90 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 90 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
91 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 91 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
92 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION: 92 case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL:
93 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF: 93 case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
94 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);
95 95
96 default: 96 default:
@@ -110,8 +110,8 @@ static struct
110} name_map[] = { 110} name_map[] = {
111 { "RECLAIM_ATTRIBUTE", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE }, 111 { "RECLAIM_ATTRIBUTE", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE },
112 { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF }, 112 { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF },
113 { "RECLAIM_ATTESTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION }, 113 { "RECLAIM_CREDENTIAL", GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL },
114 { "RECLAIM_ATTESTATION_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF }, 114 { "RECLAIM_PRESENTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION },
115 { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER }, 115 { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER },
116 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, 116 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT },
117 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, 117 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT },
diff --git a/src/reclaim/plugin_reclaim_attestation_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c
index c87d3e61a..148865223 100644
--- a/src/reclaim/plugin_reclaim_attestation_jwt.c
+++ b/src/reclaim/plugin_reclaim_credential_jwt.c
@@ -19,10 +19,9 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file reclaim-attribute/plugin_reclaim_attestation_gnuid.c 22 * @file reclaim/plugin_reclaim_credential_jwt.c
23 * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for 23 * @brief reclaim-credential-plugin-jwt attribute plugin to provide the API for
24 * fundamental 24 * JWT credentials.
25 * attribute types.
26 * 25 *
27 * @author Martin Schanzenbach 26 * @author Martin Schanzenbach
28 */ 27 */
@@ -33,10 +32,10 @@
33#include <jansson.h> 32#include <jansson.h>
34 33
35/** 34/**
36 * Convert the 'value' of an attestation to a string. 35 * Convert the 'value' of an credential to a string.
37 * 36 *
38 * @param cls closure, unused 37 * @param cls closure, unused
39 * @param type type of the attestation 38 * @param type type of the credential
40 * @param data value in binary encoding 39 * @param data value in binary encoding
41 * @param data_size number of bytes in @a data 40 * @param data_size number of bytes in @a data
42 * @return NULL on error, otherwise human-readable representation of the value 41 * @return NULL on error, otherwise human-readable representation of the value
@@ -49,7 +48,7 @@ jwt_value_to_string (void *cls,
49{ 48{
50 switch (type) 49 switch (type)
51 { 50 {
52 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT: 51 case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT:
53 return GNUNET_strndup (data, data_size); 52 return GNUNET_strndup (data, data_size);
54 53
55 default: 54 default:
@@ -59,11 +58,11 @@ jwt_value_to_string (void *cls,
59 58
60 59
61/** 60/**
62 * Convert human-readable version of a 'value' of an attestation to the binary 61 * Convert human-readable version of a 'value' of an credential to the binary
63 * representation. 62 * representation.
64 * 63 *
65 * @param cls closure, unused 64 * @param cls closure, unused
66 * @param type type of the attestation 65 * @param type type of the credential
67 * @param s human-readable string 66 * @param s human-readable string
68 * @param data set to value in binary encoding (will be allocated) 67 * @param data set to value in binary encoding (will be allocated)
69 * @param data_size set to number of bytes in @a data 68 * @param data_size set to number of bytes in @a data
@@ -80,7 +79,7 @@ jwt_string_to_value (void *cls,
80 return GNUNET_SYSERR; 79 return GNUNET_SYSERR;
81 switch (type) 80 switch (type)
82 { 81 {
83 case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT: 82 case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT:
84 *data = GNUNET_strdup (s); 83 *data = GNUNET_strdup (s);
85 *data_size = strlen (s); 84 *data_size = strlen (s);
86 return GNUNET_OK; 85 return GNUNET_OK;
@@ -92,15 +91,15 @@ jwt_string_to_value (void *cls,
92 91
93 92
94/** 93/**
95 * Mapping of attestation type numbers to human-readable 94 * Mapping of credential type numbers to human-readable
96 * attestation type names. 95 * credential type names.
97 */ 96 */
98static struct 97static struct
99{ 98{
100 const char *name; 99 const char *name;
101 uint32_t number; 100 uint32_t number;
102} jwt_attest_name_map[] = { { "JWT", GNUNET_RECLAIM_ATTESTATION_TYPE_JWT }, 101} jwt_cred_name_map[] = { { "JWT", GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT },
103 { NULL, UINT32_MAX } }; 102 { NULL, UINT32_MAX } };
104 103
105/** 104/**
106 * Convert a type name to the corresponding number. 105 * Convert a type name to the corresponding number.
@@ -115,10 +114,10 @@ jwt_typename_to_number (void *cls, const char *jwt_typename)
115 unsigned int i; 114 unsigned int i;
116 115
117 i = 0; 116 i = 0;
118 while ((NULL != jwt_attest_name_map[i].name) && 117 while ((NULL != jwt_cred_name_map[i].name) &&
119 (0 != strcasecmp (jwt_typename, jwt_attest_name_map[i].name))) 118 (0 != strcasecmp (jwt_typename, jwt_cred_name_map[i].name)))
120 i++; 119 i++;
121 return jwt_attest_name_map[i].number; 120 return jwt_cred_name_map[i].number;
122} 121}
123 122
124 123
@@ -135,11 +134,11 @@ jwt_number_to_typename (void *cls, uint32_t type)
135 unsigned int i; 134 unsigned int i;
136 135
137 i = 0; 136 i = 0;
138 while ((NULL != jwt_attest_name_map[i].name) && (type != 137 while ((NULL != jwt_cred_name_map[i].name) && (type !=
139 jwt_attest_name_map[i]. 138 jwt_cred_name_map[i].
140 number)) 139 number))
141 i++; 140 i++;
142 return jwt_attest_name_map[i].name; 141 return jwt_cred_name_map[i].name;
143} 142}
144 143
145 144
@@ -147,12 +146,12 @@ jwt_number_to_typename (void *cls, uint32_t type)
147 * Parse a JWT and return the respective claim value as Attribute 146 * Parse a JWT and return the respective claim value as Attribute
148 * 147 *
149 * @param cls the plugin 148 * @param cls the plugin
150 * @param attest the jwt attestation 149 * @param cred the jwt credential
151 * @return a GNUNET_RECLAIM_Attribute, containing the new value 150 * @return a GNUNET_RECLAIM_Attribute, containing the new value
152 */ 151 */
153struct GNUNET_RECLAIM_AttributeList * 152struct GNUNET_RECLAIM_AttributeList *
154jwt_parse_attributes (void *cls, 153jwt_parse_attributes (void *cls,
155 const struct GNUNET_RECLAIM_Attestation *attest) 154 const char *data)
156{ 155{
157 char *jwt_string; 156 char *jwt_string;
158 struct GNUNET_RECLAIM_AttributeList *attrs; 157 struct GNUNET_RECLAIM_AttributeList *attrs;
@@ -163,17 +162,14 @@ jwt_parse_attributes (void *cls,
163 json_t *json_val; 162 json_t *json_val;
164 json_error_t *json_err = NULL; 163 json_error_t *json_err = NULL;
165 164
166 /* GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n", attest->data); (not OK: 'data' is not defined as 0-terminated text, but binary) */
167 if (GNUNET_RECLAIM_ATTESTATION_TYPE_JWT != attest->type)
168 return NULL;
169 attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 165 attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
170 166
171 jwt_string = GNUNET_strdup (attest->data); 167 jwt_string = GNUNET_strdup (data);
172 const char *jwt_body = strtok (jwt_string, delim); 168 const char *jwt_body = strtok (jwt_string, delim);
173 jwt_body = strtok (NULL, delim); 169 jwt_body = strtok (NULL, delim);
174 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 170 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
175 (void **) &decoded_jwt); 171 (void **) &decoded_jwt);
176 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", decoded_jwt); 172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt);
177 GNUNET_assert (NULL != decoded_jwt); 173 GNUNET_assert (NULL != decoded_jwt);
178 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 174 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
179 const char *key; 175 const char *key;
@@ -204,15 +200,45 @@ jwt_parse_attributes (void *cls,
204 200
205 201
206/** 202/**
203 * Parse a JWT and return the respective claim value as Attribute
204 *
205 * @param cls the plugin
206 * @param cred the jwt credential
207 * @return a GNUNET_RECLAIM_Attribute, containing the new value
208 */
209struct GNUNET_RECLAIM_AttributeList *
210jwt_parse_attributes_c (void *cls,
211 const struct GNUNET_RECLAIM_Credential *cred)
212{
213 return jwt_parse_attributes (cls, cred->data);
214}
215
216
217/**
218 * Parse a JWT and return the respective claim value as Attribute
219 *
220 * @param cls the plugin
221 * @param cred the jwt credential
222 * @return a GNUNET_RECLAIM_Attribute, containing the new value
223 */
224struct GNUNET_RECLAIM_AttributeList *
225jwt_parse_attributes_p (void *cls,
226 const struct GNUNET_RECLAIM_Presentation *cred)
227{
228 return jwt_parse_attributes (cls, cred->data);
229}
230
231
232/**
207 * Parse a JWT and return the issuer 233 * Parse a JWT and return the issuer
208 * 234 *
209 * @param cls the plugin 235 * @param cls the plugin
210 * @param attest the jwt attestation 236 * @param cred the jwt credential
211 * @return a string, containing the isser 237 * @return a string, containing the isser
212 */ 238 */
213char * 239char *
214jwt_get_issuer (void *cls, 240jwt_get_issuer (void *cls,
215 const struct GNUNET_RECLAIM_Attestation *attest) 241 const char *data)
216{ 242{
217 const char *jwt_body; 243 const char *jwt_body;
218 char *jwt_string; 244 char *jwt_string;
@@ -224,9 +250,7 @@ jwt_get_issuer (void *cls,
224 json_t *json_val; 250 json_t *json_val;
225 json_error_t *json_err = NULL; 251 json_error_t *json_err = NULL;
226 252
227 if (GNUNET_RECLAIM_ATTESTATION_TYPE_JWT != attest->type) 253 jwt_string = GNUNET_strdup (data);
228 return NULL;
229 jwt_string = GNUNET_strdup (attest->data);
230 jwt_body = strtok (jwt_string, delim); 254 jwt_body = strtok (jwt_string, delim);
231 jwt_body = strtok (NULL, delim); 255 jwt_body = strtok (NULL, delim);
232 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 256 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
@@ -242,15 +266,49 @@ jwt_get_issuer (void *cls,
242 266
243 267
244/** 268/**
269 * Parse a JWT and return the issuer
270 *
271 * @param cls the plugin
272 * @param cred the jwt credential
273 * @return a string, containing the isser
274 */
275char *
276jwt_get_issuer_c (void *cls,
277 const struct GNUNET_RECLAIM_Credential *cred)
278{
279 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type)
280 return NULL;
281 return jwt_get_issuer (cls, cred->data);
282}
283
284
285/**
286 * Parse a JWT and return the issuer
287 *
288 * @param cls the plugin
289 * @param cred the jwt credential
290 * @return a string, containing the isser
291 */
292char *
293jwt_get_issuer_p (void *cls,
294 const struct GNUNET_RECLAIM_Presentation *cred)
295{
296 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type)
297 return NULL;
298 return jwt_get_issuer (cls, cred->data);
299}
300
301
302/**
245 * Parse a JWT and return the expiration 303 * Parse a JWT and return the expiration
246 * 304 *
247 * @param cls the plugin 305 * @param cls the plugin
248 * @param attest the jwt attestation 306 * @param cred the jwt credential
249 * @return a string, containing the isser 307 * @return a string, containing the isser
250 */ 308 */
251int 309int
252jwt_get_expiration (void *cls, 310jwt_get_expiration (void *cls,
253 const struct GNUNET_RECLAIM_Attestation *attest, 311 const char *data,
254 struct GNUNET_TIME_Absolute *exp) 312 struct GNUNET_TIME_Absolute *exp)
255{ 313{
256 const char *jwt_body; 314 const char *jwt_body;
@@ -262,9 +320,7 @@ jwt_get_expiration (void *cls,
262 json_t *json_val; 320 json_t *json_val;
263 json_error_t *json_err = NULL; 321 json_error_t *json_err = NULL;
264 322
265 if (GNUNET_RECLAIM_ATTESTATION_TYPE_JWT != attest->type) 323 jwt_string = GNUNET_strdup (data);
266 return GNUNET_NO;
267 jwt_string = GNUNET_strdup (attest->data);
268 jwt_body = strtok (jwt_string, delim); 324 jwt_body = strtok (jwt_string, delim);
269 jwt_body = strtok (NULL, delim); 325 jwt_body = strtok (NULL, delim);
270 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 326 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
@@ -280,24 +336,80 @@ jwt_get_expiration (void *cls,
280 336
281 337
282/** 338/**
339 * Parse a JWT and return the expiration
340 *
341 * @param cls the plugin
342 * @param cred the jwt credential
343 * @return a string, containing the isser
344 */
345int
346jwt_get_expiration_c (void *cls,
347 const struct GNUNET_RECLAIM_Credential *cred,
348 struct GNUNET_TIME_Absolute *exp)
349{
350 return jwt_get_expiration (cls, cred->data, exp);
351}
352
353
354/**
355 * Parse a JWT and return the expiration
356 *
357 * @param cls the plugin
358 * @param cred the jwt credential
359 * @return a string, containing the isser
360 */
361int
362jwt_get_expiration_p (void *cls,
363 const struct GNUNET_RECLAIM_Presentation *cred,
364 struct GNUNET_TIME_Absolute *exp)
365{
366 return jwt_get_expiration (cls, cred->data, exp);
367}
368
369
370int
371jwt_create_presentation (void *cls,
372 const struct GNUNET_RECLAIM_Credential *cred,
373 const struct GNUNET_RECLAIM_AttributeList *attrs,
374 struct GNUNET_RECLAIM_Presentation **pres)
375{
376 // FIXME sanity checks??
377 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type)
378 return GNUNET_NO;
379 *pres = GNUNET_RECLAIM_presentation_new (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT,
380 cred->data,
381 cred->data_size);
382 return GNUNET_OK;
383}
384
385
386/**
283 * Entry point for the plugin. 387 * Entry point for the plugin.
284 * 388 *
285 * @param cls NULL 389 * @param cls NULL
286 * @return the exported block API 390 * @return the exported block API
287 */ 391 */
288void * 392void *
289libgnunet_plugin_reclaim_attestation_jwt_init (void *cls) 393libgnunet_plugin_reclaim_credential_jwt_init (void *cls)
290{ 394{
291 struct GNUNET_RECLAIM_AttestationPluginFunctions *api; 395 struct GNUNET_RECLAIM_CredentialPluginFunctions *api;
292 396
293 api = GNUNET_new (struct GNUNET_RECLAIM_AttestationPluginFunctions); 397 api = GNUNET_new (struct GNUNET_RECLAIM_CredentialPluginFunctions);
294 api->value_to_string = &jwt_value_to_string; 398 api->value_to_string = &jwt_value_to_string;
295 api->string_to_value = &jwt_string_to_value; 399 api->string_to_value = &jwt_string_to_value;
296 api->typename_to_number = &jwt_typename_to_number; 400 api->typename_to_number = &jwt_typename_to_number;
297 api->number_to_typename = &jwt_number_to_typename; 401 api->number_to_typename = &jwt_number_to_typename;
298 api->get_attributes = &jwt_parse_attributes; 402 api->get_attributes = &jwt_parse_attributes_c;
299 api->get_issuer = &jwt_get_issuer; 403 api->get_issuer = &jwt_get_issuer_c;
300 api->get_expiration = &jwt_get_expiration; 404 api->get_expiration = &jwt_get_expiration_c;
405 api->value_to_string_p = &jwt_value_to_string;
406 api->string_to_value_p = &jwt_string_to_value;
407 api->typename_to_number_p = &jwt_typename_to_number;
408 api->number_to_typename_p = &jwt_number_to_typename;
409 api->get_attributes_p = &jwt_parse_attributes_p;
410 api->get_issuer_p = &jwt_get_issuer_p;
411 api->get_expiration_p = &jwt_get_expiration_p;
412 api->create_presentation = &jwt_create_presentation;
301 return api; 413 return api;
302} 414}
303 415
@@ -309,13 +421,13 @@ libgnunet_plugin_reclaim_attestation_jwt_init (void *cls)
309 * @return NULL 421 * @return NULL
310 */ 422 */
311void * 423void *
312libgnunet_plugin_reclaim_attestation_jwt_done (void *cls) 424libgnunet_plugin_reclaim_credential_jwt_done (void *cls)
313{ 425{
314 struct GNUNET_RECLAIM_AttestationPluginFunctions *api = cls; 426 struct GNUNET_RECLAIM_CredentialPluginFunctions *api = cls;
315 427
316 GNUNET_free (api); 428 GNUNET_free (api);
317 return NULL; 429 return NULL;
318} 430}
319 431
320 432
321/* end of plugin_reclaim_attestation_type_gnuid.c */ 433/* end of plugin_reclaim_credential_type_jwt.c */
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 2f44917c9..5b0bb2b6f 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -439,10 +439,14 @@ struct RequestHandle
439 struct GNUNET_RECLAIM_AttributeList *attr_userinfo_list; 439 struct GNUNET_RECLAIM_AttributeList *attr_userinfo_list;
440 440
441 /** 441 /**
442 * Attestation list 442 * Credentials
443 */ 443 */
444 struct GNUNET_RECLAIM_AttestationList *attests_list; 444 struct GNUNET_RECLAIM_CredentialList *credentials;
445 445
446 /**
447 * Presentations
448 */
449 struct GNUNET_RECLAIM_PresentationList *presentations;
446 450
447 /** 451 /**
448 * IDENTITY Operation 452 * IDENTITY Operation
@@ -461,9 +465,9 @@ struct RequestHandle
461 struct GNUNET_RECLAIM_AttributeIterator *attr_it; 465 struct GNUNET_RECLAIM_AttributeIterator *attr_it;
462 466
463 /** 467 /**
464 * Attestation iterator 468 * Credential iterator
465 */ 469 */
466 struct GNUNET_RECLAIM_AttestationIterator *attest_it; 470 struct GNUNET_RECLAIM_CredentialIterator *cred_it;
467 471
468 472
469 /** 473 /**
@@ -561,8 +565,8 @@ cleanup_handle (struct RequestHandle *handle)
561 GNUNET_SCHEDULER_cancel (handle->timeout_task); 565 GNUNET_SCHEDULER_cancel (handle->timeout_task);
562 if (NULL != handle->attr_it) 566 if (NULL != handle->attr_it)
563 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); 567 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
564 if (NULL != handle->attest_it) 568 if (NULL != handle->cred_it)
565 GNUNET_RECLAIM_get_attestations_stop (handle->attest_it); 569 GNUNET_RECLAIM_get_credentials_stop (handle->cred_it);
566 if (NULL != handle->ticket_it) 570 if (NULL != handle->ticket_it)
567 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); 571 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
568 if (NULL != handle->idp_op) 572 if (NULL != handle->idp_op)
@@ -590,8 +594,10 @@ cleanup_handle (struct RequestHandle *handle)
590 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_idtoken_list); 594 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_idtoken_list);
591 if (NULL!=handle->attr_userinfo_list) 595 if (NULL!=handle->attr_userinfo_list)
592 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list); 596 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list);
593 if (NULL!=handle->attests_list) 597 if (NULL!=handle->credentials)
594 GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list); 598 GNUNET_RECLAIM_credential_list_destroy (handle->credentials);
599 if (NULL!=handle->presentations)
600 GNUNET_RECLAIM_presentation_list_destroy (handle->presentations);
595 GNUNET_CONTAINER_DLL_remove (requests_head, 601 GNUNET_CONTAINER_DLL_remove (requests_head,
596 requests_tail, 602 requests_tail,
597 handle); 603 handle);
@@ -934,7 +940,9 @@ oidc_iteration_error (void *cls)
934 * parameter. Otherwise redirects with error 940 * parameter. Otherwise redirects with error
935 */ 941 */
936static void 942static void
937oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 943oidc_ticket_issue_cb (void *cls,
944 const struct GNUNET_RECLAIM_Ticket *ticket,
945 const struct GNUNET_RECLAIM_PresentationList *pres)
938{ 946{
939 struct RequestHandle *handle = cls; 947 struct RequestHandle *handle = cls;
940 struct MHD_Response *resp; 948 struct MHD_Response *resp;
@@ -957,7 +965,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
957 code_string = OIDC_build_authz_code (&handle->priv_key, 965 code_string = OIDC_build_authz_code (&handle->priv_key,
958 &handle->ticket, 966 &handle->ticket,
959 handle->attr_idtoken_list, 967 handle->attr_idtoken_list,
960 handle->attests_list, 968 pres,
961 handle->oidc->nonce, 969 handle->oidc->nonce,
962 handle->oidc->code_challenge); 970 handle->oidc->code_challenge);
963 if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) && 971 if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) &&
@@ -1010,13 +1018,13 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a,
1010 le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 1018 le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1011 le_m->attribute = GNUNET_RECLAIM_attribute_new (le_a->attribute->name, 1019 le_m->attribute = GNUNET_RECLAIM_attribute_new (le_a->attribute->name,
1012 &le_a->attribute-> 1020 &le_a->attribute->
1013 attestation, 1021 credential,
1014 le_a->attribute->type, 1022 le_a->attribute->type,
1015 le_a->attribute->data, 1023 le_a->attribute->data,
1016 le_a->attribute->data_size); 1024 le_a->attribute->data_size);
1017 le_m->attribute->id = le_a->attribute->id; 1025 le_m->attribute->id = le_a->attribute->id;
1018 le_m->attribute->flag = le_a->attribute->flag; 1026 le_m->attribute->flag = le_a->attribute->flag;
1019 le_m->attribute->attestation = le_a->attribute->attestation; 1027 le_m->attribute->credential = le_a->attribute->credential;
1020 GNUNET_CONTAINER_DLL_insert (merged_list->list_head, 1028 GNUNET_CONTAINER_DLL_insert (merged_list->list_head,
1021 merged_list->list_tail, 1029 merged_list->list_tail,
1022 le_m); 1030 le_m);
@@ -1035,13 +1043,13 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a,
1035 le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 1043 le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1036 le_m->attribute = GNUNET_RECLAIM_attribute_new (le_b->attribute->name, 1044 le_m->attribute = GNUNET_RECLAIM_attribute_new (le_b->attribute->name,
1037 &le_b->attribute-> 1045 &le_b->attribute->
1038 attestation, 1046 credential,
1039 le_b->attribute->type, 1047 le_b->attribute->type,
1040 le_b->attribute->data, 1048 le_b->attribute->data,
1041 le_b->attribute->data_size); 1049 le_b->attribute->data_size);
1042 le_m->attribute->id = le_b->attribute->id; 1050 le_m->attribute->id = le_b->attribute->id;
1043 le_m->attribute->flag = le_b->attribute->flag; 1051 le_m->attribute->flag = le_b->attribute->flag;
1044 le_m->attribute->attestation = le_b->attribute->attestation; 1052 le_m->attribute->credential = le_b->attribute->credential;
1045 GNUNET_CONTAINER_DLL_insert (merged_list->list_head, 1053 GNUNET_CONTAINER_DLL_insert (merged_list->list_head,
1046 merged_list->list_tail, 1054 merged_list->list_tail,
1047 le_m); 1055 le_m);
@@ -1051,13 +1059,13 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a,
1051 1059
1052 1060
1053static void 1061static void
1054oidc_attest_collect_finished_cb (void *cls) 1062oidc_cred_collect_finished_cb (void *cls)
1055{ 1063{
1056 struct RequestHandle *handle = cls; 1064 struct RequestHandle *handle = cls;
1057 struct GNUNET_RECLAIM_AttributeList *merged_list; 1065 struct GNUNET_RECLAIM_AttributeList *merged_list;
1058 struct GNUNET_RECLAIM_AttributeListEntry *le_m; 1066 struct GNUNET_RECLAIM_AttributeListEntry *le_m;
1059 1067
1060 handle->attest_it = NULL; 1068 handle->cred_it = NULL;
1061 merged_list = attribute_list_merge (handle->attr_idtoken_list, 1069 merged_list = attribute_list_merge (handle->attr_idtoken_list,
1062 handle->attr_userinfo_list); 1070 handle->attr_userinfo_list);
1063 for (le_m = merged_list->list_head; NULL != le_m; le_m = le_m->next) 1071 for (le_m = merged_list->list_head; NULL != le_m; le_m = le_m->next)
@@ -1078,40 +1086,40 @@ oidc_attest_collect_finished_cb (void *cls)
1078 * Collects all attributes for an ego if in scope parameter 1086 * Collects all attributes for an ego if in scope parameter
1079 */ 1087 */
1080static void 1088static void
1081oidc_attest_collect (void *cls, 1089oidc_cred_collect (void *cls,
1082 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1090 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1083 const struct GNUNET_RECLAIM_Attestation *attest) 1091 const struct GNUNET_RECLAIM_Credential *cred)
1084{ 1092{
1085 struct RequestHandle *handle = cls; 1093 struct RequestHandle *handle = cls;
1086 struct GNUNET_RECLAIM_AttributeListEntry *le; 1094 struct GNUNET_RECLAIM_AttributeListEntry *le;
1087 struct GNUNET_RECLAIM_AttestationListEntry *ale; 1095 struct GNUNET_RECLAIM_CredentialListEntry *ale;
1088 1096
1089 for (ale = handle->attests_list->list_head; NULL != ale; ale = ale->next) 1097 for (ale = handle->credentials->list_head; NULL != ale; ale = ale->next)
1090 { 1098 {
1091 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&ale->attestation->id, 1099 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&ale->credential->id,
1092 &attest->id)) 1100 &cred->id))
1093 continue; 1101 continue;
1094 /** Attestation already in list **/ 1102 /** Credential already in list **/
1095 GNUNET_RECLAIM_get_attestations_next (handle->attest_it); 1103 GNUNET_RECLAIM_get_credentials_next (handle->cred_it);
1096 return; 1104 return;
1097 } 1105 }
1098 1106
1099 for (le = handle->attr_idtoken_list->list_head; NULL != le; le = le->next) 1107 for (le = handle->attr_idtoken_list->list_head; NULL != le; le = le->next)
1100 { 1108 {
1101 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation, 1109 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->credential,
1102 &attest->id)) 1110 &cred->id))
1103 continue; 1111 continue;
1104 /** Attestation matches for attribute, add **/ 1112 /** Credential matches for attribute, add **/
1105 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); 1113 ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry);
1106 ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name, 1114 ale->credential = GNUNET_RECLAIM_credential_new (cred->name,
1107 attest->type, 1115 cred->type,
1108 attest->data, 1116 cred->data,
1109 attest->data_size); 1117 cred->data_size);
1110 GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, 1118 GNUNET_CONTAINER_DLL_insert (handle->credentials->list_head,
1111 handle->attests_list->list_tail, 1119 handle->credentials->list_tail,
1112 ale); 1120 ale);
1113 } 1121 }
1114 GNUNET_RECLAIM_get_attestations_next (handle->attest_it); 1122 GNUNET_RECLAIM_get_credentials_next (handle->cred_it);
1115} 1123}
1116 1124
1117 1125
@@ -1129,16 +1137,16 @@ oidc_attr_collect_finished_cb (void *cls)
1129 GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); 1137 GNUNET_SCHEDULER_add_now (&do_redirect_error, handle);
1130 return; 1138 return;
1131 } 1139 }
1132 handle->attests_list = GNUNET_new (struct GNUNET_RECLAIM_AttestationList); 1140 handle->credentials = GNUNET_new (struct GNUNET_RECLAIM_CredentialList);
1133 handle->attest_it = 1141 handle->cred_it =
1134 GNUNET_RECLAIM_get_attestations_start (idp, 1142 GNUNET_RECLAIM_get_credentials_start (idp,
1135 &handle->priv_key, 1143 &handle->priv_key,
1136 &oidc_iteration_error, 1144 &oidc_iteration_error,
1137 handle, 1145 handle,
1138 &oidc_attest_collect, 1146 &oidc_cred_collect,
1139 handle, 1147 handle,
1140 &oidc_attest_collect_finished_cb, 1148 &oidc_cred_collect_finished_cb,
1141 handle); 1149 handle);
1142 1150
1143} 1151}
1144 1152
@@ -1212,13 +1220,13 @@ oidc_attr_collect (void *cls,
1212 { 1220 {
1213 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 1221 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1214 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, 1222 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
1215 &attr->attestation, 1223 &attr->credential,
1216 attr->type, 1224 attr->type,
1217 attr->data, 1225 attr->data,
1218 attr->data_size); 1226 attr->data_size);
1219 le->attribute->id = attr->id; 1227 le->attribute->id = attr->id;
1220 le->attribute->flag = attr->flag; 1228 le->attribute->flag = attr->flag;
1221 le->attribute->attestation = attr->attestation; 1229 le->attribute->credential = attr->credential;
1222 GNUNET_CONTAINER_DLL_insert (handle->attr_idtoken_list->list_head, 1230 GNUNET_CONTAINER_DLL_insert (handle->attr_idtoken_list->list_head,
1223 handle->attr_idtoken_list->list_tail, 1231 handle->attr_idtoken_list->list_tail,
1224 le); 1232 le);
@@ -1227,13 +1235,13 @@ oidc_attr_collect (void *cls,
1227 { 1235 {
1228 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 1236 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1229 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, 1237 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
1230 &attr->attestation, 1238 &attr->credential,
1231 attr->type, 1239 attr->type,
1232 attr->data, 1240 attr->data,
1233 attr->data_size); 1241 attr->data_size);
1234 le->attribute->id = attr->id; 1242 le->attribute->id = attr->id;
1235 le->attribute->flag = attr->flag; 1243 le->attribute->flag = attr->flag;
1236 le->attribute->attestation = attr->attestation; 1244 le->attribute->credential = attr->credential;
1237 GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, 1245 GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head,
1238 handle->attr_userinfo_list->list_tail, 1246 handle->attr_userinfo_list->list_tail,
1239 le); 1247 le);
@@ -1982,7 +1990,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1982 const struct EgoEntry *ego_entry; 1990 const struct EgoEntry *ego_entry;
1983 struct GNUNET_TIME_Relative expiration_time; 1991 struct GNUNET_TIME_Relative expiration_time;
1984 struct GNUNET_RECLAIM_AttributeList *cl = NULL; 1992 struct GNUNET_RECLAIM_AttributeList *cl = NULL;
1985 struct GNUNET_RECLAIM_AttestationList *al = NULL; 1993 struct GNUNET_RECLAIM_PresentationList *pl = NULL;
1986 struct GNUNET_RECLAIM_Ticket ticket; 1994 struct GNUNET_RECLAIM_Ticket ticket;
1987 struct GNUNET_CRYPTO_EcdsaPublicKey cid; 1995 struct GNUNET_CRYPTO_EcdsaPublicKey cid;
1988 struct GNUNET_HashCode cache_key; 1996 struct GNUNET_HashCode cache_key;
@@ -2068,7 +2076,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2068 2076
2069 // decode code 2077 // decode code
2070 if (GNUNET_OK != OIDC_parse_authz_code (&cid, code, code_verifier, &ticket, 2078 if (GNUNET_OK != OIDC_parse_authz_code (&cid, code, code_verifier, &ticket,
2071 &cl, &al, &nonce)) 2079 &cl, &pl, &nonce))
2072 { 2080 {
2073 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST); 2081 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST);
2074 handle->edesc = GNUNET_strdup ("invalid code"); 2082 handle->edesc = GNUNET_strdup ("invalid code");
@@ -2108,7 +2116,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2108 id_token = OIDC_generate_id_token (&ticket.audience, 2116 id_token = OIDC_generate_id_token (&ticket.audience,
2109 &ticket.identity, 2117 &ticket.identity,
2110 cl, 2118 cl,
2111 al, 2119 pl,
2112 &expiration_time, 2120 &expiration_time,
2113 (NULL != nonce) ? nonce : NULL, 2121 (NULL != nonce) ? nonce : NULL,
2114 jwt_secret); 2122 jwt_secret);
@@ -2124,7 +2132,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2124 MHD_add_response_header (resp, "Content-Type", "application/json"); 2132 MHD_add_response_header (resp, "Content-Type", "application/json");
2125 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2133 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
2126 GNUNET_RECLAIM_attribute_list_destroy (cl); 2134 GNUNET_RECLAIM_attribute_list_destroy (cl);
2127 GNUNET_RECLAIM_attestation_list_destroy (al); 2135 GNUNET_RECLAIM_presentation_list_destroy (pl);
2128 GNUNET_free (access_token); 2136 GNUNET_free (access_token);
2129 GNUNET_free (json_response); 2137 GNUNET_free (json_response);
2130 GNUNET_free (id_token); 2138 GNUNET_free (id_token);
@@ -2139,11 +2147,11 @@ static void
2139consume_ticket (void *cls, 2147consume_ticket (void *cls,
2140 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 2148 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
2141 const struct GNUNET_RECLAIM_Attribute *attr, 2149 const struct GNUNET_RECLAIM_Attribute *attr,
2142 const struct GNUNET_RECLAIM_Attestation *attest) 2150 const struct GNUNET_RECLAIM_Presentation *pres)
2143{ 2151{
2144 struct RequestHandle *handle = cls; 2152 struct RequestHandle *handle = cls;
2145 struct GNUNET_RECLAIM_AttributeListEntry *ale; 2153 struct GNUNET_RECLAIM_AttributeListEntry *ale;
2146 struct GNUNET_RECLAIM_AttestationListEntry *atle; 2154 struct GNUNET_RECLAIM_PresentationListEntry *atle;
2147 struct MHD_Response *resp; 2155 struct MHD_Response *resp;
2148 char *result_str; 2156 char *result_str;
2149 handle->idp_op = NULL; 2157 handle->idp_op = NULL;
@@ -2152,7 +2160,7 @@ consume_ticket (void *cls,
2152 { 2160 {
2153 result_str = OIDC_generate_userinfo (&handle->ticket.identity, 2161 result_str = OIDC_generate_userinfo (&handle->ticket.identity,
2154 handle->attr_userinfo_list, 2162 handle->attr_userinfo_list,
2155 handle->attests_list); 2163 handle->presentations);
2156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Userinfo: %s\n", result_str); 2164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Userinfo: %s\n", result_str);
2157 resp = GNUNET_REST_create_response (result_str); 2165 resp = GNUNET_REST_create_response (result_str);
2158 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2166 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
@@ -2162,35 +2170,35 @@ consume_ticket (void *cls,
2162 } 2170 }
2163 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 2171 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
2164 ale->attribute = GNUNET_RECLAIM_attribute_new (attr->name, 2172 ale->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
2165 &attr->attestation, 2173 &attr->credential,
2166 attr->type, 2174 attr->type,
2167 attr->data, 2175 attr->data,
2168 attr->data_size); 2176 attr->data_size);
2169 ale->attribute->id = attr->id; 2177 ale->attribute->id = attr->id;
2170 ale->attribute->flag = attr->flag; 2178 ale->attribute->flag = attr->flag;
2171 ale->attribute->attestation = attr->attestation; 2179 ale->attribute->credential = attr->credential;
2172 GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, 2180 GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head,
2173 handle->attr_userinfo_list->list_tail, 2181 handle->attr_userinfo_list->list_tail,
2174 ale); 2182 ale);
2175 if (NULL == attest) 2183 if (NULL == pres)
2176 return; 2184 return;
2177 for (atle = handle->attests_list->list_head; NULL != atle; atle = atle->next) 2185 for (atle = handle->presentations->list_head;
2186 NULL != atle; atle = atle->next)
2178 { 2187 {
2179 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&atle->attestation->id, 2188 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&atle->presentation->credential_id,
2180 &attest->id)) 2189 &pres->credential_id))
2181 continue; 2190 continue;
2182 break; /** already in list **/ 2191 break; /** already in list **/
2183 } 2192 }
2184 if (NULL == atle) 2193 if (NULL == atle)
2185 { 2194 {
2186 /** Attestation matches for attribute, add **/ 2195 /** Credential matches for attribute, add **/
2187 atle = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); 2196 atle = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
2188 atle->attestation = GNUNET_RECLAIM_attestation_new (attest->name, 2197 atle->presentation = GNUNET_RECLAIM_presentation_new (pres->type,
2189 attest->type, 2198 pres->data,
2190 attest->data, 2199 pres->data_size);
2191 attest->data_size); 2200 GNUNET_CONTAINER_DLL_insert (handle->presentations->list_head,
2192 GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, 2201 handle->presentations->list_tail,
2193 handle->attests_list->list_tail,
2194 atle); 2202 atle);
2195 } 2203 }
2196} 2204}
@@ -2289,8 +2297,8 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2289 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); 2297 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego);
2290 handle->attr_userinfo_list = 2298 handle->attr_userinfo_list =
2291 GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 2299 GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
2292 handle->attests_list = 2300 handle->presentations =
2293 GNUNET_new (struct GNUNET_RECLAIM_AttestationList); 2301 GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
2294 2302
2295 handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, 2303 handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp,
2296 privkey, 2304 privkey,
@@ -2611,6 +2619,7 @@ libgnunet_plugin_rest_openid_connect_init (void *cls)
2611 return api; 2619 return api;
2612} 2620}
2613 2621
2622
2614static int 2623static int
2615cleanup_hashmap (void *cls, const struct GNUNET_HashCode *key, void *value) 2624cleanup_hashmap (void *cls, const struct GNUNET_HashCode *key, void *value)
2616{ 2625{
@@ -2618,6 +2627,7 @@ cleanup_hashmap (void *cls, const struct GNUNET_HashCode *key, void *value)
2618 return GNUNET_YES; 2627 return GNUNET_YES;
2619} 2628}
2620 2629
2630
2621/** 2631/**
2622 * Exit point from the plugin. 2632 * Exit point from the plugin.
2623 * 2633 *
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 870baa7f3..ff11d2a56 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 * Credential namespace
52 */ 52 */
53#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION "/reclaim/attestation" 53#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL "/reclaim/credential"
54 54
55/** 55/**
56 * Ticket namespace 56 * Ticket namespace
@@ -202,7 +202,7 @@ struct RequestHandle
202 /** 202 /**
203 * Attribute iterator 203 * Attribute iterator
204 */ 204 */
205 struct GNUNET_RECLAIM_AttestationIterator *attest_it; 205 struct GNUNET_RECLAIM_CredentialIterator *cred_it;
206 206
207 /** 207 /**
208 * Ticket iterator 208 * Ticket iterator
@@ -282,8 +282,8 @@ cleanup_handle (void *cls)
282 GNUNET_SCHEDULER_cancel (handle->timeout_task); 282 GNUNET_SCHEDULER_cancel (handle->timeout_task);
283 if (NULL != handle->attr_it) 283 if (NULL != handle->attr_it)
284 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); 284 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
285 if (NULL != handle->attest_it) 285 if (NULL != handle->cred_it)
286 GNUNET_RECLAIM_get_attestations_stop (handle->attest_it); 286 GNUNET_RECLAIM_get_credentials_stop (handle->cred_it);
287 if (NULL != handle->ticket_it) 287 if (NULL != handle->ticket_it)
288 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); 288 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
289 if (NULL != handle->url) 289 if (NULL != handle->url)
@@ -413,7 +413,7 @@ collect_finished_cb (void *cls)
413 413
414 // Done 414 // Done
415 handle->attr_it = NULL; 415 handle->attr_it = NULL;
416 handle->attest_it = NULL; 416 handle->cred_it = NULL;
417 handle->ticket_it = NULL; 417 handle->ticket_it = NULL;
418 GNUNET_SCHEDULER_add_now (&return_response, handle); 418 GNUNET_SCHEDULER_add_now (&return_response, handle);
419} 419}
@@ -460,7 +460,7 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
460 460
461 461
462static void 462static void
463add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 463add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
464 const char *url, 464 const char *url,
465 void *cls) 465 void *cls)
466{ 466{
@@ -468,19 +468,19 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
468 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; 468 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
469 const char *identity; 469 const char *identity;
470 struct EgoEntry *ego_entry; 470 struct EgoEntry *ego_entry;
471 struct GNUNET_RECLAIM_Attestation *attribute; 471 struct GNUNET_RECLAIM_Credential *attribute;
472 struct GNUNET_TIME_Relative exp; 472 struct GNUNET_TIME_Relative exp;
473 char term_data[handle->rest_handle->data_size + 1]; 473 char term_data[handle->rest_handle->data_size + 1];
474 json_t *data_json; 474 json_t *data_json;
475 json_error_t err; 475 json_error_t err;
476 struct GNUNET_JSON_Specification attrspec[] = 476 struct GNUNET_JSON_Specification attrspec[] =
477 { GNUNET_RECLAIM_JSON_spec_claim_attest (&attribute), 477 { GNUNET_RECLAIM_JSON_spec_credential (&attribute),
478 GNUNET_JSON_spec_end () }; 478 GNUNET_JSON_spec_end () };
479 479
480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
481 "Adding an attestation for %s.\n", 481 "Adding an credential for %s.\n",
482 handle->url); 482 handle->url);
483 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( 483 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
484 handle->url)) 484 handle->url))
485 { 485 {
486 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 486 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -488,7 +488,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
488 return; 488 return;
489 } 489 }
490 identity = handle->url + strlen ( 490 identity = handle->url + strlen (
491 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1; 491 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1;
492 492
493 for (ego_entry = ego_head; NULL != ego_entry; 493 for (ego_entry = ego_head; NULL != ego_entry;
494 ego_entry = ego_entry->next) 494 ego_entry = ego_entry->next)
@@ -518,7 +518,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
518 if (NULL == attribute) 518 if (NULL == attribute)
519 { 519 {
520 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 520 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
521 "Unable to parse attestation from %s\n", 521 "Unable to parse credential from %s\n",
522 term_data); 522 term_data);
523 GNUNET_SCHEDULER_add_now (&do_error, handle); 523 GNUNET_SCHEDULER_add_now (&do_error, handle);
524 return; 524 return;
@@ -529,7 +529,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
529 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) 529 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
530 GNUNET_RECLAIM_id_generate (&attribute->id); 530 GNUNET_RECLAIM_id_generate (&attribute->id);
531 exp = GNUNET_TIME_UNIT_HOURS; 531 exp = GNUNET_TIME_UNIT_HOURS;
532 handle->idp_op = GNUNET_RECLAIM_attestation_store (idp, 532 handle->idp_op = GNUNET_RECLAIM_credential_store (idp,
533 identity_priv, 533 identity_priv,
534 attribute, 534 attribute,
535 &exp, 535 &exp,
@@ -540,52 +540,52 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
540 540
541 541
542/** 542/**
543 * Collect all attestations for an ego 543 * Collect all credentials for an ego
544 * 544 *
545 */ 545 */
546static void 546static void
547attest_collect (void *cls, 547cred_collect (void *cls,
548 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 548 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
549 const struct GNUNET_RECLAIM_Attestation *attest) 549 const struct GNUNET_RECLAIM_Credential *cred)
550{ 550{
551 struct RequestHandle *handle = cls; 551 struct RequestHandle *handle = cls;
552 struct GNUNET_RECLAIM_AttributeList *attrs; 552 struct GNUNET_RECLAIM_AttributeList *attrs;
553 struct GNUNET_RECLAIM_AttributeListEntry *ale; 553 struct GNUNET_RECLAIM_AttributeListEntry *ale;
554 struct GNUNET_TIME_Absolute exp; 554 struct GNUNET_TIME_Absolute exp;
555 json_t *attr_obj; 555 json_t *attr_obj;
556 json_t *attest_obj; 556 json_t *cred_obj;
557 const char *type; 557 const char *type;
558 char *tmp_value; 558 char *tmp_value;
559 char *id_str; 559 char *id_str;
560 char *issuer; 560 char *issuer;
561 561
562 562
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n", 563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n",
564 attest->name); 564 cred->name);
565 attrs = GNUNET_RECLAIM_attestation_get_attributes (attest); 565 attrs = GNUNET_RECLAIM_credential_get_attributes (cred);
566 issuer = GNUNET_RECLAIM_attestation_get_issuer (attest); 566 issuer = GNUNET_RECLAIM_credential_get_issuer (cred);
567 tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type, 567 tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type,
568 attest->data, 568 cred->data,
569 attest->data_size); 569 cred->data_size);
570 attest_obj = json_object (); 570 cred_obj = json_object ();
571 json_object_set_new (attest_obj, "value", json_string (tmp_value)); 571 json_object_set_new (cred_obj, "value", json_string (tmp_value));
572 json_object_set_new (attest_obj, "name", json_string (attest->name)); 572 json_object_set_new (cred_obj, "name", json_string (cred->name));
573 type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type); 573 type = GNUNET_RECLAIM_credential_number_to_typename (cred->type);
574 json_object_set_new (attest_obj, "type", json_string (type)); 574 json_object_set_new (cred_obj, "type", json_string (type));
575 if (NULL != issuer) 575 if (NULL != issuer)
576 { 576 {
577 json_object_set_new (attest_obj, "issuer", json_string (issuer)); 577 json_object_set_new (cred_obj, "issuer", json_string (issuer));
578 GNUNET_free (issuer); 578 GNUNET_free (issuer);
579 } 579 }
580 if (GNUNET_OK == GNUNET_RECLAIM_attestation_get_expiration (attest, 580 if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred,
581 &exp)) 581 &exp))
582 { 582 {
583 json_object_set_new (attest_obj, "expiration", json_integer ( 583 json_object_set_new (cred_obj, "expiration", json_integer (
584 exp.abs_value_us)); 584 exp.abs_value_us));
585 } 585 }
586 id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, 586 id_str = GNUNET_STRINGS_data_to_string_alloc (&cred->id,
587 sizeof(attest->id)); 587 sizeof(cred->id));
588 json_object_set_new (attest_obj, "id", json_string (id_str)); 588 json_object_set_new (cred_obj, "id", json_string (id_str));
589 GNUNET_free (tmp_value); 589 GNUNET_free (tmp_value);
590 GNUNET_free (id_str); 590 GNUNET_free (id_str);
591 if (NULL != attrs) 591 if (NULL != attrs)
@@ -606,27 +606,27 @@ attest_collect (void *cls,
606 type = GNUNET_RECLAIM_attribute_number_to_typename (ale->attribute->type); 606 type = GNUNET_RECLAIM_attribute_number_to_typename (ale->attribute->type);
607 json_object_set_new (attr_obj, "type", json_string (type)); 607 json_object_set_new (attr_obj, "type", json_string (type));
608 json_object_set_new (attr_obj, "id", json_string ("")); 608 json_object_set_new (attr_obj, "id", json_string (""));
609 json_object_set_new (attr_obj, "attestation", json_string ("")); 609 json_object_set_new (attr_obj, "credential", json_string (""));
610 json_array_append_new (attr_arr, attr_obj); 610 json_array_append_new (attr_arr, attr_obj);
611 GNUNET_free (tmp_value); 611 GNUNET_free (tmp_value);
612 } 612 }
613 json_object_set_new (attest_obj, "attributes", attr_arr); 613 json_object_set_new (cred_obj, "attributes", attr_arr);
614 } 614 }
615 json_array_append_new (handle->resp_object, attest_obj); 615 json_array_append_new (handle->resp_object, cred_obj);
616 GNUNET_RECLAIM_attribute_list_destroy (attrs); 616 GNUNET_RECLAIM_attribute_list_destroy (attrs);
617 GNUNET_RECLAIM_get_attestations_next (handle->attest_it); 617 GNUNET_RECLAIM_get_credentials_next (handle->cred_it);
618} 618}
619 619
620 620
621/** 621/**
622 * Lists attestation for identity request 622 * Lists credential for identity request
623 * 623 *
624 * @param con_handle the connection handle 624 * @param con_handle the connection handle
625 * @param url the url 625 * @param url the url
626 * @param cls the RequestHandle 626 * @param cls the RequestHandle
627 */ 627 */
628static void 628static void
629list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 629list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
630 const char *url, 630 const char *url,
631 void *cls) 631 void *cls)
632{ 632{
@@ -636,9 +636,9 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
636 char *identity; 636 char *identity;
637 637
638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
639 "Getting attestations for %s.\n", 639 "Getting credentials for %s.\n",
640 handle->url); 640 handle->url);
641 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( 641 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
642 handle->url)) 642 handle->url))
643 { 643 {
644 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 644 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -646,7 +646,7 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
646 return; 646 return;
647 } 647 }
648 identity = handle->url + strlen ( 648 identity = handle->url + strlen (
649 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1; 649 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1;
650 650
651 for (ego_entry = ego_head; NULL != ego_entry; 651 for (ego_entry = ego_head; NULL != ego_entry;
652 ego_entry = ego_entry->next) 652 ego_entry = ego_entry->next)
@@ -663,11 +663,11 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
663 return; 663 return;
664 } 664 }
665 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 665 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
666 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (idp, 666 handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp,
667 priv_key, 667 priv_key,
668 &collect_error_cb, 668 &collect_error_cb,
669 handle, 669 handle,
670 &attest_collect, 670 &cred_collect,
671 handle, 671 handle,
672 & 672 &
673 collect_finished_cb, 673 collect_finished_cb,
@@ -676,27 +676,27 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
676 676
677 677
678/** 678/**
679 * Deletes attestation from an identity 679 * Deletes credential from an identity
680 * 680 *
681 * @param con_handle the connection handle 681 * @param con_handle the connection handle
682 * @param url the url 682 * @param url the url
683 * @param cls the RequestHandle 683 * @param cls the RequestHandle
684 */ 684 */
685static void 685static void
686delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 686delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
687 const char *url, 687 const char *url,
688 void *cls) 688 void *cls)
689{ 689{
690 struct RequestHandle *handle = cls; 690 struct RequestHandle *handle = cls;
691 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 691 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
692 struct GNUNET_RECLAIM_Attestation attr; 692 struct GNUNET_RECLAIM_Credential attr;
693 struct EgoEntry *ego_entry; 693 struct EgoEntry *ego_entry;
694 char *identity_id_str; 694 char *identity_id_str;
695 char *identity; 695 char *identity;
696 char *id; 696 char *id;
697 697
698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n"); 698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n");
699 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( 699 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
700 handle->url)) 700 handle->url))
701 { 701 {
702 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 702 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
@@ -705,7 +705,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
705 } 705 }
706 identity_id_str = 706 identity_id_str =
707 strdup (handle->url + strlen ( 707 strdup (handle->url + strlen (
708 GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1); 708 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1);
709 identity = strtok (identity_id_str, "/"); 709 identity = strtok (identity_id_str, "/");
710 id = strtok (NULL, "/"); 710 id = strtok (NULL, "/");
711 if ((NULL == identity) || (NULL == id)) 711 if ((NULL == identity) || (NULL == id))
@@ -730,10 +730,10 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
730 return; 730 return;
731 } 731 }
732 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 732 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
733 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attestation)); 733 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential));
734 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); 734 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
735 attr.name = ""; 735 attr.name = "";
736 handle->idp_op = GNUNET_RECLAIM_attestation_delete (idp, 736 handle->idp_op = GNUNET_RECLAIM_credential_delete (idp,
737 priv_key, 737 priv_key,
738 &attr, 738 &attr,
739 &delete_finished_cb, 739 &delete_finished_cb,
@@ -811,7 +811,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
811 json_t *data_json; 811 json_t *data_json;
812 json_error_t err; 812 json_error_t err;
813 struct GNUNET_JSON_Specification attrspec[] = 813 struct GNUNET_JSON_Specification attrspec[] =
814 { GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end () }; 814 { GNUNET_RECLAIM_JSON_spec_attribute (&attribute), GNUNET_JSON_spec_end () };
815 815
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Adding an attribute for %s.\n", 817 "Adding an attribute for %s.\n",
@@ -877,13 +877,13 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
877/** 877/**
878 * Parse a JWT and return the respective claim value as Attribute 878 * Parse a JWT and return the respective claim value as Attribute
879 * 879 *
880 * @param attest the jwt attestation 880 * @param cred the jwt credential
881 * @param claim the name of the claim in the JWT 881 * @param claim the name of the claim in the JWT
882 * 882 *
883 * @return a GNUNET_RECLAIM_Attribute, containing the new value 883 * @return a GNUNET_RECLAIM_Attribute, containing the new value
884 */ 884 */
885struct GNUNET_RECLAIM_Attribute * 885struct GNUNET_RECLAIM_Attribute *
886parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest, 886parse_jwt (const struct GNUNET_RECLAIM_Credential *cred,
887 const char *claim) 887 const char *claim)
888{ 888{
889 char *jwt_string; 889 char *jwt_string;
@@ -899,9 +899,9 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
899 json_t *json_val; 899 json_t *json_val;
900 json_error_t *json_err = NULL; 900 json_error_t *json_err = NULL;
901 901
902 jwt_string = GNUNET_RECLAIM_attestation_value_to_string (attest->type, 902 jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type,
903 attest->data, 903 cred->data,
904 attest->data_size); 904 cred->data_size);
905 char *jwt_body = strtok (jwt_string, delim); 905 char *jwt_body = strtok (jwt_string, delim);
906 jwt_body = strtok (NULL, delim); 906 jwt_body = strtok (NULL, delim);
907 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), 907 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
@@ -927,16 +927,16 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
927 "Error: Referenced Claim Name not Found", 927 "Error: Referenced Claim Name not Found",
928 (void **) &data, 928 (void **) &data,
929 &data_size); 929 &data_size);
930 attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id, 930 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
931 type, data, data_size); 931 type, data, data_size);
932 attr->id = attest->id; 932 attr->id = cred->id;
933 attr->flag = 1; 933 attr->flag = 1;
934 } 934 }
935 else 935 else
936 { 936 {
937 attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id, 937 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
938 type, data, data_size); 938 type, data, data_size);
939 attr->id = attest->id; 939 attr->id = cred->id;
940 attr->flag = 1; 940 attr->flag = 1;
941 } 941 }
942 return attr; 942 return attr;
@@ -965,7 +965,7 @@ attr_collect (void *cls,
965 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 965 json_object_set_new (attr_obj, "value", json_string (tmp_value));
966 json_object_set_new (attr_obj, "name", json_string (attr->name)); 966 json_object_set_new (attr_obj, "name", json_string (attr->name));
967 967
968 if (GNUNET_RECLAIM_id_is_zero (&attr->attestation)) 968 if (GNUNET_RECLAIM_id_is_zero (&attr->credential))
969 json_object_set_new (attr_obj, "flag", json_string ("0")); 969 json_object_set_new (attr_obj, "flag", json_string ("0"));
970 else 970 else
971 json_object_set_new (attr_obj, "flag", json_string ("1")); 971 json_object_set_new (attr_obj, "flag", json_string ("1"));
@@ -974,9 +974,9 @@ attr_collect (void *cls,
974 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, 974 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
975 sizeof(attr->id)); 975 sizeof(attr->id));
976 json_object_set_new (attr_obj, "id", json_string (id_str)); 976 json_object_set_new (attr_obj, "id", json_string (id_str));
977 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->attestation, 977 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential,
978 sizeof(attr->attestation)); 978 sizeof(attr->credential));
979 json_object_set_new (attr_obj, "attestation", json_string (id_str)); 979 json_object_set_new (attr_obj, "credential", json_string (id_str));
980 json_array_append (handle->resp_object, attr_obj); 980 json_array_append (handle->resp_object, attr_obj);
981 json_decref (attr_obj); 981 json_decref (attr_obj);
982 GNUNET_free (tmp_value); 982 GNUNET_free (tmp_value);
@@ -1180,7 +1180,7 @@ static void
1180consume_cont (void *cls, 1180consume_cont (void *cls,
1181 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1181 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1182 const struct GNUNET_RECLAIM_Attribute *attr, 1182 const struct GNUNET_RECLAIM_Attribute *attr,
1183 const struct GNUNET_RECLAIM_Attestation *attest) 1183 const struct GNUNET_RECLAIM_Presentation *pres)
1184{ 1184{
1185 struct RequestHandle *handle = cls; 1185 struct RequestHandle *handle = cls;
1186 char *val_str; 1186 char *val_str;
@@ -1427,11 +1427,11 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1427 { MHD_HTTP_METHOD_DELETE, 1427 { MHD_HTTP_METHOD_DELETE,
1428 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, 1428 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont },
1429 { MHD_HTTP_METHOD_GET, 1429 { MHD_HTTP_METHOD_GET,
1430 GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &list_attestation_cont }, 1430 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont },
1431 { MHD_HTTP_METHOD_POST, 1431 { MHD_HTTP_METHOD_POST,
1432 GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &add_attestation_cont }, 1432 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont },
1433 { MHD_HTTP_METHOD_DELETE, 1433 { MHD_HTTP_METHOD_DELETE,
1434 GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &delete_attestation_cont }, 1434 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont },
1435 { MHD_HTTP_METHOD_GET, 1435 { MHD_HTTP_METHOD_GET,
1436 GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, 1436 GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont },
1437 { MHD_HTTP_METHOD_POST, 1437 { MHD_HTTP_METHOD_POST,
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 7b5d7ab19..bc7f34365 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -139,9 +139,9 @@ 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 142 * Length of serialized credential data
143 */ 143 */
144 uint16_t attestation_len GNUNET_PACKED; 144 uint16_t credential_len GNUNET_PACKED;
145 145
146 /** 146 /**
147 * always zero (for alignment) 147 * always zero (for alignment)
@@ -159,9 +159,9 @@ struct AttributeResultMessage
159}; 159};
160 160
161/** 161/**
162 * Attestation is returned from the idp. 162 * Credential is returned from the idp.
163 */ 163 */
164struct AttestationResultMessage 164struct CredentialResultMessage
165{ 165{
166 /** 166 /**
167 * Message header 167 * Message header
@@ -176,7 +176,7 @@ struct AttestationResultMessage
176 /** 176 /**
177 * Length of serialized attribute data 177 * Length of serialized attribute data
178 */ 178 */
179 uint16_t attestation_len GNUNET_PACKED; 179 uint16_t credential_len GNUNET_PACKED;
180 180
181 /** 181 /**
182 * always zero (for alignment) 182 * always zero (for alignment)
@@ -189,7 +189,7 @@ struct AttestationResultMessage
189 struct GNUNET_CRYPTO_EcdsaPublicKey identity; 189 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
190 190
191 /* followed by: 191 /* followed by:
192 * serialized attestation data 192 * serialized credential data
193 */ 193 */
194}; 194};
195 195
@@ -234,9 +234,9 @@ struct AttributeIterationNextMessage
234 234
235 235
236/** 236/**
237 * Start a attestation iteration for the given identity 237 * Start a credential iteration for the given identity
238 */ 238 */
239struct AttestationIterationStartMessage 239struct CredentialIterationStartMessage
240{ 240{
241 /** 241 /**
242 * Message 242 * Message
@@ -256,9 +256,9 @@ struct AttestationIterationStartMessage
256 256
257 257
258/** 258/**
259 * Ask for next result of attestation iteration for the given operation 259 * Ask for next result of credential iteration for the given operation
260 */ 260 */
261struct AttestationIterationNextMessage 261struct CredentialIterationNextMessage
262{ 262{
263 /** 263 /**
264 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT 264 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
@@ -273,9 +273,9 @@ struct AttestationIterationNextMessage
273 273
274 274
275/** 275/**
276 * Stop attestation iteration for the given operation 276 * Stop credential iteration for the given operation
277 */ 277 */
278struct AttestationIterationStopMessage 278struct CredentialIterationStopMessage
279{ 279{
280 /** 280 /**
281 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP 281 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
@@ -463,9 +463,16 @@ struct TicketResultMessage
463 uint32_t id GNUNET_PACKED; 463 uint32_t id GNUNET_PACKED;
464 464
465 /** 465 /**
466 * Length of new presentations created
467 */
468 uint32_t presentations_len GNUNET_PACKED;
469
470 /**
466 * The new ticket 471 * The new ticket
467 */ 472 */
468 struct GNUNET_RECLAIM_Ticket ticket; 473 struct GNUNET_RECLAIM_Ticket ticket;
474
475 /* Followed by the serialized GNUNET_RECLAIM_PresentationList */
469}; 476};
470 477
471/** 478/**
@@ -520,9 +527,9 @@ struct ConsumeTicketResultMessage
520 uint16_t attrs_len GNUNET_PACKED; 527 uint16_t attrs_len GNUNET_PACKED;
521 528
522 /** 529 /**
523 * Length of attestation data 530 * Length of presentation data
524 */ 531 */
525 uint16_t attestations_len; 532 uint16_t presentations_len;
526 533
527 /** 534 /**
528 * always zero (for alignment) 535 * always zero (for alignment)
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index b432b4f2a..1e0251519 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -77,9 +77,9 @@ struct GNUNET_RECLAIM_Operation
77 GNUNET_RECLAIM_AttributeTicketResult atr_cb; 77 GNUNET_RECLAIM_AttributeTicketResult atr_cb;
78 78
79 /** 79 /**
80 * Attestation result callback 80 * Credential result callback
81 */ 81 */
82 GNUNET_RECLAIM_AttestationResult at_cb; 82 GNUNET_RECLAIM_CredentialResult at_cb;
83 83
84 /** 84 /**
85 * Revocation result callback 85 * Revocation result callback
@@ -92,6 +92,11 @@ struct GNUNET_RECLAIM_Operation
92 GNUNET_RECLAIM_TicketCallback tr_cb; 92 GNUNET_RECLAIM_TicketCallback tr_cb;
93 93
94 /** 94 /**
95 * Ticket issue result callback
96 */
97 GNUNET_RECLAIM_IssueTicketCallback ti_cb;
98
99 /**
95 * Envelope with the message for this queue entry. 100 * Envelope with the message for this queue entry.
96 */ 101 */
97 struct GNUNET_MQ_Envelope *env; 102 struct GNUNET_MQ_Envelope *env;
@@ -239,19 +244,19 @@ struct GNUNET_RECLAIM_AttributeIterator
239}; 244};
240 245
241/** 246/**
242 * Handle for a attestation iterator operation 247 * Handle for a credential iterator operation
243 */ 248 */
244struct GNUNET_RECLAIM_AttestationIterator 249struct GNUNET_RECLAIM_CredentialIterator
245{ 250{
246 /** 251 /**
247 * Kept in a DLL. 252 * Kept in a DLL.
248 */ 253 */
249 struct GNUNET_RECLAIM_AttestationIterator *next; 254 struct GNUNET_RECLAIM_CredentialIterator *next;
250 255
251 /** 256 /**
252 * Kept in a DLL. 257 * Kept in a DLL.
253 */ 258 */
254 struct GNUNET_RECLAIM_AttestationIterator *prev; 259 struct GNUNET_RECLAIM_CredentialIterator *prev;
255 260
256 /** 261 /**
257 * Main handle to access the service. 262 * Main handle to access the service.
@@ -271,7 +276,7 @@ struct GNUNET_RECLAIM_AttestationIterator
271 /** 276 /**
272 * The continuation to call with the results 277 * The continuation to call with the results
273 */ 278 */
274 GNUNET_RECLAIM_AttestationResult proc; 279 GNUNET_RECLAIM_CredentialResult proc;
275 280
276 /** 281 /**
277 * Closure for @e proc. 282 * Closure for @e proc.
@@ -349,12 +354,12 @@ struct GNUNET_RECLAIM_Handle
349 /** 354 /**
350 * Head of active iterations 355 * Head of active iterations
351 */ 356 */
352 struct GNUNET_RECLAIM_AttestationIterator *ait_head; 357 struct GNUNET_RECLAIM_CredentialIterator *ait_head;
353 358
354 /** 359 /**
355 * Tail of active iterations 360 * Tail of active iterations
356 */ 361 */
357 struct GNUNET_RECLAIM_AttestationIterator *ait_tail; 362 struct GNUNET_RECLAIM_CredentialIterator *ait_tail;
358 363
359 /** 364 /**
360 * Head of active iterations 365 * Head of active iterations
@@ -464,7 +469,7 @@ free_it (struct GNUNET_RECLAIM_AttributeIterator *it)
464 * @param ait entry to free 469 * @param ait entry to free
465 */ 470 */
466static void 471static void
467free_ait (struct GNUNET_RECLAIM_AttestationIterator *ait) 472free_ait (struct GNUNET_RECLAIM_CredentialIterator *ait)
468{ 473{
469 struct GNUNET_RECLAIM_Handle *h = ait->h; 474 struct GNUNET_RECLAIM_Handle *h = ait->h;
470 475
@@ -561,13 +566,13 @@ check_consume_ticket_result (void *cls,
561{ 566{
562 size_t msg_len; 567 size_t msg_len;
563 size_t attrs_len; 568 size_t attrs_len;
564 size_t attests_len; 569 size_t pl_len;
565 570
566 msg_len = ntohs (msg->header.size); 571 msg_len = ntohs (msg->header.size);
567 attrs_len = ntohs (msg->attrs_len); 572 attrs_len = ntohs (msg->attrs_len);
568 attests_len = ntohs (msg->attestations_len); 573 pl_len = ntohs (msg->presentations_len);
569 if (msg_len != 574 if (msg_len !=
570 sizeof(struct ConsumeTicketResultMessage) + attrs_len + attests_len) 575 sizeof(struct ConsumeTicketResultMessage) + attrs_len + pl_len)
571 { 576 {
572 GNUNET_break (0); 577 GNUNET_break (0);
573 return GNUNET_SYSERR; 578 return GNUNET_SYSERR;
@@ -590,12 +595,12 @@ handle_consume_ticket_result (void *cls,
590 struct GNUNET_RECLAIM_Handle *h = cls; 595 struct GNUNET_RECLAIM_Handle *h = cls;
591 struct GNUNET_RECLAIM_Operation *op; 596 struct GNUNET_RECLAIM_Operation *op;
592 size_t attrs_len; 597 size_t attrs_len;
593 size_t attests_len; 598 size_t pl_len;
594 uint32_t r_id = ntohl (msg->id); 599 uint32_t r_id = ntohl (msg->id);
595 char *read_ptr; 600 char *read_ptr;
596 601
597 attrs_len = ntohs (msg->attrs_len); 602 attrs_len = ntohs (msg->attrs_len);
598 attests_len = ntohs (msg->attestations_len); 603 pl_len = ntohs (msg->presentations_len);
599 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); 604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
600 605
601 606
@@ -608,13 +613,12 @@ handle_consume_ticket_result (void *cls,
608 { 613 {
609 struct GNUNET_RECLAIM_AttributeList *attrs; 614 struct GNUNET_RECLAIM_AttributeList *attrs;
610 struct GNUNET_RECLAIM_AttributeListEntry *le; 615 struct GNUNET_RECLAIM_AttributeListEntry *le;
611 struct GNUNET_RECLAIM_AttestationList *attests; 616 struct GNUNET_RECLAIM_PresentationList *pl;
612 struct GNUNET_RECLAIM_AttestationListEntry *ale; 617 struct GNUNET_RECLAIM_PresentationListEntry *ple;
613 attrs = 618 attrs =
614 GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len); 619 GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
615 read_ptr = ((char *) &msg[1]) + attrs_len; 620 read_ptr = ((char *) &msg[1]) + attrs_len;
616 attests = 621 pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
617 GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len);
618 if (NULL != op->atr_cb) 622 if (NULL != op->atr_cb)
619 { 623 {
620 if (NULL == attrs) 624 if (NULL == attrs)
@@ -626,22 +630,22 @@ handle_consume_ticket_result (void *cls,
626 for (le = attrs->list_head; NULL != le; le = le->next) 630 for (le = attrs->list_head; NULL != le; le = le->next)
627 { 631 {
628 if (GNUNET_NO == 632 if (GNUNET_NO ==
629 GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 633 GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
630 { 634 {
631 for (ale = attests->list_head; NULL != ale; ale = ale->next) 635 for (ple = pl->list_head; NULL != ple; ple = ple->next)
632 { 636 {
633 if (GNUNET_YES == 637 if (GNUNET_YES ==
634 GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation, 638 GNUNET_RECLAIM_id_is_equal (&le->attribute->credential,
635 &ale->attestation->id)) 639 &ple->presentation->credential_id))
636 { 640 {
637 op->atr_cb (op->cls, &msg->identity, 641 op->atr_cb (op->cls, &msg->identity,
638 le->attribute, ale->attestation); 642 le->attribute, ple->presentation);
639 break; 643 break;
640 } 644 }
641 645
642 } 646 }
643 } 647 }
644 else // No attestations 648 else // No credentials
645 { 649 {
646 op->atr_cb (op->cls, &msg->identity, 650 op->atr_cb (op->cls, &msg->identity,
647 le->attribute, NULL); 651 le->attribute, NULL);
@@ -649,10 +653,10 @@ handle_consume_ticket_result (void *cls,
649 } 653 }
650 if (NULL != attrs) 654 if (NULL != attrs)
651 GNUNET_RECLAIM_attribute_list_destroy (attrs); 655 GNUNET_RECLAIM_attribute_list_destroy (attrs);
652 if (NULL != attests) 656 if (NULL != pl)
653 GNUNET_RECLAIM_attestation_list_destroy (attests); 657 GNUNET_RECLAIM_presentation_list_destroy (pl);
654 attrs = NULL; 658 attrs = NULL;
655 attests = NULL; 659 pl = NULL;
656 } 660 }
657 op->atr_cb (op->cls, NULL, NULL, NULL); 661 op->atr_cb (op->cls, NULL, NULL, NULL);
658 } 662 }
@@ -768,21 +772,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
768 772
769/** 773/**
770 * Handle an incoming message of type 774 * Handle an incoming message of type
771 * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT 775 * #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT
772 * 776 *
773 * @param cls 777 * @param cls
774 * @param msg the message we received 778 * @param msg the message we received
775 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 779 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
776 */ 780 */
777static int 781static int
778check_attestation_result (void *cls, const struct AttestationResultMessage *msg) 782check_credential_result (void *cls, const struct CredentialResultMessage *msg)
779{ 783{
780 size_t msg_len; 784 size_t msg_len;
781 size_t attest_len; 785 size_t cred_len;
782 786
783 msg_len = ntohs (msg->header.size); 787 msg_len = ntohs (msg->header.size);
784 attest_len = ntohs (msg->attestation_len); 788 cred_len = ntohs (msg->credential_len);
785 if (msg_len != sizeof(struct AttestationResultMessage) + attest_len) 789 if (msg_len != sizeof(struct CredentialResultMessage) + cred_len)
786 { 790 {
787 GNUNET_break (0); 791 GNUNET_break (0);
788 return GNUNET_SYSERR; 792 return GNUNET_SYSERR;
@@ -793,24 +797,24 @@ check_attestation_result (void *cls, const struct AttestationResultMessage *msg)
793 797
794/** 798/**
795 * Handle an incoming message of type 799 * Handle an incoming message of type
796 * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT 800 * #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT
797 * 801 *
798 * @param cls 802 * @param cls
799 * @param msg the message we received 803 * @param msg the message we received
800 */ 804 */
801static void 805static void
802handle_attestation_result (void *cls, const struct 806handle_credential_result (void *cls, const struct
803 AttestationResultMessage *msg) 807 CredentialResultMessage *msg)
804{ 808{
805 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; 809 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
806 struct GNUNET_RECLAIM_Handle *h = cls; 810 struct GNUNET_RECLAIM_Handle *h = cls;
807 struct GNUNET_RECLAIM_AttestationIterator *it; 811 struct GNUNET_RECLAIM_CredentialIterator *it;
808 struct GNUNET_RECLAIM_Operation *op; 812 struct GNUNET_RECLAIM_Operation *op;
809 size_t att_len; 813 size_t att_len;
810 uint32_t r_id = ntohl (msg->id); 814 uint32_t r_id = ntohl (msg->id);
811 815
812 att_len = ntohs (msg->attestation_len); 816 att_len = ntohs (msg->credential_len);
813 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); 817 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
814 818
815 819
816 for (it = h->ait_head; NULL != it; it = it->next) 820 for (it = h->ait_head; NULL != it; it = it->next)
@@ -848,8 +852,8 @@ handle_attestation_result (void *cls, const struct
848 } 852 }
849 853
850 { 854 {
851 struct GNUNET_RECLAIM_Attestation *att; 855 struct GNUNET_RECLAIM_Credential *att;
852 att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); 856 att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len);
853 857
854 if (NULL != it) 858 if (NULL != it)
855 { 859 {
@@ -867,6 +871,30 @@ handle_attestation_result (void *cls, const struct
867 GNUNET_assert (0); 871 GNUNET_assert (0);
868} 872}
869 873
874/**
875 * Handle an incoming message of type
876 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
877 *
878 * @param cls
879 * @param msg the message we received
880 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
881 */
882static int
883check_ticket_result (void *cls, const struct TicketResultMessage *msg)
884{
885 size_t msg_len;
886 size_t pres_len;
887
888 msg_len = ntohs (msg->header.size);
889 pres_len = ntohs (msg->presentations_len);
890 if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
891 {
892 GNUNET_break (0);
893 return GNUNET_SYSERR;
894 }
895 return GNUNET_OK;
896}
897
870 898
871/** 899/**
872 * Handle an incoming message of type 900 * Handle an incoming message of type
@@ -881,8 +909,10 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
881 struct GNUNET_RECLAIM_Handle *handle = cls; 909 struct GNUNET_RECLAIM_Handle *handle = cls;
882 struct GNUNET_RECLAIM_Operation *op; 910 struct GNUNET_RECLAIM_Operation *op;
883 struct GNUNET_RECLAIM_TicketIterator *it; 911 struct GNUNET_RECLAIM_TicketIterator *it;
912 struct GNUNET_RECLAIM_PresentationList *pres;
884 uint32_t r_id = ntohl (msg->id); 913 uint32_t r_id = ntohl (msg->id);
885 static const struct GNUNET_RECLAIM_Ticket ticket; 914 static const struct GNUNET_RECLAIM_Ticket ticket;
915 uint32_t pres_len = ntohs (msg->presentations_len);
886 916
887 for (op = handle->op_head; NULL != op; op = op->next) 917 for (op = handle->op_head; NULL != op; op = op->next)
888 if (op->r_id == r_id) 918 if (op->r_id == r_id)
@@ -894,18 +924,25 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
894 return; 924 return;
895 if (NULL != op) 925 if (NULL != op)
896 { 926 {
927 if (0 < pres_len)
928 pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1],
929 pres_len);
897 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); 930 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
898 if (0 == 931 if (0 ==
899 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) 932 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
900 { 933 {
901 if (NULL != op->tr_cb) 934 if (NULL != op->ti_cb)
902 op->tr_cb (op->cls, NULL); 935 op->ti_cb (op->cls, NULL, NULL);
903 } 936 }
904 else 937 else
905 { 938 {
906 if (NULL != op->tr_cb) 939 if (NULL != op->ti_cb)
907 op->tr_cb (op->cls, &msg->ticket); 940 op->ti_cb (op->cls,
941 &msg->ticket,
942 (0 < pres_len) ? pres : NULL);
908 } 943 }
944 if (0 < pres_len)
945 GNUNET_RECLAIM_presentation_list_destroy (pres);
909 free_op (op); 946 free_op (op);
910 return; 947 return;
911 } 948 }
@@ -986,14 +1023,14 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
986 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 1023 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
987 struct AttributeResultMessage, 1024 struct AttributeResultMessage,
988 h), 1025 h),
989 GNUNET_MQ_hd_var_size (attestation_result, 1026 GNUNET_MQ_hd_var_size (credential_result,
990 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, 1027 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT,
991 struct AttestationResultMessage, 1028 struct CredentialResultMessage,
1029 h),
1030 GNUNET_MQ_hd_var_size (ticket_result,
1031 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
1032 struct TicketResultMessage,
992 h), 1033 h),
993 GNUNET_MQ_hd_fixed_size (ticket_result,
994 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
995 struct TicketResultMessage,
996 h),
997 GNUNET_MQ_hd_var_size (consume_ticket_result, 1034 GNUNET_MQ_hd_var_size (consume_ticket_result,
998 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, 1035 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT,
999 struct ConsumeTicketResultMessage, 1036 struct ConsumeTicketResultMessage,
@@ -1175,22 +1212,22 @@ GNUNET_RECLAIM_attribute_delete (
1175 1212
1176 1213
1177/** 1214/**
1178 * Store an attestation. If the attestation is already present, 1215 * Store an credential. If the credential is already present,
1179 * it is replaced with the new attestation. 1216 * it is replaced with the new credential.
1180 * 1217 *
1181 * @param h handle to the re:claimID service 1218 * @param h handle to the re:claimID service
1182 * @param pkey private key of the identity 1219 * @param pkey private key of the identity
1183 * @param attr the attestation value 1220 * @param attr the credential value
1184 * @param exp_interval the relative expiration interval for the attestation 1221 * @param exp_interval the relative expiration interval for the credential
1185 * @param cont continuation to call when done 1222 * @param cont continuation to call when done
1186 * @param cont_cls closure for @a cont 1223 * @param cont_cls closure for @a cont
1187 * @return handle to abort the request 1224 * @return handle to abort the request
1188 */ 1225 */
1189struct GNUNET_RECLAIM_Operation * 1226struct GNUNET_RECLAIM_Operation *
1190GNUNET_RECLAIM_attestation_store ( 1227GNUNET_RECLAIM_credential_store (
1191 struct GNUNET_RECLAIM_Handle *h, 1228 struct GNUNET_RECLAIM_Handle *h,
1192 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1229 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1193 const struct GNUNET_RECLAIM_Attestation *attr, 1230 const struct GNUNET_RECLAIM_Credential *attr,
1194 const struct GNUNET_TIME_Relative *exp_interval, 1231 const struct GNUNET_TIME_Relative *exp_interval,
1195 GNUNET_RECLAIM_ContinuationWithStatus cont, 1232 GNUNET_RECLAIM_ContinuationWithStatus cont,
1196 void *cont_cls) 1233 void *cont_cls)
@@ -1205,15 +1242,15 @@ GNUNET_RECLAIM_attestation_store (
1205 op->cls = cont_cls; 1242 op->cls = cont_cls;
1206 op->r_id = h->r_id_gen++; 1243 op->r_id = h->r_id_gen++;
1207 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1244 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1208 attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); 1245 attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr);
1209 op->env = GNUNET_MQ_msg_extra (sam, 1246 op->env = GNUNET_MQ_msg_extra (sam,
1210 attr_len, 1247 attr_len,
1211 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE); 1248 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE);
1212 sam->identity = *pkey; 1249 sam->identity = *pkey;
1213 sam->id = htonl (op->r_id); 1250 sam->id = htonl (op->r_id);
1214 sam->exp = GNUNET_htonll (exp_interval->rel_value_us); 1251 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1215 1252
1216 GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]); 1253 GNUNET_RECLAIM_credential_serialize (attr, (char *) &sam[1]);
1217 1254
1218 sam->attr_len = htons (attr_len); 1255 sam->attr_len = htons (attr_len);
1219 if (NULL != h->mq) 1256 if (NULL != h->mq)
@@ -1223,21 +1260,21 @@ GNUNET_RECLAIM_attestation_store (
1223 1260
1224 1261
1225/** 1262/**
1226 * Delete an attestation. Tickets used to share this attestation are updated 1263 * Delete an credential. Tickets used to share this credential are updated
1227 * accordingly. 1264 * accordingly.
1228 * 1265 *
1229 * @param h handle to the re:claimID service 1266 * @param h handle to the re:claimID service
1230 * @param pkey Private key of the identity to add an attribute to 1267 * @param pkey Private key of the identity to add an attribute to
1231 * @param attr The attestation 1268 * @param attr The credential
1232 * @param cont Continuation to call when done 1269 * @param cont Continuation to call when done
1233 * @param cont_cls Closure for @a cont 1270 * @param cont_cls Closure for @a cont
1234 * @return handle Used to to abort the request 1271 * @return handle Used to to abort the request
1235 */ 1272 */
1236struct GNUNET_RECLAIM_Operation * 1273struct GNUNET_RECLAIM_Operation *
1237GNUNET_RECLAIM_attestation_delete ( 1274GNUNET_RECLAIM_credential_delete (
1238 struct GNUNET_RECLAIM_Handle *h, 1275 struct GNUNET_RECLAIM_Handle *h,
1239 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 1276 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1240 const struct GNUNET_RECLAIM_Attestation *attr, 1277 const struct GNUNET_RECLAIM_Credential *attr,
1241 GNUNET_RECLAIM_ContinuationWithStatus cont, 1278 GNUNET_RECLAIM_ContinuationWithStatus cont,
1242 void *cont_cls) 1279 void *cont_cls)
1243{ 1280{
@@ -1251,13 +1288,13 @@ GNUNET_RECLAIM_attestation_delete (
1251 op->cls = cont_cls; 1288 op->cls = cont_cls;
1252 op->r_id = h->r_id_gen++; 1289 op->r_id = h->r_id_gen++;
1253 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1290 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1254 attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); 1291 attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr);
1255 op->env = GNUNET_MQ_msg_extra (dam, 1292 op->env = GNUNET_MQ_msg_extra (dam,
1256 attr_len, 1293 attr_len,
1257 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE); 1294 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE);
1258 dam->identity = *pkey; 1295 dam->identity = *pkey;
1259 dam->id = htonl (op->r_id); 1296 dam->id = htonl (op->r_id);
1260 GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]); 1297 GNUNET_RECLAIM_credential_serialize (attr, (char *) &dam[1]);
1261 1298
1262 dam->attr_len = htons (attr_len); 1299 dam->attr_len = htons (attr_len);
1263 if (NULL != h->mq) 1300 if (NULL != h->mq)
@@ -1376,12 +1413,12 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1376 1413
1377 1414
1378/** 1415/**
1379 * List all attestations for a local identity. 1416 * List all credentials for a local identity.
1380 * This MUST lock the `struct GNUNET_RECLAIM_Handle` 1417 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
1381 * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and 1418 * for any other calls than #GNUNET_RECLAIM_get_credentials_next() and
1382 * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once 1419 * #GNUNET_RECLAIM_get_credentials_stop. @a proc will be called once
1383 * immediately, and then again after 1420 * immediately, and then again after
1384 * #GNUNET_RECLAIM_get_attestations_next() is invoked. 1421 * #GNUNET_RECLAIM_get_credentials_next() is invoked.
1385 * 1422 *
1386 * On error (disconnect), @a error_cb will be invoked. 1423 * On error (disconnect), @a error_cb will be invoked.
1387 * On normal completion, @a finish_cb proc will be 1424 * On normal completion, @a finish_cb proc will be
@@ -1392,31 +1429,31 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1392 * @param error_cb Function to call on error (i.e. disconnect), 1429 * @param error_cb Function to call on error (i.e. disconnect),
1393 * the handle is afterwards invalid 1430 * the handle is afterwards invalid
1394 * @param error_cb_cls Closure for @a error_cb 1431 * @param error_cb_cls Closure for @a error_cb
1395 * @param proc Function to call on each attestation 1432 * @param proc Function to call on each credential
1396 * @param proc_cls Closure for @a proc 1433 * @param proc_cls Closure for @a proc
1397 * @param finish_cb Function to call on completion 1434 * @param finish_cb Function to call on completion
1398 * the handle is afterwards invalid 1435 * the handle is afterwards invalid
1399 * @param finish_cb_cls Closure for @a finish_cb 1436 * @param finish_cb_cls Closure for @a finish_cb
1400 * @return an iterator Handle to use for iteration 1437 * @return an iterator Handle to use for iteration
1401 */ 1438 */
1402struct GNUNET_RECLAIM_AttestationIterator * 1439struct GNUNET_RECLAIM_CredentialIterator *
1403GNUNET_RECLAIM_get_attestations_start ( 1440GNUNET_RECLAIM_get_credentials_start (
1404 struct GNUNET_RECLAIM_Handle *h, 1441 struct GNUNET_RECLAIM_Handle *h,
1405 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1442 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1406 GNUNET_SCHEDULER_TaskCallback error_cb, 1443 GNUNET_SCHEDULER_TaskCallback error_cb,
1407 void *error_cb_cls, 1444 void *error_cb_cls,
1408 GNUNET_RECLAIM_AttestationResult proc, 1445 GNUNET_RECLAIM_CredentialResult proc,
1409 void *proc_cls, 1446 void *proc_cls,
1410 GNUNET_SCHEDULER_TaskCallback finish_cb, 1447 GNUNET_SCHEDULER_TaskCallback finish_cb,
1411 void *finish_cb_cls) 1448 void *finish_cb_cls)
1412{ 1449{
1413 struct GNUNET_RECLAIM_AttestationIterator *ait; 1450 struct GNUNET_RECLAIM_CredentialIterator *ait;
1414 struct GNUNET_MQ_Envelope *env; 1451 struct GNUNET_MQ_Envelope *env;
1415 struct AttestationIterationStartMessage *msg; 1452 struct CredentialIterationStartMessage *msg;
1416 uint32_t rid; 1453 uint32_t rid;
1417 1454
1418 rid = h->r_id_gen++; 1455 rid = h->r_id_gen++;
1419 ait = GNUNET_new (struct GNUNET_RECLAIM_AttestationIterator); 1456 ait = GNUNET_new (struct GNUNET_RECLAIM_CredentialIterator);
1420 ait->h = h; 1457 ait->h = h;
1421 ait->error_cb = error_cb; 1458 ait->error_cb = error_cb;
1422 ait->error_cb_cls = error_cb_cls; 1459 ait->error_cb_cls = error_cb_cls;
@@ -1429,7 +1466,7 @@ GNUNET_RECLAIM_get_attestations_start (
1429 GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait); 1466 GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
1430 env = 1467 env =
1431 GNUNET_MQ_msg (msg, 1468 GNUNET_MQ_msg (msg,
1432 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START); 1469 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START);
1433 msg->id = htonl (rid); 1470 msg->id = htonl (rid);
1434 msg->identity = *identity; 1471 msg->identity = *identity;
1435 if (NULL == h->mq) 1472 if (NULL == h->mq)
@@ -1441,21 +1478,21 @@ GNUNET_RECLAIM_get_attestations_start (
1441 1478
1442 1479
1443/** 1480/**
1444 * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start 1481 * Calls the record processor specified in #GNUNET_RECLAIM_get_credential_start
1445 * for the next record. 1482 * for the next record.
1446 * 1483 *
1447 * @param it the iterator 1484 * @param it the iterator
1448 */ 1485 */
1449void 1486void
1450GNUNET_RECLAIM_get_attestations_next (struct 1487GNUNET_RECLAIM_get_credentials_next (struct
1451 GNUNET_RECLAIM_AttestationIterator *ait) 1488 GNUNET_RECLAIM_CredentialIterator *ait)
1452{ 1489{
1453 struct GNUNET_RECLAIM_Handle *h = ait->h; 1490 struct GNUNET_RECLAIM_Handle *h = ait->h;
1454 struct AttestationIterationNextMessage *msg; 1491 struct CredentialIterationNextMessage *msg;
1455 struct GNUNET_MQ_Envelope *env; 1492 struct GNUNET_MQ_Envelope *env;
1456 1493
1457 env = 1494 env =
1458 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT); 1495 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT);
1459 msg->id = htonl (ait->r_id); 1496 msg->id = htonl (ait->r_id);
1460 GNUNET_MQ_send (h->mq, env); 1497 GNUNET_MQ_send (h->mq, env);
1461} 1498}
@@ -1469,18 +1506,18 @@ GNUNET_RECLAIM_get_attestations_next (struct
1469 * @param it the iterator 1506 * @param it the iterator
1470 */ 1507 */
1471void 1508void
1472GNUNET_RECLAIM_get_attestations_stop (struct 1509GNUNET_RECLAIM_get_credentials_stop (struct
1473 GNUNET_RECLAIM_AttestationIterator *ait) 1510 GNUNET_RECLAIM_CredentialIterator *ait)
1474{ 1511{
1475 struct GNUNET_RECLAIM_Handle *h = ait->h; 1512 struct GNUNET_RECLAIM_Handle *h = ait->h;
1476 struct GNUNET_MQ_Envelope *env; 1513 struct GNUNET_MQ_Envelope *env;
1477 struct AttestationIterationStopMessage *msg; 1514 struct CredentialIterationStopMessage *msg;
1478 1515
1479 if (NULL != h->mq) 1516 if (NULL != h->mq)
1480 { 1517 {
1481 env = 1518 env =
1482 GNUNET_MQ_msg (msg, 1519 GNUNET_MQ_msg (msg,
1483 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP); 1520 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP);
1484 msg->id = htonl (ait->r_id); 1521 msg->id = htonl (ait->r_id);
1485 GNUNET_MQ_send (h->mq, env); 1522 GNUNET_MQ_send (h->mq, env);
1486 } 1523 }
@@ -1507,7 +1544,7 @@ GNUNET_RECLAIM_ticket_issue (
1507 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1544 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1508 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1545 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1509 const struct GNUNET_RECLAIM_AttributeList *attrs, 1546 const struct GNUNET_RECLAIM_AttributeList *attrs,
1510 GNUNET_RECLAIM_TicketCallback cb, 1547 GNUNET_RECLAIM_IssueTicketCallback cb,
1511 void *cb_cls) 1548 void *cb_cls)
1512{ 1549{
1513 struct GNUNET_RECLAIM_Operation *op; 1550 struct GNUNET_RECLAIM_Operation *op;
@@ -1517,7 +1554,7 @@ GNUNET_RECLAIM_ticket_issue (
1517 fprintf (stderr, "Issuing ticket\n"); 1554 fprintf (stderr, "Issuing ticket\n");
1518 op = GNUNET_new (struct GNUNET_RECLAIM_Operation); 1555 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1519 op->h = h; 1556 op->h = h;
1520 op->tr_cb = cb; 1557 op->ti_cb = cb;
1521 op->cls = cb_cls; 1558 op->cls = cb_cls;
1522 op->r_id = h->r_id_gen++; 1559 op->r_id = h->r_id_gen++;
1523 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1560 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
diff --git a/src/reclaim/reclaim_attestation.c b/src/reclaim/reclaim_attestation.c
deleted file mode 100644
index 1f2b1890b..000000000
--- a/src/reclaim/reclaim_attestation.c
+++ /dev/null
@@ -1,570 +0,0 @@
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 if (NULL == ale->attestation)
340 {
341 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
342 "Failed to deserialize malformed attestation.\n");
343 GNUNET_free (ale);
344 return al;
345 }
346 GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
347 att_len = GNUNET_RECLAIM_attestation_serialize_get_size (ale->attestation);
348 read_ptr += att_len;
349 }
350 return al;
351}
352
353
354/**
355 * Make a (deep) copy of the attestation list
356 * @param attrs claim list to copy
357 * @return copied claim list
358 */
359struct GNUNET_RECLAIM_AttestationList *
360GNUNET_RECLAIM_attestation_list_dup (
361 const struct GNUNET_RECLAIM_AttestationList *al)
362{
363 struct GNUNET_RECLAIM_AttestationListEntry *ale;
364 struct GNUNET_RECLAIM_AttestationListEntry *result_ale;
365 struct GNUNET_RECLAIM_AttestationList *result;
366
367 result = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
368 for (ale = al->list_head; NULL != ale; ale = ale->next)
369 {
370 result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
371 GNUNET_assert (NULL != ale->attestation);
372 result_ale->attestation =
373 GNUNET_RECLAIM_attestation_new (ale->attestation->name,
374 ale->attestation->type,
375 ale->attestation->data,
376 ale->attestation->data_size);
377 result_ale->attestation->id = ale->attestation->id;
378 GNUNET_CONTAINER_DLL_insert (result->list_head,
379 result->list_tail,
380 result_ale);
381 }
382 return result;
383}
384
385
386/**
387 * Destroy attestation list
388 *
389 * @param attrs list to destroy
390 */
391void
392GNUNET_RECLAIM_attestation_list_destroy (
393 struct GNUNET_RECLAIM_AttestationList *al)
394{
395 struct GNUNET_RECLAIM_AttestationListEntry *ale;
396 struct GNUNET_RECLAIM_AttestationListEntry *tmp_ale;
397
398 for (ale = al->list_head; NULL != ale;)
399 {
400 if (NULL != ale->attestation)
401 GNUNET_free (ale->attestation);
402 tmp_ale = ale;
403 ale = ale->next;
404 GNUNET_free (tmp_ale);
405 }
406 GNUNET_free (al);
407}
408
409
410/**
411 * Get required size for serialization buffer
412 *
413 * @param attr the attestation to serialize
414 * @return the required buffer size
415 */
416size_t
417GNUNET_RECLAIM_attestation_serialize_get_size (
418 const struct GNUNET_RECLAIM_Attestation *attestation)
419{
420 return sizeof(struct Attestation) + strlen (attestation->name)
421 + attestation->data_size;
422}
423
424
425/**
426 * Serialize an attestation
427 *
428 * @param attr the attestation to serialize
429 * @param result the serialized attestation
430 * @return length of serialized data
431 */
432size_t
433GNUNET_RECLAIM_attestation_serialize (
434 const struct GNUNET_RECLAIM_Attestation *attestation,
435 char *result)
436{
437 size_t data_len_ser;
438 size_t name_len;
439 struct Attestation *atts;
440 char *write_ptr;
441
442 atts = (struct Attestation *) result;
443 atts->attestation_type = htons (attestation->type);
444 atts->attestation_flag = htonl (attestation->flag);
445 atts->attestation_id = attestation->id;
446 name_len = strlen (attestation->name);
447 atts->name_len = htons (name_len);
448 write_ptr = (char *) &atts[1];
449 GNUNET_memcpy (write_ptr, attestation->name, name_len);
450 write_ptr += name_len;
451 // TODO plugin-ize
452 // data_len_ser = plugin->serialize_attribute_value (attr,
453 // &attr_ser[1]);
454 data_len_ser = attestation->data_size;
455 GNUNET_memcpy (write_ptr, attestation->data, attestation->data_size);
456 atts->data_size = htons (data_len_ser);
457
458 return sizeof(struct Attestation) + strlen (attestation->name)
459 + attestation->data_size;
460}
461
462
463/**
464 * Deserialize an attestation
465 *
466 * @param data the serialized attestation
467 * @param data_size the length of the serialized data
468 *
469 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
470 */
471struct GNUNET_RECLAIM_Attestation *
472GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size)
473{
474 struct GNUNET_RECLAIM_Attestation *attestation;
475 struct Attestation *atts;
476 size_t data_len;
477 size_t name_len;
478 char *write_ptr;
479
480 if (data_size < sizeof(struct Attestation))
481 return NULL;
482
483 atts = (struct Attestation *) data;
484 data_len = ntohs (atts->data_size);
485 name_len = ntohs (atts->name_len);
486 if (data_size < sizeof(struct Attestation) + data_len + name_len)
487 {
488 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
489 "Buffer too small to deserialize\n");
490 return NULL;
491 }
492 attestation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
493 + data_len + name_len + 1);
494 attestation->type = ntohs (atts->attestation_type);
495 attestation->flag = ntohl (atts->attestation_flag);
496 attestation->id = atts->attestation_id;
497 attestation->data_size = data_len;
498
499 write_ptr = (char *) &attestation[1];
500 GNUNET_memcpy (write_ptr, &atts[1], name_len);
501 write_ptr[name_len] = '\0';
502 attestation->name = write_ptr;
503
504 write_ptr += name_len + 1;
505 GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
506 attestation->data_size);
507 attestation->data = write_ptr;
508 return attestation;
509}
510
511
512struct GNUNET_RECLAIM_AttributeList*
513GNUNET_RECLAIM_attestation_get_attributes (const struct
514 GNUNET_RECLAIM_Attestation *attest)
515{
516 unsigned int i;
517 struct Plugin *plugin;
518 struct GNUNET_RECLAIM_AttributeList *ret;
519 init ();
520 for (i = 0; i < num_plugins; i++)
521 {
522 plugin = attest_plugins[i];
523 if (NULL !=
524 (ret = plugin->api->get_attributes (plugin->api->cls,
525 attest)))
526 return ret;
527 }
528 return NULL;
529}
530
531
532char*
533GNUNET_RECLAIM_attestation_get_issuer (const struct
534 GNUNET_RECLAIM_Attestation *attest)
535{
536 unsigned int i;
537 struct Plugin *plugin;
538 char *ret;
539 init ();
540 for (i = 0; i < num_plugins; i++)
541 {
542 plugin = attest_plugins[i];
543 if (NULL !=
544 (ret = plugin->api->get_issuer (plugin->api->cls,
545 attest)))
546 return ret;
547 }
548 return NULL;
549}
550
551
552int
553GNUNET_RECLAIM_attestation_get_expiration (const struct
554 GNUNET_RECLAIM_Attestation *attest,
555 struct GNUNET_TIME_Absolute*exp)
556{
557 unsigned int i;
558 struct Plugin *plugin;
559 init ();
560 for (i = 0; i < num_plugins; i++)
561 {
562 plugin = attest_plugins[i];
563 if (GNUNET_OK != plugin->api->get_expiration (plugin->api->cls,
564 attest,
565 exp))
566 continue;
567 return GNUNET_OK;
568 }
569 return GNUNET_SYSERR;
570}
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c
index 971bfce23..2217987ac 100644
--- a/src/reclaim/reclaim_attribute.c
+++ b/src/reclaim/reclaim_attribute.c
@@ -222,7 +222,7 @@ GNUNET_RECLAIM_attribute_value_to_string (uint32_t type,
222 * Create a new attribute. 222 * Create a new attribute.
223 * 223 *
224 * @param attr_name the attribute name 224 * @param attr_name the attribute name
225 * @param attestation attestation ID of the attribute (maybe NULL) 225 * @param credential credential ID of the attribute (maybe NULL)
226 * @param type the attribute type 226 * @param type the attribute type
227 * @param data the attribute value 227 * @param data the attribute value
228 * @param data_size the attribute value size 228 * @param data_size the attribute value size
@@ -231,7 +231,7 @@ GNUNET_RECLAIM_attribute_value_to_string (uint32_t type,
231struct GNUNET_RECLAIM_Attribute * 231struct GNUNET_RECLAIM_Attribute *
232GNUNET_RECLAIM_attribute_new (const char *attr_name, 232GNUNET_RECLAIM_attribute_new (const char *attr_name,
233 const struct 233 const struct
234 GNUNET_RECLAIM_Identifier *attestation, 234 GNUNET_RECLAIM_Identifier *credential,
235 uint32_t type, 235 uint32_t type,
236 const void *data, 236 const void *data,
237 size_t data_size) 237 size_t data_size)
@@ -244,8 +244,8 @@ GNUNET_RECLAIM_attribute_new (const char *attr_name,
244 244
245 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) 245 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
246 + strlen (attr_name_tmp) + 1 + data_size); 246 + strlen (attr_name_tmp) + 1 + data_size);
247 if (NULL != attestation) 247 if (NULL != credential)
248 attr->attestation = *attestation; 248 attr->credential = *credential;
249 attr->type = type; 249 attr->type = type;
250 attr->data_size = data_size; 250 attr->data_size = data_size;
251 attr->flag = 0; 251 attr->flag = 0;
@@ -272,7 +272,7 @@ void
272GNUNET_RECLAIM_attribute_list_add ( 272GNUNET_RECLAIM_attribute_list_add (
273 struct GNUNET_RECLAIM_AttributeList *al, 273 struct GNUNET_RECLAIM_AttributeList *al,
274 const char *attr_name, 274 const char *attr_name,
275 const struct GNUNET_RECLAIM_Identifier *attestation, 275 const struct GNUNET_RECLAIM_Identifier *credential,
276 uint32_t type, 276 uint32_t type,
277 const void *data, 277 const void *data,
278 size_t data_size) 278 size_t data_size)
@@ -281,7 +281,7 @@ GNUNET_RECLAIM_attribute_list_add (
281 281
282 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); 282 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
283 ale->attribute = 283 ale->attribute =
284 GNUNET_RECLAIM_attribute_new (attr_name, attestation, 284 GNUNET_RECLAIM_attribute_new (attr_name, credential,
285 type, data, data_size); 285 type, data, data_size);
286 GNUNET_CONTAINER_DLL_insert (al->list_head, 286 GNUNET_CONTAINER_DLL_insert (al->list_head,
287 al->list_tail, 287 al->list_tail,
@@ -403,7 +403,7 @@ GNUNET_RECLAIM_attribute_list_dup (
403 { 403 {
404 result_ale->attribute = 404 result_ale->attribute =
405 GNUNET_RECLAIM_attribute_new (ale->attribute->name, 405 GNUNET_RECLAIM_attribute_new (ale->attribute->name,
406 &ale->attribute->attestation, 406 &ale->attribute->credential,
407 ale->attribute->type, 407 ale->attribute->type,
408 ale->attribute->data, 408 ale->attribute->data,
409 ale->attribute->data_size); 409 ale->attribute->data_size);
@@ -478,7 +478,7 @@ GNUNET_RECLAIM_attribute_serialize (
478 attr_ser->attribute_type = htons (attr->type); 478 attr_ser->attribute_type = htons (attr->type);
479 attr_ser->attribute_flag = htonl (attr->flag); 479 attr_ser->attribute_flag = htonl (attr->flag);
480 attr_ser->attribute_id = attr->id; 480 attr_ser->attribute_id = attr->id;
481 attr_ser->attestation_id = attr->attestation; 481 attr_ser->credential_id = attr->credential;
482 name_len = strlen (attr->name); 482 name_len = strlen (attr->name);
483 attr_ser->name_len = htons (name_len); 483 attr_ser->name_len = htons (name_len);
484 write_ptr = (char *) &attr_ser[1]; 484 write_ptr = (char *) &attr_ser[1];
@@ -530,7 +530,7 @@ GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size,
530 attribute->type = ntohs (attr_ser->attribute_type); 530 attribute->type = ntohs (attr_ser->attribute_type);
531 attribute->flag = ntohl (attr_ser->attribute_flag); 531 attribute->flag = ntohl (attr_ser->attribute_flag);
532 attribute->id = attr_ser->attribute_id; 532 attribute->id = attr_ser->attribute_id;
533 attribute->attestation = attr_ser->attestation_id; 533 attribute->credential = attr_ser->credential_id;
534 attribute->data_size = data_len; 534 attribute->data_size = data_len;
535 535
536 write_ptr = (char *) &attribute[1]; 536 write_ptr = (char *) &attribute[1];
diff --git a/src/reclaim/reclaim_attribute.h b/src/reclaim/reclaim_attribute.h
index 203c88a34..285d75d83 100644
--- a/src/reclaim/reclaim_attribute.h
+++ b/src/reclaim/reclaim_attribute.h
@@ -51,9 +51,9 @@ struct Attribute
51 struct GNUNET_RECLAIM_Identifier attribute_id; 51 struct GNUNET_RECLAIM_Identifier attribute_id;
52 52
53 /** 53 /**
54 * Attestation ID 54 * Credential ID
55 */ 55 */
56 struct GNUNET_RECLAIM_Identifier attestation_id; 56 struct GNUNET_RECLAIM_Identifier credential_id;
57 57
58 /** 58 /**
59 * Name length 59 * Name length
@@ -68,39 +68,6 @@ struct Attribute
68 // followed by data_size Attribute value data 68 // followed by data_size Attribute value data
69}; 69};
70 70
71/**
72 * Serialized attestation claim
73 */
74struct Attestation
75{
76 /**
77 * Attestation type
78 */
79 uint32_t attestation_type GNUNET_PACKED;
80
81 /**
82 * Attestation flag
83 */
84 uint32_t attestation_flag GNUNET_PACKED;
85
86 /**
87 * Attestation ID
88 */
89 struct GNUNET_RECLAIM_Identifier attestation_id;
90
91 /**
92 * Name length
93 */
94 uint32_t name_len GNUNET_PACKED;
95
96 /**
97 * Data size
98 */
99 uint32_t data_size GNUNET_PACKED;
100
101 // followed by data_size Attestation value data
102};
103
104GNUNET_NETWORK_STRUCT_BEGIN 71GNUNET_NETWORK_STRUCT_BEGIN
105 72
106#endif 73#endif
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c
new file mode 100644
index 000000000..5c8974400
--- /dev/null
+++ b/src/reclaim/reclaim_credential.c
@@ -0,0 +1,1037 @@
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/reclaim_credential.c
23 * @brief helper library to manage identity attribute credentials
24 * @author Martin Schanzenbach
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_reclaim_plugin.h"
29#include "reclaim_credential.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_CredentialPluginFunctions *api;
46};
47
48
49/**
50 * Plugins
51 */
52static struct Plugin **credential_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_CredentialPluginFunctions *api = lib_ret;
78 struct Plugin *plugin;
79
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Loading credential 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 (credential_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_credential_",
100 NULL,
101 &add_plugin,
102 NULL);
103}
104
105
106/**
107 * Convert an credential 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_credential_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 = credential_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 credential type number to the corresponding credential type string
133 *
134 * @param type number of a type
135 * @return corresponding typestring, NULL on error
136 */
137const char *
138GNUNET_RECLAIM_credential_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 = credential_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 credential 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_credential_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 = credential_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 credential to a string
192 *
193 * @param type the type of credential
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_credential_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 = credential_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 credential.
223 *
224 * @param attr_name the credential name
225 * @param type the credential type
226 * @param data the credential value
227 * @param data_size the credential value size
228 * @return the new credential
229 */
230struct GNUNET_RECLAIM_Credential *
231GNUNET_RECLAIM_credential_new (const char *attr_name,
232 uint32_t type,
233 const void *data,
234 size_t data_size)
235{
236 struct GNUNET_RECLAIM_Credential *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_Credential)
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_credential_list_serialize_get_size (
266 const struct GNUNET_RECLAIM_CredentialList *credentials)
267{
268 struct GNUNET_RECLAIM_CredentialListEntry *le;
269 size_t len = 0;
270
271 for (le = credentials->list_head; NULL != le; le = le->next)
272 {
273 GNUNET_assert (NULL != le->credential);
274 len += GNUNET_RECLAIM_credential_serialize_get_size (le->credential);
275 len += sizeof(struct GNUNET_RECLAIM_CredentialListEntry);
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_credential_list_serialize (
290 const struct GNUNET_RECLAIM_CredentialList *credentials,
291 char *result)
292{
293 struct GNUNET_RECLAIM_CredentialListEntry *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 = credentials->list_head; NULL != le; le = le->next)
300 {
301 GNUNET_assert (NULL != le->credential);
302 len = GNUNET_RECLAIM_credential_serialize (le->credential, write_ptr);
303 total_len += len;
304 write_ptr += len;
305 }
306 return total_len;
307}
308
309
310/**
311 * Deserialize an credential 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_CredentialList *
318GNUNET_RECLAIM_credential_list_deserialize (const char *data, size_t data_size)
319{
320 struct GNUNET_RECLAIM_CredentialList *al;
321 struct GNUNET_RECLAIM_CredentialListEntry *ale;
322 size_t att_len;
323 const char *read_ptr;
324
325 al = GNUNET_new (struct GNUNET_RECLAIM_CredentialList);
326
327 if ((data_size < sizeof(struct
328 Credential)
329 + sizeof(struct GNUNET_RECLAIM_CredentialListEntry)))
330 return al;
331
332 read_ptr = data;
333 while (((data + data_size) - read_ptr) >= sizeof(struct Credential))
334 {
335 ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry);
336 ale->credential =
337 GNUNET_RECLAIM_credential_deserialize (read_ptr,
338 data_size - (read_ptr - data));
339 if (NULL == ale->credential)
340 {
341 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
342 "Failed to deserialize malformed credential.\n");
343 GNUNET_free (ale);
344 return al;
345 }
346 GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
347 att_len = GNUNET_RECLAIM_credential_serialize_get_size (ale->credential);
348 read_ptr += att_len;
349 }
350 return al;
351}
352
353
354/**
355 * Make a (deep) copy of the credential list
356 * @param attrs claim list to copy
357 * @return copied claim list
358 */
359struct GNUNET_RECLAIM_CredentialList *
360GNUNET_RECLAIM_credential_list_dup (
361 const struct GNUNET_RECLAIM_CredentialList *al)
362{
363 struct GNUNET_RECLAIM_CredentialListEntry *ale;
364 struct GNUNET_RECLAIM_CredentialListEntry *result_ale;
365 struct GNUNET_RECLAIM_CredentialList *result;
366
367 result = GNUNET_new (struct GNUNET_RECLAIM_CredentialList);
368 for (ale = al->list_head; NULL != ale; ale = ale->next)
369 {
370 result_ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry);
371 GNUNET_assert (NULL != ale->credential);
372 result_ale->credential =
373 GNUNET_RECLAIM_credential_new (ale->credential->name,
374 ale->credential->type,
375 ale->credential->data,
376 ale->credential->data_size);
377 result_ale->credential->id = ale->credential->id;
378 GNUNET_CONTAINER_DLL_insert (result->list_head,
379 result->list_tail,
380 result_ale);
381 }
382 return result;
383}
384
385
386/**
387 * Destroy credential list
388 *
389 * @param attrs list to destroy
390 */
391void
392GNUNET_RECLAIM_credential_list_destroy (
393 struct GNUNET_RECLAIM_CredentialList *al)
394{
395 struct GNUNET_RECLAIM_CredentialListEntry *ale;
396 struct GNUNET_RECLAIM_CredentialListEntry *tmp_ale;
397
398 for (ale = al->list_head; NULL != ale;)
399 {
400 if (NULL != ale->credential)
401 GNUNET_free (ale->credential);
402 tmp_ale = ale;
403 ale = ale->next;
404 GNUNET_free (tmp_ale);
405 }
406 GNUNET_free (al);
407}
408
409
410/**
411 * Get required size for serialization buffer
412 *
413 * @param attr the credential to serialize
414 * @return the required buffer size
415 */
416size_t
417GNUNET_RECLAIM_credential_serialize_get_size (
418 const struct GNUNET_RECLAIM_Credential *credential)
419{
420 return sizeof(struct Credential) + strlen (credential->name)
421 + credential->data_size;
422}
423
424
425/**
426 * Serialize an credential
427 *
428 * @param attr the credential to serialize
429 * @param result the serialized credential
430 * @return length of serialized data
431 */
432size_t
433GNUNET_RECLAIM_credential_serialize (
434 const struct GNUNET_RECLAIM_Credential *credential,
435 char *result)
436{
437 size_t data_len_ser;
438 size_t name_len;
439 struct Credential *atts;
440 char *write_ptr;
441
442 atts = (struct Credential *) result;
443 atts->credential_type = htons (credential->type);
444 atts->credential_flag = htonl (credential->flag);
445 atts->credential_id = credential->id;
446 name_len = strlen (credential->name);
447 atts->name_len = htons (name_len);
448 write_ptr = (char *) &atts[1];
449 GNUNET_memcpy (write_ptr, credential->name, name_len);
450 write_ptr += name_len;
451 // TODO plugin-ize
452 // data_len_ser = plugin->serialize_attribute_value (attr,
453 // &attr_ser[1]);
454 data_len_ser = credential->data_size;
455 GNUNET_memcpy (write_ptr, credential->data, credential->data_size);
456 atts->data_size = htons (data_len_ser);
457
458 return sizeof(struct Credential) + strlen (credential->name)
459 + credential->data_size;
460}
461
462
463/**
464 * Deserialize an credential
465 *
466 * @param data the serialized credential
467 * @param data_size the length of the serialized data
468 *
469 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
470 */
471struct GNUNET_RECLAIM_Credential *
472GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size)
473{
474 struct GNUNET_RECLAIM_Credential *credential;
475 struct Credential *atts;
476 size_t data_len;
477 size_t name_len;
478 char *write_ptr;
479
480 if (data_size < sizeof(struct Credential))
481 return NULL;
482
483 atts = (struct Credential *) data;
484 data_len = ntohs (atts->data_size);
485 name_len = ntohs (atts->name_len);
486 if (data_size < sizeof(struct Credential) + data_len + name_len)
487 {
488 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
489 "Buffer too small to deserialize\n");
490 return NULL;
491 }
492 credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential)
493 + data_len + name_len + 1);
494 credential->type = ntohs (atts->credential_type);
495 credential->flag = ntohl (atts->credential_flag);
496 credential->id = atts->credential_id;
497 credential->data_size = data_len;
498
499 write_ptr = (char *) &credential[1];
500 GNUNET_memcpy (write_ptr, &atts[1], name_len);
501 write_ptr[name_len] = '\0';
502 credential->name = write_ptr;
503
504 write_ptr += name_len + 1;
505 GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
506 credential->data_size);
507 credential->data = write_ptr;
508 return credential;
509}
510
511
512struct GNUNET_RECLAIM_AttributeList*
513GNUNET_RECLAIM_credential_get_attributes (const struct
514 GNUNET_RECLAIM_Credential *credential)
515{
516 unsigned int i;
517 struct Plugin *plugin;
518 struct GNUNET_RECLAIM_AttributeList *ret;
519 init ();
520 for (i = 0; i < num_plugins; i++)
521 {
522 plugin = credential_plugins[i];
523 if (NULL !=
524 (ret = plugin->api->get_attributes (plugin->api->cls,
525 credential)))
526 return ret;
527 }
528 return NULL;
529}
530
531
532char*
533GNUNET_RECLAIM_credential_get_issuer (const struct
534 GNUNET_RECLAIM_Credential *credential)
535{
536 unsigned int i;
537 struct Plugin *plugin;
538 char *ret;
539 init ();
540 for (i = 0; i < num_plugins; i++)
541 {
542 plugin = credential_plugins[i];
543 if (NULL !=
544 (ret = plugin->api->get_issuer (plugin->api->cls,
545 credential)))
546 return ret;
547 }
548 return NULL;
549}
550
551
552int
553GNUNET_RECLAIM_credential_get_expiration (const struct
554 GNUNET_RECLAIM_Credential *credential,
555 struct GNUNET_TIME_Absolute*exp)
556{
557 unsigned int i;
558 struct Plugin *plugin;
559 init ();
560 for (i = 0; i < num_plugins; i++)
561 {
562 plugin = credential_plugins[i];
563 if (GNUNET_OK != plugin->api->get_expiration (plugin->api->cls,
564 credential,
565 exp))
566 continue;
567 return GNUNET_OK;
568 }
569 return GNUNET_SYSERR;
570}
571
572
573/**
574 * Convert an presentation type name to the corresponding number
575 *
576 * @param typename name to convert
577 * @return corresponding number, UINT32_MAX on error
578 */
579uint32_t
580GNUNET_RECLAIM_presentation_typename_to_number (const char *typename)
581{
582 unsigned int i;
583 struct Plugin *plugin;
584 uint32_t ret;
585 init ();
586 for (i = 0; i < num_plugins; i++)
587 {
588 plugin = credential_plugins[i];
589 if (UINT32_MAX !=
590 (ret = plugin->api->typename_to_number_p (plugin->api->cls,
591 typename)))
592 return ret;
593 }
594 return UINT32_MAX;
595}
596
597
598/**
599 * Convert an presentation type number to the corresponding presentation type string
600 *
601 * @param type number of a type
602 * @return corresponding typestring, NULL on error
603 */
604const char *
605GNUNET_RECLAIM_presentation_number_to_typename (uint32_t type)
606{
607 unsigned int i;
608 struct Plugin *plugin;
609 const char *ret;
610
611 init ();
612 for (i = 0; i < num_plugins; i++)
613 {
614 plugin = credential_plugins[i];
615 if (NULL !=
616 (ret = plugin->api->number_to_typename_p (plugin->api->cls, type)))
617 return ret;
618 }
619 return NULL;
620}
621
622
623/**
624 * Convert human-readable version of a 'claim' of an presentation to the binary
625 * representation
626 *
627 * @param type type of the claim
628 * @param s human-readable string
629 * @param data set to value in binary encoding (will be allocated)
630 * @param data_size set to number of bytes in @a data
631 * @return #GNUNET_OK on success
632 */
633int
634GNUNET_RECLAIM_presentation_string_to_value (uint32_t type,
635 const char *s,
636 void **data,
637 size_t *data_size)
638{
639 unsigned int i;
640 struct Plugin *plugin;
641
642 init ();
643 for (i = 0; i < num_plugins; i++)
644 {
645 plugin = credential_plugins[i];
646 if (GNUNET_OK == plugin->api->string_to_value_p (plugin->api->cls,
647 type,
648 s,
649 data,
650 data_size))
651 return GNUNET_OK;
652 }
653 return GNUNET_SYSERR;
654}
655
656
657/**
658 * Convert the 'claim' of an presentation to a string
659 *
660 * @param type the type of presentation
661 * @param data claim in binary encoding
662 * @param data_size number of bytes in @a data
663 * @return NULL on error, otherwise human-readable representation of the claim
664 */
665char *
666GNUNET_RECLAIM_presentation_value_to_string (uint32_t type,
667 const void *data,
668 size_t data_size)
669{
670 unsigned int i;
671 struct Plugin *plugin;
672 char *ret;
673
674 init ();
675 for (i = 0; i < num_plugins; i++)
676 {
677 plugin = credential_plugins[i];
678 if (NULL != (ret = plugin->api->value_to_string_p (plugin->api->cls,
679 type,
680 data,
681 data_size)))
682 return ret;
683 }
684 return NULL;
685}
686
687
688struct GNUNET_RECLAIM_Presentation *
689GNUNET_RECLAIM_presentation_new (uint32_t type,
690 const void *data,
691 size_t data_size)
692{
693 struct GNUNET_RECLAIM_Presentation *attr;
694 char *write_ptr;
695
696 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
697 + data_size);
698 attr->type = type;
699 attr->data_size = data_size;
700 write_ptr = (char *) &attr[1];
701 GNUNET_memcpy (write_ptr, data, data_size);
702 attr->data = write_ptr;
703 return attr;
704}
705
706
707/**
708 * Get required size for serialization buffer
709 *
710 * @param attrs the attribute list to serialize
711 * @return the required buffer size
712 */
713size_t
714GNUNET_RECLAIM_presentation_list_serialize_get_size (
715 const struct GNUNET_RECLAIM_PresentationList *presentations)
716{
717 struct GNUNET_RECLAIM_PresentationListEntry *le;
718 size_t len = 0;
719
720 for (le = presentations->list_head; NULL != le; le = le->next)
721 {
722 GNUNET_assert (NULL != le->presentation);
723 len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation);
724 len += sizeof(struct GNUNET_RECLAIM_PresentationListEntry);
725 }
726 return len;
727}
728
729
730/**
731 * Serialize an attribute list
732 *
733 * @param attrs the attribute list to serialize
734 * @param result the serialized attribute
735 * @return length of serialized data
736 */
737size_t
738GNUNET_RECLAIM_presentation_list_serialize (
739 const struct GNUNET_RECLAIM_PresentationList *presentations,
740 char *result)
741{
742 struct GNUNET_RECLAIM_PresentationListEntry *le;
743 size_t len;
744 size_t total_len;
745 char *write_ptr;
746 write_ptr = result;
747 total_len = 0;
748 for (le = presentations->list_head; NULL != le; le = le->next)
749 {
750 GNUNET_assert (NULL != le->presentation);
751 len = GNUNET_RECLAIM_presentation_serialize (le->presentation, write_ptr);
752 total_len += len;
753 write_ptr += len;
754 }
755 return total_len;
756}
757
758
759/**
760 * Deserialize an presentation list
761 *
762 * @param data the serialized attribute list
763 * @param data_size the length of the serialized data
764 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
765 */
766struct GNUNET_RECLAIM_PresentationList *
767GNUNET_RECLAIM_presentation_list_deserialize (const char *data, size_t
768 data_size)
769{
770 struct GNUNET_RECLAIM_PresentationList *al;
771 struct GNUNET_RECLAIM_PresentationListEntry *ale;
772 size_t att_len;
773 const char *read_ptr;
774
775 al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
776
777 if ((data_size < sizeof(struct Presentation)
778 + sizeof(struct GNUNET_RECLAIM_PresentationListEntry)))
779 return al;
780
781 read_ptr = data;
782 while (((data + data_size) - read_ptr) >= sizeof(struct Presentation))
783 {
784 ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
785 ale->presentation =
786 GNUNET_RECLAIM_presentation_deserialize (read_ptr,
787 data_size - (read_ptr - data));
788 if (NULL == ale->presentation)
789 {
790 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
791 "Failed to deserialize malformed presentation.\n");
792 GNUNET_free (ale);
793 return al;
794 }
795 GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
796 att_len = GNUNET_RECLAIM_presentation_serialize_get_size (
797 ale->presentation);
798 read_ptr += att_len;
799 }
800 return al;
801}
802
803
804/**
805 * Make a (deep) copy of the presentation list
806 * @param attrs claim list to copy
807 * @return copied claim list
808 */
809struct GNUNET_RECLAIM_PresentationList *
810GNUNET_RECLAIM_presentation_list_dup (
811 const struct GNUNET_RECLAIM_PresentationList *al)
812{
813 struct GNUNET_RECLAIM_PresentationListEntry *ale;
814 struct GNUNET_RECLAIM_PresentationListEntry *result_ale;
815 struct GNUNET_RECLAIM_PresentationList *result;
816
817 result = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
818 for (ale = al->list_head; NULL != ale; ale = ale->next)
819 {
820 result_ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
821 GNUNET_assert (NULL != ale->presentation);
822 result_ale->presentation =
823 GNUNET_RECLAIM_presentation_new (ale->presentation->type,
824 ale->presentation->data,
825 ale->presentation->data_size);
826 result_ale->presentation->credential_id = ale->presentation->credential_id;
827 GNUNET_CONTAINER_DLL_insert (result->list_head,
828 result->list_tail,
829 result_ale);
830 }
831 return result;
832}
833
834
835/**
836 * Destroy presentation list
837 *
838 * @param attrs list to destroy
839 */
840void
841GNUNET_RECLAIM_presentation_list_destroy (
842 struct GNUNET_RECLAIM_PresentationList *al)
843{
844 struct GNUNET_RECLAIM_PresentationListEntry *ale;
845 struct GNUNET_RECLAIM_PresentationListEntry *tmp_ale;
846
847 for (ale = al->list_head; NULL != ale;)
848 {
849 if (NULL != ale->presentation)
850 GNUNET_free (ale->presentation);
851 tmp_ale = ale;
852 ale = ale->next;
853 GNUNET_free (tmp_ale);
854 }
855 GNUNET_free (al);
856}
857
858
859/**
860 * Get required size for serialization buffer
861 *
862 * @param attr the presentation to serialize
863 * @return the required buffer size
864 */
865size_t
866GNUNET_RECLAIM_presentation_serialize_get_size (
867 const struct GNUNET_RECLAIM_Presentation *presentation)
868{
869 return sizeof(struct Presentation) + presentation->data_size;
870}
871
872
873/**
874 * Serialize an presentation
875 *
876 * @param attr the presentation to serialize
877 * @param result the serialized presentation
878 * @return length of serialized data
879 */
880size_t
881GNUNET_RECLAIM_presentation_serialize (
882 const struct GNUNET_RECLAIM_Presentation *presentation,
883 char *result)
884{
885 struct Presentation *atts;
886 char *write_ptr;
887
888 atts = (struct Presentation *) result;
889 atts->presentation_type = htons (presentation->type);
890 atts->credential_id = presentation->credential_id;
891 write_ptr = (char *) &atts[1];
892 GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size);
893 atts->data_size = htons (presentation->data_size);
894
895 return sizeof(struct Presentation) + presentation->data_size;
896}
897
898
899/**
900 * Deserialize an presentation
901 *
902 * @param data the serialized presentation
903 * @param data_size the length of the serialized data
904 *
905 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
906 */
907struct GNUNET_RECLAIM_Presentation *
908GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size)
909{
910 struct GNUNET_RECLAIM_Presentation *presentation;
911 struct Presentation *atts;
912 size_t data_len;
913 char *write_ptr;
914
915 if (data_size < sizeof(struct Presentation))
916 return NULL;
917
918 atts = (struct Presentation *) data;
919 data_len = ntohs (atts->data_size);
920 if (data_size < sizeof(struct Presentation) + data_len)
921 {
922 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
923 "Buffer too small to deserialize\n");
924 return NULL;
925 }
926 presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
927 + data_len);
928 presentation->type = ntohs (atts->presentation_type);
929 presentation->credential_id = atts->credential_id;
930 presentation->data_size = data_len;
931
932 write_ptr = (char *) &presentation[1];
933 GNUNET_memcpy (write_ptr, &atts[1], data_len);
934 presentation->data = write_ptr;
935 return presentation;
936}
937
938
939struct GNUNET_RECLAIM_AttributeList*
940GNUNET_RECLAIM_presentation_get_attributes (const struct
941 GNUNET_RECLAIM_Presentation *
942 presentation)
943{
944 unsigned int i;
945 struct Plugin *plugin;
946 struct GNUNET_RECLAIM_AttributeList *ret;
947 init ();
948 for (i = 0; i < num_plugins; i++)
949 {
950 plugin = credential_plugins[i];
951 if (NULL !=
952 (ret = plugin->api->get_attributes_p (plugin->api->cls,
953 presentation)))
954 return ret;
955 }
956 return NULL;
957}
958
959
960char*
961GNUNET_RECLAIM_presentation_get_issuer (const struct
962 GNUNET_RECLAIM_Presentation *
963 presentation)
964{
965 unsigned int i;
966 struct Plugin *plugin;
967 char *ret;
968 init ();
969 for (i = 0; i < num_plugins; i++)
970 {
971 plugin = credential_plugins[i];
972 if (NULL !=
973 (ret = plugin->api->get_issuer_p (plugin->api->cls,
974 presentation)))
975 return ret;
976 }
977 return NULL;
978}
979
980
981int
982GNUNET_RECLAIM_presentation_get_expiration (const struct
983 GNUNET_RECLAIM_Presentation *
984 presentation,
985 struct GNUNET_TIME_Absolute*exp)
986{
987 unsigned int i;
988 struct Plugin *plugin;
989 init ();
990 for (i = 0; i < num_plugins; i++)
991 {
992 plugin = credential_plugins[i];
993 if (GNUNET_OK != plugin->api->get_expiration_p (plugin->api->cls,
994 presentation,
995 exp))
996 continue;
997 return GNUNET_OK;
998 }
999 return GNUNET_SYSERR;
1000}
1001
1002/**
1003 * Create a presentation from a credential and a lift of (selected)
1004 * attributes in the credential.
1005 * FIXME not yet implemented
1006 *
1007 * @param cred the credential to use
1008 * @param attrs the attributes to present from the credential
1009 * @return the credential presentation presenting the attributes according
1010 * to the presentation mechanism of the credential
1011 * or NULL on error.
1012 */
1013int
1014GNUNET_RECLAIM_credential_get_presentation (
1015 const struct GNUNET_RECLAIM_Credential *cred,
1016 const struct GNUNET_RECLAIM_AttributeList *attrs,
1017 struct GNUNET_RECLAIM_Presentation **pres)
1018{
1019 unsigned int i;
1020 struct Plugin *plugin;
1021 init ();
1022 for (i = 0; i < num_plugins; i++)
1023 {
1024 plugin = credential_plugins[i];
1025 if (GNUNET_OK != plugin->api->create_presentation (plugin->api->cls,
1026 cred,
1027 attrs,
1028 pres))
1029 continue;
1030 (*pres)->credential_id = cred->id;
1031 return GNUNET_OK;
1032 }
1033 return GNUNET_SYSERR;
1034}
1035
1036
1037
diff --git a/src/reclaim/reclaim_attestation.h b/src/reclaim/reclaim_credential.h
index 5747d8896..7704ed968 100644
--- a/src/reclaim/reclaim_attestation.h
+++ b/src/reclaim/reclaim_credential.h
@@ -19,34 +19,34 @@
19 */ 19 */
20/** 20/**
21 * @author Martin Schanzenbach 21 * @author Martin Schanzenbach
22 * @file reclaim-attribute/reclaim_attestation.h 22 * @file reclaim/reclaim_credential.h
23 * @brief GNUnet reclaim identity attribute attestations 23 * @brief GNUnet reclaim identity attribute credentials
24 * 24 *
25 */ 25 */
26#ifndef RECLAIM_ATTESTATION_H 26#ifndef RECLAIM_CREDENTIAL_H
27#define RECLAIM_ATTESTATION_H 27#define RECLAIM_CREDENTIAL_H
28 28
29#include "gnunet_reclaim_service.h" 29#include "gnunet_reclaim_service.h"
30 30
31/** 31/**
32 * Serialized attestation claim 32 * Serialized credential claim
33 */ 33 */
34struct Attestation 34struct Credential
35{ 35{
36 /** 36 /**
37 * Attestation type 37 * Credential type
38 */ 38 */
39 uint32_t attestation_type; 39 uint32_t credential_type;
40 40
41 /** 41 /**
42 * Attestation flag 42 * Credential flag
43 */ 43 */
44 uint32_t attestation_flag; 44 uint32_t credential_flag;
45 45
46 /** 46 /**
47 * Attestation ID 47 * Credential ID
48 */ 48 */
49 struct GNUNET_RECLAIM_Identifier attestation_id; 49 struct GNUNET_RECLAIM_Identifier credential_id;
50 50
51 /** 51 /**
52 * Name length 52 * Name length
@@ -58,7 +58,42 @@ struct Attestation
58 */ 58 */
59 uint32_t data_size; 59 uint32_t data_size;
60 60
61 // followed by data_size Attestation value data 61 // followed by data_size Credential value data
62}; 62};
63 63
64
65/**
66 * Serialized presentation claim
67 */
68struct Presentation
69{
70 /**
71 * Presentation type
72 */
73 uint32_t presentation_type;
74
75 /**
76 * Presentation flag
77 */
78 uint32_t presentation_flag;
79
80 /**
81 * Credential ID
82 */
83 struct GNUNET_RECLAIM_Identifier credential_id;
84
85 /**
86 * Name length
87 */
88 uint32_t name_len;
89
90 /**
91 * Data size
92 */
93 uint32_t data_size;
94
95 // followed by data_size Presentation value data
96};
97
98
64#endif 99#endif