aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-07 21:53:44 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-07 21:53:44 +0000
commit67eeadf357c24abec2dd790a54be74b7db71560d (patch)
tree01046bd16d390d420597797471adfb614c5073ea
parenta46808363beba27ad2c7e52246ef1ec694f8bf3a (diff)
-sending session ID back over same CADET channel is redundant
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.h14
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c24
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_bob.c17
-rw-r--r--src/scalarproduct/scalarproduct.h2
-rw-r--r--src/scalarproduct/scalarproduct_api.c8
5 files changed, 29 insertions, 36 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.h b/src/scalarproduct/gnunet-service-scalarproduct.h
index 05b2a842c2..82b2d10c5a 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.h
+++ b/src/scalarproduct/gnunet-service-scalarproduct.h
@@ -89,10 +89,10 @@ struct AliceCryptodataMessage
* Message type passed from responding service Bob to responding
* service Alice to complete a request and allow Alice to compute the
* result. If Bob's reply does not fit into this one message, the
- * conversation may be continued with `struct MultipartMessage`
+ * conversation may be continued with `struct BobCryptodataMultipartMessage`
* messages afterwards.
*/
-struct ServiceResponseMessage
+struct BobCryptodataMessage
{
/**
* GNUNET message header with type
@@ -116,12 +116,6 @@ struct ServiceResponseMessage
uint32_t contained_element_count GNUNET_PACKED;
/**
- * The transaction/session key used to identify a session.
- * FIXME: needed? CADET should already identify sessions!
- */
- struct GNUNET_HashCode key;
-
- /**
* followed by s | s' | k[i][perm]
*/
};
@@ -130,11 +124,11 @@ struct ServiceResponseMessage
/**
* Multipart Message type passed between to supply additional elements
* for the peer. Send from Bob to Alice with additional elements
- * of k[i][perm] after his `struct ServiceResponseMessage *`.
+ * of k[i][perm] after his `struct BobCryptodataMessage *`.
* Once all k-values have been transmitted, Bob is finished and
* Alice can transmit the final result to the client.
*/
-struct MultipartMessage
+struct BobCryptodataMultipartMessage
{
/**
* GNUNET message header
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
index 3bfb4ffe02..522af201d1 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,
const struct GNUNET_MessageHeader *message)
{
struct AliceServiceSession *s = *channel_ctx;
- const struct MultipartMessage *msg;
+ const struct BobCryptodataMultipartMessage *msg;
const struct GNUNET_CRYPTO_PaillierCiphertext *payload;
size_t i;
uint32_t contained;
@@ -653,14 +653,14 @@ handle_bobs_cryptodata_multipart (void *cls,
return GNUNET_SYSERR;
}
msg_size = ntohs (message->size);
- if (sizeof (struct MultipartMessage) > msg_size)
+ if (sizeof (struct BobCryptodataMultipartMessage) > msg_size)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- msg = (const struct MultipartMessage *) message;
+ msg = (const struct BobCryptodataMultipartMessage *) message;
contained = ntohl (msg->contained_element_count);
- required_size = sizeof (struct MultipartMessage)
+ required_size = sizeof (struct BobCryptodataMultipartMessage)
+ 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext);
if ( (required_size != msg_size) ||
(s->transferred_element_count + contained > s->used_element_count) )
@@ -712,7 +712,7 @@ handle_bobs_cryptodata_message (void *cls,
const struct GNUNET_MessageHeader *message)
{
struct AliceServiceSession *s = *channel_ctx;
- const struct ServiceResponseMessage *msg;
+ const struct BobCryptodataMessage *msg;
const struct GNUNET_CRYPTO_PaillierCiphertext *payload;
uint32_t i;
uint32_t contained;
@@ -725,12 +725,12 @@ handle_bobs_cryptodata_message (void *cls,
return GNUNET_SYSERR;
}
msg_size = ntohs (message->size);
- if (sizeof (struct ServiceResponseMessage) > msg_size)
+ if (sizeof (struct BobCryptodataMessage) > msg_size)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- msg = (const struct ServiceResponseMessage *) message;
+ msg = (const struct BobCryptodataMessage *) message;
GNUNET_break_op (0 == ntohl (msg->reserved));
if (s->used_element_count != ntohl (msg->intersection_element_count))
{
@@ -739,7 +739,7 @@ handle_bobs_cryptodata_message (void *cls,
return GNUNET_SYSERR;
}
contained = ntohl (msg->contained_element_count);
- required_size = sizeof (struct ServiceResponseMessage)
+ required_size = sizeof (struct BobCryptodataMessage)
+ 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)
+ 2 * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext);
if ( (msg_size != required_size) ||
@@ -1099,7 +1099,7 @@ GSS_handle_alice_client_message_multipart (void *cls,
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- const struct ComputationMultipartMessage * msg;
+ const struct ComputationBobCryptodataMultipartMessage * msg;
struct AliceServiceSession *s;
uint32_t contained_count;
const struct GNUNET_SCALARPRODUCT_Element *elements;
@@ -1119,17 +1119,17 @@ GSS_handle_alice_client_message_multipart (void *cls,
return;
}
msize = ntohs (message->size);
- if (msize < sizeof (struct ComputationMultipartMessage))
+ if (msize < sizeof (struct ComputationBobCryptodataMultipartMessage))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
return;
}
- msg = (const struct ComputationMultipartMessage *) message;
+ msg = (const struct ComputationBobCryptodataMultipartMessage *) message;
contained_count = ntohl (msg->element_count_contained);
- if ( (msize != (sizeof (struct ComputationMultipartMessage) +
+ if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) +
contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) ||
(0 == contained_count) ||
(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 cd2a9ee6ea..2001c39e87 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)
/**
* Maximum count of elements we can put into a multipart message
*/
-#define ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct MultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext))
+#define ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext))
/**
@@ -526,7 +526,7 @@ static void
transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s)
{
struct GNUNET_CRYPTO_PaillierCiphertext *payload;
- struct MultipartMessage *msg;
+ struct BobCryptodataMultipartMessage *msg;
struct GNUNET_MQ_Envelope *e;
unsigned int i;
unsigned int j;
@@ -581,12 +581,12 @@ transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s)
static void
transmit_bobs_cryptodata_message (struct BobServiceSession *s)
{
- struct ServiceResponseMessage *msg;
+ struct BobCryptodataMessage *msg;
struct GNUNET_MQ_Envelope *e;
struct GNUNET_CRYPTO_PaillierCiphertext *payload;
unsigned int i;
- s->cadet_transmitted_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ServiceResponseMessage)) /
+ s->cadet_transmitted_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMessage)) /
(sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * 2) - 2;
if (s->cadet_transmitted_element_count > s->used_element_count)
s->cadet_transmitted_element_count = s->used_element_count;
@@ -598,7 +598,6 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s)
msg->reserved = htonl (0);
msg->intersection_element_count = htonl (s->used_element_count);
msg->contained_element_count = htonl (s->cadet_transmitted_element_count);
- msg->key = s->session_id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending %u/%u crypto values to Alice\n",
@@ -1148,7 +1147,7 @@ GSS_handle_bob_client_message_multipart (void *cls,
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- const struct ComputationMultipartMessage * msg;
+ const struct ComputationBobCryptodataMultipartMessage * msg;
struct BobServiceSession *s;
uint32_t contained_count;
const struct GNUNET_SCALARPRODUCT_Element *elements;
@@ -1168,17 +1167,17 @@ GSS_handle_bob_client_message_multipart (void *cls,
return;
}
msize = ntohs (message->size);
- if (msize < sizeof (struct ComputationMultipartMessage))
+ if (msize < sizeof (struct ComputationBobCryptodataMultipartMessage))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
return;
}
- msg = (const struct ComputationMultipartMessage *) message;
+ msg = (const struct ComputationBobCryptodataMultipartMessage *) message;
contained_count = ntohl (msg->element_count_contained);
- if ( (msize != (sizeof (struct ComputationMultipartMessage) +
+ if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) +
contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) ||
(0 == contained_count) ||
(UINT16_MAX < contained_count) ||
diff --git a/src/scalarproduct/scalarproduct.h b/src/scalarproduct/scalarproduct.h
index bcd2d68212..a59f7641d0 100644
--- a/src/scalarproduct/scalarproduct.h
+++ b/src/scalarproduct/scalarproduct.h
@@ -119,7 +119,7 @@ struct BobComputationMessage
/**
* multipart messages following `struct ComputationMessage`
*/
-struct ComputationMultipartMessage
+struct ComputationBobCryptodataMultipartMessage
{
/**
* GNUNET message header
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c
index 8a4a0af982..eea17c8f6f 100644
--- a/src/scalarproduct/scalarproduct_api.c
+++ b/src/scalarproduct/scalarproduct_api.c
@@ -270,7 +270,7 @@ do_send_message (void *cls,
void *buf)
{
struct GNUNET_SCALARPRODUCT_ComputationHandle *h = cls;
- struct ComputationMultipartMessage *msg;
+ struct ComputationBobCryptodataMultipartMessage *msg;
size_t ret;
uint32_t nsize;
uint32_t todo;
@@ -300,14 +300,14 @@ do_send_message (void *cls,
}
todo = h->element_count_total - h->element_count_transfered;
- nsize = sizeof (struct ComputationMultipartMessage)
+ nsize = sizeof (struct ComputationBobCryptodataMultipartMessage)
+ todo * sizeof (struct GNUNET_SCALARPRODUCT_Element);
if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= size)
{
/* cannot do all of them, limit to what is possible in one message */
- todo = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ComputationMultipartMessage))
+ todo = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct ComputationBobCryptodataMultipartMessage))
/ sizeof (struct GNUNET_SCALARPRODUCT_Element);
- nsize = sizeof (struct ComputationMultipartMessage)
+ nsize = sizeof (struct ComputationBobCryptodataMultipartMessage)
+ todo * sizeof (struct GNUNET_SCALARPRODUCT_Element);
}