diff options
Diffstat (limited to 'src/reclaim')
21 files changed, 2415 insertions, 1481 deletions
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am index a9829c47e..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 | ||
16 | ATTESTATION_PLUGIN = \ | 16 | CREDENTIAL_PLUGIN = \ |
17 | libgnunet_plugin_reclaim_attestation_jwt.la | 17 | libgnunet_plugin_reclaim_credential_jwt.la |
18 | 18 | ||
19 | EXTRA_DIST = \ | 19 | EXTRA_DIST = \ |
20 | reclaim.conf \ | 20 | reclaim.conf \ |
@@ -34,7 +34,7 @@ lib_LTLIBRARIES = \ | |||
34 | plugin_LTLIBRARIES = \ | 34 | plugin_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 | ||
40 | bin_PROGRAMS = \ | 40 | bin_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 |
120 | libgnunetreclaim_la_LIBADD = \ | 120 | libgnunetreclaim_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 = \ | |||
133 | libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \ | 133 | libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \ |
134 | $(GN_PLUGIN_LDFLAGS) | 134 | $(GN_PLUGIN_LDFLAGS) |
135 | 135 | ||
136 | libgnunet_plugin_reclaim_attestation_jwt_la_SOURCES = \ | 136 | libgnunet_plugin_reclaim_credential_jwt_la_SOURCES = \ |
137 | plugin_reclaim_attestation_jwt.c | 137 | plugin_reclaim_credential_jwt.c |
138 | libgnunet_plugin_reclaim_attestation_jwt_la_LIBADD = \ | 138 | libgnunet_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) |
143 | libgnunet_plugin_reclaim_attestation_jwt_la_LDFLAGS = \ | 143 | libgnunet_plugin_reclaim_credential_jwt_la_LDFLAGS = \ |
144 | $(GN_PLUGIN_LDFLAGS) | 144 | $(GN_PLUGIN_LDFLAGS) |
145 | 145 | ||
146 | gnunet_reclaim_SOURCES = \ | 146 | gnunet_reclaim_SOURCES = \ |
@@ -152,11 +152,20 @@ gnunet_reclaim_LDADD = \ | |||
152 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 152 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
153 | $(GN_LIBINTL) | 153 | $(GN_LIBINTL) |
154 | 154 | ||
155 | test_reclaim_attribute_SOURCES = \ | ||
156 | test_reclaim_attribute.c | ||
157 | test_reclaim_attribute_LDADD = \ | ||
158 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
159 | libgnunetreclaim.la \ | ||
160 | $(GN_LIBINTL) | ||
161 | |||
155 | check_SCRIPTS = \ | 162 | check_SCRIPTS = \ |
156 | test_reclaim_attribute.sh \ | 163 | test_reclaim_attribute.sh \ |
157 | test_reclaim_issue.sh \ | 164 | test_reclaim_issue.sh \ |
158 | test_reclaim_consume.sh | 165 | test_reclaim_consume.sh |
159 | # test_reclaim_revoke.sh | 166 | |
167 | check_PROGRAMS = \ | ||
168 | test_reclaim_attribute | ||
160 | 169 | ||
161 | if ENABLE_TEST_RUN | 170 | if ENABLE_TEST_RUN |
162 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 171 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
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; | |||
43 | static int list; | 43 | static int list; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * List attestations flag | 46 | * List credentials flag |
47 | */ | 47 | */ |
48 | static int list_attestations; | 48 | static int list_credentials; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Attestation ID string | 51 | * Credential ID string |
52 | */ | 52 | */ |
53 | static char *attestation_id; | 53 | static char *credential_id; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Attestation ID | 56 | * Credential ID |
57 | */ | 57 | */ |
58 | static struct GNUNET_RECLAIM_Identifier attestation; | 58 | static struct GNUNET_RECLAIM_Identifier credential; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Attestation name | 61 | * Credential name |
62 | */ | 62 | */ |
63 | static char *attestation_name; | 63 | static char *credential_name; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Attestation exists | 66 | * Credential type |
67 | */ | 67 | */ |
68 | static int attestation_exists; | 68 | static char *credential_type; |
69 | |||
70 | /** | ||
71 | * Credential exists | ||
72 | */ | ||
73 | static int credential_exists; | ||
69 | 74 | ||
70 | /** | 75 | /** |
71 | * Relying party | 76 | * Relying party |
@@ -133,9 +138,9 @@ static struct GNUNET_RECLAIM_Operation *reclaim_op; | |||
133 | static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; | 138 | static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; |
134 | 139 | ||
135 | /** | 140 | /** |
136 | * Attestation iterator | 141 | * Credential iterator |
137 | */ | 142 | */ |
138 | static struct GNUNET_RECLAIM_AttestationIterator *attest_iterator; | 143 | static 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 | */ |
144 | static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator; | 149 | static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator; |
145 | 150 | ||
146 | /** | ||
147 | * Master ABE key | ||
148 | */ | ||
149 | static 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 | ||
228 | static void | 229 | static void |
229 | ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | 230 | ticket_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 | |||
260 | process_attrs (void *cls, | 263 | process_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 | |||
362 | iter_error (void *cls) | 363 | iter_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 | ||
610 | static void | 612 | static void |
611 | attest_iter_finished (void *cls) | 613 | cred_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 | ||
650 | static void | 654 | static void |
651 | attest_iter_cb (void *cls, | 655 | cred_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 0cd8c10a5..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 | |||
646 | send_ticket_result (const struct IdpClient *client, | 646 | send_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 | */ |
675 | static void | 690 | static void |
676 | issue_ticket_result_cb (void *cls, | 691 | issue_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); |
@@ -732,6 +749,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
732 | struct TicketIssueOperation *tio; | 749 | struct TicketIssueOperation *tio; |
733 | struct IdpClient *idp = cls; | 750 | struct IdpClient *idp = cls; |
734 | struct GNUNET_RECLAIM_AttributeList *attrs; | 751 | struct GNUNET_RECLAIM_AttributeList *attrs; |
752 | struct GNUNET_RECLAIM_AttributeListEntry *le; | ||
735 | size_t attrs_len; | 753 | size_t attrs_len; |
736 | 754 | ||
737 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); | 755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); |
@@ -739,6 +757,10 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
739 | attrs_len = ntohs (im->attr_len); | 757 | attrs_len = ntohs (im->attr_len); |
740 | attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1], | 758 | attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1], |
741 | attrs_len); | 759 | attrs_len); |
760 | for (le = attrs->list_head; NULL != le; le = le->next) | ||
761 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
762 | "List entry: %s\n", le->attribute->name); | ||
763 | |||
742 | tio->r_id = ntohl (im->id); | 764 | tio->r_id = ntohl (im->id); |
743 | tio->client = idp; | 765 | tio->client = idp; |
744 | GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); | 766 | GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); |
@@ -842,7 +864,7 @@ static void | |||
842 | consume_result_cb (void *cls, | 864 | consume_result_cb (void *cls, |
843 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 865 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
844 | const struct GNUNET_RECLAIM_AttributeList *attrs, | 866 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
845 | const struct GNUNET_RECLAIM_AttestationList *attests, | 867 | const struct GNUNET_RECLAIM_PresentationList *presentations, |
846 | int32_t success, | 868 | int32_t success, |
847 | const char *emsg) | 869 | const char *emsg) |
848 | { | 870 | { |
@@ -851,28 +873,28 @@ consume_result_cb (void *cls, | |||
851 | struct GNUNET_MQ_Envelope *env; | 873 | struct GNUNET_MQ_Envelope *env; |
852 | char *data_tmp; | 874 | char *data_tmp; |
853 | size_t attrs_len = 0; | 875 | size_t attrs_len = 0; |
854 | size_t attests_len = 0; | 876 | size_t pres_len = 0; |
855 | 877 | ||
856 | if (GNUNET_OK != success) | 878 | if (GNUNET_OK != success) |
857 | { | 879 | { |
858 | 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); |
859 | } | 881 | } |
860 | attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); | 882 | attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); |
861 | attests_len = GNUNET_RECLAIM_attestation_list_serialize_get_size (attests); | 883 | pres_len = GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations); |
862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 884 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
863 | "Sending CONSUME_TICKET_RESULT message\n"); | 885 | "Sending CONSUME_TICKET_RESULT message\n"); |
864 | env = GNUNET_MQ_msg_extra (crm, | 886 | env = GNUNET_MQ_msg_extra (crm, |
865 | attrs_len + attests_len, | 887 | attrs_len + pres_len, |
866 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); | 888 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); |
867 | crm->id = htonl (cop->r_id); | 889 | crm->id = htonl (cop->r_id); |
868 | crm->attrs_len = htons (attrs_len); | 890 | crm->attrs_len = htons (attrs_len); |
869 | crm->attestations_len = htons (attests_len); | 891 | crm->presentations_len = htons (pres_len); |
870 | crm->identity = *identity; | 892 | crm->identity = *identity; |
871 | crm->result = htonl (success); | 893 | crm->result = htonl (success); |
872 | data_tmp = (char *) &crm[1]; | 894 | data_tmp = (char *) &crm[1]; |
873 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); | 895 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); |
874 | data_tmp += attrs_len; | 896 | data_tmp += attrs_len; |
875 | GNUNET_RECLAIM_attestation_list_serialize (attests, data_tmp); | 897 | GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp); |
876 | GNUNET_MQ_send (cop->client->mq, env); | 898 | GNUNET_MQ_send (cop->client->mq, env); |
877 | GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, | 899 | GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, |
878 | cop->client->consume_op_tail, | 900 | cop->client->consume_op_tail, |
@@ -1053,8 +1075,9 @@ handle_attribute_store_message (void *cls, | |||
1053 | data_len = ntohs (sam->attr_len); | 1075 | data_len = ntohs (sam->attr_len); |
1054 | 1076 | ||
1055 | ash = GNUNET_new (struct AttributeStoreHandle); | 1077 | ash = GNUNET_new (struct AttributeStoreHandle); |
1056 | ash->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1], | 1078 | GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1], |
1057 | data_len); | 1079 | data_len, |
1080 | &ash->claim); | ||
1058 | 1081 | ||
1059 | ash->r_id = ntohl (sam->id); | 1082 | ash->r_id = ntohl (sam->id); |
1060 | ash->identity = sam->identity; | 1083 | ash->identity = sam->identity; |
@@ -1069,14 +1092,14 @@ handle_attribute_store_message (void *cls, | |||
1069 | 1092 | ||
1070 | 1093 | ||
1071 | /** | 1094 | /** |
1072 | * Attestation store result handler | 1095 | * Credential store result handler |
1073 | * | 1096 | * |
1074 | * @param cls our attribute store handle | 1097 | * @param cls our attribute store handle |
1075 | * @param success GNUNET_OK if successful | 1098 | * @param success GNUNET_OK if successful |
1076 | * @param emsg error message (NULL if success=GNUNET_OK) | 1099 | * @param emsg error message (NULL if success=GNUNET_OK) |
1077 | */ | 1100 | */ |
1078 | static void | 1101 | static void |
1079 | attest_store_cont (void *cls, int32_t success, const char *emsg) | 1102 | cred_store_cont (void *cls, int32_t success, const char *emsg) |
1080 | { | 1103 | { |
1081 | struct AttributeStoreHandle *ash = cls; | 1104 | struct AttributeStoreHandle *ash = cls; |
1082 | struct GNUNET_MQ_Envelope *env; | 1105 | struct GNUNET_MQ_Envelope *env; |
@@ -1090,7 +1113,7 @@ attest_store_cont (void *cls, int32_t success, const char *emsg) | |||
1090 | if (GNUNET_SYSERR == success) | 1113 | if (GNUNET_SYSERR == success) |
1091 | { | 1114 | { |
1092 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1093 | "Failed to store attestation %s\n", | 1116 | "Failed to store credential: %s\n", |
1094 | emsg); | 1117 | emsg); |
1095 | cleanup_as_handle (ash); | 1118 | cleanup_as_handle (ash); |
1096 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1119 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
@@ -1107,16 +1130,16 @@ attest_store_cont (void *cls, int32_t success, const char *emsg) | |||
1107 | 1130 | ||
1108 | 1131 | ||
1109 | /** | 1132 | /** |
1110 | * Error looking up potential attestation. Abort. | 1133 | * Error looking up potential credential. Abort. |
1111 | * | 1134 | * |
1112 | * @param cls our attribute store handle | 1135 | * @param cls our attribute store handle |
1113 | */ | 1136 | */ |
1114 | static void | 1137 | static void |
1115 | attest_error (void *cls) | 1138 | cred_error (void *cls) |
1116 | { | 1139 | { |
1117 | struct AttributeStoreHandle *ash = cls; | 1140 | struct AttributeStoreHandle *ash = cls; |
1118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1141 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1119 | "Failed to check for existing Attestation\n"); | 1142 | "Failed to check for existing credential.\n"); |
1120 | cleanup_as_handle (ash); | 1143 | cleanup_as_handle (ash); |
1121 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1144 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1122 | return; | 1145 | return; |
@@ -1124,7 +1147,7 @@ attest_error (void *cls) | |||
1124 | 1147 | ||
1125 | 1148 | ||
1126 | /** | 1149 | /** |
1127 | * Check for existing record before storing attestation | 1150 | * Check for existing record before storing credential |
1128 | * | 1151 | * |
1129 | * @param cls our attribute store handle | 1152 | * @param cls our attribute store handle |
1130 | * @param zone zone we are iterating | 1153 | * @param zone zone we are iterating |
@@ -1133,33 +1156,34 @@ attest_error (void *cls) | |||
1133 | * @param rd records | 1156 | * @param rd records |
1134 | */ | 1157 | */ |
1135 | static void | 1158 | static void |
1136 | attest_add_cb (void *cls, | 1159 | cred_add_cb (void *cls, |
1137 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1160 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1138 | const char *label, | 1161 | const char *label, |
1139 | unsigned int rd_count, | 1162 | unsigned int rd_count, |
1140 | const struct GNUNET_GNSRECORD_Data *rd) | 1163 | const struct GNUNET_GNSRECORD_Data *rd) |
1141 | { | 1164 | { |
1142 | struct AttributeStoreHandle *ash = cls; | 1165 | struct AttributeStoreHandle *ash = cls; |
1166 | struct GNUNET_GNSRECORD_Data rd_new[1]; | ||
1143 | char *buf; | 1167 | char *buf; |
1144 | size_t buf_size; | 1168 | size_t buf_size; |
1145 | buf_size = GNUNET_RECLAIM_attestation_serialize_get_size (ash->attest); | 1169 | |
1170 | buf_size = GNUNET_RECLAIM_credential_serialize_get_size (ash->credential); | ||
1146 | buf = GNUNET_malloc (buf_size); | 1171 | buf = GNUNET_malloc (buf_size); |
1147 | GNUNET_RECLAIM_attestation_serialize (ash->attest, buf); | 1172 | GNUNET_RECLAIM_credential_serialize (ash->credential, buf); |
1148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1149 | "Storing new Attestation\n"); | 1174 | "Storing new credential under `%s'.\n", |
1150 | struct GNUNET_GNSRECORD_Data rd_new[1]; | 1175 | label); |
1151 | rd_new[0].data_size = buf_size; | 1176 | rd_new[0].data_size = buf_size; |
1152 | rd_new[0].data = buf; | 1177 | rd_new[0].data = buf; |
1153 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION; | 1178 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL; |
1154 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1179 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1155 | rd_new[0].expiration_time = ash->exp.rel_value_us; | 1180 | rd_new[0].expiration_time = ash->exp.rel_value_us; |
1156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1157 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1181 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
1158 | &ash->identity, | 1182 | &ash->identity, |
1159 | label, | 1183 | label, |
1160 | 1, | 1184 | 1, |
1161 | rd_new, | 1185 | rd_new, |
1162 | &attest_store_cont, | 1186 | &cred_store_cont, |
1163 | ash); | 1187 | ash); |
1164 | GNUNET_free (buf); | 1188 | GNUNET_free (buf); |
1165 | return; | 1189 | return; |
@@ -1167,44 +1191,43 @@ attest_add_cb (void *cls, | |||
1167 | 1191 | ||
1168 | 1192 | ||
1169 | /** | 1193 | /** |
1170 | * Add a new attestation | 1194 | * Add a new credential |
1171 | * | 1195 | * |
1172 | * @param cls the AttributeStoreHandle | 1196 | * @param cls the AttributeStoreHandle |
1173 | */ | 1197 | */ |
1174 | static void | 1198 | static void |
1175 | attest_store_task (void *cls) | 1199 | cred_store_task (void *cls) |
1176 | { | 1200 | { |
1177 | struct AttributeStoreHandle *ash = cls; | 1201 | struct AttributeStoreHandle *ash = cls; |
1178 | char *label; | 1202 | char *label; |
1179 | 1203 | ||
1180 | // Give the ash a new id if unset | 1204 | // Give the ash a new id if unset |
1181 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->attest->id)) | 1205 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->credential->id)) |
1182 | GNUNET_RECLAIM_id_generate (&ash->attest->id); | 1206 | GNUNET_RECLAIM_id_generate (&ash->credential->id); |
1183 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, | 1207 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->credential->id, |
1184 | sizeof (ash->attest->id)); | 1208 | sizeof (ash->credential->id)); |
1185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1186 | "Looking up existing data under label %s\n", label); | 1210 | "Looking up existing data under label `%s'\n", label); |
1187 | // Test for the content of the existing ID | ||
1188 | ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | 1211 | ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, |
1189 | &ash->identity, | 1212 | &ash->identity, |
1190 | label, | 1213 | label, |
1191 | &attest_error, | 1214 | &cred_error, |
1192 | ash, | 1215 | ash, |
1193 | &attest_add_cb, | 1216 | &cred_add_cb, |
1194 | ash); | 1217 | ash); |
1195 | GNUNET_free (label); | 1218 | GNUNET_free (label); |
1196 | } | 1219 | } |
1197 | 1220 | ||
1198 | 1221 | ||
1199 | /** | 1222 | /** |
1200 | * Check an attestation store message | 1223 | * Check an credential store message |
1201 | * | 1224 | * |
1202 | * @param cls unused | 1225 | * @param cls unused |
1203 | * @param sam the message to check | 1226 | * @param sam the message to check |
1204 | */ | 1227 | */ |
1205 | static int | 1228 | static int |
1206 | check_attestation_store_message (void *cls, | 1229 | check_credential_store_message (void *cls, |
1207 | const struct AttributeStoreMessage *sam) | 1230 | const struct AttributeStoreMessage *sam) |
1208 | { | 1231 | { |
1209 | uint16_t size; | 1232 | uint16_t size; |
1210 | 1233 | ||
@@ -1219,26 +1242,26 @@ check_attestation_store_message (void *cls, | |||
1219 | 1242 | ||
1220 | 1243 | ||
1221 | /** | 1244 | /** |
1222 | * Handle an attestation store message | 1245 | * Handle a credential store message |
1223 | * | 1246 | * |
1224 | * @param cls our client | 1247 | * @param cls our client |
1225 | * @param sam the message to handle | 1248 | * @param sam the message to handle |
1226 | */ | 1249 | */ |
1227 | static void | 1250 | static void |
1228 | handle_attestation_store_message (void *cls, | 1251 | handle_credential_store_message (void *cls, |
1229 | const struct AttributeStoreMessage *sam) | 1252 | const struct AttributeStoreMessage *sam) |
1230 | { | 1253 | { |
1231 | struct AttributeStoreHandle *ash; | 1254 | struct AttributeStoreHandle *ash; |
1232 | struct IdpClient *idp = cls; | 1255 | struct IdpClient *idp = cls; |
1233 | size_t data_len; | 1256 | size_t data_len; |
1234 | 1257 | ||
1235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_STORE message\n"); | 1258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n"); |
1236 | 1259 | ||
1237 | data_len = ntohs (sam->attr_len); | 1260 | data_len = ntohs (sam->attr_len); |
1238 | 1261 | ||
1239 | ash = GNUNET_new (struct AttributeStoreHandle); | 1262 | ash = GNUNET_new (struct AttributeStoreHandle); |
1240 | ash->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &sam[1], | 1263 | ash->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &sam[1], |
1241 | data_len); | 1264 | data_len); |
1242 | 1265 | ||
1243 | ash->r_id = ntohl (sam->id); | 1266 | ash->r_id = ntohl (sam->id); |
1244 | ash->identity = sam->identity; | 1267 | ash->identity = sam->identity; |
@@ -1248,7 +1271,7 @@ handle_attestation_store_message (void *cls, | |||
1248 | GNUNET_SERVICE_client_continue (idp->client); | 1271 | GNUNET_SERVICE_client_continue (idp->client); |
1249 | ash->client = idp; | 1272 | ash->client = idp; |
1250 | 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); |
1251 | GNUNET_SCHEDULER_add_now (&attest_store_task, ash); | 1274 | GNUNET_SCHEDULER_add_now (&cred_store_task, ash); |
1252 | } | 1275 | } |
1253 | 1276 | ||
1254 | 1277 | ||
@@ -1304,12 +1327,12 @@ ticket_iter (void *cls, | |||
1304 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1327 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1305 | &adh->claim->id)) | 1328 | &adh->claim->id)) |
1306 | continue; | 1329 | continue; |
1307 | if (adh->attest != NULL) | 1330 | if (adh->credential != NULL) |
1308 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1331 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1309 | &adh->attest->id)) | 1332 | &adh->credential->id)) |
1310 | continue; | 1333 | continue; |
1311 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1334 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1312 | "Attribute or Attestation to delete found (%s)\n", | 1335 | "Attribute to delete found (%s)\n", |
1313 | adh->label); | 1336 | adh->label); |
1314 | has_changed = GNUNET_YES; | 1337 | has_changed = GNUNET_YES; |
1315 | break; | 1338 | break; |
@@ -1404,10 +1427,10 @@ update_tickets (void *cls) | |||
1404 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1427 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1405 | &adh->claim->id))) | 1428 | &adh->claim->id))) |
1406 | continue; | 1429 | continue; |
1407 | if (adh->attest != NULL) | 1430 | if (adh->credential != NULL) |
1408 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) | 1431 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) |
1409 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1432 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1410 | &adh->attest->id))) | 1433 | &adh->credential->id))) |
1411 | continue; | 1434 | continue; |
1412 | rd_new[j] = rd[i]; | 1435 | rd_new[j] = rd[i]; |
1413 | j++; | 1436 | j++; |
@@ -1548,9 +1571,10 @@ handle_attribute_delete_message (void *cls, | |||
1548 | data_len = ntohs (dam->attr_len); | 1571 | data_len = ntohs (dam->attr_len); |
1549 | 1572 | ||
1550 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1573 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1551 | adh->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1], | 1574 | GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1], |
1552 | data_len); | 1575 | data_len, |
1553 | adh->attest = NULL; | 1576 | &adh->claim); |
1577 | adh->credential = NULL; | ||
1554 | 1578 | ||
1555 | adh->r_id = ntohl (dam->id); | 1579 | adh->r_id = ntohl (dam->id); |
1556 | adh->identity = dam->identity; | 1580 | adh->identity = dam->identity; |
@@ -1571,14 +1595,14 @@ handle_attribute_delete_message (void *cls, | |||
1571 | 1595 | ||
1572 | 1596 | ||
1573 | /** | 1597 | /** |
1574 | * Attestation deleted callback | 1598 | * Credential deleted callback |
1575 | * | 1599 | * |
1576 | * @param cls our handle | 1600 | * @param cls our handle |
1577 | * @param success success status | 1601 | * @param success success status |
1578 | * @param emsg error message (NULL if success=GNUNET_OK) | 1602 | * @param emsg error message (NULL if success=GNUNET_OK) |
1579 | */ | 1603 | */ |
1580 | static void | 1604 | static void |
1581 | attest_delete_cont (void *cls, int32_t success, const char *emsg) | 1605 | cred_delete_cont (void *cls, int32_t success, const char *emsg) |
1582 | { | 1606 | { |
1583 | struct AttributeDeleteHandle *adh = cls; | 1607 | struct AttributeDeleteHandle *adh = cls; |
1584 | 1608 | ||
@@ -1586,7 +1610,7 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1586 | if (GNUNET_SYSERR == success) | 1610 | if (GNUNET_SYSERR == success) |
1587 | { | 1611 | { |
1588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1612 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1589 | "Error deleting attestation %s\n", | 1613 | "Error deleting credential `%s'\n", |
1590 | adh->label); | 1614 | adh->label); |
1591 | send_delete_response (adh, GNUNET_SYSERR); | 1615 | send_delete_response (adh, GNUNET_SYSERR); |
1592 | cleanup_adh (adh); | 1616 | cleanup_adh (adh); |
@@ -1598,14 +1622,14 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1598 | 1622 | ||
1599 | 1623 | ||
1600 | /** | 1624 | /** |
1601 | * Check attestation delete message format | 1625 | * Check credential delete message format |
1602 | * | 1626 | * |
1603 | * @cls unused | 1627 | * @cls unused |
1604 | * @dam message to check | 1628 | * @dam message to check |
1605 | */ | 1629 | */ |
1606 | static int | 1630 | static int |
1607 | check_attestation_delete_message (void *cls, | 1631 | check_credential_delete_message (void *cls, |
1608 | const struct AttributeDeleteMessage *dam) | 1632 | const struct AttributeDeleteMessage *dam) |
1609 | { | 1633 | { |
1610 | uint16_t size; | 1634 | uint16_t size; |
1611 | 1635 | ||
@@ -1620,33 +1644,33 @@ check_attestation_delete_message (void *cls, | |||
1620 | 1644 | ||
1621 | 1645 | ||
1622 | /** | 1646 | /** |
1623 | * Handle attestation deletion | 1647 | * Handle credential deletion |
1624 | * | 1648 | * |
1625 | * @param cls our client | 1649 | * @param cls our client |
1626 | * @param dam deletion message | 1650 | * @param dam deletion message |
1627 | */ | 1651 | */ |
1628 | static void | 1652 | static void |
1629 | handle_attestation_delete_message (void *cls, | 1653 | handle_credential_delete_message (void *cls, |
1630 | const struct AttributeDeleteMessage *dam) | 1654 | const struct AttributeDeleteMessage *dam) |
1631 | { | 1655 | { |
1632 | struct AttributeDeleteHandle *adh; | 1656 | struct AttributeDeleteHandle *adh; |
1633 | struct IdpClient *idp = cls; | 1657 | struct IdpClient *idp = cls; |
1634 | size_t data_len; | 1658 | size_t data_len; |
1635 | 1659 | ||
1636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_DELETE message\n"); | 1660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n"); |
1637 | 1661 | ||
1638 | data_len = ntohs (dam->attr_len); | 1662 | data_len = ntohs (dam->attr_len); |
1639 | 1663 | ||
1640 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1664 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1641 | adh->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &dam[1], | 1665 | adh->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &dam[1], |
1642 | data_len); | 1666 | data_len); |
1643 | adh->claim = NULL; | 1667 | adh->claim = NULL; |
1644 | 1668 | ||
1645 | adh->r_id = ntohl (dam->id); | 1669 | adh->r_id = ntohl (dam->id); |
1646 | adh->identity = dam->identity; | 1670 | adh->identity = dam->identity; |
1647 | adh->label | 1671 | adh->label |
1648 | = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, | 1672 | = GNUNET_STRINGS_data_to_string_alloc (&adh->credential->id, |
1649 | sizeof(adh->attest->id)); | 1673 | sizeof(adh->credential->id)); |
1650 | GNUNET_SERVICE_client_continue (idp->client); | 1674 | GNUNET_SERVICE_client_continue (idp->client); |
1651 | adh->client = idp; | 1675 | adh->client = idp; |
1652 | 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); |
@@ -1655,7 +1679,7 @@ handle_attestation_delete_message (void *cls, | |||
1655 | adh->label, | 1679 | adh->label, |
1656 | 0, | 1680 | 0, |
1657 | NULL, | 1681 | NULL, |
1658 | &attest_delete_cont, | 1682 | &cred_delete_cont, |
1659 | adh); | 1683 | adh); |
1660 | } | 1684 | } |
1661 | 1685 | ||
@@ -1705,7 +1729,7 @@ attr_iter_error (void *cls) | |||
1705 | 1729 | ||
1706 | 1730 | ||
1707 | /** | 1731 | /** |
1708 | * Got record. Return if it is an attribute or attestation. | 1732 | * Got record. Return if it is an attribute. |
1709 | * | 1733 | * |
1710 | * @param cls our attribute iterator | 1734 | * @param cls our attribute iterator |
1711 | * @param zone zone we are iterating | 1735 | * @param zone zone we are iterating |
@@ -1845,51 +1869,51 @@ handle_iteration_next (void *cls, | |||
1845 | 1869 | ||
1846 | 1870 | ||
1847 | /************************************************* | 1871 | /************************************************* |
1848 | * Attestation iteration | 1872 | * Credential iteration |
1849 | *************************************************/ | 1873 | *************************************************/ |
1850 | 1874 | ||
1851 | 1875 | ||
1852 | /** | 1876 | /** |
1853 | * Done iterating over attestations | 1877 | * Done iterating over credentials |
1854 | * | 1878 | * |
1855 | * @param cls our iterator handle | 1879 | * @param cls our iterator handle |
1856 | */ | 1880 | */ |
1857 | static void | 1881 | static void |
1858 | attest_iter_finished (void *cls) | 1882 | cred_iter_finished (void *cls) |
1859 | { | 1883 | { |
1860 | struct Iterator *ai = cls; | 1884 | struct Iterator *ai = cls; |
1861 | struct GNUNET_MQ_Envelope *env; | 1885 | struct GNUNET_MQ_Envelope *env; |
1862 | struct AttestationResultMessage *arm; | 1886 | struct CredentialResultMessage *arm; |
1863 | 1887 | ||
1864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTESTATION_RESULT message\n"); | 1888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n"); |
1865 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); | 1889 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); |
1866 | arm->id = htonl (ai->request_id); | 1890 | arm->id = htonl (ai->request_id); |
1867 | arm->attestation_len = htons (0); | 1891 | arm->credential_len = htons (0); |
1868 | GNUNET_MQ_send (ai->client->mq, env); | 1892 | GNUNET_MQ_send (ai->client->mq, env); |
1869 | GNUNET_CONTAINER_DLL_remove (ai->client->attest_iter_head, | 1893 | GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head, |
1870 | ai->client->attest_iter_tail, | 1894 | ai->client->cred_iter_tail, |
1871 | ai); | 1895 | ai); |
1872 | GNUNET_free (ai); | 1896 | GNUNET_free (ai); |
1873 | } | 1897 | } |
1874 | 1898 | ||
1875 | 1899 | ||
1876 | /** | 1900 | /** |
1877 | * Error iterating over attestations. Abort. | 1901 | * Error iterating over credentials. Abort. |
1878 | * | 1902 | * |
1879 | * @param cls our attribute iteration handle | 1903 | * @param cls our attribute iteration handle |
1880 | */ | 1904 | */ |
1881 | static void | 1905 | static void |
1882 | attest_iter_error (void *cls) | 1906 | cred_iter_error (void *cls) |
1883 | { | 1907 | { |
1884 | struct Iterator *ai = cls; | 1908 | struct Iterator *ai = cls; |
1885 | 1909 | ||
1886 | 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"); |
1887 | attest_iter_finished (ai); | 1911 | cred_iter_finished (ai); |
1888 | } | 1912 | } |
1889 | 1913 | ||
1890 | 1914 | ||
1891 | /** | 1915 | /** |
1892 | * Got record. Return attestation. | 1916 | * Got record. Return credential. |
1893 | * | 1917 | * |
1894 | * @param cls our attribute iterator | 1918 | * @param cls our attribute iterator |
1895 | * @param zone zone we are iterating | 1919 | * @param zone zone we are iterating |
@@ -1898,32 +1922,32 @@ attest_iter_error (void *cls) | |||
1898 | * @param rd records | 1922 | * @param rd records |
1899 | */ | 1923 | */ |
1900 | static void | 1924 | static void |
1901 | attest_iter_cb (void *cls, | 1925 | cred_iter_cb (void *cls, |
1902 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1926 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1903 | const char *label, | 1927 | const char *label, |
1904 | unsigned int rd_count, | 1928 | unsigned int rd_count, |
1905 | const struct GNUNET_GNSRECORD_Data *rd) | 1929 | const struct GNUNET_GNSRECORD_Data *rd) |
1906 | { | 1930 | { |
1907 | struct Iterator *ai = cls; | 1931 | struct Iterator *ai = cls; |
1908 | struct GNUNET_MQ_Envelope *env; | 1932 | struct GNUNET_MQ_Envelope *env; |
1909 | struct AttestationResultMessage *arm; | 1933 | struct CredentialResultMessage *arm; |
1910 | char *data_tmp; | 1934 | char *data_tmp; |
1911 | 1935 | ||
1912 | if ((rd_count != 1) || | 1936 | if ((rd_count != 1) || |
1913 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) | 1937 | (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL != rd->record_type)) |
1914 | { | 1938 | { |
1915 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 1939 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); |
1916 | return; | 1940 | return; |
1917 | } | 1941 | } |
1918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", | 1942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n", |
1919 | label); | 1943 | label); |
1920 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1944 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1921 | "Sending ATTESTATION_RESULT message\n"); | 1945 | "Sending CREDENTIAL_RESULT message\n"); |
1922 | env = GNUNET_MQ_msg_extra (arm, | 1946 | env = GNUNET_MQ_msg_extra (arm, |
1923 | rd->data_size, | 1947 | rd->data_size, |
1924 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); | 1948 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); |
1925 | arm->id = htonl (ai->request_id); | 1949 | arm->id = htonl (ai->request_id); |
1926 | arm->attestation_len = htons (rd->data_size); | 1950 | arm->credential_len = htons (rd->data_size); |
1927 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | 1951 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); |
1928 | data_tmp = (char *) &arm[1]; | 1952 | data_tmp = (char *) &arm[1]; |
1929 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 1953 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
@@ -1939,29 +1963,29 @@ attest_iter_cb (void *cls, | |||
1939 | * @param ais_msg the iteration message to start | 1963 | * @param ais_msg the iteration message to start |
1940 | */ | 1964 | */ |
1941 | static void | 1965 | static void |
1942 | handle_attestation_iteration_start (void *cls, | 1966 | handle_credential_iteration_start (void *cls, |
1943 | const struct | 1967 | const struct |
1944 | AttestationIterationStartMessage *ais_msg) | 1968 | CredentialIterationStartMessage *ais_msg) |
1945 | { | 1969 | { |
1946 | struct IdpClient *idp = cls; | 1970 | struct IdpClient *idp = cls; |
1947 | struct Iterator *ai; | 1971 | struct Iterator *ai; |
1948 | 1972 | ||
1949 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1973 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1950 | "Received ATTESTATION_ITERATION_START message\n"); | 1974 | "Received CREDENTIAL_ITERATION_START message\n"); |
1951 | ai = GNUNET_new (struct Iterator); | 1975 | ai = GNUNET_new (struct Iterator); |
1952 | ai->request_id = ntohl (ais_msg->id); | 1976 | ai->request_id = ntohl (ais_msg->id); |
1953 | ai->client = idp; | 1977 | ai->client = idp; |
1954 | ai->identity = ais_msg->identity; | 1978 | ai->identity = ais_msg->identity; |
1955 | 1979 | ||
1956 | 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, |
1957 | ai); | 1981 | ai); |
1958 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 1982 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
1959 | &ai->identity, | 1983 | &ai->identity, |
1960 | &attest_iter_error, | 1984 | &cred_iter_error, |
1961 | ai, | 1985 | ai, |
1962 | &attest_iter_cb, | 1986 | &cred_iter_cb, |
1963 | ai, | 1987 | ai, |
1964 | &attest_iter_finished, | 1988 | &cred_iter_finished, |
1965 | ai); | 1989 | ai); |
1966 | GNUNET_SERVICE_client_continue (idp->client); | 1990 | GNUNET_SERVICE_client_continue (idp->client); |
1967 | } | 1991 | } |
@@ -1974,9 +1998,9 @@ handle_attestation_iteration_start (void *cls, | |||
1974 | * @param ais_msg the stop message | 1998 | * @param ais_msg the stop message |
1975 | */ | 1999 | */ |
1976 | static void | 2000 | static void |
1977 | handle_attestation_iteration_stop (void *cls, | 2001 | handle_credential_iteration_stop (void *cls, |
1978 | const struct | 2002 | const struct |
1979 | AttestationIterationStopMessage *ais_msg) | 2003 | CredentialIterationStopMessage *ais_msg) |
1980 | { | 2004 | { |
1981 | struct IdpClient *idp = cls; | 2005 | struct IdpClient *idp = cls; |
1982 | struct Iterator *ai; | 2006 | struct Iterator *ai; |
@@ -1984,9 +2008,9 @@ handle_attestation_iteration_stop (void *cls, | |||
1984 | 2008 | ||
1985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1986 | "Received `%s' message\n", | 2010 | "Received `%s' message\n", |
1987 | "ATTESTATION_ITERATION_STOP"); | 2011 | "CREDENTIAL_ITERATION_STOP"); |
1988 | rid = ntohl (ais_msg->id); | 2012 | rid = ntohl (ais_msg->id); |
1989 | for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) | 2013 | for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next) |
1990 | if (ai->request_id == rid) | 2014 | if (ai->request_id == rid) |
1991 | break; | 2015 | break; |
1992 | if (NULL == ai) | 2016 | if (NULL == ai) |
@@ -1995,7 +2019,7 @@ handle_attestation_iteration_stop (void *cls, | |||
1995 | GNUNET_SERVICE_client_drop (idp->client); | 2019 | GNUNET_SERVICE_client_drop (idp->client); |
1996 | return; | 2020 | return; |
1997 | } | 2021 | } |
1998 | 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, |
1999 | ai); | 2023 | ai); |
2000 | GNUNET_free (ai); | 2024 | GNUNET_free (ai); |
2001 | GNUNET_SERVICE_client_continue (idp->client); | 2025 | GNUNET_SERVICE_client_continue (idp->client); |
@@ -2003,24 +2027,24 @@ handle_attestation_iteration_stop (void *cls, | |||
2003 | 2027 | ||
2004 | 2028 | ||
2005 | /** | 2029 | /** |
2006 | * Client requests next attestation from iterator | 2030 | * Client requests next credential from iterator |
2007 | * | 2031 | * |
2008 | * @param cls the client | 2032 | * @param cls the client |
2009 | * @param ais_msg the message | 2033 | * @param ais_msg the message |
2010 | */ | 2034 | */ |
2011 | static void | 2035 | static void |
2012 | handle_attestation_iteration_next (void *cls, | 2036 | handle_credential_iteration_next (void *cls, |
2013 | const struct | 2037 | const struct |
2014 | AttestationIterationNextMessage *ais_msg) | 2038 | CredentialIterationNextMessage *ais_msg) |
2015 | { | 2039 | { |
2016 | struct IdpClient *idp = cls; | 2040 | struct IdpClient *idp = cls; |
2017 | struct Iterator *ai; | 2041 | struct Iterator *ai; |
2018 | uint32_t rid; | 2042 | uint32_t rid; |
2019 | 2043 | ||
2020 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2044 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2021 | "Received ATTESTATION_ITERATION_NEXT message\n"); | 2045 | "Received CREDENTIAL_ITERATION_NEXT message\n"); |
2022 | rid = ntohl (ais_msg->id); | 2046 | rid = ntohl (ais_msg->id); |
2023 | for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) | 2047 | for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next) |
2024 | if (ai->request_id == rid) | 2048 | if (ai->request_id == rid) |
2025 | break; | 2049 | break; |
2026 | if (NULL == ai) | 2050 | if (NULL == ai) |
@@ -2262,16 +2286,16 @@ GNUNET_SERVICE_MAIN ( | |||
2262 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, | 2286 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, |
2263 | struct AttributeStoreMessage, | 2287 | struct AttributeStoreMessage, |
2264 | NULL), | 2288 | NULL), |
2265 | GNUNET_MQ_hd_var_size (attestation_store_message, | 2289 | GNUNET_MQ_hd_var_size (credential_store_message, |
2266 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE, | 2290 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, |
2267 | struct AttributeStoreMessage, | 2291 | struct AttributeStoreMessage, |
2268 | NULL), | 2292 | NULL), |
2269 | GNUNET_MQ_hd_var_size (attribute_delete_message, | 2293 | GNUNET_MQ_hd_var_size (attribute_delete_message, |
2270 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, | 2294 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, |
2271 | struct AttributeDeleteMessage, | 2295 | struct AttributeDeleteMessage, |
2272 | NULL), | 2296 | NULL), |
2273 | GNUNET_MQ_hd_var_size (attestation_delete_message, | 2297 | GNUNET_MQ_hd_var_size (credential_delete_message, |
2274 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, | 2298 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, |
2275 | struct AttributeDeleteMessage, | 2299 | struct AttributeDeleteMessage, |
2276 | NULL), | 2300 | NULL), |
2277 | GNUNET_MQ_hd_fixed_size (iteration_start, | 2301 | GNUNET_MQ_hd_fixed_size (iteration_start, |
@@ -2286,17 +2310,17 @@ GNUNET_SERVICE_MAIN ( | |||
2286 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, | 2310 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, |
2287 | struct AttributeIterationStopMessage, | 2311 | struct AttributeIterationStopMessage, |
2288 | NULL), | 2312 | NULL), |
2289 | GNUNET_MQ_hd_fixed_size (attestation_iteration_start, | 2313 | GNUNET_MQ_hd_fixed_size (credential_iteration_start, |
2290 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START, | 2314 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, |
2291 | struct AttestationIterationStartMessage, | 2315 | struct CredentialIterationStartMessage, |
2292 | NULL), | 2316 | NULL), |
2293 | GNUNET_MQ_hd_fixed_size (attestation_iteration_next, | 2317 | GNUNET_MQ_hd_fixed_size (credential_iteration_next, |
2294 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT, | 2318 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, |
2295 | struct AttestationIterationNextMessage, | 2319 | struct CredentialIterationNextMessage, |
2296 | NULL), | 2320 | NULL), |
2297 | GNUNET_MQ_hd_fixed_size (attestation_iteration_stop, | 2321 | GNUNET_MQ_hd_fixed_size (credential_iteration_stop, |
2298 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP, | 2322 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, |
2299 | struct AttestationIterationStopMessage, | 2323 | struct CredentialIterationStopMessage, |
2300 | NULL), | 2324 | NULL), |
2301 | 2325 | ||
2302 | 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 7e6b07514..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; |
@@ -694,8 +699,9 @@ rvk_move_attr_cb (void *cls, | |||
694 | { | 699 | { |
695 | /** find a new place for this attribute **/ | 700 | /** find a new place for this attribute **/ |
696 | struct GNUNET_RECLAIM_Attribute *claim; | 701 | struct GNUNET_RECLAIM_Attribute *claim; |
697 | claim = GNUNET_RECLAIM_attribute_deserialize (rd[i].data, | 702 | GNUNET_RECLAIM_attribute_deserialize (rd[i].data, |
698 | rd[i].data_size); | 703 | rd[i].data_size, |
704 | &claim); | ||
699 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
700 | "Attribute to update: Name=%s\n", | 706 | "Attribute to update: Name=%s\n", |
701 | claim->name); | 707 | claim->name); |
@@ -714,20 +720,20 @@ rvk_move_attr_cb (void *cls, | |||
714 | 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); |
715 | GNUNET_free (claim); | 721 | GNUNET_free (claim); |
716 | } | 722 | } |
717 | else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type) | 723 | else if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type) |
718 | { | 724 | { |
719 | struct GNUNET_RECLAIM_Attestation *attest; | 725 | struct GNUNET_RECLAIM_Credential *credential; |
720 | attest = GNUNET_RECLAIM_attestation_deserialize (rd[i].data, | 726 | credential = GNUNET_RECLAIM_credential_deserialize (rd[i].data, |
721 | rd[i].data_size); | 727 | rd[i].data_size); |
722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
723 | "Attestation to update: Name=%s\n", | 729 | "Credential to update: Name=%s\n", |
724 | attest->name); | 730 | credential->name); |
725 | attest->id = rvk->move_attr->new_id; | 731 | credential->id = rvk->move_attr->new_id; |
726 | new_rd[i].data_size = | 732 | new_rd[i].data_size = |
727 | GNUNET_RECLAIM_attestation_serialize_get_size (attest); | 733 | GNUNET_RECLAIM_credential_serialize_get_size (credential); |
728 | attr_data = GNUNET_malloc (rd[i].data_size); | 734 | attr_data = GNUNET_malloc (rd[i].data_size); |
729 | new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest, | 735 | new_rd[i].data_size = GNUNET_RECLAIM_credential_serialize (credential, |
730 | attr_data); | 736 | attr_data); |
731 | new_rd[i].data = attr_data; | 737 | new_rd[i].data = attr_data; |
732 | new_rd[i].record_type = rd[i].record_type; | 738 | new_rd[i].record_type = rd[i].record_type; |
733 | new_rd[i].flags = rd[i].flags; | 739 | new_rd[i].flags = rd[i].flags; |
@@ -735,9 +741,9 @@ rvk_move_attr_cb (void *cls, | |||
735 | new_label = | 741 | new_label = |
736 | GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | 742 | GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, |
737 | sizeof (rvk->move_attr->new_id)); | 743 | sizeof (rvk->move_attr->new_id)); |
738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n", | 744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", |
739 | new_label); | 745 | new_label); |
740 | GNUNET_free (attest); | 746 | GNUNET_free (credential); |
741 | } | 747 | } |
742 | } | 748 | } |
743 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 749 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
@@ -980,8 +986,8 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
980 | 986 | ||
981 | if (NULL != cth->attrs) | 987 | if (NULL != cth->attrs) |
982 | GNUNET_RECLAIM_attribute_list_destroy (cth->attrs); | 988 | GNUNET_RECLAIM_attribute_list_destroy (cth->attrs); |
983 | if (NULL != cth->attests) | 989 | if (NULL != cth->presentations) |
984 | GNUNET_RECLAIM_attestation_list_destroy (cth->attests); | 990 | GNUNET_RECLAIM_presentation_list_destroy (cth->presentations); |
985 | GNUNET_free (cth); | 991 | GNUNET_free (cth); |
986 | } | 992 | } |
987 | 993 | ||
@@ -1026,40 +1032,20 @@ process_parallel_lookup_result (void *cls, | |||
1026 | // REMARK: It is possible now to find rd_count > 1 | 1032 | // REMARK: It is possible now to find rd_count > 1 |
1027 | for (int i = 0; i < rd_count; i++) | 1033 | for (int i = 0; i < rd_count; i++) |
1028 | { | 1034 | { |
1029 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type) | 1035 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type) |
1030 | { | ||
1031 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | ||
1032 | attr_le->attribute = | ||
1033 | GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size); | ||
1034 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, | ||
1035 | cth->attrs->list_tail, | ||
1036 | attr_le); | ||
1037 | } | ||
1038 | else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type) | ||
1039 | { | ||
1040 | struct GNUNET_RECLAIM_AttestationListEntry *ale; | ||
1041 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); | ||
1042 | ale->attestation = | ||
1043 | GNUNET_RECLAIM_attestation_deserialize (rd[i].data, | ||
1044 | rd[i].data_size); | ||
1045 | GNUNET_CONTAINER_DLL_insert (cth->attests->list_head, | ||
1046 | cth->attests->list_tail, | ||
1047 | ale); | ||
1048 | } | ||
1049 | else | ||
1050 | { | ||
1051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1052 | "Parallel Lookup of Reference without Attestation"); | ||
1053 | continue; | 1036 | continue; |
1054 | } | 1037 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
1055 | 1038 | GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size, | |
1056 | 1039 | &attr_le->attribute); | |
1040 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, | ||
1041 | cth->attrs->list_tail, | ||
1042 | attr_le); | ||
1057 | } | 1043 | } |
1058 | if (NULL != cth->parallel_lookups_head) | 1044 | if (NULL != cth->parallel_lookups_head) |
1059 | return; // Wait for more | 1045 | return; // Wait for more |
1060 | /* Else we are done */ | 1046 | /* Else we are done */ |
1061 | cth->cb (cth->cb_cls, &cth->ticket.identity, | 1047 | cth->cb (cth->cb_cls, &cth->ticket.identity, |
1062 | cth->attrs, cth->attests, GNUNET_OK, NULL); | 1048 | cth->attrs, cth->presentations, GNUNET_OK, NULL); |
1063 | cleanup_cth (cth); | 1049 | cleanup_cth (cth); |
1064 | } | 1050 | } |
1065 | 1051 | ||
@@ -1109,6 +1095,7 @@ lookup_authz_cb (void *cls, | |||
1109 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; | 1095 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; |
1110 | struct ParallelLookup *parallel_lookup; | 1096 | struct ParallelLookup *parallel_lookup; |
1111 | char *lbl; | 1097 | char *lbl; |
1098 | struct GNUNET_RECLAIM_PresentationListEntry *ale; | ||
1112 | 1099 | ||
1113 | cth->lookup_request = NULL; | 1100 | cth->lookup_request = NULL; |
1114 | 1101 | ||
@@ -1125,26 +1112,44 @@ lookup_authz_cb (void *cls, | |||
1125 | 1112 | ||
1126 | for (int i = 0; i < rd_count; i++) | 1113 | for (int i = 0; i < rd_count; i++) |
1127 | { | 1114 | { |
1128 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) && | 1115 | /** |
1129 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type)) | 1116 | * Check if record is a credential presentation or an attribute |
1130 | continue; | 1117 | * reference. |
1131 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); | 1118 | */ |
1132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl); | 1119 | switch (rd[i].record_type) |
1133 | parallel_lookup = GNUNET_new (struct ParallelLookup); | 1120 | { |
1134 | parallel_lookup->handle = cth; | 1121 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: |
1135 | parallel_lookup->label = lbl; | 1122 | ale = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry); |
1136 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); | 1123 | ale->presentation = |
1137 | parallel_lookup->lookup_request = | 1124 | GNUNET_RECLAIM_presentation_deserialize (rd[i].data, |
1138 | GNUNET_GNS_lookup (gns, | 1125 | rd[i].data_size); |
1139 | lbl, | 1126 | GNUNET_CONTAINER_DLL_insert (cth->presentations->list_head, |
1140 | &cth->ticket.identity, | 1127 | cth->presentations->list_tail, |
1141 | GNUNET_GNSRECORD_TYPE_ANY, | 1128 | ale); |
1142 | GNUNET_GNS_LO_DEFAULT, | 1129 | break; |
1143 | &process_parallel_lookup_result, | 1130 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: |
1144 | parallel_lookup); | 1131 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); |
1145 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, | 1132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl); |
1146 | cth->parallel_lookups_tail, | 1133 | parallel_lookup = GNUNET_new (struct ParallelLookup); |
1147 | 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 | } | ||
1148 | } | 1153 | } |
1149 | /** | 1154 | /** |
1150 | * We started lookups. Add a timeout task. | 1155 | * We started lookups. Add a timeout task. |
@@ -1162,7 +1167,7 @@ lookup_authz_cb (void *cls, | |||
1162 | * No references found, return empty attribute list | 1167 | * No references found, return empty attribute list |
1163 | */ | 1168 | */ |
1164 | cth->cb (cth->cb_cls, &cth->ticket.identity, | 1169 | cth->cb (cth->cb_cls, &cth->ticket.identity, |
1165 | cth->attrs, cth->attests, GNUNET_OK, NULL); | 1170 | cth->attrs, NULL, GNUNET_OK, NULL); |
1166 | cleanup_cth (cth); | 1171 | cleanup_cth (cth); |
1167 | } | 1172 | } |
1168 | 1173 | ||
@@ -1192,7 +1197,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | |||
1192 | cth->identity = *id; | 1197 | cth->identity = *id; |
1193 | GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); | 1198 | GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); |
1194 | cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 1199 | cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
1195 | cth->attests = GNUNET_new (struct GNUNET_RECLAIM_AttestationList); | 1200 | cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
1196 | cth->ticket = *ticket; | 1201 | cth->ticket = *ticket; |
1197 | cth->cb = cb; | 1202 | cth->cb = cb; |
1198 | cth->cb_cls = cb_cls; | 1203 | cth->cb_cls = cb_cls; |
@@ -1230,8 +1235,8 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
1230 | 1235 | ||
1231 | 1236 | ||
1232 | /******************************* | 1237 | /******************************* |
1233 | * Ticket issue | 1238 | * Ticket issue |
1234 | *******************************/ | 1239 | *******************************/ |
1235 | 1240 | ||
1236 | /** | 1241 | /** |
1237 | * Cleanup ticket consume handle | 1242 | * Cleanup ticket consume handle |
@@ -1264,11 +1269,15 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | |||
1264 | { | 1269 | { |
1265 | handle->cb (handle->cb_cls, | 1270 | handle->cb (handle->cb_cls, |
1266 | &handle->ticket, | 1271 | &handle->ticket, |
1272 | NULL, | ||
1267 | GNUNET_SYSERR, | 1273 | GNUNET_SYSERR, |
1268 | "Error storing AuthZ ticket in GNS"); | 1274 | "Error storing AuthZ ticket in GNS"); |
1269 | return; | 1275 | return; |
1270 | } | 1276 | } |
1271 | 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); | ||
1272 | cleanup_issue_handle (handle); | 1281 | cleanup_issue_handle (handle); |
1273 | } | 1282 | } |
1274 | 1283 | ||
@@ -1284,48 +1293,92 @@ static void | |||
1284 | issue_ticket (struct TicketIssueHandle *ih) | 1293 | issue_ticket (struct TicketIssueHandle *ih) |
1285 | { | 1294 | { |
1286 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 1295 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
1296 | struct GNUNET_RECLAIM_PresentationListEntry *ple; | ||
1287 | struct GNUNET_GNSRECORD_Data *attrs_record; | 1297 | struct GNUNET_GNSRECORD_Data *attrs_record; |
1288 | char *label; | 1298 | char *label; |
1289 | int i; | 1299 | int i; |
1300 | int j; | ||
1290 | int attrs_count = 0; | 1301 | int attrs_count = 0; |
1291 | 1302 | ||
1292 | for (le = ih->attrs->list_head; NULL != le; le = le->next) | 1303 | for (le = ih->attrs->list_head; NULL != le; le = le->next) |
1293 | attrs_count++; | 1304 | attrs_count++; |
1294 | 1305 | ||
1295 | // Worst case we have one attestation per attribute | 1306 | // Worst case we have one presentation per attribute |
1296 | attrs_record = | 1307 | attrs_record = |
1297 | GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data)); | 1308 | GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data)); |
1298 | i = 0; | 1309 | i = 0; |
1299 | for (le = ih->attrs->list_head; NULL != le; le = le->next) | 1310 | for (le = ih->attrs->list_head; NULL != le; le = le->next) |
1300 | { | 1311 | { |
1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1313 | "Adding list entry: %s\n", le->attribute->name); | ||
1314 | |||
1301 | attrs_record[i].data = &le->attribute->id; | 1315 | attrs_record[i].data = &le->attribute->id; |
1302 | attrs_record[i].data_size = sizeof(le->attribute->id); | 1316 | attrs_record[i].data_size = sizeof(le->attribute->id); |
1303 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | 1317 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
1304 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF; | 1318 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF; |
1305 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1319 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1306 | i++; | 1320 | i++; |
1307 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) | 1321 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) |
1308 | { | 1322 | { |
1309 | int j; | 1323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1324 | "Attribute is backed by credential. Adding...\n"); | ||
1325 | struct GNUNET_RECLAIM_Presentation *pres = NULL; | ||
1310 | for (j = 0; j < i; j++) | 1326 | for (j = 0; j < i; j++) |
1311 | { | 1327 | { |
1312 | if (attrs_record[j].record_type | 1328 | if (attrs_record[j].record_type |
1313 | != GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF) | 1329 | != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION) |
1330 | continue; | ||
1331 | pres = GNUNET_RECLAIM_presentation_deserialize (attrs_record[j].data, | ||
1332 | attrs_record[j]. | ||
1333 | data_size); | ||
1334 | if (NULL == pres) | ||
1335 | { | ||
1336 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1337 | "Failed to deserialize presentation\n"); | ||
1314 | continue; | 1338 | continue; |
1315 | if (0 == memcmp (attrs_record[j].data, | 1339 | } |
1316 | &le->attribute->attestation, | 1340 | if (0 == memcmp (&pres->credential_id, |
1317 | sizeof (le->attribute->attestation))) | 1341 | &le->attribute->credential, |
1342 | sizeof (le->attribute->credential))) | ||
1318 | 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; | ||
1319 | } | 1381 | } |
1320 | if (j < i) | ||
1321 | continue; // Skip as we have already added this attestation. | ||
1322 | attrs_record[i].data = &le->attribute->attestation; | ||
1323 | attrs_record[i].data_size = sizeof(le->attribute->attestation); | ||
1324 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | ||
1325 | attrs_record[i].record_type = | ||
1326 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF; | ||
1327 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1328 | i++; | ||
1329 | } | 1382 | } |
1330 | } | 1383 | } |
1331 | attrs_record[i].data = &ih->ticket; | 1384 | attrs_record[i].data = &ih->ticket; |
@@ -1347,14 +1400,23 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1347 | attrs_record, | 1400 | attrs_record, |
1348 | &store_ticket_issue_cont, | 1401 | &store_ticket_issue_cont, |
1349 | 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 | } | ||
1350 | GNUNET_free (attrs_record); | 1412 | GNUNET_free (attrs_record); |
1351 | GNUNET_free (label); | 1413 | GNUNET_free (label); |
1352 | } | 1414 | } |
1353 | 1415 | ||
1354 | 1416 | ||
1355 | /************************************************* | 1417 | /************************************************* |
1356 | * Ticket iteration (finding a specific ticket) | 1418 | * Ticket iteration (finding a specific ticket) |
1357 | *************************************************/ | 1419 | *************************************************/ |
1358 | 1420 | ||
1359 | 1421 | ||
1360 | /** | 1422 | /** |
@@ -1370,6 +1432,7 @@ filter_tickets_error_cb (void *cls) | |||
1370 | tih->ns_it = NULL; | 1432 | tih->ns_it = NULL; |
1371 | tih->cb (tih->cb_cls, | 1433 | tih->cb (tih->cb_cls, |
1372 | &tih->ticket, | 1434 | &tih->ticket, |
1435 | NULL, | ||
1373 | GNUNET_SYSERR, | 1436 | GNUNET_SYSERR, |
1374 | "Error storing AuthZ ticket in GNS"); | 1437 | "Error storing AuthZ ticket in GNS"); |
1375 | cleanup_issue_handle (tih); | 1438 | cleanup_issue_handle (tih); |
@@ -1397,22 +1460,25 @@ filter_tickets_cb (void *cls, | |||
1397 | { | 1460 | { |
1398 | struct TicketIssueHandle *tih = cls; | 1461 | struct TicketIssueHandle *tih = cls; |
1399 | struct GNUNET_RECLAIM_Ticket *ticket = NULL; | 1462 | struct GNUNET_RECLAIM_Ticket *ticket = NULL; |
1400 | 1463 | struct GNUNET_RECLAIM_Presentation *pres; | |
1401 | // 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; | ||
1402 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 1467 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
1403 | unsigned int attr_cnt = 0; | 1468 | unsigned int attr_cnt = 0; |
1404 | unsigned int attest_cnt = 0; | 1469 | unsigned int pres_cnt = 0; |
1405 | 1470 | ||
1406 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | 1471 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1407 | { | 1472 | { |
1408 | attr_cnt++; | 1473 | attr_cnt++; |
1409 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) | 1474 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) |
1410 | attest_cnt++; | 1475 | pres_cnt++; |
1411 | } | 1476 | } |
1412 | 1477 | ||
1413 | // ticket search | 1478 | // ticket search |
1414 | unsigned int found_attrs_cnt = 0; | 1479 | unsigned int found_attrs_cnt = 0; |
1415 | unsigned int found_attests_cnt = 0; | 1480 | unsigned int found_pres_cnt = 0; |
1481 | ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); | ||
1416 | 1482 | ||
1417 | for (int i = 0; i < rd_count; i++) | 1483 | for (int i = 0; i < rd_count; i++) |
1418 | { | 1484 | { |
@@ -1432,20 +1498,75 @@ filter_tickets_cb (void *cls, | |||
1432 | } | 1498 | } |
1433 | 1499 | ||
1434 | // cmp requested attributes with ticket attributes | 1500 | // cmp requested attributes with ticket attributes |
1435 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) && | 1501 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) |
1436 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type)) | ||
1437 | continue; | ||
1438 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | ||
1439 | { | 1502 | { |
1440 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1503 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1441 | &le->attribute->id)) | 1504 | { |
1442 | found_attrs_cnt++; | 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) | ||
1511 | { | ||
1512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1513 | "Found credential...\n"); | ||
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 | } | ||
1443 | } | 1546 | } |
1444 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | 1547 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type) |
1445 | { | 1548 | { |
1446 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1549 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1447 | &le->attribute->attestation)) | 1550 | { |
1448 | 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 | } | ||
1449 | } | 1570 | } |
1450 | } | 1571 | } |
1451 | 1572 | ||
@@ -1454,11 +1575,12 @@ filter_tickets_cb (void *cls, | |||
1454 | * we are done. | 1575 | * we are done. |
1455 | */ | 1576 | */ |
1456 | if ((attr_cnt == found_attrs_cnt) && | 1577 | if ((attr_cnt == found_attrs_cnt) && |
1457 | (attest_cnt == found_attests_cnt) && | 1578 | (pres_cnt == found_pres_cnt) && |
1458 | (NULL != ticket)) | 1579 | (NULL != ticket)) |
1459 | { | 1580 | { |
1460 | GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); | 1581 | GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); |
1461 | 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); | ||
1462 | cleanup_issue_handle (tih); | 1584 | cleanup_issue_handle (tih); |
1463 | return; | 1585 | return; |
1464 | } | 1586 | } |
@@ -1510,6 +1632,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
1510 | tih->cb = cb; | 1632 | tih->cb = cb; |
1511 | tih->cb_cls = cb_cls; | 1633 | tih->cb_cls = cb_cls; |
1512 | 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); | ||
1513 | tih->identity = *identity; | 1636 | tih->identity = *identity; |
1514 | tih->ticket.audience = *audience; | 1637 | tih->ticket.audience = *audience; |
1515 | 1638 | ||
@@ -1527,8 +1650,8 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
1527 | 1650 | ||
1528 | 1651 | ||
1529 | /************************************ | 1652 | /************************************ |
1530 | * Ticket iteration | 1653 | * Ticket iteration |
1531 | ************************************/ | 1654 | ************************************/ |
1532 | 1655 | ||
1533 | /** | 1656 | /** |
1534 | * 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) ( | |||
120 | typedef void (*RECLAIM_TICKETS_TicketResult) ( | 121 | typedef 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 | */ |
144 | struct GNUNET_JSON_Specification | 144 | struct GNUNET_JSON_Specification |
145 | GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr) | 145 | GNUNET_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 | */ |
289 | static int | 289 | static int |
290 | parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | 290 | parse_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 | */ |
358 | static void | 358 | static void |
359 | clean_attest (void *cls, struct GNUNET_JSON_Specification *spec) | 359 | clean_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 | */ |
378 | struct GNUNET_JSON_Specification | 378 | struct GNUNET_JSON_Specification |
379 | GNUNET_RECLAIM_JSON_spec_claim_attest (struct | 379 | GNUNET_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 | */ |
38 | struct GNUNET_JSON_Specification | 38 | struct GNUNET_JSON_Specification |
39 | GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr); | 39 | GNUNET_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 | |||
48 | GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket); | 48 | GNUNET_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 | */ |
56 | struct GNUNET_JSON_Specification | 56 | struct GNUNET_JSON_Specification |
57 | GNUNET_RECLAIM_JSON_spec_claim_attest (struct | 57 | GNUNET_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 9b5938c43..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 | ||
70 | GNUNET_NETWORK_STRUCT_END | 70 | GNUNET_NETWORK_STRUCT_END |
@@ -156,25 +156,25 @@ fix_base64 (char *str) | |||
156 | 156 | ||
157 | static json_t* | 157 | static json_t* |
158 | generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | 158 | generate_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 | */ |
292 | char * | 297 | char * |
293 | OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | 298 | OIDC_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, | |||
317 | char * | 323 | char * |
318 | OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | 324 | OIDC_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, | |||
433 | char * | 440 | char * |
434 | OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, | 441 | OIDC_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; |
@@ -621,6 +628,7 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | |||
621 | 628 | ||
622 | // cmp code_challenge code_verifier | 629 | // cmp code_challenge code_verifier |
623 | code_challenge_len = ntohl (params->code_challenge_len); | 630 | code_challenge_len = ntohl (params->code_challenge_len); |
631 | code_challenge = ((char *) ¶ms[1]); | ||
624 | if (0 != code_challenge_len) /* Only check if this code requires a CV */ | 632 | if (0 != code_challenge_len) /* Only check if this code requires a CV */ |
625 | { | 633 | { |
626 | if (NULL == code_verifier) | 634 | if (NULL == code_verifier) |
@@ -639,7 +647,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | |||
639 | // encode code verifier | 647 | // encode code verifier |
640 | GNUNET_STRINGS_base64url_encode (code_verifier_hash, 256 / 8, | 648 | GNUNET_STRINGS_base64url_encode (code_verifier_hash, 256 / 8, |
641 | &expected_code_challenge); | 649 | &expected_code_challenge); |
642 | code_challenge = ((char *) ¶ms[1]); | ||
643 | GNUNET_free (code_verifier_hash); | 650 | GNUNET_free (code_verifier_hash); |
644 | if (0 != | 651 | if (0 != |
645 | strncmp (expected_code_challenge, code_challenge, code_challenge_len)) | 652 | strncmp (expected_code_challenge, code_challenge, code_challenge_len)) |
@@ -692,10 +699,11 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | |||
692 | attrs_ser = ((char *) ¶ms[1]) + code_challenge_len + nonce_len; | 699 | attrs_ser = ((char *) ¶ms[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; |
@@ -769,7 +777,7 @@ OIDC_access_token_parse (const char *token, | |||
769 | 777 | ||
770 | /** | 778 | /** |
771 | * Checks if a claim is implicitly requested through standard | 779 | * Checks if a claim is implicitly requested through standard |
772 | * scope(s) | 780 | * scope(s) or explicitly through non-standard scope. |
773 | * | 781 | * |
774 | * @param scopes the scopes which have been requested | 782 | * @param scopes the scopes which have been requested |
775 | * @param attr the attribute name to check | 783 | * @param attr the attribute name to check |
@@ -832,6 +840,11 @@ OIDC_check_scopes_for_claim_request (const char*scopes, | |||
832 | } | 840 | } |
833 | } | 841 | } |
834 | 842 | ||
843 | } else if (0 == strcmp (attr, scope_variable)) | ||
844 | { | ||
845 | /** attribute matches requested scope **/ | ||
846 | GNUNET_free (scope_variables); | ||
847 | return GNUNET_YES; | ||
835 | } | 848 | } |
836 | scope_variable = strtok (NULL, delimiter); | 849 | scope_variable = strtok (NULL, delimiter); |
837 | } | 850 | } |
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 @@ | |||
51 | char* | 52 | char* |
52 | OIDC_generate_id_token (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | 53 | OIDC_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, | |||
71 | char* | 73 | char* |
72 | OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, | 74 | OIDC_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 | */ |
138 | enum GNUNET_GenericReturnValue | 141 | enum GNUNET_GenericReturnValue |
139 | OIDC_check_scopes_for_claim_request (const char*scopes, | 142 | OIDC_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 | */ |
151 | char * | 154 | char * |
152 | OIDC_generate_userinfo (const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | 155 | OIDC_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 | */ |
98 | static struct | 97 | static 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 | */ |
153 | struct GNUNET_RECLAIM_AttributeList * | 152 | struct GNUNET_RECLAIM_AttributeList * |
154 | jwt_parse_attributes (void *cls, | 153 | jwt_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 | */ | ||
209 | struct GNUNET_RECLAIM_AttributeList * | ||
210 | jwt_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 | */ | ||
224 | struct GNUNET_RECLAIM_AttributeList * | ||
225 | jwt_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 | */ |
213 | char * | 239 | char * |
214 | jwt_get_issuer (void *cls, | 240 | jwt_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 | */ | ||
275 | char * | ||
276 | jwt_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 | */ | ||
292 | char * | ||
293 | jwt_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 | */ |
251 | int | 309 | int |
252 | jwt_get_expiration (void *cls, | 310 | jwt_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 | */ | ||
345 | int | ||
346 | jwt_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 | */ | ||
361 | int | ||
362 | jwt_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 | |||
370 | int | ||
371 | jwt_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 | */ |
288 | void * | 392 | void * |
289 | libgnunet_plugin_reclaim_attestation_jwt_init (void *cls) | 393 | libgnunet_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 | */ |
311 | void * | 423 | void * |
312 | libgnunet_plugin_reclaim_attestation_jwt_done (void *cls) | 424 | libgnunet_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 06e1b0061..5b0bb2b6f 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -393,6 +393,15 @@ struct EgoEntry | |||
393 | 393 | ||
394 | struct RequestHandle | 394 | struct RequestHandle |
395 | { | 395 | { |
396 | /** | ||
397 | * DLL | ||
398 | */ | ||
399 | struct RequestHandle *next; | ||
400 | |||
401 | /** | ||
402 | * DLL | ||
403 | */ | ||
404 | struct RequestHandle *prev; | ||
396 | 405 | ||
397 | /** | 406 | /** |
398 | * Selected ego | 407 | * Selected ego |
@@ -430,10 +439,14 @@ struct RequestHandle | |||
430 | struct GNUNET_RECLAIM_AttributeList *attr_userinfo_list; | 439 | struct GNUNET_RECLAIM_AttributeList *attr_userinfo_list; |
431 | 440 | ||
432 | /** | 441 | /** |
433 | * Attestation list | 442 | * Credentials |
434 | */ | 443 | */ |
435 | struct GNUNET_RECLAIM_AttestationList *attests_list; | 444 | struct GNUNET_RECLAIM_CredentialList *credentials; |
436 | 445 | ||
446 | /** | ||
447 | * Presentations | ||
448 | */ | ||
449 | struct GNUNET_RECLAIM_PresentationList *presentations; | ||
437 | 450 | ||
438 | /** | 451 | /** |
439 | * IDENTITY Operation | 452 | * IDENTITY Operation |
@@ -452,9 +465,9 @@ struct RequestHandle | |||
452 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; | 465 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; |
453 | 466 | ||
454 | /** | 467 | /** |
455 | * Attestation iterator | 468 | * Credential iterator |
456 | */ | 469 | */ |
457 | struct GNUNET_RECLAIM_AttestationIterator *attest_it; | 470 | struct GNUNET_RECLAIM_CredentialIterator *cred_it; |
458 | 471 | ||
459 | 472 | ||
460 | /** | 473 | /** |
@@ -528,6 +541,16 @@ struct RequestHandle | |||
528 | int public_client; | 541 | int public_client; |
529 | }; | 542 | }; |
530 | 543 | ||
544 | /** | ||
545 | * DLL | ||
546 | */ | ||
547 | static struct RequestHandle *requests_head; | ||
548 | |||
549 | /** | ||
550 | * DLL | ||
551 | */ | ||
552 | static struct RequestHandle *requests_tail; | ||
553 | |||
531 | 554 | ||
532 | /** | 555 | /** |
533 | * Cleanup lookup handle | 556 | * Cleanup lookup handle |
@@ -542,8 +565,8 @@ cleanup_handle (struct RequestHandle *handle) | |||
542 | GNUNET_SCHEDULER_cancel (handle->timeout_task); | 565 | GNUNET_SCHEDULER_cancel (handle->timeout_task); |
543 | if (NULL != handle->attr_it) | 566 | if (NULL != handle->attr_it) |
544 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); | 567 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); |
545 | if (NULL != handle->attest_it) | 568 | if (NULL != handle->cred_it) |
546 | GNUNET_RECLAIM_get_attestations_stop (handle->attest_it); | 569 | GNUNET_RECLAIM_get_credentials_stop (handle->cred_it); |
547 | if (NULL != handle->ticket_it) | 570 | if (NULL != handle->ticket_it) |
548 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); | 571 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); |
549 | if (NULL != handle->idp_op) | 572 | if (NULL != handle->idp_op) |
@@ -571,20 +594,17 @@ cleanup_handle (struct RequestHandle *handle) | |||
571 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_idtoken_list); | 594 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_idtoken_list); |
572 | if (NULL!=handle->attr_userinfo_list) | 595 | if (NULL!=handle->attr_userinfo_list) |
573 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list); | 596 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list); |
574 | if (NULL!=handle->attests_list) | 597 | if (NULL!=handle->credentials) |
575 | GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list); | 598 | GNUNET_RECLAIM_credential_list_destroy (handle->credentials); |
576 | 599 | if (NULL!=handle->presentations) | |
600 | GNUNET_RECLAIM_presentation_list_destroy (handle->presentations); | ||
601 | GNUNET_CONTAINER_DLL_remove (requests_head, | ||
602 | requests_tail, | ||
603 | handle); | ||
577 | GNUNET_free (handle); | 604 | GNUNET_free (handle); |
578 | } | 605 | } |
579 | 606 | ||
580 | 607 | ||
581 | static void | ||
582 | cleanup_handle_delayed (void *cls) | ||
583 | { | ||
584 | cleanup_handle (cls); | ||
585 | } | ||
586 | |||
587 | |||
588 | /** | 608 | /** |
589 | * Task run on error, sends error message. Cleans up everything. | 609 | * Task run on error, sends error message. Cleans up everything. |
590 | * | 610 | * |
@@ -613,7 +633,7 @@ do_error (void *cls) | |||
613 | MHD_HTTP_HEADER_CONTENT_TYPE, | 633 | MHD_HTTP_HEADER_CONTENT_TYPE, |
614 | "application/json"); | 634 | "application/json"); |
615 | handle->proc (handle->proc_cls, resp, handle->response_code); | 635 | handle->proc (handle->proc_cls, resp, handle->response_code); |
616 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 636 | cleanup_handle (handle); |
617 | GNUNET_free (json_error); | 637 | GNUNET_free (json_error); |
618 | } | 638 | } |
619 | 639 | ||
@@ -640,7 +660,7 @@ do_userinfo_error (void *cls) | |||
640 | resp = GNUNET_REST_create_response (""); | 660 | resp = GNUNET_REST_create_response (""); |
641 | MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); | 661 | MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); |
642 | handle->proc (handle->proc_cls, resp, handle->response_code); | 662 | handle->proc (handle->proc_cls, resp, handle->response_code); |
643 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 663 | cleanup_handle (handle); |
644 | GNUNET_free (error); | 664 | GNUNET_free (error); |
645 | } | 665 | } |
646 | 666 | ||
@@ -667,7 +687,7 @@ do_redirect_error (void *cls) | |||
667 | resp = GNUNET_REST_create_response (""); | 687 | resp = GNUNET_REST_create_response (""); |
668 | MHD_add_response_header (resp, "Location", redirect); | 688 | MHD_add_response_header (resp, "Location", redirect); |
669 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 689 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
670 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 690 | cleanup_handle (handle); |
671 | GNUNET_free (redirect); | 691 | GNUNET_free (redirect); |
672 | } | 692 | } |
673 | 693 | ||
@@ -897,7 +917,7 @@ login_redirect (void *cls) | |||
897 | } | 917 | } |
898 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 918 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
899 | GNUNET_free (new_redirect); | 919 | GNUNET_free (new_redirect); |
900 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 920 | cleanup_handle (handle); |
901 | } | 921 | } |
902 | 922 | ||
903 | 923 | ||
@@ -920,7 +940,9 @@ oidc_iteration_error (void *cls) | |||
920 | * parameter. Otherwise redirects with error | 940 | * parameter. Otherwise redirects with error |
921 | */ | 941 | */ |
922 | static void | 942 | static void |
923 | oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | 943 | oidc_ticket_issue_cb (void *cls, |
944 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
945 | const struct GNUNET_RECLAIM_PresentationList *pres) | ||
924 | { | 946 | { |
925 | struct RequestHandle *handle = cls; | 947 | struct RequestHandle *handle = cls; |
926 | struct MHD_Response *resp; | 948 | struct MHD_Response *resp; |
@@ -943,7 +965,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
943 | code_string = OIDC_build_authz_code (&handle->priv_key, | 965 | code_string = OIDC_build_authz_code (&handle->priv_key, |
944 | &handle->ticket, | 966 | &handle->ticket, |
945 | handle->attr_idtoken_list, | 967 | handle->attr_idtoken_list, |
946 | handle->attests_list, | 968 | pres, |
947 | handle->oidc->nonce, | 969 | handle->oidc->nonce, |
948 | handle->oidc->code_challenge); | 970 | handle->oidc->code_challenge); |
949 | if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) && | 971 | if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) && |
@@ -974,7 +996,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
974 | resp = GNUNET_REST_create_response (""); | 996 | resp = GNUNET_REST_create_response (""); |
975 | MHD_add_response_header (resp, "Location", redirect_uri); | 997 | MHD_add_response_header (resp, "Location", redirect_uri); |
976 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 998 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
977 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 999 | cleanup_handle (handle); |
978 | GNUNET_free (redirect_uri); | 1000 | GNUNET_free (redirect_uri); |
979 | GNUNET_free (ticket_str); | 1001 | GNUNET_free (ticket_str); |
980 | GNUNET_free (code_string); | 1002 | GNUNET_free (code_string); |
@@ -996,13 +1018,13 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a, | |||
996 | le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 1018 | le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
997 | le_m->attribute = GNUNET_RECLAIM_attribute_new (le_a->attribute->name, | 1019 | le_m->attribute = GNUNET_RECLAIM_attribute_new (le_a->attribute->name, |
998 | &le_a->attribute-> | 1020 | &le_a->attribute-> |
999 | attestation, | 1021 | credential, |
1000 | le_a->attribute->type, | 1022 | le_a->attribute->type, |
1001 | le_a->attribute->data, | 1023 | le_a->attribute->data, |
1002 | le_a->attribute->data_size); | 1024 | le_a->attribute->data_size); |
1003 | le_m->attribute->id = le_a->attribute->id; | 1025 | le_m->attribute->id = le_a->attribute->id; |
1004 | le_m->attribute->flag = le_a->attribute->flag; | 1026 | le_m->attribute->flag = le_a->attribute->flag; |
1005 | le_m->attribute->attestation = le_a->attribute->attestation; | 1027 | le_m->attribute->credential = le_a->attribute->credential; |
1006 | GNUNET_CONTAINER_DLL_insert (merged_list->list_head, | 1028 | GNUNET_CONTAINER_DLL_insert (merged_list->list_head, |
1007 | merged_list->list_tail, | 1029 | merged_list->list_tail, |
1008 | le_m); | 1030 | le_m); |
@@ -1021,13 +1043,13 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a, | |||
1021 | le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 1043 | le_m = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
1022 | le_m->attribute = GNUNET_RECLAIM_attribute_new (le_b->attribute->name, | 1044 | le_m->attribute = GNUNET_RECLAIM_attribute_new (le_b->attribute->name, |
1023 | &le_b->attribute-> | 1045 | &le_b->attribute-> |
1024 | attestation, | 1046 | credential, |
1025 | le_b->attribute->type, | 1047 | le_b->attribute->type, |
1026 | le_b->attribute->data, | 1048 | le_b->attribute->data, |
1027 | le_b->attribute->data_size); | 1049 | le_b->attribute->data_size); |
1028 | le_m->attribute->id = le_b->attribute->id; | 1050 | le_m->attribute->id = le_b->attribute->id; |
1029 | le_m->attribute->flag = le_b->attribute->flag; | 1051 | le_m->attribute->flag = le_b->attribute->flag; |
1030 | le_m->attribute->attestation = le_b->attribute->attestation; | 1052 | le_m->attribute->credential = le_b->attribute->credential; |
1031 | GNUNET_CONTAINER_DLL_insert (merged_list->list_head, | 1053 | GNUNET_CONTAINER_DLL_insert (merged_list->list_head, |
1032 | merged_list->list_tail, | 1054 | merged_list->list_tail, |
1033 | le_m); | 1055 | le_m); |
@@ -1037,14 +1059,19 @@ attribute_list_merge (struct GNUNET_RECLAIM_AttributeList *list_a, | |||
1037 | 1059 | ||
1038 | 1060 | ||
1039 | static void | 1061 | static void |
1040 | oidc_attest_collect_finished_cb (void *cls) | 1062 | oidc_cred_collect_finished_cb (void *cls) |
1041 | { | 1063 | { |
1042 | struct RequestHandle *handle = cls; | 1064 | struct RequestHandle *handle = cls; |
1043 | struct GNUNET_RECLAIM_AttributeList *merged_list; | 1065 | struct GNUNET_RECLAIM_AttributeList *merged_list; |
1066 | struct GNUNET_RECLAIM_AttributeListEntry *le_m; | ||
1044 | 1067 | ||
1045 | handle->attest_it = NULL; | 1068 | handle->cred_it = NULL; |
1046 | merged_list = attribute_list_merge (handle->attr_idtoken_list, | 1069 | merged_list = attribute_list_merge (handle->attr_idtoken_list, |
1047 | handle->attr_userinfo_list); | 1070 | handle->attr_userinfo_list); |
1071 | for (le_m = merged_list->list_head; NULL != le_m; le_m = le_m->next) | ||
1072 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1073 | "List Attibute in ticket to issue: %s\n", | ||
1074 | le_m->attribute->name); | ||
1048 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (idp, | 1075 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (idp, |
1049 | &handle->priv_key, | 1076 | &handle->priv_key, |
1050 | &handle->oidc->client_pkey, | 1077 | &handle->oidc->client_pkey, |
@@ -1059,40 +1086,40 @@ oidc_attest_collect_finished_cb (void *cls) | |||
1059 | * Collects all attributes for an ego if in scope parameter | 1086 | * Collects all attributes for an ego if in scope parameter |
1060 | */ | 1087 | */ |
1061 | static void | 1088 | static void |
1062 | oidc_attest_collect (void *cls, | 1089 | oidc_cred_collect (void *cls, |
1063 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 1090 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
1064 | const struct GNUNET_RECLAIM_Attestation *attest) | 1091 | const struct GNUNET_RECLAIM_Credential *cred) |
1065 | { | 1092 | { |
1066 | struct RequestHandle *handle = cls; | 1093 | struct RequestHandle *handle = cls; |
1067 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 1094 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
1068 | struct GNUNET_RECLAIM_AttestationListEntry *ale; | 1095 | struct GNUNET_RECLAIM_CredentialListEntry *ale; |
1069 | 1096 | ||
1070 | for (ale = handle->attests_list->list_head; NULL != ale; ale = ale->next) | 1097 | for (ale = handle->credentials->list_head; NULL != ale; ale = ale->next) |
1071 | { | 1098 | { |
1072 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&ale->attestation->id, | 1099 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&ale->credential->id, |
1073 | &attest->id)) | 1100 | &cred->id)) |
1074 | continue; | 1101 | continue; |
1075 | /** Attestation already in list **/ | 1102 | /** Credential already in list **/ |
1076 | GNUNET_RECLAIM_get_attestations_next (handle->attest_it); | 1103 | GNUNET_RECLAIM_get_credentials_next (handle->cred_it); |
1077 | return; | 1104 | return; |
1078 | } | 1105 | } |
1079 | 1106 | ||
1080 | 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) |
1081 | { | 1108 | { |
1082 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation, | 1109 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->credential, |
1083 | &attest->id)) | 1110 | &cred->id)) |
1084 | continue; | 1111 | continue; |
1085 | /** Attestation matches for attribute, add **/ | 1112 | /** Credential matches for attribute, add **/ |
1086 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); | 1113 | ale = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry); |
1087 | ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name, | 1114 | ale->credential = GNUNET_RECLAIM_credential_new (cred->name, |
1088 | attest->type, | 1115 | cred->type, |
1089 | attest->data, | 1116 | cred->data, |
1090 | attest->data_size); | 1117 | cred->data_size); |
1091 | GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, | 1118 | GNUNET_CONTAINER_DLL_insert (handle->credentials->list_head, |
1092 | handle->attests_list->list_tail, | 1119 | handle->credentials->list_tail, |
1093 | ale); | 1120 | ale); |
1094 | } | 1121 | } |
1095 | GNUNET_RECLAIM_get_attestations_next (handle->attest_it); | 1122 | GNUNET_RECLAIM_get_credentials_next (handle->cred_it); |
1096 | } | 1123 | } |
1097 | 1124 | ||
1098 | 1125 | ||
@@ -1110,16 +1137,16 @@ oidc_attr_collect_finished_cb (void *cls) | |||
1110 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 1137 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
1111 | return; | 1138 | return; |
1112 | } | 1139 | } |
1113 | handle->attests_list = GNUNET_new (struct GNUNET_RECLAIM_AttestationList); | 1140 | handle->credentials = GNUNET_new (struct GNUNET_RECLAIM_CredentialList); |
1114 | handle->attest_it = | 1141 | handle->cred_it = |
1115 | GNUNET_RECLAIM_get_attestations_start (idp, | 1142 | GNUNET_RECLAIM_get_credentials_start (idp, |
1116 | &handle->priv_key, | 1143 | &handle->priv_key, |
1117 | &oidc_iteration_error, | 1144 | &oidc_iteration_error, |
1118 | handle, | 1145 | handle, |
1119 | &oidc_attest_collect, | 1146 | &oidc_cred_collect, |
1120 | handle, | 1147 | handle, |
1121 | &oidc_attest_collect_finished_cb, | 1148 | &oidc_cred_collect_finished_cb, |
1122 | handle); | 1149 | handle); |
1123 | 1150 | ||
1124 | } | 1151 | } |
1125 | 1152 | ||
@@ -1136,7 +1163,7 @@ attr_in_claims_request (struct RequestHandle *handle, | |||
1136 | const char *key; | 1163 | const char *key; |
1137 | json_t *value; | 1164 | json_t *value; |
1138 | 1165 | ||
1139 | /** Check if attribute is requested through standard scope **/ | 1166 | /** Check if attribute is requested through a scope **/ |
1140 | if (GNUNET_YES == OIDC_check_scopes_for_claim_request (handle->oidc->scope, | 1167 | if (GNUNET_YES == OIDC_check_scopes_for_claim_request (handle->oidc->scope, |
1141 | attr_name)) | 1168 | attr_name)) |
1142 | return GNUNET_YES; | 1169 | return GNUNET_YES; |
@@ -1193,13 +1220,13 @@ oidc_attr_collect (void *cls, | |||
1193 | { | 1220 | { |
1194 | le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 1221 | le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
1195 | le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, | 1222 | le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, |
1196 | &attr->attestation, | 1223 | &attr->credential, |
1197 | attr->type, | 1224 | attr->type, |
1198 | attr->data, | 1225 | attr->data, |
1199 | attr->data_size); | 1226 | attr->data_size); |
1200 | le->attribute->id = attr->id; | 1227 | le->attribute->id = attr->id; |
1201 | le->attribute->flag = attr->flag; | 1228 | le->attribute->flag = attr->flag; |
1202 | le->attribute->attestation = attr->attestation; | 1229 | le->attribute->credential = attr->credential; |
1203 | GNUNET_CONTAINER_DLL_insert (handle->attr_idtoken_list->list_head, | 1230 | GNUNET_CONTAINER_DLL_insert (handle->attr_idtoken_list->list_head, |
1204 | handle->attr_idtoken_list->list_tail, | 1231 | handle->attr_idtoken_list->list_tail, |
1205 | le); | 1232 | le); |
@@ -1208,13 +1235,13 @@ oidc_attr_collect (void *cls, | |||
1208 | { | 1235 | { |
1209 | le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 1236 | le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
1210 | le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, | 1237 | le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, |
1211 | &attr->attestation, | 1238 | &attr->credential, |
1212 | attr->type, | 1239 | attr->type, |
1213 | attr->data, | 1240 | attr->data, |
1214 | attr->data_size); | 1241 | attr->data_size); |
1215 | le->attribute->id = attr->id; | 1242 | le->attribute->id = attr->id; |
1216 | le->attribute->flag = attr->flag; | 1243 | le->attribute->flag = attr->flag; |
1217 | le->attribute->attestation = attr->attestation; | 1244 | le->attribute->credential = attr->credential; |
1218 | GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, | 1245 | GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, |
1219 | handle->attr_userinfo_list->list_tail, | 1246 | handle->attr_userinfo_list->list_tail, |
1220 | le); | 1247 | le); |
@@ -1332,7 +1359,7 @@ build_redirect (void *cls) | |||
1332 | resp = GNUNET_REST_create_response (""); | 1359 | resp = GNUNET_REST_create_response (""); |
1333 | MHD_add_response_header (resp, "Location", redirect_uri); | 1360 | MHD_add_response_header (resp, "Location", redirect_uri); |
1334 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 1361 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
1335 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1362 | cleanup_handle (handle); |
1336 | GNUNET_free (redirect_uri); | 1363 | GNUNET_free (redirect_uri); |
1337 | return; | 1364 | return; |
1338 | } | 1365 | } |
@@ -1709,7 +1736,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1709 | term_data); | 1736 | term_data); |
1710 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 1737 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); |
1711 | json_decref (root); | 1738 | json_decref (root); |
1712 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1739 | cleanup_handle (handle); |
1713 | return; | 1740 | return; |
1714 | } | 1741 | } |
1715 | GNUNET_asprintf (&cookie, "Identity=%s", json_string_value (identity)); | 1742 | GNUNET_asprintf (&cookie, "Identity=%s", json_string_value (identity)); |
@@ -1739,7 +1766,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1739 | GNUNET_free (cookie); | 1766 | GNUNET_free (cookie); |
1740 | GNUNET_free (header_val); | 1767 | GNUNET_free (header_val); |
1741 | json_decref (root); | 1768 | json_decref (root); |
1742 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1769 | cleanup_handle (handle); |
1743 | } | 1770 | } |
1744 | 1771 | ||
1745 | 1772 | ||
@@ -1963,10 +1990,9 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1963 | const struct EgoEntry *ego_entry; | 1990 | const struct EgoEntry *ego_entry; |
1964 | struct GNUNET_TIME_Relative expiration_time; | 1991 | struct GNUNET_TIME_Relative expiration_time; |
1965 | struct GNUNET_RECLAIM_AttributeList *cl = NULL; | 1992 | struct GNUNET_RECLAIM_AttributeList *cl = NULL; |
1966 | struct GNUNET_RECLAIM_AttestationList *al = NULL; | 1993 | struct GNUNET_RECLAIM_PresentationList *pl = NULL; |
1967 | struct GNUNET_RECLAIM_Ticket ticket; | 1994 | struct GNUNET_RECLAIM_Ticket ticket; |
1968 | struct GNUNET_CRYPTO_EcdsaPublicKey cid; | 1995 | struct GNUNET_CRYPTO_EcdsaPublicKey cid; |
1969 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | ||
1970 | struct GNUNET_HashCode cache_key; | 1996 | struct GNUNET_HashCode cache_key; |
1971 | struct MHD_Response *resp; | 1997 | struct MHD_Response *resp; |
1972 | char *grant_type; | 1998 | char *grant_type; |
@@ -2038,7 +2064,6 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2038 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2064 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2039 | return; | 2065 | return; |
2040 | } | 2066 | } |
2041 | privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
2042 | 2067 | ||
2043 | // REQUIRED code verifier | 2068 | // REQUIRED code verifier |
2044 | code_verifier = get_url_parameter_copy (handle, OIDC_CODE_VERIFIER_KEY); | 2069 | code_verifier = get_url_parameter_copy (handle, OIDC_CODE_VERIFIER_KEY); |
@@ -2051,7 +2076,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2051 | 2076 | ||
2052 | // decode code | 2077 | // decode code |
2053 | 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, |
2054 | &cl, &al, &nonce)) | 2079 | &cl, &pl, &nonce)) |
2055 | { | 2080 | { |
2056 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST); | 2081 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST); |
2057 | handle->edesc = GNUNET_strdup ("invalid code"); | 2082 | handle->edesc = GNUNET_strdup ("invalid code"); |
@@ -2091,7 +2116,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2091 | id_token = OIDC_generate_id_token (&ticket.audience, | 2116 | id_token = OIDC_generate_id_token (&ticket.audience, |
2092 | &ticket.identity, | 2117 | &ticket.identity, |
2093 | cl, | 2118 | cl, |
2094 | al, | 2119 | pl, |
2095 | &expiration_time, | 2120 | &expiration_time, |
2096 | (NULL != nonce) ? nonce : NULL, | 2121 | (NULL != nonce) ? nonce : NULL, |
2097 | jwt_secret); | 2122 | jwt_secret); |
@@ -2107,11 +2132,11 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2107 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 2132 | MHD_add_response_header (resp, "Content-Type", "application/json"); |
2108 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 2133 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
2109 | GNUNET_RECLAIM_attribute_list_destroy (cl); | 2134 | GNUNET_RECLAIM_attribute_list_destroy (cl); |
2110 | GNUNET_RECLAIM_attestation_list_destroy (al); | 2135 | GNUNET_RECLAIM_presentation_list_destroy (pl); |
2111 | GNUNET_free (access_token); | 2136 | GNUNET_free (access_token); |
2112 | GNUNET_free (json_response); | 2137 | GNUNET_free (json_response); |
2113 | GNUNET_free (id_token); | 2138 | GNUNET_free (id_token); |
2114 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 2139 | cleanup_handle (handle); |
2115 | } | 2140 | } |
2116 | 2141 | ||
2117 | 2142 | ||
@@ -2122,22 +2147,21 @@ static void | |||
2122 | consume_ticket (void *cls, | 2147 | consume_ticket (void *cls, |
2123 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 2148 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
2124 | const struct GNUNET_RECLAIM_Attribute *attr, | 2149 | const struct GNUNET_RECLAIM_Attribute *attr, |
2125 | const struct GNUNET_RECLAIM_Attestation *attest) | 2150 | const struct GNUNET_RECLAIM_Presentation *pres) |
2126 | { | 2151 | { |
2127 | struct RequestHandle *handle = cls; | 2152 | struct RequestHandle *handle = cls; |
2128 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | 2153 | struct GNUNET_RECLAIM_AttributeListEntry *ale; |
2129 | struct GNUNET_RECLAIM_AttestationListEntry *atle; | 2154 | struct GNUNET_RECLAIM_PresentationListEntry *atle; |
2130 | struct MHD_Response *resp; | 2155 | struct MHD_Response *resp; |
2131 | char *result_str; | 2156 | char *result_str; |
2132 | handle->idp_op = NULL; | 2157 | handle->idp_op = NULL; |
2133 | 2158 | ||
2134 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attr: %s\n", attr->name); | ||
2135 | if (NULL == identity) | 2159 | if (NULL == identity) |
2136 | { | 2160 | { |
2137 | result_str = OIDC_generate_userinfo (&handle->ticket.identity, | 2161 | result_str = OIDC_generate_userinfo (&handle->ticket.identity, |
2138 | handle->attr_userinfo_list, | 2162 | handle->attr_userinfo_list, |
2139 | handle->attests_list); | 2163 | handle->presentations); |
2140 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Userinfo: %s\n", result_str); | 2164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Userinfo: %s\n", result_str); |
2141 | resp = GNUNET_REST_create_response (result_str); | 2165 | resp = GNUNET_REST_create_response (result_str); |
2142 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 2166 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
2143 | GNUNET_free (result_str); | 2167 | GNUNET_free (result_str); |
@@ -2146,33 +2170,35 @@ consume_ticket (void *cls, | |||
2146 | } | 2170 | } |
2147 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 2171 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
2148 | ale->attribute = GNUNET_RECLAIM_attribute_new (attr->name, | 2172 | ale->attribute = GNUNET_RECLAIM_attribute_new (attr->name, |
2149 | &attr->attestation, | 2173 | &attr->credential, |
2150 | attr->type, | 2174 | attr->type, |
2151 | attr->data, | 2175 | attr->data, |
2152 | attr->data_size); | 2176 | attr->data_size); |
2153 | ale->attribute->id = attr->id; | 2177 | ale->attribute->id = attr->id; |
2154 | ale->attribute->flag = attr->flag; | 2178 | ale->attribute->flag = attr->flag; |
2155 | ale->attribute->attestation = attr->attestation; | 2179 | ale->attribute->credential = attr->credential; |
2156 | GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, | 2180 | GNUNET_CONTAINER_DLL_insert (handle->attr_userinfo_list->list_head, |
2157 | handle->attr_userinfo_list->list_tail, | 2181 | handle->attr_userinfo_list->list_tail, |
2158 | ale); | 2182 | ale); |
2159 | for (atle = handle->attests_list->list_head; NULL != atle; atle = atle->next) | 2183 | if (NULL == pres) |
2184 | return; | ||
2185 | for (atle = handle->presentations->list_head; | ||
2186 | NULL != atle; atle = atle->next) | ||
2160 | { | 2187 | { |
2161 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&atle->attestation->id, | 2188 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&atle->presentation->credential_id, |
2162 | &attest->id)) | 2189 | &pres->credential_id)) |
2163 | continue; | 2190 | continue; |
2164 | break; /** already in list **/ | 2191 | break; /** already in list **/ |
2165 | } | 2192 | } |
2166 | if (NULL == atle) | 2193 | if (NULL == atle) |
2167 | { | 2194 | { |
2168 | /** Attestation matches for attribute, add **/ | 2195 | /** Credential matches for attribute, add **/ |
2169 | atle = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); | 2196 | atle = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry); |
2170 | atle->attestation = GNUNET_RECLAIM_attestation_new (attest->name, | 2197 | atle->presentation = GNUNET_RECLAIM_presentation_new (pres->type, |
2171 | attest->type, | 2198 | pres->data, |
2172 | attest->data, | 2199 | pres->data_size); |
2173 | attest->data_size); | 2200 | GNUNET_CONTAINER_DLL_insert (handle->presentations->list_head, |
2174 | GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, | 2201 | handle->presentations->list_tail, |
2175 | handle->attests_list->list_tail, | ||
2176 | atle); | 2202 | atle); |
2177 | } | 2203 | } |
2178 | } | 2204 | } |
@@ -2271,8 +2297,8 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2271 | privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); | 2297 | privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); |
2272 | handle->attr_userinfo_list = | 2298 | handle->attr_userinfo_list = |
2273 | GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 2299 | GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
2274 | handle->attests_list = | 2300 | handle->presentations = |
2275 | GNUNET_new (struct GNUNET_RECLAIM_AttestationList); | 2301 | GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
2276 | 2302 | ||
2277 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, | 2303 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, |
2278 | privkey, | 2304 | privkey, |
@@ -2442,6 +2468,12 @@ oidc_config_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2442 | json_string ("openid")); | 2468 | json_string ("openid")); |
2443 | json_array_append_new (scopes, | 2469 | json_array_append_new (scopes, |
2444 | json_string ("profile")); | 2470 | json_string ("profile")); |
2471 | json_array_append_new (scopes, | ||
2472 | json_string ("email")); | ||
2473 | json_array_append_new (scopes, | ||
2474 | json_string ("address")); | ||
2475 | json_array_append_new (scopes, | ||
2476 | json_string ("phone")); | ||
2445 | json_object_set_new (oidc_config, | 2477 | json_object_set_new (oidc_config, |
2446 | "scopes_supported", | 2478 | "scopes_supported", |
2447 | scopes); | 2479 | scopes); |
@@ -2533,14 +2565,17 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
2533 | handle->proc = proc; | 2565 | handle->proc = proc; |
2534 | handle->rest_handle = rest_handle; | 2566 | handle->rest_handle = rest_handle; |
2535 | handle->url = GNUNET_strdup (rest_handle->url); | 2567 | handle->url = GNUNET_strdup (rest_handle->url); |
2568 | handle->timeout_task = | ||
2569 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
2570 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
2571 | requests_tail, | ||
2572 | handle); | ||
2536 | if (handle->url[strlen (handle->url) - 1] == '/') | 2573 | if (handle->url[strlen (handle->url) - 1] == '/') |
2537 | handle->url[strlen (handle->url) - 1] = '\0'; | 2574 | handle->url[strlen (handle->url) - 1] = '\0'; |
2538 | if (GNUNET_NO == | 2575 | if (GNUNET_NO == |
2539 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | 2576 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
2540 | return GNUNET_NO; | 2577 | return GNUNET_NO; |
2541 | 2578 | ||
2542 | handle->timeout_task = | ||
2543 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
2544 | return GNUNET_YES; | 2579 | return GNUNET_YES; |
2545 | } | 2580 | } |
2546 | 2581 | ||
@@ -2585,6 +2620,14 @@ libgnunet_plugin_rest_openid_connect_init (void *cls) | |||
2585 | } | 2620 | } |
2586 | 2621 | ||
2587 | 2622 | ||
2623 | static int | ||
2624 | cleanup_hashmap (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
2625 | { | ||
2626 | GNUNET_free (value); | ||
2627 | return GNUNET_YES; | ||
2628 | } | ||
2629 | |||
2630 | |||
2588 | /** | 2631 | /** |
2589 | * Exit point from the plugin. | 2632 | * Exit point from the plugin. |
2590 | * | 2633 | * |
@@ -2599,19 +2642,15 @@ libgnunet_plugin_rest_openid_connect_done (void *cls) | |||
2599 | struct EgoEntry *ego_entry; | 2642 | struct EgoEntry *ego_entry; |
2600 | 2643 | ||
2601 | plugin->cfg = NULL; | 2644 | plugin->cfg = NULL; |
2602 | 2645 | while (NULL != requests_head) | |
2603 | struct GNUNET_CONTAINER_MultiHashMapIterator *hashmap_it; | 2646 | cleanup_handle (requests_head); |
2604 | void *value = NULL; | 2647 | if (NULL != OIDC_cookie_jar_map) |
2605 | hashmap_it = | 2648 | { |
2606 | GNUNET_CONTAINER_multihashmap_iterator_create (OIDC_cookie_jar_map); | 2649 | GNUNET_CONTAINER_multihashmap_iterate (OIDC_cookie_jar_map, |
2607 | while (GNUNET_YES == | 2650 | &cleanup_hashmap, |
2608 | GNUNET_CONTAINER_multihashmap_iterator_next (hashmap_it, NULL, | 2651 | NULL); |
2609 | value)) | 2652 | GNUNET_CONTAINER_multihashmap_destroy (OIDC_cookie_jar_map); |
2610 | GNUNET_free (value); | 2653 | } |
2611 | GNUNET_CONTAINER_multihashmap_iterator_destroy (hashmap_it); | ||
2612 | GNUNET_CONTAINER_multihashmap_destroy (OIDC_cookie_jar_map); | ||
2613 | |||
2614 | GNUNET_CONTAINER_multihashmap_iterator_destroy (hashmap_it); | ||
2615 | GNUNET_free (allow_methods); | 2654 | GNUNET_free (allow_methods); |
2616 | if (NULL != gns_handle) | 2655 | if (NULL != gns_handle) |
2617 | GNUNET_GNS_disconnect (gns_handle); | 2656 | GNUNET_GNS_disconnect (gns_handle); |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index c2d14825e..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 |
@@ -154,6 +154,15 @@ struct EgoEntry | |||
154 | 154 | ||
155 | struct RequestHandle | 155 | struct RequestHandle |
156 | { | 156 | { |
157 | /** | ||
158 | * DLL | ||
159 | */ | ||
160 | struct RequestHandle *next; | ||
161 | |||
162 | /** | ||
163 | * DLL | ||
164 | */ | ||
165 | struct RequestHandle *prev; | ||
157 | 166 | ||
158 | /** | 167 | /** |
159 | * Selected ego | 168 | * Selected ego |
@@ -193,7 +202,7 @@ struct RequestHandle | |||
193 | /** | 202 | /** |
194 | * Attribute iterator | 203 | * Attribute iterator |
195 | */ | 204 | */ |
196 | struct GNUNET_RECLAIM_AttestationIterator *attest_it; | 205 | struct GNUNET_RECLAIM_CredentialIterator *cred_it; |
197 | 206 | ||
198 | /** | 207 | /** |
199 | * Ticket iterator | 208 | * Ticket iterator |
@@ -247,6 +256,17 @@ struct RequestHandle | |||
247 | }; | 256 | }; |
248 | 257 | ||
249 | /** | 258 | /** |
259 | * DLL | ||
260 | */ | ||
261 | static struct RequestHandle *requests_head; | ||
262 | |||
263 | /** | ||
264 | * DLL | ||
265 | */ | ||
266 | static struct RequestHandle *requests_tail; | ||
267 | |||
268 | |||
269 | /** | ||
250 | * Cleanup lookup handle | 270 | * Cleanup lookup handle |
251 | * @param handle Handle to clean up | 271 | * @param handle Handle to clean up |
252 | */ | 272 | */ |
@@ -262,8 +282,8 @@ cleanup_handle (void *cls) | |||
262 | GNUNET_SCHEDULER_cancel (handle->timeout_task); | 282 | GNUNET_SCHEDULER_cancel (handle->timeout_task); |
263 | if (NULL != handle->attr_it) | 283 | if (NULL != handle->attr_it) |
264 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); | 284 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); |
265 | if (NULL != handle->attest_it) | 285 | if (NULL != handle->cred_it) |
266 | GNUNET_RECLAIM_get_attestations_stop (handle->attest_it); | 286 | GNUNET_RECLAIM_get_credentials_stop (handle->cred_it); |
267 | if (NULL != handle->ticket_it) | 287 | if (NULL != handle->ticket_it) |
268 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); | 288 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); |
269 | if (NULL != handle->url) | 289 | if (NULL != handle->url) |
@@ -272,6 +292,9 @@ cleanup_handle (void *cls) | |||
272 | GNUNET_free (handle->emsg); | 292 | GNUNET_free (handle->emsg); |
273 | if (NULL != handle->attr_list) | 293 | if (NULL != handle->attr_list) |
274 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list); | 294 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list); |
295 | GNUNET_CONTAINER_DLL_remove (requests_head, | ||
296 | requests_tail, | ||
297 | handle); | ||
275 | GNUNET_free (handle); | 298 | GNUNET_free (handle); |
276 | } | 299 | } |
277 | 300 | ||
@@ -296,7 +319,7 @@ do_error (void *cls) | |||
296 | resp = GNUNET_REST_create_response (json_error); | 319 | resp = GNUNET_REST_create_response (json_error); |
297 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 320 | MHD_add_response_header (resp, "Content-Type", "application/json"); |
298 | handle->proc (handle->proc_cls, resp, handle->response_code); | 321 | handle->proc (handle->proc_cls, resp, handle->response_code); |
299 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 322 | cleanup_handle (handle); |
300 | GNUNET_free (json_error); | 323 | GNUNET_free (json_error); |
301 | } | 324 | } |
302 | 325 | ||
@@ -319,7 +342,7 @@ do_timeout (void *cls) | |||
319 | static void | 342 | static void |
320 | collect_error_cb (void *cls) | 343 | collect_error_cb (void *cls) |
321 | { | 344 | { |
322 | do_error (cls); | 345 | GNUNET_SCHEDULER_add_now (&do_error, cls); |
323 | } | 346 | } |
324 | 347 | ||
325 | 348 | ||
@@ -329,6 +352,7 @@ finished_cont (void *cls, int32_t success, const char *emsg) | |||
329 | struct RequestHandle *handle = cls; | 352 | struct RequestHandle *handle = cls; |
330 | struct MHD_Response *resp; | 353 | struct MHD_Response *resp; |
331 | 354 | ||
355 | handle->idp_op = NULL; | ||
332 | resp = GNUNET_REST_create_response (emsg); | 356 | resp = GNUNET_REST_create_response (emsg); |
333 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 357 | MHD_add_response_header (resp, "Content-Type", "application/json"); |
334 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | 358 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); |
@@ -389,7 +413,7 @@ collect_finished_cb (void *cls) | |||
389 | 413 | ||
390 | // Done | 414 | // Done |
391 | handle->attr_it = NULL; | 415 | handle->attr_it = NULL; |
392 | handle->attest_it = NULL; | 416 | handle->cred_it = NULL; |
393 | handle->ticket_it = NULL; | 417 | handle->ticket_it = NULL; |
394 | GNUNET_SCHEDULER_add_now (&return_response, handle); | 418 | GNUNET_SCHEDULER_add_now (&return_response, handle); |
395 | } | 419 | } |
@@ -436,7 +460,7 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
436 | 460 | ||
437 | 461 | ||
438 | static void | 462 | static void |
439 | add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | 463 | add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
440 | const char *url, | 464 | const char *url, |
441 | void *cls) | 465 | void *cls) |
442 | { | 466 | { |
@@ -444,19 +468,19 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
444 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; | 468 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; |
445 | const char *identity; | 469 | const char *identity; |
446 | struct EgoEntry *ego_entry; | 470 | struct EgoEntry *ego_entry; |
447 | struct GNUNET_RECLAIM_Attestation *attribute; | 471 | struct GNUNET_RECLAIM_Credential *attribute; |
448 | struct GNUNET_TIME_Relative exp; | 472 | struct GNUNET_TIME_Relative exp; |
449 | char term_data[handle->rest_handle->data_size + 1]; | 473 | char term_data[handle->rest_handle->data_size + 1]; |
450 | json_t *data_json; | 474 | json_t *data_json; |
451 | json_error_t err; | 475 | json_error_t err; |
452 | struct GNUNET_JSON_Specification attrspec[] = | 476 | struct GNUNET_JSON_Specification attrspec[] = |
453 | { GNUNET_RECLAIM_JSON_spec_claim_attest (&attribute), | 477 | { GNUNET_RECLAIM_JSON_spec_credential (&attribute), |
454 | GNUNET_JSON_spec_end () }; | 478 | GNUNET_JSON_spec_end () }; |
455 | 479 | ||
456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 480 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
457 | "Adding an attestation for %s.\n", | 481 | "Adding an credential for %s.\n", |
458 | handle->url); | 482 | handle->url); |
459 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( | 483 | if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen ( |
460 | handle->url)) | 484 | handle->url)) |
461 | { | 485 | { |
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 486 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
@@ -464,7 +488,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
464 | return; | 488 | return; |
465 | } | 489 | } |
466 | identity = handle->url + strlen ( | 490 | identity = handle->url + strlen ( |
467 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1; | 491 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1; |
468 | 492 | ||
469 | for (ego_entry = ego_head; NULL != ego_entry; | 493 | for (ego_entry = ego_head; NULL != ego_entry; |
470 | ego_entry = ego_entry->next) | 494 | ego_entry = ego_entry->next) |
@@ -494,7 +518,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
494 | if (NULL == attribute) | 518 | if (NULL == attribute) |
495 | { | 519 | { |
496 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 520 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
497 | "Unable to parse attestation from %s\n", | 521 | "Unable to parse credential from %s\n", |
498 | term_data); | 522 | term_data); |
499 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 523 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
500 | return; | 524 | return; |
@@ -505,7 +529,7 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
505 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) | 529 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id)) |
506 | GNUNET_RECLAIM_id_generate (&attribute->id); | 530 | GNUNET_RECLAIM_id_generate (&attribute->id); |
507 | exp = GNUNET_TIME_UNIT_HOURS; | 531 | exp = GNUNET_TIME_UNIT_HOURS; |
508 | handle->idp_op = GNUNET_RECLAIM_attestation_store (idp, | 532 | handle->idp_op = GNUNET_RECLAIM_credential_store (idp, |
509 | identity_priv, | 533 | identity_priv, |
510 | attribute, | 534 | attribute, |
511 | &exp, | 535 | &exp, |
@@ -516,52 +540,52 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
516 | 540 | ||
517 | 541 | ||
518 | /** | 542 | /** |
519 | * Collect all attestations for an ego | 543 | * Collect all credentials for an ego |
520 | * | 544 | * |
521 | */ | 545 | */ |
522 | static void | 546 | static void |
523 | attest_collect (void *cls, | 547 | cred_collect (void *cls, |
524 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 548 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
525 | const struct GNUNET_RECLAIM_Attestation *attest) | 549 | const struct GNUNET_RECLAIM_Credential *cred) |
526 | { | 550 | { |
527 | struct RequestHandle *handle = cls; | 551 | struct RequestHandle *handle = cls; |
528 | struct GNUNET_RECLAIM_AttributeList *attrs; | 552 | struct GNUNET_RECLAIM_AttributeList *attrs; |
529 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | 553 | struct GNUNET_RECLAIM_AttributeListEntry *ale; |
530 | struct GNUNET_TIME_Absolute exp; | 554 | struct GNUNET_TIME_Absolute exp; |
531 | json_t *attr_obj; | 555 | json_t *attr_obj; |
532 | json_t *attest_obj; | 556 | json_t *cred_obj; |
533 | const char *type; | 557 | const char *type; |
534 | char *tmp_value; | 558 | char *tmp_value; |
535 | char *id_str; | 559 | char *id_str; |
536 | char *issuer; | 560 | char *issuer; |
537 | 561 | ||
538 | 562 | ||
539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n", | 563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n", |
540 | attest->name); | 564 | cred->name); |
541 | attrs = GNUNET_RECLAIM_attestation_get_attributes (attest); | 565 | attrs = GNUNET_RECLAIM_credential_get_attributes (cred); |
542 | issuer = GNUNET_RECLAIM_attestation_get_issuer (attest); | 566 | issuer = GNUNET_RECLAIM_credential_get_issuer (cred); |
543 | tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type, | 567 | tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type, |
544 | attest->data, | 568 | cred->data, |
545 | attest->data_size); | 569 | cred->data_size); |
546 | attest_obj = json_object (); | 570 | cred_obj = json_object (); |
547 | json_object_set_new (attest_obj, "value", json_string (tmp_value)); | 571 | json_object_set_new (cred_obj, "value", json_string (tmp_value)); |
548 | json_object_set_new (attest_obj, "name", json_string (attest->name)); | 572 | json_object_set_new (cred_obj, "name", json_string (cred->name)); |
549 | type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type); | 573 | type = GNUNET_RECLAIM_credential_number_to_typename (cred->type); |
550 | json_object_set_new (attest_obj, "type", json_string (type)); | 574 | json_object_set_new (cred_obj, "type", json_string (type)); |
551 | if (NULL != issuer) | 575 | if (NULL != issuer) |
552 | { | 576 | { |
553 | json_object_set_new (attest_obj, "issuer", json_string (issuer)); | 577 | json_object_set_new (cred_obj, "issuer", json_string (issuer)); |
554 | GNUNET_free (issuer); | 578 | GNUNET_free (issuer); |
555 | } | 579 | } |
556 | if (GNUNET_OK == GNUNET_RECLAIM_attestation_get_expiration (attest, | 580 | if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred, |
557 | &exp)) | 581 | &exp)) |
558 | { | 582 | { |
559 | json_object_set_new (attest_obj, "expiration", json_integer ( | 583 | json_object_set_new (cred_obj, "expiration", json_integer ( |
560 | exp.abs_value_us)); | 584 | exp.abs_value_us)); |
561 | } | 585 | } |
562 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, | 586 | id_str = GNUNET_STRINGS_data_to_string_alloc (&cred->id, |
563 | sizeof(attest->id)); | 587 | sizeof(cred->id)); |
564 | json_object_set_new (attest_obj, "id", json_string (id_str)); | 588 | json_object_set_new (cred_obj, "id", json_string (id_str)); |
565 | GNUNET_free (tmp_value); | 589 | GNUNET_free (tmp_value); |
566 | GNUNET_free (id_str); | 590 | GNUNET_free (id_str); |
567 | if (NULL != attrs) | 591 | if (NULL != attrs) |
@@ -582,27 +606,27 @@ attest_collect (void *cls, | |||
582 | type = GNUNET_RECLAIM_attribute_number_to_typename (ale->attribute->type); | 606 | type = GNUNET_RECLAIM_attribute_number_to_typename (ale->attribute->type); |
583 | json_object_set_new (attr_obj, "type", json_string (type)); | 607 | json_object_set_new (attr_obj, "type", json_string (type)); |
584 | json_object_set_new (attr_obj, "id", json_string ("")); | 608 | json_object_set_new (attr_obj, "id", json_string ("")); |
585 | json_object_set_new (attr_obj, "attestation", json_string ("")); | 609 | json_object_set_new (attr_obj, "credential", json_string ("")); |
586 | json_array_append_new (attr_arr, attr_obj); | 610 | json_array_append_new (attr_arr, attr_obj); |
587 | GNUNET_free (tmp_value); | 611 | GNUNET_free (tmp_value); |
588 | } | 612 | } |
589 | json_object_set_new (attest_obj, "attributes", attr_arr); | 613 | json_object_set_new (cred_obj, "attributes", attr_arr); |
590 | } | 614 | } |
591 | json_array_append_new (handle->resp_object, attest_obj); | 615 | json_array_append_new (handle->resp_object, cred_obj); |
592 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | 616 | GNUNET_RECLAIM_attribute_list_destroy (attrs); |
593 | GNUNET_RECLAIM_get_attestations_next (handle->attest_it); | 617 | GNUNET_RECLAIM_get_credentials_next (handle->cred_it); |
594 | } | 618 | } |
595 | 619 | ||
596 | 620 | ||
597 | /** | 621 | /** |
598 | * Lists attestation for identity request | 622 | * Lists credential for identity request |
599 | * | 623 | * |
600 | * @param con_handle the connection handle | 624 | * @param con_handle the connection handle |
601 | * @param url the url | 625 | * @param url the url |
602 | * @param cls the RequestHandle | 626 | * @param cls the RequestHandle |
603 | */ | 627 | */ |
604 | static void | 628 | static void |
605 | list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | 629 | list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
606 | const char *url, | 630 | const char *url, |
607 | void *cls) | 631 | void *cls) |
608 | { | 632 | { |
@@ -612,9 +636,9 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
612 | char *identity; | 636 | char *identity; |
613 | 637 | ||
614 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
615 | "Getting attestations for %s.\n", | 639 | "Getting credentials for %s.\n", |
616 | handle->url); | 640 | handle->url); |
617 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( | 641 | if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen ( |
618 | handle->url)) | 642 | handle->url)) |
619 | { | 643 | { |
620 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 644 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
@@ -622,7 +646,7 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
622 | return; | 646 | return; |
623 | } | 647 | } |
624 | identity = handle->url + strlen ( | 648 | identity = handle->url + strlen ( |
625 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1; | 649 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1; |
626 | 650 | ||
627 | for (ego_entry = ego_head; NULL != ego_entry; | 651 | for (ego_entry = ego_head; NULL != ego_entry; |
628 | ego_entry = ego_entry->next) | 652 | ego_entry = ego_entry->next) |
@@ -639,11 +663,11 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
639 | return; | 663 | return; |
640 | } | 664 | } |
641 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 665 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
642 | handle->attest_it = GNUNET_RECLAIM_get_attestations_start (idp, | 666 | handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp, |
643 | priv_key, | 667 | priv_key, |
644 | &collect_error_cb, | 668 | &collect_error_cb, |
645 | handle, | 669 | handle, |
646 | &attest_collect, | 670 | &cred_collect, |
647 | handle, | 671 | handle, |
648 | & | 672 | & |
649 | collect_finished_cb, | 673 | collect_finished_cb, |
@@ -652,27 +676,27 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
652 | 676 | ||
653 | 677 | ||
654 | /** | 678 | /** |
655 | * Deletes attestation from an identity | 679 | * Deletes credential from an identity |
656 | * | 680 | * |
657 | * @param con_handle the connection handle | 681 | * @param con_handle the connection handle |
658 | * @param url the url | 682 | * @param url the url |
659 | * @param cls the RequestHandle | 683 | * @param cls the RequestHandle |
660 | */ | 684 | */ |
661 | static void | 685 | static void |
662 | delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | 686 | delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
663 | const char *url, | 687 | const char *url, |
664 | void *cls) | 688 | void *cls) |
665 | { | 689 | { |
666 | struct RequestHandle *handle = cls; | 690 | struct RequestHandle *handle = cls; |
667 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 691 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
668 | struct GNUNET_RECLAIM_Attestation attr; | 692 | struct GNUNET_RECLAIM_Credential attr; |
669 | struct EgoEntry *ego_entry; | 693 | struct EgoEntry *ego_entry; |
670 | char *identity_id_str; | 694 | char *identity_id_str; |
671 | char *identity; | 695 | char *identity; |
672 | char *id; | 696 | char *id; |
673 | 697 | ||
674 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n"); | 698 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n"); |
675 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen ( | 699 | if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen ( |
676 | handle->url)) | 700 | handle->url)) |
677 | { | 701 | { |
678 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
@@ -681,7 +705,7 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
681 | } | 705 | } |
682 | identity_id_str = | 706 | identity_id_str = |
683 | strdup (handle->url + strlen ( | 707 | strdup (handle->url + strlen ( |
684 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1); | 708 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) + 1); |
685 | identity = strtok (identity_id_str, "/"); | 709 | identity = strtok (identity_id_str, "/"); |
686 | id = strtok (NULL, "/"); | 710 | id = strtok (NULL, "/"); |
687 | if ((NULL == identity) || (NULL == id)) | 711 | if ((NULL == identity) || (NULL == id)) |
@@ -706,10 +730,10 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
706 | return; | 730 | return; |
707 | } | 731 | } |
708 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 732 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
709 | memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attestation)); | 733 | memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential)); |
710 | 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)); |
711 | attr.name = ""; | 735 | attr.name = ""; |
712 | handle->idp_op = GNUNET_RECLAIM_attestation_delete (idp, | 736 | handle->idp_op = GNUNET_RECLAIM_credential_delete (idp, |
713 | priv_key, | 737 | priv_key, |
714 | &attr, | 738 | &attr, |
715 | &delete_finished_cb, | 739 | &delete_finished_cb, |
@@ -787,7 +811,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
787 | json_t *data_json; | 811 | json_t *data_json; |
788 | json_error_t err; | 812 | json_error_t err; |
789 | struct GNUNET_JSON_Specification attrspec[] = | 813 | struct GNUNET_JSON_Specification attrspec[] = |
790 | { GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end () }; | 814 | { GNUNET_RECLAIM_JSON_spec_attribute (&attribute), GNUNET_JSON_spec_end () }; |
791 | 815 | ||
792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
793 | "Adding an attribute for %s.\n", | 817 | "Adding an attribute for %s.\n", |
@@ -853,13 +877,13 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
853 | /** | 877 | /** |
854 | * Parse a JWT and return the respective claim value as Attribute | 878 | * Parse a JWT and return the respective claim value as Attribute |
855 | * | 879 | * |
856 | * @param attest the jwt attestation | 880 | * @param cred the jwt credential |
857 | * @param claim the name of the claim in the JWT | 881 | * @param claim the name of the claim in the JWT |
858 | * | 882 | * |
859 | * @return a GNUNET_RECLAIM_Attribute, containing the new value | 883 | * @return a GNUNET_RECLAIM_Attribute, containing the new value |
860 | */ | 884 | */ |
861 | struct GNUNET_RECLAIM_Attribute * | 885 | struct GNUNET_RECLAIM_Attribute * |
862 | parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest, | 886 | parse_jwt (const struct GNUNET_RECLAIM_Credential *cred, |
863 | const char *claim) | 887 | const char *claim) |
864 | { | 888 | { |
865 | char *jwt_string; | 889 | char *jwt_string; |
@@ -875,9 +899,9 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest, | |||
875 | json_t *json_val; | 899 | json_t *json_val; |
876 | json_error_t *json_err = NULL; | 900 | json_error_t *json_err = NULL; |
877 | 901 | ||
878 | jwt_string = GNUNET_RECLAIM_attestation_value_to_string (attest->type, | 902 | jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type, |
879 | attest->data, | 903 | cred->data, |
880 | attest->data_size); | 904 | cred->data_size); |
881 | char *jwt_body = strtok (jwt_string, delim); | 905 | char *jwt_body = strtok (jwt_string, delim); |
882 | jwt_body = strtok (NULL, delim); | 906 | jwt_body = strtok (NULL, delim); |
883 | GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), | 907 | GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), |
@@ -903,16 +927,16 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest, | |||
903 | "Error: Referenced Claim Name not Found", | 927 | "Error: Referenced Claim Name not Found", |
904 | (void **) &data, | 928 | (void **) &data, |
905 | &data_size); | 929 | &data_size); |
906 | attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id, | 930 | attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id, |
907 | type, data, data_size); | 931 | type, data, data_size); |
908 | attr->id = attest->id; | 932 | attr->id = cred->id; |
909 | attr->flag = 1; | 933 | attr->flag = 1; |
910 | } | 934 | } |
911 | else | 935 | else |
912 | { | 936 | { |
913 | attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id, | 937 | attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id, |
914 | type, data, data_size); | 938 | type, data, data_size); |
915 | attr->id = attest->id; | 939 | attr->id = cred->id; |
916 | attr->flag = 1; | 940 | attr->flag = 1; |
917 | } | 941 | } |
918 | return attr; | 942 | return attr; |
@@ -941,7 +965,7 @@ attr_collect (void *cls, | |||
941 | json_object_set_new (attr_obj, "value", json_string (tmp_value)); | 965 | json_object_set_new (attr_obj, "value", json_string (tmp_value)); |
942 | json_object_set_new (attr_obj, "name", json_string (attr->name)); | 966 | json_object_set_new (attr_obj, "name", json_string (attr->name)); |
943 | 967 | ||
944 | if (GNUNET_RECLAIM_id_is_zero (&attr->attestation)) | 968 | if (GNUNET_RECLAIM_id_is_zero (&attr->credential)) |
945 | json_object_set_new (attr_obj, "flag", json_string ("0")); | 969 | json_object_set_new (attr_obj, "flag", json_string ("0")); |
946 | else | 970 | else |
947 | json_object_set_new (attr_obj, "flag", json_string ("1")); | 971 | json_object_set_new (attr_obj, "flag", json_string ("1")); |
@@ -950,9 +974,9 @@ attr_collect (void *cls, | |||
950 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, | 974 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, |
951 | sizeof(attr->id)); | 975 | sizeof(attr->id)); |
952 | json_object_set_new (attr_obj, "id", json_string (id_str)); | 976 | json_object_set_new (attr_obj, "id", json_string (id_str)); |
953 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->attestation, | 977 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential, |
954 | sizeof(attr->attestation)); | 978 | sizeof(attr->credential)); |
955 | json_object_set_new (attr_obj, "attestation", json_string (id_str)); | 979 | json_object_set_new (attr_obj, "credential", json_string (id_str)); |
956 | json_array_append (handle->resp_object, attr_obj); | 980 | json_array_append (handle->resp_object, attr_obj); |
957 | json_decref (attr_obj); | 981 | json_decref (attr_obj); |
958 | GNUNET_free (tmp_value); | 982 | GNUNET_free (tmp_value); |
@@ -1156,7 +1180,7 @@ static void | |||
1156 | consume_cont (void *cls, | 1180 | consume_cont (void *cls, |
1157 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 1181 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
1158 | const struct GNUNET_RECLAIM_Attribute *attr, | 1182 | const struct GNUNET_RECLAIM_Attribute *attr, |
1159 | const struct GNUNET_RECLAIM_Attestation *attest) | 1183 | const struct GNUNET_RECLAIM_Presentation *pres) |
1160 | { | 1184 | { |
1161 | struct RequestHandle *handle = cls; | 1185 | struct RequestHandle *handle = cls; |
1162 | char *val_str; | 1186 | char *val_str; |
@@ -1403,11 +1427,11 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1403 | { MHD_HTTP_METHOD_DELETE, | 1427 | { MHD_HTTP_METHOD_DELETE, |
1404 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, | 1428 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, |
1405 | { MHD_HTTP_METHOD_GET, | 1429 | { MHD_HTTP_METHOD_GET, |
1406 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &list_attestation_cont }, | 1430 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont }, |
1407 | { MHD_HTTP_METHOD_POST, | 1431 | { MHD_HTTP_METHOD_POST, |
1408 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &add_attestation_cont }, | 1432 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont }, |
1409 | { MHD_HTTP_METHOD_DELETE, | 1433 | { MHD_HTTP_METHOD_DELETE, |
1410 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION, &delete_attestation_cont }, | 1434 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont }, |
1411 | { MHD_HTTP_METHOD_GET, | 1435 | { MHD_HTTP_METHOD_GET, |
1412 | GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, | 1436 | GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, |
1413 | { MHD_HTTP_METHOD_POST, | 1437 | { MHD_HTTP_METHOD_POST, |
@@ -1422,12 +1446,16 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1422 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1446 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
1423 | handle->proc_cls = proc_cls; | 1447 | handle->proc_cls = proc_cls; |
1424 | handle->proc = proc; | 1448 | handle->proc = proc; |
1425 | state = ID_REST_STATE_INIT; | ||
1426 | handle->rest_handle = rest_handle; | 1449 | handle->rest_handle = rest_handle; |
1427 | 1450 | ||
1428 | handle->url = GNUNET_strdup (rest_handle->url); | 1451 | handle->url = GNUNET_strdup (rest_handle->url); |
1429 | if (handle->url[strlen (handle->url) - 1] == '/') | 1452 | if (handle->url[strlen (handle->url) - 1] == '/') |
1430 | handle->url[strlen (handle->url) - 1] = '\0'; | 1453 | handle->url[strlen (handle->url) - 1] = '\0'; |
1454 | handle->timeout_task = | ||
1455 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
1456 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
1457 | requests_tail, | ||
1458 | handle); | ||
1431 | if (GNUNET_NO == | 1459 | if (GNUNET_NO == |
1432 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | 1460 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
1433 | { | 1461 | { |
@@ -1435,8 +1463,6 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1435 | return GNUNET_NO; | 1463 | return GNUNET_NO; |
1436 | } | 1464 | } |
1437 | 1465 | ||
1438 | handle->timeout_task = | ||
1439 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
1440 | return GNUNET_YES; | 1466 | return GNUNET_YES; |
1441 | } | 1467 | } |
1442 | 1468 | ||
@@ -1470,6 +1496,7 @@ libgnunet_plugin_rest_reclaim_init (void *cls) | |||
1470 | MHD_HTTP_METHOD_DELETE, | 1496 | MHD_HTTP_METHOD_DELETE, |
1471 | MHD_HTTP_METHOD_OPTIONS); | 1497 | MHD_HTTP_METHOD_OPTIONS); |
1472 | identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); | 1498 | identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); |
1499 | state = ID_REST_STATE_INIT; | ||
1473 | idp = GNUNET_RECLAIM_connect (cfg); | 1500 | idp = GNUNET_RECLAIM_connect (cfg); |
1474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1475 | _ ("Identity Provider REST API initialized\n")); | 1502 | _ ("Identity Provider REST API initialized\n")); |
@@ -1488,10 +1515,13 @@ libgnunet_plugin_rest_reclaim_done (void *cls) | |||
1488 | { | 1515 | { |
1489 | struct GNUNET_REST_Plugin *api = cls; | 1516 | struct GNUNET_REST_Plugin *api = cls; |
1490 | struct Plugin *plugin = api->cls; | 1517 | struct Plugin *plugin = api->cls; |
1518 | struct RequestHandle *request; | ||
1491 | struct EgoEntry *ego_entry; | 1519 | struct EgoEntry *ego_entry; |
1492 | struct EgoEntry *ego_tmp; | 1520 | struct EgoEntry *ego_tmp; |
1493 | 1521 | ||
1494 | plugin->cfg = NULL; | 1522 | plugin->cfg = NULL; |
1523 | while (NULL != (request = requests_head)) | ||
1524 | do_error (request); | ||
1495 | if (NULL != idp) | 1525 | if (NULL != idp) |
1496 | GNUNET_RECLAIM_disconnect (idp); | 1526 | GNUNET_RECLAIM_disconnect (idp); |
1497 | if (NULL != identity_handle) | 1527 | if (NULL != identity_handle) |
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 | */ |
164 | struct AttestationResultMessage | 164 | struct 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 | */ |
239 | struct AttestationIterationStartMessage | 239 | struct 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 | */ |
261 | struct AttestationIterationNextMessage | 261 | struct 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 | */ |
278 | struct AttestationIterationStopMessage | 278 | struct 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 d73241a6f..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 | */ |
244 | struct GNUNET_RECLAIM_AttestationIterator | 249 | struct 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 | */ |
466 | static void | 471 | static void |
467 | free_ait (struct GNUNET_RECLAIM_AttestationIterator *ait) | 472 | free_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 | } |
@@ -747,7 +751,8 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
747 | 751 | ||
748 | { | 752 | { |
749 | struct GNUNET_RECLAIM_Attribute *attr; | 753 | struct GNUNET_RECLAIM_Attribute *attr; |
750 | attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len); | 754 | GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len, |
755 | &attr); | ||
751 | if (NULL != it) | 756 | if (NULL != it) |
752 | { | 757 | { |
753 | if (NULL != it->proc) | 758 | if (NULL != it->proc) |
@@ -767,21 +772,21 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
767 | 772 | ||
768 | /** | 773 | /** |
769 | * Handle an incoming message of type | 774 | * Handle an incoming message of type |
770 | * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT | 775 | * #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT |
771 | * | 776 | * |
772 | * @param cls | 777 | * @param cls |
773 | * @param msg the message we received | 778 | * @param msg the message we received |
774 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 779 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
775 | */ | 780 | */ |
776 | static int | 781 | static int |
777 | check_attestation_result (void *cls, const struct AttestationResultMessage *msg) | 782 | check_credential_result (void *cls, const struct CredentialResultMessage *msg) |
778 | { | 783 | { |
779 | size_t msg_len; | 784 | size_t msg_len; |
780 | size_t attest_len; | 785 | size_t cred_len; |
781 | 786 | ||
782 | msg_len = ntohs (msg->header.size); | 787 | msg_len = ntohs (msg->header.size); |
783 | attest_len = ntohs (msg->attestation_len); | 788 | cred_len = ntohs (msg->credential_len); |
784 | if (msg_len != sizeof(struct AttestationResultMessage) + attest_len) | 789 | if (msg_len != sizeof(struct CredentialResultMessage) + cred_len) |
785 | { | 790 | { |
786 | GNUNET_break (0); | 791 | GNUNET_break (0); |
787 | return GNUNET_SYSERR; | 792 | return GNUNET_SYSERR; |
@@ -792,24 +797,24 @@ check_attestation_result (void *cls, const struct AttestationResultMessage *msg) | |||
792 | 797 | ||
793 | /** | 798 | /** |
794 | * Handle an incoming message of type | 799 | * Handle an incoming message of type |
795 | * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT | 800 | * #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT |
796 | * | 801 | * |
797 | * @param cls | 802 | * @param cls |
798 | * @param msg the message we received | 803 | * @param msg the message we received |
799 | */ | 804 | */ |
800 | static void | 805 | static void |
801 | handle_attestation_result (void *cls, const struct | 806 | handle_credential_result (void *cls, const struct |
802 | AttestationResultMessage *msg) | 807 | CredentialResultMessage *msg) |
803 | { | 808 | { |
804 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | 809 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; |
805 | struct GNUNET_RECLAIM_Handle *h = cls; | 810 | struct GNUNET_RECLAIM_Handle *h = cls; |
806 | struct GNUNET_RECLAIM_AttestationIterator *it; | 811 | struct GNUNET_RECLAIM_CredentialIterator *it; |
807 | struct GNUNET_RECLAIM_Operation *op; | 812 | struct GNUNET_RECLAIM_Operation *op; |
808 | size_t att_len; | 813 | size_t att_len; |
809 | uint32_t r_id = ntohl (msg->id); | 814 | uint32_t r_id = ntohl (msg->id); |
810 | 815 | ||
811 | att_len = ntohs (msg->attestation_len); | 816 | att_len = ntohs (msg->credential_len); |
812 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); | 817 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n"); |
813 | 818 | ||
814 | 819 | ||
815 | for (it = h->ait_head; NULL != it; it = it->next) | 820 | for (it = h->ait_head; NULL != it; it = it->next) |
@@ -847,8 +852,8 @@ handle_attestation_result (void *cls, const struct | |||
847 | } | 852 | } |
848 | 853 | ||
849 | { | 854 | { |
850 | struct GNUNET_RECLAIM_Attestation *att; | 855 | struct GNUNET_RECLAIM_Credential *att; |
851 | att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); | 856 | att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len); |
852 | 857 | ||
853 | if (NULL != it) | 858 | if (NULL != it) |
854 | { | 859 | { |
@@ -866,6 +871,30 @@ handle_attestation_result (void *cls, const struct | |||
866 | GNUNET_assert (0); | 871 | GNUNET_assert (0); |
867 | } | 872 | } |
868 | 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 | */ | ||
882 | static int | ||
883 | check_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 | |||
869 | 898 | ||
870 | /** | 899 | /** |
871 | * Handle an incoming message of type | 900 | * Handle an incoming message of type |
@@ -880,8 +909,10 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
880 | struct GNUNET_RECLAIM_Handle *handle = cls; | 909 | struct GNUNET_RECLAIM_Handle *handle = cls; |
881 | struct GNUNET_RECLAIM_Operation *op; | 910 | struct GNUNET_RECLAIM_Operation *op; |
882 | struct GNUNET_RECLAIM_TicketIterator *it; | 911 | struct GNUNET_RECLAIM_TicketIterator *it; |
912 | struct GNUNET_RECLAIM_PresentationList *pres; | ||
883 | uint32_t r_id = ntohl (msg->id); | 913 | uint32_t r_id = ntohl (msg->id); |
884 | static const struct GNUNET_RECLAIM_Ticket ticket; | 914 | static const struct GNUNET_RECLAIM_Ticket ticket; |
915 | uint32_t pres_len = ntohs (msg->presentations_len); | ||
885 | 916 | ||
886 | for (op = handle->op_head; NULL != op; op = op->next) | 917 | for (op = handle->op_head; NULL != op; op = op->next) |
887 | if (op->r_id == r_id) | 918 | if (op->r_id == r_id) |
@@ -893,18 +924,25 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
893 | return; | 924 | return; |
894 | if (NULL != op) | 925 | if (NULL != op) |
895 | { | 926 | { |
927 | if (0 < pres_len) | ||
928 | pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1], | ||
929 | pres_len); | ||
896 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); | 930 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); |
897 | if (0 == | 931 | if (0 == |
898 | memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) | 932 | memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) |
899 | { | 933 | { |
900 | if (NULL != op->tr_cb) | 934 | if (NULL != op->ti_cb) |
901 | op->tr_cb (op->cls, NULL); | 935 | op->ti_cb (op->cls, NULL, NULL); |
902 | } | 936 | } |
903 | else | 937 | else |
904 | { | 938 | { |
905 | if (NULL != op->tr_cb) | 939 | if (NULL != op->ti_cb) |
906 | op->tr_cb (op->cls, &msg->ticket); | 940 | op->ti_cb (op->cls, |
941 | &msg->ticket, | ||
942 | (0 < pres_len) ? pres : NULL); | ||
907 | } | 943 | } |
944 | if (0 < pres_len) | ||
945 | GNUNET_RECLAIM_presentation_list_destroy (pres); | ||
908 | free_op (op); | 946 | free_op (op); |
909 | return; | 947 | return; |
910 | } | 948 | } |
@@ -985,14 +1023,14 @@ reconnect (struct GNUNET_RECLAIM_Handle *h) | |||
985 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, | 1023 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, |
986 | struct AttributeResultMessage, | 1024 | struct AttributeResultMessage, |
987 | h), | 1025 | h), |
988 | GNUNET_MQ_hd_var_size (attestation_result, | 1026 | GNUNET_MQ_hd_var_size (credential_result, |
989 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, | 1027 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, |
990 | 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, | ||
991 | h), | 1033 | h), |
992 | GNUNET_MQ_hd_fixed_size (ticket_result, | ||
993 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, | ||
994 | struct TicketResultMessage, | ||
995 | h), | ||
996 | GNUNET_MQ_hd_var_size (consume_ticket_result, | 1034 | GNUNET_MQ_hd_var_size (consume_ticket_result, |
997 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, | 1035 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, |
998 | struct ConsumeTicketResultMessage, | 1036 | struct ConsumeTicketResultMessage, |
@@ -1174,22 +1212,22 @@ GNUNET_RECLAIM_attribute_delete ( | |||
1174 | 1212 | ||
1175 | 1213 | ||
1176 | /** | 1214 | /** |
1177 | * Store an attestation. If the attestation is already present, | 1215 | * Store an credential. If the credential is already present, |
1178 | * it is replaced with the new attestation. | 1216 | * it is replaced with the new credential. |
1179 | * | 1217 | * |
1180 | * @param h handle to the re:claimID service | 1218 | * @param h handle to the re:claimID service |
1181 | * @param pkey private key of the identity | 1219 | * @param pkey private key of the identity |
1182 | * @param attr the attestation value | 1220 | * @param attr the credential value |
1183 | * @param exp_interval the relative expiration interval for the attestation | 1221 | * @param exp_interval the relative expiration interval for the credential |
1184 | * @param cont continuation to call when done | 1222 | * @param cont continuation to call when done |
1185 | * @param cont_cls closure for @a cont | 1223 | * @param cont_cls closure for @a cont |
1186 | * @return handle to abort the request | 1224 | * @return handle to abort the request |
1187 | */ | 1225 | */ |
1188 | struct GNUNET_RECLAIM_Operation * | 1226 | struct GNUNET_RECLAIM_Operation * |
1189 | GNUNET_RECLAIM_attestation_store ( | 1227 | GNUNET_RECLAIM_credential_store ( |
1190 | struct GNUNET_RECLAIM_Handle *h, | 1228 | struct GNUNET_RECLAIM_Handle *h, |
1191 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1229 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1192 | const struct GNUNET_RECLAIM_Attestation *attr, | 1230 | const struct GNUNET_RECLAIM_Credential *attr, |
1193 | const struct GNUNET_TIME_Relative *exp_interval, | 1231 | const struct GNUNET_TIME_Relative *exp_interval, |
1194 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1232 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1195 | void *cont_cls) | 1233 | void *cont_cls) |
@@ -1204,15 +1242,15 @@ GNUNET_RECLAIM_attestation_store ( | |||
1204 | op->cls = cont_cls; | 1242 | op->cls = cont_cls; |
1205 | op->r_id = h->r_id_gen++; | 1243 | op->r_id = h->r_id_gen++; |
1206 | 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); |
1207 | attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); | 1245 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr); |
1208 | op->env = GNUNET_MQ_msg_extra (sam, | 1246 | op->env = GNUNET_MQ_msg_extra (sam, |
1209 | attr_len, | 1247 | attr_len, |
1210 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE); | 1248 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE); |
1211 | sam->identity = *pkey; | 1249 | sam->identity = *pkey; |
1212 | sam->id = htonl (op->r_id); | 1250 | sam->id = htonl (op->r_id); |
1213 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 1251 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
1214 | 1252 | ||
1215 | GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]); | 1253 | GNUNET_RECLAIM_credential_serialize (attr, (char *) &sam[1]); |
1216 | 1254 | ||
1217 | sam->attr_len = htons (attr_len); | 1255 | sam->attr_len = htons (attr_len); |
1218 | if (NULL != h->mq) | 1256 | if (NULL != h->mq) |
@@ -1222,21 +1260,21 @@ GNUNET_RECLAIM_attestation_store ( | |||
1222 | 1260 | ||
1223 | 1261 | ||
1224 | /** | 1262 | /** |
1225 | * Delete an attestation. Tickets used to share this attestation are updated | 1263 | * Delete an credential. Tickets used to share this credential are updated |
1226 | * accordingly. | 1264 | * accordingly. |
1227 | * | 1265 | * |
1228 | * @param h handle to the re:claimID service | 1266 | * @param h handle to the re:claimID service |
1229 | * @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 |
1230 | * @param attr The attestation | 1268 | * @param attr The credential |
1231 | * @param cont Continuation to call when done | 1269 | * @param cont Continuation to call when done |
1232 | * @param cont_cls Closure for @a cont | 1270 | * @param cont_cls Closure for @a cont |
1233 | * @return handle Used to to abort the request | 1271 | * @return handle Used to to abort the request |
1234 | */ | 1272 | */ |
1235 | struct GNUNET_RECLAIM_Operation * | 1273 | struct GNUNET_RECLAIM_Operation * |
1236 | GNUNET_RECLAIM_attestation_delete ( | 1274 | GNUNET_RECLAIM_credential_delete ( |
1237 | struct GNUNET_RECLAIM_Handle *h, | 1275 | struct GNUNET_RECLAIM_Handle *h, |
1238 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1276 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1239 | const struct GNUNET_RECLAIM_Attestation *attr, | 1277 | const struct GNUNET_RECLAIM_Credential *attr, |
1240 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 1278 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
1241 | void *cont_cls) | 1279 | void *cont_cls) |
1242 | { | 1280 | { |
@@ -1250,13 +1288,13 @@ GNUNET_RECLAIM_attestation_delete ( | |||
1250 | op->cls = cont_cls; | 1288 | op->cls = cont_cls; |
1251 | op->r_id = h->r_id_gen++; | 1289 | op->r_id = h->r_id_gen++; |
1252 | 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); |
1253 | attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr); | 1291 | attr_len = GNUNET_RECLAIM_credential_serialize_get_size (attr); |
1254 | op->env = GNUNET_MQ_msg_extra (dam, | 1292 | op->env = GNUNET_MQ_msg_extra (dam, |
1255 | attr_len, | 1293 | attr_len, |
1256 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE); | 1294 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE); |
1257 | dam->identity = *pkey; | 1295 | dam->identity = *pkey; |
1258 | dam->id = htonl (op->r_id); | 1296 | dam->id = htonl (op->r_id); |
1259 | GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]); | 1297 | GNUNET_RECLAIM_credential_serialize (attr, (char *) &dam[1]); |
1260 | 1298 | ||
1261 | dam->attr_len = htons (attr_len); | 1299 | dam->attr_len = htons (attr_len); |
1262 | if (NULL != h->mq) | 1300 | if (NULL != h->mq) |
@@ -1375,12 +1413,12 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1375 | 1413 | ||
1376 | 1414 | ||
1377 | /** | 1415 | /** |
1378 | * List all attestations for a local identity. | 1416 | * List all credentials for a local identity. |
1379 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | 1417 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
1380 | * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and | 1418 | * for any other calls than #GNUNET_RECLAIM_get_credentials_next() and |
1381 | * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once | 1419 | * #GNUNET_RECLAIM_get_credentials_stop. @a proc will be called once |
1382 | * immediately, and then again after | 1420 | * immediately, and then again after |
1383 | * #GNUNET_RECLAIM_get_attestations_next() is invoked. | 1421 | * #GNUNET_RECLAIM_get_credentials_next() is invoked. |
1384 | * | 1422 | * |
1385 | * On error (disconnect), @a error_cb will be invoked. | 1423 | * On error (disconnect), @a error_cb will be invoked. |
1386 | * On normal completion, @a finish_cb proc will be | 1424 | * On normal completion, @a finish_cb proc will be |
@@ -1391,31 +1429,31 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1391 | * @param error_cb Function to call on error (i.e. disconnect), | 1429 | * @param error_cb Function to call on error (i.e. disconnect), |
1392 | * the handle is afterwards invalid | 1430 | * the handle is afterwards invalid |
1393 | * @param error_cb_cls Closure for @a error_cb | 1431 | * @param error_cb_cls Closure for @a error_cb |
1394 | * @param proc Function to call on each attestation | 1432 | * @param proc Function to call on each credential |
1395 | * @param proc_cls Closure for @a proc | 1433 | * @param proc_cls Closure for @a proc |
1396 | * @param finish_cb Function to call on completion | 1434 | * @param finish_cb Function to call on completion |
1397 | * the handle is afterwards invalid | 1435 | * the handle is afterwards invalid |
1398 | * @param finish_cb_cls Closure for @a finish_cb | 1436 | * @param finish_cb_cls Closure for @a finish_cb |
1399 | * @return an iterator Handle to use for iteration | 1437 | * @return an iterator Handle to use for iteration |
1400 | */ | 1438 | */ |
1401 | struct GNUNET_RECLAIM_AttestationIterator * | 1439 | struct GNUNET_RECLAIM_CredentialIterator * |
1402 | GNUNET_RECLAIM_get_attestations_start ( | 1440 | GNUNET_RECLAIM_get_credentials_start ( |
1403 | struct GNUNET_RECLAIM_Handle *h, | 1441 | struct GNUNET_RECLAIM_Handle *h, |
1404 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1442 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1405 | GNUNET_SCHEDULER_TaskCallback error_cb, | 1443 | GNUNET_SCHEDULER_TaskCallback error_cb, |
1406 | void *error_cb_cls, | 1444 | void *error_cb_cls, |
1407 | GNUNET_RECLAIM_AttestationResult proc, | 1445 | GNUNET_RECLAIM_CredentialResult proc, |
1408 | void *proc_cls, | 1446 | void *proc_cls, |
1409 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 1447 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
1410 | void *finish_cb_cls) | 1448 | void *finish_cb_cls) |
1411 | { | 1449 | { |
1412 | struct GNUNET_RECLAIM_AttestationIterator *ait; | 1450 | struct GNUNET_RECLAIM_CredentialIterator *ait; |
1413 | struct GNUNET_MQ_Envelope *env; | 1451 | struct GNUNET_MQ_Envelope *env; |
1414 | struct AttestationIterationStartMessage *msg; | 1452 | struct CredentialIterationStartMessage *msg; |
1415 | uint32_t rid; | 1453 | uint32_t rid; |
1416 | 1454 | ||
1417 | rid = h->r_id_gen++; | 1455 | rid = h->r_id_gen++; |
1418 | ait = GNUNET_new (struct GNUNET_RECLAIM_AttestationIterator); | 1456 | ait = GNUNET_new (struct GNUNET_RECLAIM_CredentialIterator); |
1419 | ait->h = h; | 1457 | ait->h = h; |
1420 | ait->error_cb = error_cb; | 1458 | ait->error_cb = error_cb; |
1421 | ait->error_cb_cls = error_cb_cls; | 1459 | ait->error_cb_cls = error_cb_cls; |
@@ -1428,7 +1466,7 @@ GNUNET_RECLAIM_get_attestations_start ( | |||
1428 | 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); |
1429 | env = | 1467 | env = |
1430 | GNUNET_MQ_msg (msg, | 1468 | GNUNET_MQ_msg (msg, |
1431 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START); | 1469 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START); |
1432 | msg->id = htonl (rid); | 1470 | msg->id = htonl (rid); |
1433 | msg->identity = *identity; | 1471 | msg->identity = *identity; |
1434 | if (NULL == h->mq) | 1472 | if (NULL == h->mq) |
@@ -1440,21 +1478,21 @@ GNUNET_RECLAIM_get_attestations_start ( | |||
1440 | 1478 | ||
1441 | 1479 | ||
1442 | /** | 1480 | /** |
1443 | * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start | 1481 | * Calls the record processor specified in #GNUNET_RECLAIM_get_credential_start |
1444 | * for the next record. | 1482 | * for the next record. |
1445 | * | 1483 | * |
1446 | * @param it the iterator | 1484 | * @param it the iterator |
1447 | */ | 1485 | */ |
1448 | void | 1486 | void |
1449 | GNUNET_RECLAIM_get_attestations_next (struct | 1487 | GNUNET_RECLAIM_get_credentials_next (struct |
1450 | GNUNET_RECLAIM_AttestationIterator *ait) | 1488 | GNUNET_RECLAIM_CredentialIterator *ait) |
1451 | { | 1489 | { |
1452 | struct GNUNET_RECLAIM_Handle *h = ait->h; | 1490 | struct GNUNET_RECLAIM_Handle *h = ait->h; |
1453 | struct AttestationIterationNextMessage *msg; | 1491 | struct CredentialIterationNextMessage *msg; |
1454 | struct GNUNET_MQ_Envelope *env; | 1492 | struct GNUNET_MQ_Envelope *env; |
1455 | 1493 | ||
1456 | env = | 1494 | env = |
1457 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT); | 1495 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT); |
1458 | msg->id = htonl (ait->r_id); | 1496 | msg->id = htonl (ait->r_id); |
1459 | GNUNET_MQ_send (h->mq, env); | 1497 | GNUNET_MQ_send (h->mq, env); |
1460 | } | 1498 | } |
@@ -1468,18 +1506,18 @@ GNUNET_RECLAIM_get_attestations_next (struct | |||
1468 | * @param it the iterator | 1506 | * @param it the iterator |
1469 | */ | 1507 | */ |
1470 | void | 1508 | void |
1471 | GNUNET_RECLAIM_get_attestations_stop (struct | 1509 | GNUNET_RECLAIM_get_credentials_stop (struct |
1472 | GNUNET_RECLAIM_AttestationIterator *ait) | 1510 | GNUNET_RECLAIM_CredentialIterator *ait) |
1473 | { | 1511 | { |
1474 | struct GNUNET_RECLAIM_Handle *h = ait->h; | 1512 | struct GNUNET_RECLAIM_Handle *h = ait->h; |
1475 | struct GNUNET_MQ_Envelope *env; | 1513 | struct GNUNET_MQ_Envelope *env; |
1476 | struct AttestationIterationStopMessage *msg; | 1514 | struct CredentialIterationStopMessage *msg; |
1477 | 1515 | ||
1478 | if (NULL != h->mq) | 1516 | if (NULL != h->mq) |
1479 | { | 1517 | { |
1480 | env = | 1518 | env = |
1481 | GNUNET_MQ_msg (msg, | 1519 | GNUNET_MQ_msg (msg, |
1482 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP); | 1520 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP); |
1483 | msg->id = htonl (ait->r_id); | 1521 | msg->id = htonl (ait->r_id); |
1484 | GNUNET_MQ_send (h->mq, env); | 1522 | GNUNET_MQ_send (h->mq, env); |
1485 | } | 1523 | } |
@@ -1506,7 +1544,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1506 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 1544 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
1507 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 1545 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
1508 | const struct GNUNET_RECLAIM_AttributeList *attrs, | 1546 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
1509 | GNUNET_RECLAIM_TicketCallback cb, | 1547 | GNUNET_RECLAIM_IssueTicketCallback cb, |
1510 | void *cb_cls) | 1548 | void *cb_cls) |
1511 | { | 1549 | { |
1512 | struct GNUNET_RECLAIM_Operation *op; | 1550 | struct GNUNET_RECLAIM_Operation *op; |
@@ -1516,7 +1554,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1516 | fprintf (stderr, "Issuing ticket\n"); | 1554 | fprintf (stderr, "Issuing ticket\n"); |
1517 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1555 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1518 | op->h = h; | 1556 | op->h = h; |
1519 | op->tr_cb = cb; | 1557 | op->ti_cb = cb; |
1520 | op->cls = cb_cls; | 1558 | op->cls = cb_cls; |
1521 | op->r_id = h->r_id_gen++; | 1559 | op->r_id = h->r_id_gen++; |
1522 | 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); |
@@ -1573,7 +1611,7 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1573 | if (NULL != h->mq) | 1611 | if (NULL != h->mq) |
1574 | GNUNET_MQ_send_copy (h->mq, op->env); | 1612 | GNUNET_MQ_send_copy (h->mq, op->env); |
1575 | else | 1613 | else |
1576 | reconnect(h); | 1614 | reconnect (h); |
1577 | return op; | 1615 | return op; |
1578 | } | 1616 | } |
1579 | 1617 | ||
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 | */ | ||
35 | struct 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 | */ | ||
52 | static struct Plugin **attest_plugins; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Number of plugins | ||
57 | */ | ||
58 | static unsigned int num_plugins; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Init canary | ||
63 | */ | ||
64 | static 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 | */ | ||
74 | static void | ||
75 | add_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 | */ | ||
93 | static void | ||
94 | init () | ||
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 | */ | ||
112 | uint32_t | ||
113 | GNUNET_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 | */ | ||
137 | const char * | ||
138 | GNUNET_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 | */ | ||
166 | int | ||
167 | GNUNET_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 | */ | ||
198 | char * | ||
199 | GNUNET_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 | */ | ||
230 | struct GNUNET_RECLAIM_Attestation * | ||
231 | GNUNET_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 | */ | ||
264 | size_t | ||
265 | GNUNET_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 | */ | ||
288 | size_t | ||
289 | GNUNET_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 | */ | ||
317 | struct GNUNET_RECLAIM_AttestationList * | ||
318 | GNUNET_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 | */ | ||
359 | struct GNUNET_RECLAIM_AttestationList * | ||
360 | GNUNET_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 | */ | ||
391 | void | ||
392 | GNUNET_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 | */ | ||
416 | size_t | ||
417 | GNUNET_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 | */ | ||
432 | size_t | ||
433 | GNUNET_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 | */ | ||
471 | struct GNUNET_RECLAIM_Attestation * | ||
472 | GNUNET_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 | |||
512 | struct GNUNET_RECLAIM_AttributeList* | ||
513 | GNUNET_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 | |||
532 | char* | ||
533 | GNUNET_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 | |||
552 | int | ||
553 | GNUNET_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 05bdc1ac6..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, | |||
231 | struct GNUNET_RECLAIM_Attribute * | 231 | struct GNUNET_RECLAIM_Attribute * |
232 | GNUNET_RECLAIM_attribute_new (const char *attr_name, | 232 | GNUNET_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 | |||
272 | GNUNET_RECLAIM_attribute_list_add ( | 272 | GNUNET_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, |
@@ -306,7 +306,6 @@ GNUNET_RECLAIM_attribute_list_serialize_get_size ( | |||
306 | { | 306 | { |
307 | GNUNET_assert (NULL != ale->attribute); | 307 | GNUNET_assert (NULL != ale->attribute); |
308 | len += GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute); | 308 | len += GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute); |
309 | len += sizeof(struct GNUNET_RECLAIM_AttributeListEntry); | ||
310 | } | 309 | } |
311 | return len; | 310 | return len; |
312 | } | 311 | } |
@@ -355,27 +354,28 @@ GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size) | |||
355 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | 354 | struct GNUNET_RECLAIM_AttributeListEntry *ale; |
356 | size_t attr_len; | 355 | size_t attr_len; |
357 | const char *read_ptr; | 356 | const char *read_ptr; |
357 | size_t left = data_size; | ||
358 | 358 | ||
359 | al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 359 | al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
360 | if (data_size < sizeof(struct Attribute) + sizeof(struct | 360 | if (data_size < sizeof(struct Attribute)) |
361 | GNUNET_RECLAIM_AttributeListEntry)) | ||
362 | return al; | 361 | return al; |
363 | read_ptr = data; | 362 | read_ptr = data; |
364 | while (((data + data_size) - read_ptr) >= sizeof(struct Attribute)) | 363 | while (left >= sizeof(struct Attribute)) |
365 | { | 364 | { |
366 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | 365 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
367 | ale->attribute = | 366 | attr_len = |
368 | GNUNET_RECLAIM_attribute_deserialize (read_ptr, | 367 | GNUNET_RECLAIM_attribute_deserialize (read_ptr, |
369 | data_size - (read_ptr - data)); | 368 | left, |
370 | if (NULL == ale->attribute) | 369 | &ale->attribute); |
370 | if (-1 == attr_len) | ||
371 | { | 371 | { |
372 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 372 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
373 | "Failed to deserialize malformed attribute.\n"); | 373 | "Failed to deserialize malformed attribute.\n"); |
374 | GNUNET_free (ale); | 374 | GNUNET_free (ale); |
375 | return al; | 375 | return al; |
376 | } | 376 | } |
377 | left -= attr_len; | ||
377 | GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale); | 378 | GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale); |
378 | attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute); | ||
379 | read_ptr += attr_len; | 379 | read_ptr += attr_len; |
380 | } | 380 | } |
381 | return al; | 381 | return al; |
@@ -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]; |
@@ -503,17 +503,18 @@ GNUNET_RECLAIM_attribute_serialize ( | |||
503 | * | 503 | * |
504 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 504 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
505 | */ | 505 | */ |
506 | struct GNUNET_RECLAIM_Attribute * | 506 | ssize_t |
507 | GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size) | 507 | GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, |
508 | struct GNUNET_RECLAIM_Attribute **attr) | ||
508 | { | 509 | { |
509 | struct GNUNET_RECLAIM_Attribute *attr; | ||
510 | struct Attribute *attr_ser; | 510 | struct Attribute *attr_ser; |
511 | struct GNUNET_RECLAIM_Attribute *attribute; | ||
511 | size_t data_len; | 512 | size_t data_len; |
512 | size_t name_len; | 513 | size_t name_len; |
513 | char *write_ptr; | 514 | char *write_ptr; |
514 | 515 | ||
515 | if (data_size < sizeof(struct Attribute)) | 516 | if (data_size < sizeof(struct Attribute)) |
516 | return NULL; | 517 | return -1; |
517 | 518 | ||
518 | attr_ser = (struct Attribute *) data; | 519 | attr_ser = (struct Attribute *) data; |
519 | data_len = ntohs (attr_ser->data_size); | 520 | data_len = ntohs (attr_ser->data_size); |
@@ -522,25 +523,27 @@ GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size) | |||
522 | { | 523 | { |
523 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 524 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
524 | "Buffer too small to deserialize\n"); | 525 | "Buffer too small to deserialize\n"); |
525 | return NULL; | 526 | return -1; |
526 | } | 527 | } |
527 | attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) | 528 | attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) |
528 | + data_len + name_len + 1); | 529 | + data_len + name_len + 1); |
529 | attr->type = ntohs (attr_ser->attribute_type); | 530 | attribute->type = ntohs (attr_ser->attribute_type); |
530 | attr->flag = ntohl (attr_ser->attribute_flag); | 531 | attribute->flag = ntohl (attr_ser->attribute_flag); |
531 | attr->id = attr_ser->attribute_id; | 532 | attribute->id = attr_ser->attribute_id; |
532 | attr->attestation = attr_ser->attestation_id; | 533 | attribute->credential = attr_ser->credential_id; |
533 | attr->data_size = data_len; | 534 | attribute->data_size = data_len; |
534 | 535 | ||
535 | write_ptr = (char *) &attr[1]; | 536 | write_ptr = (char *) &attribute[1]; |
536 | GNUNET_memcpy (write_ptr, &attr_ser[1], name_len); | 537 | GNUNET_memcpy (write_ptr, &attr_ser[1], name_len); |
537 | write_ptr[name_len] = '\0'; | 538 | write_ptr[name_len] = '\0'; |
538 | attr->name = write_ptr; | 539 | attribute->name = write_ptr; |
539 | 540 | ||
540 | write_ptr += name_len + 1; | 541 | write_ptr += name_len + 1; |
541 | GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size); | 542 | GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, |
542 | attr->data = write_ptr; | 543 | attribute->data_size); |
543 | return attr; | 544 | *attr = attribute; |
545 | attribute->data = write_ptr; | ||
546 | return sizeof(struct Attribute) + data_len + name_len; | ||
544 | } | 547 | } |
545 | 548 | ||
546 | 549 | ||
diff --git a/src/reclaim/reclaim_attribute.h b/src/reclaim/reclaim_attribute.h index e54b210b9..285d75d83 100644 --- a/src/reclaim/reclaim_attribute.h +++ b/src/reclaim/reclaim_attribute.h | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #include "gnunet_reclaim_service.h" | 29 | #include "gnunet_reclaim_service.h" |
30 | 30 | ||
31 | GNUNET_NETWORK_STRUCT_BEGIN | ||
32 | |||
31 | /** | 33 | /** |
32 | * Serialized claim | 34 | * Serialized claim |
33 | */ | 35 | */ |
@@ -36,12 +38,12 @@ struct Attribute | |||
36 | /** | 38 | /** |
37 | * Attribute type | 39 | * Attribute type |
38 | */ | 40 | */ |
39 | uint32_t attribute_type; | 41 | uint32_t attribute_type GNUNET_PACKED; |
40 | 42 | ||
41 | /** | 43 | /** |
42 | * Attribute flag | 44 | * Attribute flag |
43 | */ | 45 | */ |
44 | uint32_t attribute_flag; | 46 | uint32_t attribute_flag GNUNET_PACKED; |
45 | 47 | ||
46 | /** | 48 | /** |
47 | * Attribute ID | 49 | * Attribute ID |
@@ -49,54 +51,23 @@ struct Attribute | |||
49 | struct GNUNET_RECLAIM_Identifier attribute_id; | 51 | struct GNUNET_RECLAIM_Identifier attribute_id; |
50 | 52 | ||
51 | /** | 53 | /** |
52 | * Attestation ID | 54 | * Credential ID |
53 | */ | 55 | */ |
54 | struct GNUNET_RECLAIM_Identifier attestation_id; | 56 | struct GNUNET_RECLAIM_Identifier credential_id; |
55 | 57 | ||
56 | /** | 58 | /** |
57 | * Name length | 59 | * Name length |
58 | */ | 60 | */ |
59 | uint32_t name_len; | 61 | uint32_t name_len GNUNET_PACKED; |
60 | 62 | ||
61 | /** | 63 | /** |
62 | * Data size | 64 | * Data size |
63 | */ | 65 | */ |
64 | uint32_t data_size; | 66 | uint32_t data_size GNUNET_PACKED; |
65 | 67 | ||
66 | // followed by data_size Attribute value data | 68 | // followed by data_size Attribute value data |
67 | }; | 69 | }; |
68 | 70 | ||
69 | /** | 71 | GNUNET_NETWORK_STRUCT_BEGIN |
70 | * Serialized attestation claim | ||
71 | */ | ||
72 | struct Attestation | ||
73 | { | ||
74 | /** | ||
75 | * Attestation type | ||
76 | */ | ||
77 | uint32_t attestation_type; | ||
78 | |||
79 | /** | ||
80 | * Attestation flag | ||
81 | */ | ||
82 | uint32_t attestation_flag; | ||
83 | |||
84 | /** | ||
85 | * Attestation ID | ||
86 | */ | ||
87 | struct GNUNET_RECLAIM_Identifier attestation_id; | ||
88 | |||
89 | /** | ||
90 | * Name length | ||
91 | */ | ||
92 | uint32_t name_len; | ||
93 | |||
94 | /** | ||
95 | * Data size | ||
96 | */ | ||
97 | uint32_t data_size; | ||
98 | |||
99 | // followed by data_size Attestation value data | ||
100 | }; | ||
101 | 72 | ||
102 | #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 | */ | ||
35 | struct 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 | */ | ||
52 | static struct Plugin **credential_plugins; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Number of plugins | ||
57 | */ | ||
58 | static unsigned int num_plugins; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Init canary | ||
63 | */ | ||
64 | static 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 | */ | ||
74 | static void | ||
75 | add_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 | */ | ||
93 | static void | ||
94 | init () | ||
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 | */ | ||
112 | uint32_t | ||
113 | GNUNET_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 | */ | ||
137 | const char * | ||
138 | GNUNET_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 | */ | ||
166 | int | ||
167 | GNUNET_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 | */ | ||
198 | char * | ||
199 | GNUNET_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 | */ | ||
230 | struct GNUNET_RECLAIM_Credential * | ||
231 | GNUNET_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 | */ | ||
264 | size_t | ||
265 | GNUNET_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 | */ | ||
288 | size_t | ||
289 | GNUNET_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 | */ | ||
317 | struct GNUNET_RECLAIM_CredentialList * | ||
318 | GNUNET_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 | */ | ||
359 | struct GNUNET_RECLAIM_CredentialList * | ||
360 | GNUNET_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 | */ | ||
391 | void | ||
392 | GNUNET_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 | */ | ||
416 | size_t | ||
417 | GNUNET_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 | */ | ||
432 | size_t | ||
433 | GNUNET_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 | */ | ||
471 | struct GNUNET_RECLAIM_Credential * | ||
472 | GNUNET_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 | |||
512 | struct GNUNET_RECLAIM_AttributeList* | ||
513 | GNUNET_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 | |||
532 | char* | ||
533 | GNUNET_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 | |||
552 | int | ||
553 | GNUNET_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 | */ | ||
579 | uint32_t | ||
580 | GNUNET_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 | */ | ||
604 | const char * | ||
605 | GNUNET_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 | */ | ||
633 | int | ||
634 | GNUNET_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 | */ | ||
665 | char * | ||
666 | GNUNET_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 | |||
688 | struct GNUNET_RECLAIM_Presentation * | ||
689 | GNUNET_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 | */ | ||
713 | size_t | ||
714 | GNUNET_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 | */ | ||
737 | size_t | ||
738 | GNUNET_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 | */ | ||
766 | struct GNUNET_RECLAIM_PresentationList * | ||
767 | GNUNET_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 | */ | ||
809 | struct GNUNET_RECLAIM_PresentationList * | ||
810 | GNUNET_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 | */ | ||
840 | void | ||
841 | GNUNET_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 | */ | ||
865 | size_t | ||
866 | GNUNET_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 | */ | ||
880 | size_t | ||
881 | GNUNET_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 | */ | ||
907 | struct GNUNET_RECLAIM_Presentation * | ||
908 | GNUNET_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 | |||
939 | struct GNUNET_RECLAIM_AttributeList* | ||
940 | GNUNET_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 | |||
960 | char* | ||
961 | GNUNET_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 | |||
981 | int | ||
982 | GNUNET_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 | */ | ||
1013 | int | ||
1014 | GNUNET_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 | */ |
34 | struct Attestation | 34 | struct 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 | */ | ||
68 | struct 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 |
diff --git a/src/reclaim/test_reclaim_attribute.c b/src/reclaim/test_reclaim_attribute.c new file mode 100644 index 000000000..f71d86b56 --- /dev/null +++ b/src/reclaim/test_reclaim_attribute.c | |||
@@ -0,0 +1,51 @@ | |||
1 | #include "platform.h" | ||
2 | #include "gnunet_common.h" | ||
3 | #include "gnunet_reclaim_lib.h" | ||
4 | #include "gnunet_container_lib.h" | ||
5 | |||
6 | int | ||
7 | main (int argc, char *argv[]) | ||
8 | { | ||
9 | struct GNUNET_RECLAIM_AttributeList *al; | ||
10 | struct GNUNET_RECLAIM_AttributeList *al_two; | ||
11 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | ||
12 | struct GNUNET_RECLAIM_Attribute *attr; | ||
13 | char attrname[100]; | ||
14 | char attrdata[100]; | ||
15 | size_t ser_len_claimed; | ||
16 | size_t ser_len_actual; | ||
17 | ssize_t deser_len; | ||
18 | char *ser_data; | ||
19 | int count = 0; | ||
20 | |||
21 | al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | ||
22 | for (int i = 0; i < 12; i++) | ||
23 | { | ||
24 | memset (attrname, 0, 100); | ||
25 | memset (attrdata, 0, 100); | ||
26 | sprintf (attrname, "attr%d", i); | ||
27 | sprintf (attrdata, "%d", i); | ||
28 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); | ||
29 | ale->attribute = GNUNET_RECLAIM_attribute_new (attrname, | ||
30 | &GNUNET_RECLAIM_ID_ZERO, | ||
31 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, | ||
32 | attrdata, | ||
33 | strlen (attrdata)); | ||
34 | GNUNET_CONTAINER_DLL_insert (al->list_head, | ||
35 | al->list_tail, | ||
36 | ale); | ||
37 | } | ||
38 | ser_len_claimed = GNUNET_RECLAIM_attribute_list_serialize_get_size (al); | ||
39 | ser_data = GNUNET_malloc (ser_len_claimed); | ||
40 | ser_len_actual = GNUNET_RECLAIM_attribute_list_serialize (al, | ||
41 | ser_data); | ||
42 | GNUNET_assert (ser_len_claimed == ser_len_actual); | ||
43 | al_two = GNUNET_RECLAIM_attribute_list_deserialize (ser_data, | ||
44 | ser_len_actual); | ||
45 | for (ale = al_two->list_head; NULL != ale; ale = ale->next) | ||
46 | count++; | ||
47 | GNUNET_assert (12 == count); | ||
48 | //GNUNET_assert (-1 != deser_len); | ||
49 | GNUNET_free (ser_data); | ||
50 | GNUNET_RECLAIM_attribute_list_destroy (al); | ||
51 | } | ||