diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-07 21:53:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-07 21:53:44 +0000 |
commit | 67eeadf357c24abec2dd790a54be74b7db71560d (patch) | |
tree | 01046bd16d390d420597797471adfb614c5073ea /src | |
parent | a46808363beba27ad2c7e52246ef1ec694f8bf3a (diff) | |
download | gnunet-67eeadf357c24abec2dd790a54be74b7db71560d.tar.gz gnunet-67eeadf357c24abec2dd790a54be74b7db71560d.zip |
-sending session ID back over same CADET channel is redundant
Diffstat (limited to 'src')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.h | 14 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_alice.c | 24 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_bob.c | 17 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct.h | 2 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_api.c | 8 |
5 files changed, 29 insertions, 36 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.h b/src/scalarproduct/gnunet-service-scalarproduct.h index 05b2a842c..82b2d10c5 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.h +++ b/src/scalarproduct/gnunet-service-scalarproduct.h | |||
@@ -89,10 +89,10 @@ struct AliceCryptodataMessage | |||
89 | * Message type passed from responding service Bob to responding | 89 | * Message type passed from responding service Bob to responding |
90 | * service Alice to complete a request and allow Alice to compute the | 90 | * service Alice to complete a request and allow Alice to compute the |
91 | * result. If Bob's reply does not fit into this one message, the | 91 | * result. If Bob's reply does not fit into this one message, the |
92 | * conversation may be continued with `struct MultipartMessage` | 92 | * conversation may be continued with `struct BobCryptodataMultipartMessage` |
93 | * messages afterwards. | 93 | * messages afterwards. |
94 | */ | 94 | */ |
95 | struct ServiceResponseMessage | 95 | struct BobCryptodataMessage |
96 | { | 96 | { |
97 | /** | 97 | /** |
98 | * GNUNET message header with type | 98 | * GNUNET message header with type |
@@ -116,12 +116,6 @@ struct ServiceResponseMessage | |||
116 | uint32_t contained_element_count GNUNET_PACKED; | 116 | uint32_t contained_element_count GNUNET_PACKED; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * The transaction/session key used to identify a session. | ||
120 | * FIXME: needed? CADET should already identify sessions! | ||
121 | */ | ||
122 | struct GNUNET_HashCode key; | ||
123 | |||
124 | /** | ||
125 | * followed by s | s' | k[i][perm] | 119 | * followed by s | s' | k[i][perm] |
126 | */ | 120 | */ |
127 | }; | 121 | }; |
@@ -130,11 +124,11 @@ struct ServiceResponseMessage | |||
130 | /** | 124 | /** |
131 | * Multipart Message type passed between to supply additional elements | 125 | * Multipart Message type passed between to supply additional elements |
132 | * for the peer. Send from Bob to Alice with additional elements | 126 | * for the peer. Send from Bob to Alice with additional elements |
133 | * of k[i][perm] after his `struct ServiceResponseMessage *`. | 127 | * of k[i][perm] after his `struct BobCryptodataMessage *`. |
134 | * Once all k-values have been transmitted, Bob is finished and | 128 | * Once all k-values have been transmitted, Bob is finished and |
135 | * Alice can transmit the final result to the client. | 129 | * Alice can transmit the final result to the client. |
136 | */ | 130 | */ |
137 | struct MultipartMessage | 131 | struct BobCryptodataMultipartMessage |
138 | { | 132 | { |
139 | /** | 133 | /** |
140 | * GNUNET message header | 134 | * GNUNET message header |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 3bfb4ffe0..522af201d 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -640,7 +640,7 @@ handle_bobs_cryptodata_multipart (void *cls, | |||
640 | const struct GNUNET_MessageHeader *message) | 640 | const struct GNUNET_MessageHeader *message) |
641 | { | 641 | { |
642 | struct AliceServiceSession *s = *channel_ctx; | 642 | struct AliceServiceSession *s = *channel_ctx; |
643 | const struct MultipartMessage *msg; | 643 | const struct BobCryptodataMultipartMessage *msg; |
644 | const struct GNUNET_CRYPTO_PaillierCiphertext *payload; | 644 | const struct GNUNET_CRYPTO_PaillierCiphertext *payload; |
645 | size_t i; | 645 | size_t i; |
646 | uint32_t contained; | 646 | uint32_t contained; |
@@ -653,14 +653,14 @@ handle_bobs_cryptodata_multipart (void *cls, | |||
653 | return GNUNET_SYSERR; | 653 | return GNUNET_SYSERR; |
654 | } | 654 | } |
655 | msg_size = ntohs (message->size); | 655 | msg_size = ntohs (message->size); |
656 | if (sizeof (struct MultipartMessage) > msg_size) | 656 | if (sizeof (struct BobCryptodataMultipartMessage) > msg_size) |
657 | { | 657 | { |
658 | GNUNET_break_op (0); | 658 | GNUNET_break_op (0); |
659 | return GNUNET_SYSERR; | 659 | return GNUNET_SYSERR; |
660 | } | 660 | } |
661 | msg = (const struct MultipartMessage *) message; | 661 | msg = (const struct BobCryptodataMultipartMessage *) message; |
662 | contained = ntohl (msg->contained_element_count); | 662 | contained = ntohl (msg->contained_element_count); |
663 | required_size = sizeof (struct MultipartMessage) | 663 | required_size = sizeof (struct BobCryptodataMultipartMessage) |
664 | + 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext); | 664 | + 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext); |
665 | if ( (required_size != msg_size) || | 665 | if ( (required_size != msg_size) || |
666 | (s->transferred_element_count + contained > s->used_element_count) ) | 666 | (s->transferred_element_count + contained > s->used_element_count) ) |
@@ -712,7 +712,7 @@ handle_bobs_cryptodata_message (void *cls, | |||
712 | const struct GNUNET_MessageHeader *message) | 712 | const struct GNUNET_MessageHeader *message) |
713 | { | 713 | { |
714 | struct AliceServiceSession *s = *channel_ctx; | 714 | struct AliceServiceSession *s = *channel_ctx; |
715 | const struct ServiceResponseMessage *msg; | 715 | const struct BobCryptodataMessage *msg; |
716 | const struct GNUNET_CRYPTO_PaillierCiphertext *payload; | 716 | const struct GNUNET_CRYPTO_PaillierCiphertext *payload; |
717 | uint32_t i; | 717 | uint32_t i; |
718 | uint32_t contained; | 718 | uint32_t contained; |
@@ -725,12 +725,12 @@ handle_bobs_cryptodata_message (void *cls, | |||
725 | return GNUNET_SYSERR; | 725 | return GNUNET_SYSERR; |
726 | } | 726 | } |
727 | msg_size = ntohs (message->size); | 727 | msg_size = ntohs (message->size); |
728 | if (sizeof (struct ServiceResponseMessage) > msg_size) | 728 | if (sizeof (struct BobCryptodataMessage) > msg_size) |
729 | { | 729 | { |
730 | GNUNET_break_op (0); | 730 | GNUNET_break_op (0); |
731 | return GNUNET_SYSERR; | 731 | return GNUNET_SYSERR; |
732 | } | 732 | } |
733 | msg = (const struct ServiceResponseMessage *) message; | 733 | msg = (const struct BobCryptodataMessage *) message; |
734 | GNUNET_break_op (0 == ntohl (msg->reserved)); | 734 | GNUNET_break_op (0 == ntohl (msg->reserved)); |
735 | if (s->used_element_count != ntohl (msg->intersection_element_count)) | 735 | if (s->used_element_count != ntohl (msg->intersection_element_count)) |
736 | { | 736 | { |
@@ -739,7 +739,7 @@ handle_bobs_cryptodata_message (void *cls, | |||
739 | return GNUNET_SYSERR; | 739 | return GNUNET_SYSERR; |
740 | } | 740 | } |
741 | contained = ntohl (msg->contained_element_count); | 741 | contained = ntohl (msg->contained_element_count); |
742 | required_size = sizeof (struct ServiceResponseMessage) | 742 | required_size = sizeof (struct BobCryptodataMessage) |
743 | + 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) | 743 | + 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) |
744 | + 2 * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext); | 744 | + 2 * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext); |
745 | if ( (msg_size != required_size) || | 745 | if ( (msg_size != required_size) || |
@@ -1099,7 +1099,7 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
1099 | struct GNUNET_SERVER_Client *client, | 1099 | struct GNUNET_SERVER_Client *client, |
1100 | const struct GNUNET_MessageHeader *message) | 1100 | const struct GNUNET_MessageHeader *message) |
1101 | { | 1101 | { |
1102 | const struct ComputationMultipartMessage * msg; | 1102 | const struct ComputationBobCryptodataMultipartMessage * msg; |
1103 | struct AliceServiceSession *s; | 1103 | struct AliceServiceSession *s; |
1104 | uint32_t contained_count; | 1104 | uint32_t contained_count; |
1105 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1105 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
@@ -1119,17 +1119,17 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
1119 | return; | 1119 | return; |
1120 | } | 1120 | } |
1121 | msize = ntohs (message->size); | 1121 | msize = ntohs (message->size); |
1122 | if (msize < sizeof (struct ComputationMultipartMessage)) | 1122 | if (msize < sizeof (struct ComputationBobCryptodataMultipartMessage)) |
1123 | { | 1123 | { |
1124 | GNUNET_break (0); | 1124 | GNUNET_break (0); |
1125 | GNUNET_SERVER_receive_done (client, | 1125 | GNUNET_SERVER_receive_done (client, |
1126 | GNUNET_SYSERR); | 1126 | GNUNET_SYSERR); |
1127 | return; | 1127 | return; |
1128 | } | 1128 | } |
1129 | msg = (const struct ComputationMultipartMessage *) message; | 1129 | msg = (const struct ComputationBobCryptodataMultipartMessage *) message; |
1130 | contained_count = ntohl (msg->element_count_contained); | 1130 | contained_count = ntohl (msg->element_count_contained); |
1131 | 1131 | ||
1132 | if ( (msize != (sizeof (struct ComputationMultipartMessage) + | 1132 | if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) + |
1133 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || | 1133 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || |
1134 | (0 == contained_count) || | 1134 | (0 == contained_count) || |
1135 | (s->total == s->transferred_element_count) || | 1135 | (s->total == s->transferred_element_count) || |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index cd2a9ee6e..2001c39e8 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c | |||
@@ -513,7 +513,7 @@ bob_cadet_done_cb (void *cls) | |||
513 | /** | 513 | /** |
514 | * Maximum count of elements we can put into a multipart message | 514 | * Maximum count of elements we can put into a multipart message |
515 | */ | 515 | */ |
516 | #define ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct MultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)) | 516 | #define ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)) |
517 | 517 | ||
518 | 518 | ||
519 | /** | 519 | /** |
@@ -526,7 +526,7 @@ static void | |||
526 | transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s) | 526 | transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s) |
527 | { | 527 | { |
528 | struct GNUNET_CRYPTO_PaillierCiphertext *payload; | 528 | struct GNUNET_CRYPTO_PaillierCiphertext *payload; |
529 | struct MultipartMessage *msg; | 529 | struct BobCryptodataMultipartMessage *msg; |
530 | struct GNUNET_MQ_Envelope *e; | 530 | struct GNUNET_MQ_Envelope *e; |
531 | unsigned int i; | 531 | unsigned int i; |
532 | unsigned int j; | 532 | unsigned int j; |
@@ -581,12 +581,12 @@ transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s) | |||
581 | static void | 581 | static void |
582 | transmit_bobs_cryptodata_message (struct BobServiceSession *s) | 582 | transmit_bobs_cryptodata_message (struct BobServiceSession *s) |
583 | { | 583 | { |
584 | struct ServiceResponseMessage *msg; | 584 | struct BobCryptodataMessage *msg; |
585 | struct GNUNET_MQ_Envelope *e; | 585 | struct GNUNET_MQ_Envelope *e; |
586 | struct GNUNET_CRYPTO_PaillierCiphertext *payload; | 586 | struct GNUNET_CRYPTO_PaillierCiphertext *payload; |
587 | unsigned int i; | 587 | unsigned int i; |
588 | 588 | ||
589 | s->cadet_transmitted_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ServiceResponseMessage)) / | 589 | s->cadet_transmitted_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMessage)) / |
590 | (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * 2) - 2; | 590 | (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * 2) - 2; |
591 | if (s->cadet_transmitted_element_count > s->used_element_count) | 591 | if (s->cadet_transmitted_element_count > s->used_element_count) |
592 | s->cadet_transmitted_element_count = s->used_element_count; | 592 | s->cadet_transmitted_element_count = s->used_element_count; |
@@ -598,7 +598,6 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s) | |||
598 | msg->reserved = htonl (0); | 598 | msg->reserved = htonl (0); |
599 | msg->intersection_element_count = htonl (s->used_element_count); | 599 | msg->intersection_element_count = htonl (s->used_element_count); |
600 | msg->contained_element_count = htonl (s->cadet_transmitted_element_count); | 600 | msg->contained_element_count = htonl (s->cadet_transmitted_element_count); |
601 | msg->key = s->session_id; | ||
602 | 601 | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
604 | "Sending %u/%u crypto values to Alice\n", | 603 | "Sending %u/%u crypto values to Alice\n", |
@@ -1148,7 +1147,7 @@ GSS_handle_bob_client_message_multipart (void *cls, | |||
1148 | struct GNUNET_SERVER_Client *client, | 1147 | struct GNUNET_SERVER_Client *client, |
1149 | const struct GNUNET_MessageHeader *message) | 1148 | const struct GNUNET_MessageHeader *message) |
1150 | { | 1149 | { |
1151 | const struct ComputationMultipartMessage * msg; | 1150 | const struct ComputationBobCryptodataMultipartMessage * msg; |
1152 | struct BobServiceSession *s; | 1151 | struct BobServiceSession *s; |
1153 | uint32_t contained_count; | 1152 | uint32_t contained_count; |
1154 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1153 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
@@ -1168,17 +1167,17 @@ GSS_handle_bob_client_message_multipart (void *cls, | |||
1168 | return; | 1167 | return; |
1169 | } | 1168 | } |
1170 | msize = ntohs (message->size); | 1169 | msize = ntohs (message->size); |
1171 | if (msize < sizeof (struct ComputationMultipartMessage)) | 1170 | if (msize < sizeof (struct ComputationBobCryptodataMultipartMessage)) |
1172 | { | 1171 | { |
1173 | GNUNET_break (0); | 1172 | GNUNET_break (0); |
1174 | GNUNET_SERVER_receive_done (client, | 1173 | GNUNET_SERVER_receive_done (client, |
1175 | GNUNET_SYSERR); | 1174 | GNUNET_SYSERR); |
1176 | return; | 1175 | return; |
1177 | } | 1176 | } |
1178 | msg = (const struct ComputationMultipartMessage *) message; | 1177 | msg = (const struct ComputationBobCryptodataMultipartMessage *) message; |
1179 | contained_count = ntohl (msg->element_count_contained); | 1178 | contained_count = ntohl (msg->element_count_contained); |
1180 | 1179 | ||
1181 | if ( (msize != (sizeof (struct ComputationMultipartMessage) + | 1180 | if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) + |
1182 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || | 1181 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || |
1183 | (0 == contained_count) || | 1182 | (0 == contained_count) || |
1184 | (UINT16_MAX < contained_count) || | 1183 | (UINT16_MAX < contained_count) || |
diff --git a/src/scalarproduct/scalarproduct.h b/src/scalarproduct/scalarproduct.h index bcd2d6821..a59f7641d 100644 --- a/src/scalarproduct/scalarproduct.h +++ b/src/scalarproduct/scalarproduct.h | |||
@@ -119,7 +119,7 @@ struct BobComputationMessage | |||
119 | /** | 119 | /** |
120 | * multipart messages following `struct ComputationMessage` | 120 | * multipart messages following `struct ComputationMessage` |
121 | */ | 121 | */ |
122 | struct ComputationMultipartMessage | 122 | struct ComputationBobCryptodataMultipartMessage |
123 | { | 123 | { |
124 | /** | 124 | /** |
125 | * GNUNET message header | 125 | * GNUNET message header |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index 8a4a0af98..eea17c8f6 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -270,7 +270,7 @@ do_send_message (void *cls, | |||
270 | void *buf) | 270 | void *buf) |
271 | { | 271 | { |
272 | struct GNUNET_SCALARPRODUCT_ComputationHandle *h = cls; | 272 | struct GNUNET_SCALARPRODUCT_ComputationHandle *h = cls; |
273 | struct ComputationMultipartMessage *msg; | 273 | struct ComputationBobCryptodataMultipartMessage *msg; |
274 | size_t ret; | 274 | size_t ret; |
275 | uint32_t nsize; | 275 | uint32_t nsize; |
276 | uint32_t todo; | 276 | uint32_t todo; |
@@ -300,14 +300,14 @@ do_send_message (void *cls, | |||
300 | } | 300 | } |
301 | 301 | ||
302 | todo = h->element_count_total - h->element_count_transfered; | 302 | todo = h->element_count_total - h->element_count_transfered; |
303 | nsize = sizeof (struct ComputationMultipartMessage) | 303 | nsize = sizeof (struct ComputationBobCryptodataMultipartMessage) |
304 | + todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); | 304 | + todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); |
305 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= size) | 305 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= size) |
306 | { | 306 | { |
307 | /* cannot do all of them, limit to what is possible in one message */ | 307 | /* cannot do all of them, limit to what is possible in one message */ |
308 | todo = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ComputationMultipartMessage)) | 308 | todo = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ComputationBobCryptodataMultipartMessage)) |
309 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); | 309 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); |
310 | nsize = sizeof (struct ComputationMultipartMessage) | 310 | nsize = sizeof (struct ComputationBobCryptodataMultipartMessage) |
311 | + todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); | 311 | + todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); |
312 | } | 312 | } |
313 | 313 | ||