aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------contrib/gana0
m---------contrib/handbook0
-rw-r--r--src/cli/reclaim/gnunet-reclaim.c26
-rw-r--r--src/include/gnunet_reclaim_service.h23
-rw-r--r--src/service/messenger/messenger_api.c24
-rw-r--r--src/service/reclaim/gnunet-service-reclaim.c46
-rw-r--r--src/service/reclaim/gnunet-service-reclaim_tickets.c31
-rw-r--r--src/service/reclaim/gnunet-service-reclaim_tickets.h8
-rw-r--r--src/service/reclaim/reclaim.h16
-rw-r--r--src/service/reclaim/reclaim_api.c107
-rw-r--r--src/service/rest/json_reclaim.c11
-rw-r--r--src/service/rest/reclaim_plugin.c27
12 files changed, 106 insertions, 213 deletions
diff --git a/contrib/gana b/contrib/gana
Subproject d505fecdf8f1339f4115f10f1ae236da7cfea0e Subproject 9eddc2cf7b65bb43d285c75ef22fd9bc9cc7020
diff --git a/contrib/handbook b/contrib/handbook
Subproject 7d66dc1695829f2511f8e8ecc227a64d73d1562 Subproject 5c20e0aaa95c7cebc225d02231221d18fdcbdb5
diff --git a/src/cli/reclaim/gnunet-reclaim.c b/src/cli/reclaim/gnunet-reclaim.c
index 901dd6bf6..63152d478 100644
--- a/src/cli/reclaim/gnunet-reclaim.c
+++ b/src/cli/reclaim/gnunet-reclaim.c
@@ -155,11 +155,6 @@ static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator;
155static const struct GNUNET_CRYPTO_PrivateKey *pkey; 155static const struct GNUNET_CRYPTO_PrivateKey *pkey;
156 156
157/** 157/**
158 * rp public key
159 */
160static struct GNUNET_CRYPTO_PublicKey rp_key;
161
162/**
163 * Ticket to consume 158 * Ticket to consume
164 */ 159 */
165static struct GNUNET_RECLAIM_Ticket ticket; 160static struct GNUNET_RECLAIM_Ticket ticket;
@@ -342,20 +337,14 @@ ticket_iter_fin (void *cls)
342static void 337static void
343ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 338ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
344{ 339{
345 char *aud;
346 char *ref; 340 char *ref;
347 char *tkt; 341 char *tkt;
348 342
349 aud =
350 GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
351 sizeof(struct
352 GNUNET_CRYPTO_PublicKey));
353 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd)); 343 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
354 tkt = 344 tkt =
355 GNUNET_STRINGS_data_to_string_alloc (ticket, 345 GNUNET_STRINGS_data_to_string_alloc (ticket,
356 sizeof(struct GNUNET_RECLAIM_Ticket)); 346 sizeof(struct GNUNET_RECLAIM_Ticket));
357 fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud); 347 fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, ticket->rp_uri);
358 GNUNET_free (aud);
359 GNUNET_free (ref); 348 GNUNET_free (ref);
360 GNUNET_free (tkt); 349 GNUNET_free (tkt);
361 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); 350 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
@@ -447,7 +436,6 @@ iter_finished (void *cls)
447 fprintf (stdout, "No such attribute ``%s''\n", attr_str); 436 fprintf (stdout, "No such attribute ``%s''\n", attr_str);
448 break; 437 break;
449 } 438 }
450
451 attr_str = strtok (NULL, ","); 439 attr_str = strtok (NULL, ",");
452 } 440 }
453 GNUNET_free (attrs_tmp); 441 GNUNET_free (attrs_tmp);
@@ -456,10 +444,9 @@ iter_finished (void *cls)
456 GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 444 GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
457 return; 445 return;
458 } 446 }
459
460 reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle, 447 reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
461 pkey, 448 pkey,
462 &rp_key, 449 rp,
463 attr_list, 450 attr_list,
464 &ticket_issue_cb, 451 &ticket_issue_cb,
465 NULL); 452 NULL);
@@ -468,7 +455,6 @@ iter_finished (void *cls)
468 if (consume_ticket) 455 if (consume_ticket)
469 { 456 {
470 reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, 457 reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
471 pkey,
472 &ticket, 458 &ticket,
473 &process_attrs, 459 &process_attrs,
474 NULL); 460 NULL);
@@ -767,14 +753,6 @@ start_process ()
767 return; 753 return;
768 } 754 }
769 755
770 if ((NULL != rp) &&
771 (GNUNET_OK !=
772 GNUNET_CRYPTO_public_key_from_string (rp, &rp_key)) )
773 {
774 fprintf (stderr, "%s is not a public key!\n", rp);
775 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
776 return;
777 }
778 if (NULL != consume_ticket) 756 if (NULL != consume_ticket)
779 GNUNET_STRINGS_string_to_data (consume_ticket, 757 GNUNET_STRINGS_string_to_data (consume_ticket,
780 strlen (consume_ticket), 758 strlen (consume_ticket),
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index a8ab8776e..08f3f60a3 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -49,7 +49,7 @@ extern "C" {
49/** 49/**
50 * Version number of the re:claimID API. 50 * Version number of the re:claimID API.
51 */ 51 */
52#define GNUNET_RECLAIM_VERSION 0x00000001 52#define GNUNET_RECLAIM_VERSION 0x00000002
53 53
54/** 54/**
55 * Opaque handle to access the service. 55 * Opaque handle to access the service.
@@ -62,6 +62,9 @@ struct GNUNET_RECLAIM_Handle;
62 */ 62 */
63struct GNUNET_RECLAIM_Operation; 63struct GNUNET_RECLAIM_Operation;
64 64
65#define GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN 256
66
67#define GNUNET_RECLAIM_TICKET_RP_URI_URN_PREFIX "urn:gns:"
65 68
66/** 69/**
67 * The authorization ticket. This ticket is meant to be transferred 70 * The authorization ticket. This ticket is meant to be transferred
@@ -77,14 +80,17 @@ struct GNUNET_RECLAIM_Ticket
77 struct GNUNET_CRYPTO_PublicKey identity; 80 struct GNUNET_CRYPTO_PublicKey identity;
78 81
79 /** 82 /**
80 * The ticket audience (= relying party) 83 * The ticket random identifier
81 */ 84 */
82 struct GNUNET_CRYPTO_PublicKey audience; 85 struct GNUNET_RECLAIM_Identifier rnd;
86
83 87
84 /** 88 /**
85 * The ticket random identifier 89 * Followed by the ticket audience (= relying party) URI.
90 * 0-terminated string.
91 * Example: "urn:gns:000G002B4RF1XPBXDPGZA0PT16BHQCS427YQK4NC84KZMK7TK8C2Z5GMK8"
86 */ 92 */
87 struct GNUNET_RECLAIM_Identifier rnd; 93 char rp_uri[GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN];
88}; 94};
89 95
90 96
@@ -376,7 +382,7 @@ GNUNET_RECLAIM_get_credentials_stop (
376 * 382 *
377 * @param h the identity provider to use 383 * @param h the identity provider to use
378 * @param iss the issuing identity (= the user) 384 * @param iss the issuing identity (= the user)
379 * @param rp the subject of the ticket (= the relying party) 385 * @param rp the subject of the ticket (= the relying party) see #GNUNET_RECLAIM_Ticket
380 * @param attrs the attributes that the relying party is given access to 386 * @param attrs the attributes that the relying party is given access to
381 * @param cb the callback 387 * @param cb the callback
382 * @param cb_cls the callback closure 388 * @param cb_cls the callback closure
@@ -386,7 +392,7 @@ struct GNUNET_RECLAIM_Operation *
386GNUNET_RECLAIM_ticket_issue ( 392GNUNET_RECLAIM_ticket_issue (
387 struct GNUNET_RECLAIM_Handle *h, 393 struct GNUNET_RECLAIM_Handle *h,
388 const struct GNUNET_CRYPTO_PrivateKey *iss, 394 const struct GNUNET_CRYPTO_PrivateKey *iss,
389 const struct GNUNET_CRYPTO_PublicKey *rp, 395 const char *rp,
390 const struct GNUNET_RECLAIM_AttributeList *attrs, 396 const struct GNUNET_RECLAIM_AttributeList *attrs,
391 GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); 397 GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls);
392 398
@@ -417,8 +423,6 @@ GNUNET_RECLAIM_ticket_revoke (
417 * information from the issuer 423 * information from the issuer
418 * 424 *
419 * @param h the identity provider to use 425 * @param h the identity provider to use
420 * @param identity the identity that is the subject of the issued ticket (the
421 * relying party)
422 * @param ticket the issued ticket to consume 426 * @param ticket the issued ticket to consume
423 * @param cb the callback to call 427 * @param cb the callback to call
424 * @param cb_cls the callback closure 428 * @param cb_cls the callback closure
@@ -427,7 +431,6 @@ GNUNET_RECLAIM_ticket_revoke (
427struct GNUNET_RECLAIM_Operation * 431struct GNUNET_RECLAIM_Operation *
428GNUNET_RECLAIM_ticket_consume ( 432GNUNET_RECLAIM_ticket_consume (
429 struct GNUNET_RECLAIM_Handle *h, 433 struct GNUNET_RECLAIM_Handle *h,
430 const struct GNUNET_CRYPTO_PrivateKey *identity,
431 const struct GNUNET_RECLAIM_Ticket *ticket, 434 const struct GNUNET_RECLAIM_Ticket *ticket,
432 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); 435 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls);
433 436
diff --git a/src/service/messenger/messenger_api.c b/src/service/messenger/messenger_api.c
index ecdd1feb2..0778d3a48 100644
--- a/src/service/messenger/messenger_api.c
+++ b/src/service/messenger/messenger_api.c
@@ -752,7 +752,7 @@ dequeue_messages_from_room (struct GNUNET_MESSENGER_Room *room)
752 else 752 else
753 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 753 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
754 "Sending transcript aborted: Encryption failed!\n"); 754 "Sending transcript aborted: Encryption failed!\n");
755 755
756 destroy_message (transcript); 756 destroy_message (transcript);
757 } while (message); 757 } while (message);
758 758
@@ -960,7 +960,8 @@ iterate_find_room (void *cls,
960 if ((find->counter > 0) && ((! find->contact) || (GNUNET_YES == 960 if ((find->counter > 0) && ((! find->contact) || (GNUNET_YES ==
961 find_room_member (room, 961 find_room_member (room,
962 find-> 962 find->
963 contact)))) 963 contact)))
964 )
964 { 965 {
965 find->counter--; 966 find->counter--;
966 967
@@ -1229,7 +1230,8 @@ GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
1229 1230
1230struct GNUNET_MESSENGER_CheckTicket 1231struct GNUNET_MESSENGER_CheckTicket
1231{ 1232{
1232 const struct GNUNET_CRYPTO_PublicKey *audience; 1233 const char *check_rp;
1234 struct GNUNET_CRYPTO_PublicKey key;
1233 enum GNUNET_GenericReturnValue result; 1235 enum GNUNET_GenericReturnValue result;
1234}; 1236};
1235 1237
@@ -1240,13 +1242,19 @@ check_ticket_audience (void *cls,
1240 const struct GNUNET_MESSENGER_Contact *contact) 1242 const struct GNUNET_MESSENGER_Contact *contact)
1241{ 1243{
1242 struct GNUNET_MESSENGER_CheckTicket *check = cls; 1244 struct GNUNET_MESSENGER_CheckTicket *check = cls;
1243
1244 const struct GNUNET_CRYPTO_PublicKey *key; 1245 const struct GNUNET_CRYPTO_PublicKey *key;
1245 key = get_non_anonymous_key (get_contact_key (contact)); 1246 char check_rp[GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN];
1247 char *key_str;
1246 1248
1247 if ((key) && (0 == GNUNET_memcmp (key, check->audience))) 1249 key = get_non_anonymous_key (get_contact_key (contact));
1250 key_str = GNUNET_CRYPTO_public_key_to_string(key);
1251 GNUNET_snprintf (check_rp, GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN, "%s%s",
1252 GNUNET_RECLAIM_TICKET_RP_URI_URN_PREFIX, key_str);
1253 GNUNET_free (key_str);
1254 if ((key) && (0 == strcmp (check_rp, check->check_rp)))
1248 { 1255 {
1249 check->result = GNUNET_YES; 1256 check->result = GNUNET_YES;
1257 check->key = *key;
1250 return GNUNET_NO; 1258 return GNUNET_NO;
1251 } 1259 }
1252 1260
@@ -1272,7 +1280,7 @@ GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room,
1272 } 1280 }
1273 1281
1274 struct GNUNET_MESSENGER_CheckTicket check; 1282 struct GNUNET_MESSENGER_CheckTicket check;
1275 check.audience = &(ticket->audience); 1283 check.check_rp = ticket->rp_uri;
1276 check.result = GNUNET_NO; 1284 check.result = GNUNET_NO;
1277 1285
1278 const int members = iterate_room_members ( 1286 const int members = iterate_room_members (
@@ -1298,5 +1306,5 @@ GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room,
1298 return; 1306 return;
1299 } 1307 }
1300 1308
1301 send_message_to_room_with_key (room, message, &(ticket->audience)); 1309 send_message_to_room_with_key (room, message, &check.key);
1302} 1310}
diff --git a/src/service/reclaim/gnunet-service-reclaim.c b/src/service/reclaim/gnunet-service-reclaim.c
index 6edd93341..368e39ec3 100644
--- a/src/service/reclaim/gnunet-service-reclaim.c
+++ b/src/service/reclaim/gnunet-service-reclaim.c
@@ -739,14 +739,14 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
739 uint16_t size; 739 uint16_t size;
740 size_t attrs_len; 740 size_t attrs_len;
741 size_t key_len; 741 size_t key_len;
742 size_t pkey_len; 742 size_t rp_len;
743 743
744 size = ntohs (im->header.size); 744 size = ntohs (im->header.size);
745 attrs_len = ntohs (im->attr_len); 745 attrs_len = ntohs (im->attr_len);
746 key_len = ntohs (im->key_len); 746 key_len = ntohs (im->key_len);
747 pkey_len = ntohs (im->pkey_len); 747 rp_len = ntohs (im->rp_uri_len);
748 if (size != attrs_len + key_len + pkey_len + sizeof(struct 748 if (size != attrs_len + key_len + rp_len + sizeof(struct
749 IssueTicketMessage)) 749 IssueTicketMessage))
750 { 750 {
751 GNUNET_break (0); 751 GNUNET_break (0);
752 return GNUNET_SYSERR; 752 return GNUNET_SYSERR;
@@ -769,10 +769,10 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
769 struct GNUNET_RECLAIM_AttributeList *attrs; 769 struct GNUNET_RECLAIM_AttributeList *attrs;
770 struct GNUNET_RECLAIM_AttributeListEntry *le; 770 struct GNUNET_RECLAIM_AttributeListEntry *le;
771 struct GNUNET_CRYPTO_PrivateKey identity; 771 struct GNUNET_CRYPTO_PrivateKey identity;
772 struct GNUNET_CRYPTO_PublicKey rp; 772 const char *rp;
773 size_t attrs_len; 773 size_t attrs_len;
774 size_t key_len; 774 size_t key_len;
775 size_t pkey_len; 775 size_t rp_len;
776 size_t read; 776 size_t read;
777 char *buf; 777 char *buf;
778 778
@@ -790,18 +790,9 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
790 return; 790 return;
791 } 791 }
792 buf += read; 792 buf += read;
793 pkey_len = ntohs (im->pkey_len); 793 rp_len = ntohs (im->rp_uri_len);
794 if ((GNUNET_SYSERR == 794 rp = buf;
795 GNUNET_CRYPTO_read_public_key_from_buffer (buf, pkey_len, 795 buf += rp_len;
796 &rp, &read)) ||
797 (read != pkey_len))
798 {
799 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
800 "Failed to read public key\n");
801 GNUNET_SERVICE_client_drop (idp->client);
802 return;
803 }
804 buf += read;
805 tio = GNUNET_new (struct TicketIssueOperation); 796 tio = GNUNET_new (struct TicketIssueOperation);
806 attrs_len = ntohs (im->attr_len); 797 attrs_len = ntohs (im->attr_len);
807 attrs = GNUNET_RECLAIM_attribute_list_deserialize (buf, 798 attrs = GNUNET_RECLAIM_attribute_list_deserialize (buf,
@@ -815,7 +806,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
815 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); 806 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
816 RECLAIM_TICKETS_issue (&identity, 807 RECLAIM_TICKETS_issue (&identity,
817 attrs, 808 attrs,
818 &rp, 809 rp,
819 &issue_ticket_result_cb, 810 &issue_ticket_result_cb,
820 tio); 811 tio);
821 GNUNET_SERVICE_client_continue (idp->client); 812 GNUNET_SERVICE_client_continue (idp->client);
@@ -1027,27 +1018,12 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1027{ 1018{
1028 struct ConsumeTicketOperation *cop; 1019 struct ConsumeTicketOperation *cop;
1029 struct IdpClient *idp = cls; 1020 struct IdpClient *idp = cls;
1030 struct GNUNET_CRYPTO_PrivateKey identity;
1031 struct GNUNET_RECLAIM_Ticket ticket; 1021 struct GNUNET_RECLAIM_Ticket ticket;
1032 size_t key_len;
1033 size_t tkt_len; 1022 size_t tkt_len;
1034 size_t read; 1023 size_t read;
1035 char *buf; 1024 char *buf;
1036 1025
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); 1026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1038 key_len = ntohs (cm->key_len);
1039 buf = (char *) &cm[1];
1040 if ((GNUNET_SYSERR ==
1041 GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len,
1042 &identity, &read)) ||
1043 (read != key_len))
1044 {
1045 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1046 "Failed to read private key\n");
1047 GNUNET_SERVICE_client_drop (idp->client);
1048 return;
1049 }
1050 buf += read;
1051 tkt_len = ntohs (cm->tkt_len); 1027 tkt_len = ntohs (cm->tkt_len);
1052 if ((GNUNET_SYSERR == 1028 if ((GNUNET_SYSERR ==
1053 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, 1029 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
@@ -1063,7 +1039,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1063 cop->r_id = ntohl (cm->id); 1039 cop->r_id = ntohl (cm->id);
1064 cop->client = idp; 1040 cop->client = idp;
1065 cop->ch 1041 cop->ch
1066 = RECLAIM_TICKETS_consume (&identity, &ticket, &consume_result_cb, 1042 = RECLAIM_TICKETS_consume (&ticket, &consume_result_cb,
1067 cop); 1043 cop);
1068 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); 1044 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
1069 GNUNET_SERVICE_client_continue (idp->client); 1045 GNUNET_SERVICE_client_continue (idp->client);
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.c b/src/service/reclaim/gnunet-service-reclaim_tickets.c
index acd2b6859..637fcfcce 100644
--- a/src/service/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/service/reclaim/gnunet-service-reclaim_tickets.c
@@ -25,6 +25,7 @@
25 * 25 *
26 */ 26 */
27#include "gnunet-service-reclaim_tickets.h" 27#include "gnunet-service-reclaim_tickets.h"
28#include <string.h>
28 29
29 30
30/** 31/**
@@ -83,16 +84,6 @@ struct RECLAIM_TICKETS_ConsumeHandle
83 struct GNUNET_GNS_LookupRequest *lookup_request; 84 struct GNUNET_GNS_LookupRequest *lookup_request;
84 85
85 /** 86 /**
86 * Audience Key
87 */
88 struct GNUNET_CRYPTO_PrivateKey identity;
89
90 /**
91 * Audience Key
92 */
93 struct GNUNET_CRYPTO_PublicKey identity_pub;
94
95 /**
96 * Lookup DLL 87 * Lookup DLL
97 */ 88 */
98 struct ParallelLookup *parallel_lookups_head; 89 struct ParallelLookup *parallel_lookups_head;
@@ -1178,8 +1169,7 @@ lookup_authz_cb (void *cls,
1178 * @return handle to the operation 1169 * @return handle to the operation
1179 */ 1170 */
1180struct RECLAIM_TICKETS_ConsumeHandle * 1171struct RECLAIM_TICKETS_ConsumeHandle *
1181RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_PrivateKey *id, 1172RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket,
1182 const struct GNUNET_RECLAIM_Ticket *ticket,
1183 RECLAIM_TICKETS_ConsumeCallback cb, 1173 RECLAIM_TICKETS_ConsumeCallback cb,
1184 void *cb_cls) 1174 void *cb_cls)
1185{ 1175{
@@ -1188,8 +1178,6 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_PrivateKey *id,
1188 1178
1189 cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle); 1179 cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle);
1190 1180
1191 cth->identity = *id;
1192 GNUNET_CRYPTO_key_get_public (&cth->identity, &cth->identity_pub);
1193 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 1181 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1194 cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); 1182 cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1195 cth->ticket = *ticket; 1183 cth->ticket = *ticket;
@@ -1513,9 +1501,8 @@ filter_tickets_cb (void *cls,
1513 // cmp audience 1501 // cmp audience
1514 // FIXME this is ugly, GNUNET_CRYPTO_PublicKey cannot be compared 1502 // FIXME this is ugly, GNUNET_CRYPTO_PublicKey cannot be compared
1515 // like this 1503 // like this
1516 if (0 == memcmp (&tih->ticket.audience, 1504 if (0 == strcmp (tih->ticket.rp_uri,
1517 &ticket.audience, 1505 ticket.rp_uri))
1518 sizeof(struct GNUNET_CRYPTO_PublicKey)))
1519 { 1506 {
1520 tih->ticket = ticket; 1507 tih->ticket = ticket;
1521 ticket_found = GNUNET_YES; 1508 ticket_found = GNUNET_YES;
@@ -1543,7 +1530,8 @@ filter_tickets_cb (void *cls,
1543 cred = GNUNET_RECLAIM_credential_deserialize (rd[i].data, 1530 cred = GNUNET_RECLAIM_credential_deserialize (rd[i].data,
1544 rd[i].data_size); 1531 rd[i].data_size);
1545 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id, 1532 if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id,
1546 &le->attribute->credential)) 1533 &le->attribute->credential
1534 ))
1547 { 1535 {
1548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1549 "No match.\n"); 1537 "No match.\n");
@@ -1576,7 +1564,8 @@ filter_tickets_cb (void *cls,
1576 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1564 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1577 { 1565 {
1578 presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data, 1566 presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1579 rd[i].data_size); 1567 rd[i].data_size)
1568 ;
1580 if (NULL == presentation) 1569 if (NULL == presentation)
1581 { 1570 {
1582 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1571 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1650,7 +1639,7 @@ filter_tickets_finished_cb (void *cls)
1650void 1639void
1651RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity, 1640RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity,
1652 const struct GNUNET_RECLAIM_AttributeList *attrs, 1641 const struct GNUNET_RECLAIM_AttributeList *attrs,
1653 const struct GNUNET_CRYPTO_PublicKey *audience, 1642 const char *rp,
1654 RECLAIM_TICKETS_TicketResult cb, 1643 RECLAIM_TICKETS_TicketResult cb,
1655 void *cb_cls) 1644 void *cb_cls)
1656{ 1645{
@@ -1662,7 +1651,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity,
1662 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs); 1651 tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs);
1663 tih->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); 1652 tih->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1664 tih->identity = *identity; 1653 tih->identity = *identity;
1665 tih->ticket.audience = *audience; 1654 memcpy (tih->ticket.rp_uri, rp, strlen (rp) + 1);
1666 1655
1667 // First check whether the ticket has already been issued 1656 // First check whether the ticket has already been issued
1668 tih->ns_it = 1657 tih->ns_it =
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.h b/src/service/reclaim/gnunet-service-reclaim_tickets.h
index 0ec232f49..93e48628a 100644
--- a/src/service/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/service/reclaim/gnunet-service-reclaim_tickets.h
@@ -186,15 +186,13 @@ RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
186 * We first looking attribute references under the label 186 * We first looking attribute references under the label
187 * ticket.rnd in GNS. 187 * ticket.rnd in GNS.
188 * 188 *
189 * @param id the audience of the ticket
190 * @param ticket the ticket to consume 189 * @param ticket the ticket to consume
191 * @param cb callback to call with attributes of ticket 190 * @param cb callback to call with attributes of ticket
192 * @param cb_cls callback closure 191 * @param cb_cls callback closure
193 * @return handle to the operation 192 * @return handle to the operation
194 */ 193 */
195struct RECLAIM_TICKETS_ConsumeHandle * 194struct RECLAIM_TICKETS_ConsumeHandle *
196RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_PrivateKey *id, 195RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket,
197 const struct GNUNET_RECLAIM_Ticket *ticket,
198 RECLAIM_TICKETS_ConsumeCallback cb, 196 RECLAIM_TICKETS_ConsumeCallback cb,
199 void *cb_cls); 197 void *cb_cls);
200 198
@@ -214,7 +212,7 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
214 * 212 *
215 * @param identity the issuer 213 * @param identity the issuer
216 * @param attrs the attributes to share 214 * @param attrs the attributes to share
217 * @param audience the audience to share the attributes with 215 * @param rp the RP URI
218 * @param cb the callback to call with the ticket result 216 * @param cb the callback to call with the ticket result
219 * @param cb_cls the callback closure 217 * @param cb_cls the callback closure
220 * FIXME: Return handle?? 218 * FIXME: Return handle??
@@ -222,7 +220,7 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
222void 220void
223RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity, 221RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity,
224 const struct GNUNET_RECLAIM_AttributeList *attrs, 222 const struct GNUNET_RECLAIM_AttributeList *attrs,
225 const struct GNUNET_CRYPTO_PublicKey *audience, 223 const char *rp,
226 RECLAIM_TICKETS_TicketResult cb, 224 RECLAIM_TICKETS_TicketResult cb,
227 void *cb_cls); 225 void *cb_cls);
228 226
diff --git a/src/service/reclaim/reclaim.h b/src/service/reclaim/reclaim.h
index 9d5118269..eebd39c29 100644
--- a/src/service/reclaim/reclaim.h
+++ b/src/service/reclaim/reclaim.h
@@ -420,13 +420,13 @@ struct IssueTicketMessage
420 uint16_t key_len GNUNET_PACKED; 420 uint16_t key_len GNUNET_PACKED;
421 421
422 /** 422 /**
423 * The length of the relying party public key 423 * The length of the relying party URI
424 */ 424 */
425 uint16_t pkey_len GNUNET_PACKED; 425 uint16_t rp_uri_len GNUNET_PACKED;
426 426
427 /** 427 /**
428 * Followed by the private key. 428 * Followed by the private key.
429 * Followed by the public key. 429 * Followed by the RP URI.
430 * Followed by a serialized attribute list 430 * Followed by a serialized attribute list
431 */ 431 */
432}; 432};
@@ -532,17 +532,11 @@ struct ConsumeTicketMessage
532 uint32_t id GNUNET_PACKED; 532 uint32_t id GNUNET_PACKED;
533 533
534 /** 534 /**
535 * The length of the private key
536 */
537 uint16_t key_len GNUNET_PACKED;
538
539 /**
540 * The length of the ticket 535 * The length of the ticket
541 */ 536 */
542 uint16_t tkt_len GNUNET_PACKED; 537 uint16_t tkt_len GNUNET_PACKED;
543 538
544 /** 539 /**
545 * Followed by the private key.
546 * Followed by the serialized ticket. 540 * Followed by the serialized ticket.
547 */ 541 */
548}; 542};
@@ -583,12 +577,12 @@ struct ConsumeTicketResultMessage
583 uint16_t presentations_len; 577 uint16_t presentations_len;
584 578
585 /** 579 /**
586 * The length of the private key 580 * The length of the identity public key
587 */ 581 */
588 uint16_t key_len GNUNET_PACKED; 582 uint16_t key_len GNUNET_PACKED;
589 583
590 /** 584 /**
591 * Followed by the private key. 585 * Followed by the identity public key.
592 * followed by: 586 * followed by:
593 * serialized attributes data 587 * serialized attributes data
594 */ 588 */
diff --git a/src/service/reclaim/reclaim_api.c b/src/service/reclaim/reclaim_api.c
index d865f0050..0fe49c37d 100644
--- a/src/service/reclaim/reclaim_api.c
+++ b/src/service/reclaim/reclaim_api.c
@@ -621,9 +621,9 @@ handle_consume_ticket_result (void *cls,
621 read_ptr = (char *) &msg[1]; 621 read_ptr = (char *) &msg[1];
622 GNUNET_assert (GNUNET_SYSERR != 622 GNUNET_assert (GNUNET_SYSERR !=
623 GNUNET_CRYPTO_read_public_key_from_buffer (read_ptr, 623 GNUNET_CRYPTO_read_public_key_from_buffer (read_ptr,
624 key_len, 624 key_len,
625 &identity, 625 &identity,
626 &read)); 626 &read));
627 read_ptr += read; 627 read_ptr += read;
628 attrs = 628 attrs =
629 GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len); 629 GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len);
@@ -646,7 +646,8 @@ handle_consume_ticket_result (void *cls,
646 { 646 {
647 if (GNUNET_YES == 647 if (GNUNET_YES ==
648 GNUNET_RECLAIM_id_is_equal (&le->attribute->credential, 648 GNUNET_RECLAIM_id_is_equal (&le->attribute->credential,
649 &ple->presentation->credential_id)) 649 &ple->presentation->credential_id)
650 )
650 { 651 {
651 op->atr_cb (op->cls, &identity, 652 op->atr_cb (op->cls, &identity,
652 le->attribute, ple->presentation); 653 le->attribute, ple->presentation);
@@ -765,9 +766,9 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
765 struct GNUNET_RECLAIM_Attribute *attr; 766 struct GNUNET_RECLAIM_Attribute *attr;
766 GNUNET_assert (GNUNET_SYSERR != 767 GNUNET_assert (GNUNET_SYSERR !=
767 GNUNET_CRYPTO_read_public_key_from_buffer (buf, 768 GNUNET_CRYPTO_read_public_key_from_buffer (buf,
768 key_len, 769 key_len,
769 &identity, 770 &identity,
770 &read)); 771 &read));
771 buf += read; 772 buf += read;
772 GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr); 773 GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr);
773 if (NULL != it) 774 if (NULL != it)
@@ -854,9 +855,9 @@ handle_credential_result (void *cls, const struct
854 { 855 {
855 GNUNET_assert (GNUNET_SYSERR != 856 GNUNET_assert (GNUNET_SYSERR !=
856 GNUNET_CRYPTO_read_public_key_from_buffer (buf, 857 GNUNET_CRYPTO_read_public_key_from_buffer (buf,
857 key_len, 858 key_len,
858 &identity, 859 &identity,
859 &read)); 860 &read));
860 buf += read; 861 buf += read;
861 } 862 }
862 if (0 == key_len) 863 if (0 == key_len)
@@ -966,10 +967,10 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
966 if (0 < tkt_len) 967 if (0 < tkt_len)
967 { 968 {
968 GNUNET_assert (GNUNET_SYSERR != 969 GNUNET_assert (GNUNET_SYSERR !=
969 GNUNET_RECLAIM_read_ticket_from_buffer (buf, 970 GNUNET_RECLAIM_read_ticket_from_buffer (buf,
970 tkt_len, 971 tkt_len,
971 &ticket, 972 &ticket,
972 &tb_read)); 973 &tb_read));
973 buf += tb_read; 974 buf += tb_read;
974 } 975 }
975 if (NULL != op) 976 if (NULL != op)
@@ -1440,7 +1441,8 @@ GNUNET_RECLAIM_get_credentials_start (
1440 env = 1441 env =
1441 GNUNET_MQ_msg_extra (msg, 1442 GNUNET_MQ_msg_extra (msg,
1442 key_len, 1443 key_len,
1443 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START); 1444 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START)
1445 ;
1444 msg->id = htonl (rid); 1446 msg->id = htonl (rid);
1445 msg->key_len = htons (key_len); 1447 msg->key_len = htons (key_len);
1446 GNUNET_CRYPTO_write_private_key_to_buffer (identity, &msg[1], key_len); 1448 GNUNET_CRYPTO_write_private_key_to_buffer (identity, &msg[1], key_len);
@@ -1491,7 +1493,7 @@ struct GNUNET_RECLAIM_Operation *
1491GNUNET_RECLAIM_ticket_issue ( 1493GNUNET_RECLAIM_ticket_issue (
1492 struct GNUNET_RECLAIM_Handle *h, 1494 struct GNUNET_RECLAIM_Handle *h,
1493 const struct GNUNET_CRYPTO_PrivateKey *iss, 1495 const struct GNUNET_CRYPTO_PrivateKey *iss,
1494 const struct GNUNET_CRYPTO_PublicKey *rp, 1496 const char *rp,
1495 const struct GNUNET_RECLAIM_AttributeList *attrs, 1497 const struct GNUNET_RECLAIM_AttributeList *attrs,
1496 GNUNET_RECLAIM_IssueTicketCallback cb, 1498 GNUNET_RECLAIM_IssueTicketCallback cb,
1497 void *cb_cls) 1499 void *cb_cls)
@@ -1510,19 +1512,20 @@ GNUNET_RECLAIM_ticket_issue (
1510 op->cls = cb_cls; 1512 op->cls = cb_cls;
1511 op->r_id = h->r_id_gen++; 1513 op->r_id = h->r_id_gen++;
1512 key_len = GNUNET_CRYPTO_private_key_get_length (iss); 1514 key_len = GNUNET_CRYPTO_private_key_get_length (iss);
1513 rpk_len = GNUNET_CRYPTO_public_key_get_length (rp); 1515 rpk_len = strlen (rp) + 1;
1514 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1516 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1515 attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); 1517 attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
1516 op->env = GNUNET_MQ_msg_extra (tim, 1518 op->env = GNUNET_MQ_msg_extra (tim,
1517 attr_len + key_len + rpk_len, 1519 attr_len + key_len + rpk_len,
1518 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); 1520 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
1519 tim->key_len = htons (key_len); 1521 tim->key_len = htons (key_len);
1520 tim->pkey_len = htons (rpk_len); 1522 tim->rp_uri_len = htons (rpk_len);
1521 buf = (char *) &tim[1]; 1523 buf = (char *) &tim[1];
1522 written = GNUNET_CRYPTO_write_private_key_to_buffer (iss, buf, key_len); 1524 written = GNUNET_CRYPTO_write_private_key_to_buffer (iss, buf, key_len);
1523 GNUNET_assert (0 <= written); 1525 GNUNET_assert (0 <= written);
1524 buf += written; 1526 buf += written;
1525 written = GNUNET_CRYPTO_write_public_key_to_buffer (rp, buf, rpk_len); 1527 memcpy (buf, rp, rpk_len);
1528 written = rpk_len;
1526 GNUNET_assert (0 <= written); 1529 GNUNET_assert (0 <= written);
1527 buf += written; 1530 buf += written;
1528 tim->id = htonl (op->r_id); 1531 tim->id = htonl (op->r_id);
@@ -1535,29 +1538,15 @@ GNUNET_RECLAIM_ticket_issue (
1535} 1538}
1536 1539
1537 1540
1538/**
1539 * Consumes an issued ticket. The ticket is persisted
1540 * and used to retrieve identity information from the issuer
1541 *
1542 * @param h the reclaim to use
1543 * @param identity the identity that is the subject of the issued ticket (the
1544 * relying party)
1545 * @param ticket the issued ticket to consume
1546 * @param cb the callback to call
1547 * @param cb_cls the callback closure
1548 * @return handle to abort the operation
1549 */
1550struct GNUNET_RECLAIM_Operation * 1541struct GNUNET_RECLAIM_Operation *
1551GNUNET_RECLAIM_ticket_consume ( 1542GNUNET_RECLAIM_ticket_consume (
1552 struct GNUNET_RECLAIM_Handle *h, 1543 struct GNUNET_RECLAIM_Handle *h,
1553 const struct GNUNET_CRYPTO_PrivateKey *identity,
1554 const struct GNUNET_RECLAIM_Ticket *ticket, 1544 const struct GNUNET_RECLAIM_Ticket *ticket,
1555 GNUNET_RECLAIM_AttributeTicketResult cb, 1545 GNUNET_RECLAIM_AttributeTicketResult cb,
1556 void *cb_cls) 1546 void *cb_cls)
1557{ 1547{
1558 struct GNUNET_RECLAIM_Operation *op; 1548 struct GNUNET_RECLAIM_Operation *op;
1559 struct ConsumeTicketMessage *ctm; 1549 struct ConsumeTicketMessage *ctm;
1560 size_t key_len;
1561 size_t tkt_len; 1550 size_t tkt_len;
1562 char *buf; 1551 char *buf;
1563 1552
@@ -1566,16 +1555,12 @@ GNUNET_RECLAIM_ticket_consume (
1566 op->atr_cb = cb; 1555 op->atr_cb = cb;
1567 op->cls = cb_cls; 1556 op->cls = cb_cls;
1568 op->r_id = h->r_id_gen++; 1557 op->r_id = h->r_id_gen++;
1569 key_len = GNUNET_CRYPTO_private_key_get_length (identity);
1570 tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket); 1558 tkt_len = GNUNET_RECLAIM_ticket_serialize_get_size (ticket);
1571 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1559 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1572 op->env = GNUNET_MQ_msg_extra (ctm, 1560 op->env = GNUNET_MQ_msg_extra (ctm,
1573 key_len + tkt_len, 1561 tkt_len,
1574 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); 1562 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1575 ctm->key_len = htons (key_len);
1576 buf = (char*) &ctm[1]; 1563 buf = (char*) &ctm[1];
1577 GNUNET_CRYPTO_write_private_key_to_buffer (identity, buf, key_len);
1578 buf += key_len;
1579 ctm->tkt_len = htons (tkt_len); 1564 ctm->tkt_len = htons (tkt_len);
1580 GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); 1565 GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len);
1581 ctm->id = htonl (op->r_id); 1566 ctm->id = htonl (op->r_id);
@@ -1619,12 +1604,13 @@ GNUNET_RECLAIM_ticket_iteration_start (
1619 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it); 1604 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1620 env = GNUNET_MQ_msg_extra (msg, 1605 env = GNUNET_MQ_msg_extra (msg,
1621 key_len, 1606 key_len,
1622 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); 1607 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START)
1608 ;
1623 msg->id = htonl (rid); 1609 msg->id = htonl (rid);
1624 msg->key_len = htons (key_len); 1610 msg->key_len = htons (key_len);
1625 GNUNET_CRYPTO_write_private_key_to_buffer (identity, 1611 GNUNET_CRYPTO_write_private_key_to_buffer (identity,
1626 &msg[1], 1612 &msg[1],
1627 key_len); 1613 key_len);
1628 if (NULL == h->mq) 1614 if (NULL == h->mq)
1629 it->env = env; 1615 it->env = env;
1630 else 1616 else
@@ -1723,8 +1709,8 @@ GNUNET_RECLAIM_ticket_revoke (
1723 msg->tkt_len = htons (tkt_len); 1709 msg->tkt_len = htons (tkt_len);
1724 buf = (char*) &msg[1]; 1710 buf = (char*) &msg[1];
1725 written = GNUNET_CRYPTO_write_private_key_to_buffer (identity, 1711 written = GNUNET_CRYPTO_write_private_key_to_buffer (identity,
1726 buf, 1712 buf,
1727 key_len); 1713 key_len);
1728 GNUNET_assert (0 <= written); 1714 GNUNET_assert (0 <= written);
1729 buf += written; 1715 buf += written;
1730 GNUNET_RECLAIM_write_ticket_to_buffer (ticket, 1716 GNUNET_RECLAIM_write_ticket_to_buffer (ticket,
@@ -1738,16 +1724,18 @@ GNUNET_RECLAIM_ticket_revoke (
1738 return op; 1724 return op;
1739} 1725}
1740 1726
1727
1741size_t 1728size_t
1742GNUNET_RECLAIM_ticket_serialize_get_size (const struct 1729GNUNET_RECLAIM_ticket_serialize_get_size (const struct
1743 GNUNET_RECLAIM_Ticket *tkt) 1730 GNUNET_RECLAIM_Ticket *tkt)
1744{ 1731{
1745 size_t size = sizeof (tkt->rnd); 1732 size_t size = sizeof (tkt->rnd);
1746 size += GNUNET_CRYPTO_public_key_get_length (&tkt->identity); 1733 size += GNUNET_CRYPTO_public_key_get_length (&tkt->identity);
1747 size += GNUNET_CRYPTO_public_key_get_length (&tkt->audience); 1734 size += strlen (tkt->rp_uri) + 1;
1748 return size; 1735 return size;
1749} 1736}
1750 1737
1738
1751enum GNUNET_GenericReturnValue 1739enum GNUNET_GenericReturnValue
1752GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer, 1740GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer,
1753 size_t len, 1741 size_t len,
@@ -1759,22 +1747,19 @@ GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer,
1759 size_t left = len; 1747 size_t left = len;
1760 if (GNUNET_SYSERR == 1748 if (GNUNET_SYSERR ==
1761 GNUNET_CRYPTO_read_public_key_from_buffer (tmp, 1749 GNUNET_CRYPTO_read_public_key_from_buffer (tmp,
1762 left, 1750 left,
1763 &tkt->identity, 1751 &tkt->identity,
1764 &read)) 1752 &read))
1765 return GNUNET_SYSERR; 1753 return GNUNET_SYSERR;
1766 left -= read; 1754 left -= read;
1767 tmp += read; 1755 tmp += read;
1768 if (GNUNET_SYSERR == 1756 if (left <= sizeof (tkt->rnd))
1769 GNUNET_CRYPTO_read_public_key_from_buffer (tmp,
1770 left,
1771 &tkt->audience,
1772 &read))
1773 return GNUNET_SYSERR; 1757 return GNUNET_SYSERR;
1774 left -= read; 1758 if (left - sizeof (tkt->rnd) > GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN)
1775 tmp += read;
1776 if (left < sizeof (tkt->rnd))
1777 return GNUNET_SYSERR; 1759 return GNUNET_SYSERR;
1760 memcpy (tkt->rp_uri, tmp, left - sizeof (tkt->rnd));
1761 tmp += left - sizeof (tkt->rnd);
1762 left = sizeof (tkt->rnd);
1778 memcpy (&tkt->rnd, tmp, sizeof (tkt->rnd)); 1763 memcpy (&tkt->rnd, tmp, sizeof (tkt->rnd));
1779 *tb_read = tmp - (char*) buffer + sizeof (tkt->rnd); 1764 *tb_read = tmp - (char*) buffer + sizeof (tkt->rnd);
1780 return GNUNET_OK; 1765 return GNUNET_OK;
@@ -1791,17 +1776,14 @@ GNUNET_RECLAIM_write_ticket_to_buffer (const struct
1791 size_t left = len; 1776 size_t left = len;
1792 ssize_t written = 0; 1777 ssize_t written = 0;
1793 written = GNUNET_CRYPTO_write_public_key_to_buffer (&tkt->identity, 1778 written = GNUNET_CRYPTO_write_public_key_to_buffer (&tkt->identity,
1794 buffer, 1779 buffer,
1795 left); 1780 left);
1796 if (0 > written) 1781 if (0 > written)
1797 return written; 1782 return written;
1798 left -= written; 1783 left -= written;
1799 tmp += written; 1784 tmp += written;
1800 written = GNUNET_CRYPTO_write_public_key_to_buffer (&tkt->audience, 1785 memcpy (&tmp, tkt->rp_uri, strlen (tkt->rp_uri) + 1);
1801 tmp, 1786 written = strlen (tkt->rp_uri) + 1;
1802 left);
1803 if (0 > written)
1804 return written;
1805 left -= written; 1787 left -= written;
1806 tmp += written; 1788 tmp += written;
1807 if (left < sizeof (tkt->rnd)) 1789 if (left < sizeof (tkt->rnd))
@@ -1811,5 +1793,4 @@ GNUNET_RECLAIM_write_ticket_to_buffer (const struct
1811} 1793}
1812 1794
1813 1795
1814
1815/* end of reclaim_api.c */ 1796/* end of reclaim_api.c */
diff --git a/src/service/rest/json_reclaim.c b/src/service/rest/json_reclaim.c
index b1ca7a4a5..6cbd44adf 100644
--- a/src/service/rest/json_reclaim.c
+++ b/src/service/rest/json_reclaim.c
@@ -219,16 +219,7 @@ parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
219 return GNUNET_SYSERR; 219 return GNUNET_SYSERR;
220 } 220 }
221 221
222 if (GNUNET_OK != 222 strcpy (ticket->rp_uri, aud_str);
223 GNUNET_STRINGS_string_to_data (aud_str,
224 strlen (aud_str),
225 &ticket->audience,
226 sizeof(ticket->audience)))
227 {
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n");
229 GNUNET_free (ticket);
230 return GNUNET_SYSERR;
231 }
232 223
233 *(struct GNUNET_RECLAIM_Ticket **) spec->ptr = ticket; 224 *(struct GNUNET_RECLAIM_Ticket **) spec->ptr = ticket;
234 return GNUNET_OK; 225 return GNUNET_OK;
diff --git a/src/service/rest/reclaim_plugin.c b/src/service/rest/reclaim_plugin.c
index e1afce00b..921faf8ca 100644
--- a/src/service/rest/reclaim_plugin.c
+++ b/src/service/rest/reclaim_plugin.c
@@ -454,12 +454,7 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
454 value = json_string (tmp); 454 value = json_string (tmp);
455 json_object_set_new (json_resource, "issuer", value); 455 json_object_set_new (json_resource, "issuer", value);
456 GNUNET_free (tmp); 456 GNUNET_free (tmp);
457 tmp = 457 json_object_set_new (json_resource, "audience", json_string (ticket->rp_uri));
458 GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
459 sizeof(struct
460 GNUNET_CRYPTO_PublicKey));
461 value = json_string (tmp);
462 json_object_set_new (json_resource, "audience", value);
463 GNUNET_free (tmp); 458 GNUNET_free (tmp);
464 tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd)); 459 tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
465 value = json_string (tmp); 460 value = json_string (tmp);
@@ -1236,11 +1231,8 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
1236 const char *url, 1231 const char *url,
1237 void *cls) 1232 void *cls)
1238{ 1233{
1239 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
1240 struct RequestHandle *handle = cls; 1234 struct RequestHandle *handle = cls;
1241 struct EgoEntry *ego_entry;
1242 struct GNUNET_RECLAIM_Ticket *ticket; 1235 struct GNUNET_RECLAIM_Ticket *ticket;
1243 struct GNUNET_CRYPTO_PublicKey tmp_pk;
1244 char term_data[handle->rest_handle->data_size + 1]; 1236 char term_data[handle->rest_handle->data_size + 1];
1245 json_t *data_json; 1237 json_t *data_json;
1246 json_error_t err; 1238 json_error_t err;
@@ -1274,25 +1266,8 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
1274 json_decref (data_json); 1266 json_decref (data_json);
1275 return; 1267 return;
1276 } 1268 }
1277 for (ego_entry = ego_head; NULL != ego_entry;
1278 ego_entry = ego_entry->next)
1279 {
1280 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1281 if (0 == memcmp (&ticket->audience,
1282 &tmp_pk,
1283 sizeof(struct GNUNET_CRYPTO_PublicKey)))
1284 break;
1285 }
1286 if (NULL == ego_entry)
1287 {
1288 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1289 GNUNET_JSON_parse_free (tktspec);
1290 return;
1291 }
1292 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1293 handle->resp_object = json_object (); 1269 handle->resp_object = json_object ();
1294 handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, 1270 handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp,
1295 identity_priv,
1296 ticket, 1271 ticket,
1297 &consume_cont, 1272 &consume_cont,
1298 handle); 1273 handle);