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