diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2024-05-07 14:44:42 +0200 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2024-05-07 14:44:42 +0200 |
commit | d43b76cb0f1d7c66ec8253f9ec5effa55a824694 (patch) | |
tree | 4ae37cbf9090da758ce5e27787eef236cf3316f7 | |
parent | dbfd21c2f14d439ce897edb427222a4445a07072 (diff) | |
download | gnunet-d43b76cb0f1d7c66ec8253f9ec5effa55a824694.tar.gz gnunet-d43b76cb0f1d7c66ec8253f9ec5effa55a824694.zip |
RECLAIM: Forgot to modify consume API to new issue behaviour
-rw-r--r-- | src/cli/reclaim/gnunet-reclaim.c | 18 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_service.h | 6 | ||||
-rw-r--r-- | src/service/reclaim/gnunet-service-reclaim.c | 12 | ||||
-rw-r--r-- | src/service/reclaim/gnunet-service-reclaim_tickets.c | 8 | ||||
-rw-r--r-- | src/service/reclaim/gnunet-service-reclaim_tickets.h | 2 | ||||
-rw-r--r-- | src/service/reclaim/reclaim.h | 6 | ||||
-rw-r--r-- | src/service/reclaim/reclaim_api.c | 4 | ||||
-rw-r--r-- | src/service/rest/reclaim_plugin.c | 7 |
8 files changed, 56 insertions, 7 deletions
diff --git a/src/cli/reclaim/gnunet-reclaim.c b/src/cli/reclaim/gnunet-reclaim.c index 38d29ac09..b7342d3ff 100644 --- a/src/cli/reclaim/gnunet-reclaim.c +++ b/src/cli/reclaim/gnunet-reclaim.c | |||
@@ -53,6 +53,11 @@ static int list_credentials; | |||
53 | static char *credential_id; | 53 | static char *credential_id; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * The expected RP URI | ||
57 | */ | ||
58 | static char *ex_rp_uri; | ||
59 | |||
60 | /** | ||
56 | * Credential ID | 61 | * Credential ID |
57 | */ | 62 | */ |
58 | static struct GNUNET_RECLAIM_Identifier credential; | 63 | static struct GNUNET_RECLAIM_Identifier credential; |
@@ -445,8 +450,15 @@ iter_finished (void *cls) | |||
445 | } | 450 | } |
446 | if (consume_ticket) | 451 | if (consume_ticket) |
447 | { | 452 | { |
453 | if (NULL == ex_rp_uri) | ||
454 | { | ||
455 | fprintf (stderr, "Expected an RP URI to consume ticket\n"); | ||
456 | GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); | ||
457 | return; | ||
458 | } | ||
448 | reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, | 459 | reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, |
449 | &ticket, | 460 | &ticket, |
461 | ex_rp_uri, | ||
450 | &process_attrs, | 462 | &process_attrs, |
451 | NULL); | 463 | NULL); |
452 | timeout = GNUNET_SCHEDULER_add_delayed ( | 464 | timeout = GNUNET_SCHEDULER_add_delayed ( |
@@ -858,6 +870,12 @@ main (int argc, char *const argv[]) | |||
858 | gettext_noop ( | 870 | gettext_noop ( |
859 | "Specify the relying party for issue"), | 871 | "Specify the relying party for issue"), |
860 | &rp), | 872 | &rp), |
873 | GNUNET_GETOPT_option_string ('u', | ||
874 | "rpuri", | ||
875 | "RPURI", | ||
876 | gettext_noop ( | ||
877 | "Specify the relying party URI for a ticket to consume"), | ||
878 | &ex_rp_uri), | ||
861 | GNUNET_GETOPT_option_flag ('D', | 879 | GNUNET_GETOPT_option_flag ('D', |
862 | "dump", | 880 | "dump", |
863 | gettext_noop ("List attributes for EGO"), | 881 | gettext_noop ("List attributes for EGO"), |
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h index 15472fb9f..086c3f021 100644 --- a/src/include/gnunet_reclaim_service.h +++ b/src/include/gnunet_reclaim_service.h | |||
@@ -392,7 +392,7 @@ GNUNET_RECLAIM_get_credentials_stop ( | |||
392 | * | 392 | * |
393 | * @param h the identity provider to use | 393 | * @param h the identity provider to use |
394 | * @param iss the issuing identity (= the user) | 394 | * @param iss the issuing identity (= the user) |
395 | * @param rp the subject of the ticket (= the relying party) see #GNUNET_RECLAIM_Ticket | 395 | * @param rp_uri the subject of the ticket (= the relying party) see #GNUNET_RECLAIM_Ticket |
396 | * @param attrs the attributes that the relying party is given access to | 396 | * @param attrs the attributes that the relying party is given access to |
397 | * @param cb the callback | 397 | * @param cb the callback |
398 | * @param cb_cls the callback closure | 398 | * @param cb_cls the callback closure |
@@ -402,7 +402,7 @@ struct GNUNET_RECLAIM_Operation * | |||
402 | GNUNET_RECLAIM_ticket_issue ( | 402 | GNUNET_RECLAIM_ticket_issue ( |
403 | struct GNUNET_RECLAIM_Handle *h, | 403 | struct GNUNET_RECLAIM_Handle *h, |
404 | const struct GNUNET_CRYPTO_PrivateKey *iss, | 404 | const struct GNUNET_CRYPTO_PrivateKey *iss, |
405 | const char *rp, | 405 | const char *rp_uri, |
406 | const struct GNUNET_RECLAIM_AttributeList *attrs, | 406 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
407 | GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); | 407 | GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); |
408 | 408 | ||
@@ -434,6 +434,7 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
434 | * | 434 | * |
435 | * @param h the identity provider to use | 435 | * @param h the identity provider to use |
436 | * @param ticket the issued ticket to consume | 436 | * @param ticket the issued ticket to consume |
437 | * @param rp_uri the RP URI | ||
437 | * @param cb the callback to call | 438 | * @param cb the callback to call |
438 | * @param cb_cls the callback closure | 439 | * @param cb_cls the callback closure |
439 | * @return handle to abort the operation | 440 | * @return handle to abort the operation |
@@ -442,6 +443,7 @@ struct GNUNET_RECLAIM_Operation * | |||
442 | GNUNET_RECLAIM_ticket_consume ( | 443 | GNUNET_RECLAIM_ticket_consume ( |
443 | struct GNUNET_RECLAIM_Handle *h, | 444 | struct GNUNET_RECLAIM_Handle *h, |
444 | const struct GNUNET_RECLAIM_Ticket *ticket, | 445 | const struct GNUNET_RECLAIM_Ticket *ticket, |
446 | const char *rp_uri, | ||
445 | GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); | 447 | GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); |
446 | 448 | ||
447 | 449 | ||
diff --git a/src/service/reclaim/gnunet-service-reclaim.c b/src/service/reclaim/gnunet-service-reclaim.c index f5762c83d..c381a5aaf 100644 --- a/src/service/reclaim/gnunet-service-reclaim.c +++ b/src/service/reclaim/gnunet-service-reclaim.c | |||
@@ -984,9 +984,13 @@ static int | |||
984 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | 984 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) |
985 | { | 985 | { |
986 | uint16_t size; | 986 | uint16_t size; |
987 | uint16_t tkt_size; | ||
988 | uint16_t rp_uri_size; | ||
987 | 989 | ||
988 | size = ntohs (cm->header.size); | 990 | size = ntohs (cm->header.size); |
989 | if (size <= sizeof(struct ConsumeTicketMessage)) | 991 | tkt_size = ntohs (cm->tkt_len); |
992 | rp_uri_size = ntohs (cm->rp_uri_len); | ||
993 | if (size < sizeof(struct ConsumeTicketMessage) + tkt_size + rp_uri_size) | ||
990 | { | 994 | { |
991 | GNUNET_break (0); | 995 | GNUNET_break (0); |
992 | return GNUNET_SYSERR; | 996 | return GNUNET_SYSERR; |
@@ -1008,15 +1012,19 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | |||
1008 | struct IdpClient *idp = cls; | 1012 | struct IdpClient *idp = cls; |
1009 | struct GNUNET_RECLAIM_Ticket *ticket; | 1013 | struct GNUNET_RECLAIM_Ticket *ticket; |
1010 | char *buf; | 1014 | char *buf; |
1015 | const char *rp_uri; | ||
1011 | 1016 | ||
1012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); | 1017 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); |
1013 | buf = (char*) &cm[1]; | 1018 | buf = (char*) &cm[1]; |
1014 | ticket = (struct GNUNET_RECLAIM_Ticket *) buf; | 1019 | ticket = (struct GNUNET_RECLAIM_Ticket *) buf; |
1020 | rp_uri = buf + ntohs (cm->tkt_len); | ||
1015 | cop = GNUNET_new (struct ConsumeTicketOperation); | 1021 | cop = GNUNET_new (struct ConsumeTicketOperation); |
1016 | cop->r_id = ntohl (cm->id); | 1022 | cop->r_id = ntohl (cm->id); |
1017 | cop->client = idp; | 1023 | cop->client = idp; |
1018 | cop->ch | 1024 | cop->ch |
1019 | = RECLAIM_TICKETS_consume (ticket, &consume_result_cb, | 1025 | = RECLAIM_TICKETS_consume (ticket, |
1026 | rp_uri, | ||
1027 | &consume_result_cb, | ||
1020 | cop); | 1028 | cop); |
1021 | GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); | 1029 | GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); |
1022 | GNUNET_SERVICE_client_continue (idp->client); | 1030 | 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 0d0cc5cc5..23ce8ad92 100644 --- a/src/service/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/service/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -1047,7 +1047,8 @@ process_parallel_lookup_result (void *cls, | |||
1047 | if (NULL != cth->parallel_lookups_head) | 1047 | if (NULL != cth->parallel_lookups_head) |
1048 | return; // Wait for more | 1048 | return; // Wait for more |
1049 | /* Else we are done */ | 1049 | /* Else we are done */ |
1050 | GNUNET_assert (GNUNET_OK == GNUNET_GNS_parse_ztld (cth->ticket.gns_name, &iss)); | 1050 | GNUNET_assert (GNUNET_OK == GNUNET_GNS_parse_ztld (cth->ticket.gns_name, &iss) |
1051 | ); | ||
1051 | cth->cb (cth->cb_cls, &iss, | 1052 | cth->cb (cth->cb_cls, &iss, |
1052 | cth->attrs, cth->presentations, GNUNET_OK, NULL); | 1053 | cth->attrs, cth->presentations, GNUNET_OK, NULL); |
1053 | cleanup_cth (cth); | 1054 | cleanup_cth (cth); |
@@ -1152,7 +1153,8 @@ lookup_authz_cb (void *cls, | |||
1152 | "Ignoring unknown record type %d", rd[i].record_type); | 1153 | "Ignoring unknown record type %d", rd[i].record_type); |
1153 | } | 1154 | } |
1154 | } | 1155 | } |
1155 | GNUNET_assert (GNUNET_OK == GNUNET_GNS_parse_ztld (cth->ticket.gns_name, &iss)); | 1156 | GNUNET_assert (GNUNET_OK == GNUNET_GNS_parse_ztld (cth->ticket.gns_name, &iss) |
1157 | ); | ||
1156 | if (NULL == rp_uri) | 1158 | if (NULL == rp_uri) |
1157 | { | 1159 | { |
1158 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1160 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1212,6 +1214,7 @@ lookup_authz_cb (void *cls, | |||
1212 | */ | 1214 | */ |
1213 | struct RECLAIM_TICKETS_ConsumeHandle * | 1215 | struct RECLAIM_TICKETS_ConsumeHandle * |
1214 | RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket, | 1216 | RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket, |
1217 | const char *rp_uri, | ||
1215 | RECLAIM_TICKETS_ConsumeCallback cb, | 1218 | RECLAIM_TICKETS_ConsumeCallback cb, |
1216 | void *cb_cls) | 1219 | void *cb_cls) |
1217 | { | 1220 | { |
@@ -1224,6 +1227,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket, | |||
1224 | cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 1227 | cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
1225 | cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); | 1228 | cth->presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
1226 | cth->ticket = *ticket; | 1229 | cth->ticket = *ticket; |
1230 | memcpy (cth->rp_uri, rp_uri, strlen (rp_uri) + 1); | ||
1227 | cth->cb = cb; | 1231 | cth->cb = cb; |
1228 | cth->cb_cls = cb_cls; | 1232 | cth->cb_cls = cb_cls; |
1229 | tmp = GNUNET_strdup (ticket->gns_name); | 1233 | tmp = GNUNET_strdup (ticket->gns_name); |
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.h b/src/service/reclaim/gnunet-service-reclaim_tickets.h index 6e610493b..b425a3dba 100644 --- a/src/service/reclaim/gnunet-service-reclaim_tickets.h +++ b/src/service/reclaim/gnunet-service-reclaim_tickets.h | |||
@@ -189,12 +189,14 @@ RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh); | |||
189 | * ticket.rnd in GNS. | 189 | * ticket.rnd in GNS. |
190 | * | 190 | * |
191 | * @param ticket the ticket to consume | 191 | * @param ticket the ticket to consume |
192 | * @param rp_uri the expected RP URI | ||
192 | * @param cb callback to call with attributes of ticket | 193 | * @param cb callback to call with attributes of ticket |
193 | * @param cb_cls callback closure | 194 | * @param cb_cls callback closure |
194 | * @return handle to the operation | 195 | * @return handle to the operation |
195 | */ | 196 | */ |
196 | struct RECLAIM_TICKETS_ConsumeHandle * | 197 | struct RECLAIM_TICKETS_ConsumeHandle * |
197 | RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket, | 198 | RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket, |
199 | const char *rp_uri, | ||
198 | RECLAIM_TICKETS_ConsumeCallback cb, | 200 | RECLAIM_TICKETS_ConsumeCallback cb, |
199 | void *cb_cls); | 201 | void *cb_cls); |
200 | 202 | ||
diff --git a/src/service/reclaim/reclaim.h b/src/service/reclaim/reclaim.h index 33764c831..1fb50eafe 100644 --- a/src/service/reclaim/reclaim.h +++ b/src/service/reclaim/reclaim.h | |||
@@ -543,7 +543,13 @@ struct ConsumeTicketMessage | |||
543 | uint16_t tkt_len GNUNET_PACKED; | 543 | uint16_t tkt_len GNUNET_PACKED; |
544 | 544 | ||
545 | /** | 545 | /** |
546 | * RP URI length | ||
547 | */ | ||
548 | uint16_t rp_uri_len GNUNET_PACKED; | ||
549 | |||
550 | /** | ||
546 | * Followed by the serialized ticket. | 551 | * Followed by the serialized ticket. |
552 | * Followed by the RP URI | ||
547 | */ | 553 | */ |
548 | }; | 554 | }; |
549 | 555 | ||
diff --git a/src/service/reclaim/reclaim_api.c b/src/service/reclaim/reclaim_api.c index a9d9bdada..001e69095 100644 --- a/src/service/reclaim/reclaim_api.c +++ b/src/service/reclaim/reclaim_api.c | |||
@@ -1546,6 +1546,7 @@ struct GNUNET_RECLAIM_Operation * | |||
1546 | GNUNET_RECLAIM_ticket_consume ( | 1546 | GNUNET_RECLAIM_ticket_consume ( |
1547 | struct GNUNET_RECLAIM_Handle *h, | 1547 | struct GNUNET_RECLAIM_Handle *h, |
1548 | const struct GNUNET_RECLAIM_Ticket *ticket, | 1548 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1549 | const char *rp_uri, | ||
1549 | GNUNET_RECLAIM_AttributeTicketResult cb, | 1550 | GNUNET_RECLAIM_AttributeTicketResult cb, |
1550 | void *cb_cls) | 1551 | void *cb_cls) |
1551 | { | 1552 | { |
@@ -1565,8 +1566,11 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1565 | tkt_len, | 1566 | tkt_len, |
1566 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); | 1567 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); |
1567 | buf = (char*) &ctm[1]; | 1568 | buf = (char*) &ctm[1]; |
1569 | ctm->rp_uri_len = htons (strlen (rp_uri) + 1); | ||
1568 | ctm->tkt_len = htons (tkt_len); | 1570 | ctm->tkt_len = htons (tkt_len); |
1569 | memcpy (buf, ticket, tkt_len); | 1571 | memcpy (buf, ticket, tkt_len); |
1572 | buf += tkt_len; | ||
1573 | memcpy (buf, rp_uri, strlen (rp_uri) + 1); | ||
1570 | ctm->id = htonl (op->r_id); | 1574 | ctm->id = htonl (op->r_id); |
1571 | if (NULL != h->mq) | 1575 | if (NULL != h->mq) |
1572 | GNUNET_MQ_send_copy (h->mq, op->env); | 1576 | GNUNET_MQ_send_copy (h->mq, op->env); |
diff --git a/src/service/rest/reclaim_plugin.c b/src/service/rest/reclaim_plugin.c index adddab5c6..ed86601d1 100644 --- a/src/service/rest/reclaim_plugin.c +++ b/src/service/rest/reclaim_plugin.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * @brief GNUnet reclaim REST plugin | 24 | * @brief GNUnet reclaim REST plugin |
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | #include "gnunet_json_lib.h" | ||
27 | #include "platform.h" | 28 | #include "platform.h" |
28 | #include "microhttpd.h" | 29 | #include "microhttpd.h" |
29 | #include <inttypes.h> | 30 | #include <inttypes.h> |
@@ -1225,10 +1226,13 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1225 | struct RequestHandle *handle = cls; | 1226 | struct RequestHandle *handle = cls; |
1226 | struct GNUNET_RECLAIM_Ticket *ticket; | 1227 | struct GNUNET_RECLAIM_Ticket *ticket; |
1227 | char term_data[handle->rest_handle->data_size + 1]; | 1228 | char term_data[handle->rest_handle->data_size + 1]; |
1229 | const char *rp_uri; | ||
1228 | json_t *data_json; | 1230 | json_t *data_json; |
1229 | json_error_t err; | 1231 | json_error_t err; |
1230 | struct GNUNET_JSON_Specification tktspec[] = | 1232 | struct GNUNET_JSON_Specification tktspec[] = |
1231 | { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end () }; | 1233 | { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), |
1234 | GNUNET_JSON_spec_string("rp_uri", &rp_uri), | ||
1235 | GNUNET_JSON_spec_end () }; | ||
1232 | 1236 | ||
1233 | if (0 >= handle->rest_handle->data_size) | 1237 | if (0 >= handle->rest_handle->data_size) |
1234 | { | 1238 | { |
@@ -1260,6 +1264,7 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1260 | handle->resp_object = json_object (); | 1264 | handle->resp_object = json_object (); |
1261 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, | 1265 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (idp, |
1262 | ticket, | 1266 | ticket, |
1267 | rp_uri, | ||
1263 | &consume_cont, | 1268 | &consume_cont, |
1264 | handle); | 1269 | handle); |
1265 | GNUNET_JSON_parse_free (tktspec); | 1270 | GNUNET_JSON_parse_free (tktspec); |