uint32_t cadet_transmitted_element_count;
/**
- * Is this session active (#GNUNET_YES), Concluded (#GNUNET_NO), or had an error (#GNUNET_SYSERR)
+ * State of this session. In
+ * #GNUNET_SCALARPRODUCT_STATUS_ACTIVE while operation is
+ * ongoing, afterwards in #GNUNET_SCALARPRODUCT_STATUS_SUCCESS or
+ * #GNUNET_SCALARPRODUCT_STATUS_FAILURE.
*/
- int32_t active;
+ enum GNUNET_SCALARPRODUCT_ResponseStatus status;
/**
* Are we already in #destroy_service_session()?
}
+/**
+ * Callback used to free the elements in the map.
+ *
+ * @param cls NULL
+ * @param key key of the element
+ * @param value the value to free
+ */
+static int
+free_element_cb (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct GNUNET_SCALARPRODUCT_Element *element = value;
+
+ GNUNET_free (element);
+ return GNUNET_OK;
+}
+
+
/**
* Destroy session state, we are done with it.
*
s));
if (NULL != s->intersected_elements)
{
- /* FIXME: free elements */
+ GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
+ &free_element_cb,
+ NULL);
GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements);
s->intersected_elements = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending session-end notification with status %d to client for session %s\n",
- session->active,
+ session->status,
GNUNET_h2s (&session->session_id));
e = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
msg->range = 0;
msg->product_length = htonl (0);
- msg->status = htonl (session->active);
+ msg->status = htonl (session->status);
GNUNET_MQ_send (session->client_mq,
e);
}
"Peer disconnected, terminating session %s with peer %s\n",
GNUNET_h2s (&in->session_id),
GNUNET_i2s (&in->peer));
+ if (NULL != in->cadet_mq)
+ {
+ GNUNET_MQ_destroy (in->cadet_mq);
+ in->cadet_mq = NULL;
+ }
in->channel = NULL;
if (NULL != (s = in->s))
{
- if (GNUNET_YES == s->active)
+ if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
{
- s->active = GNUNET_SYSERR;
+ s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
prepare_client_end_notification (s);
}
}
{
struct BobServiceSession *session = cls;
- session->active = GNUNET_NO; /* that means, done */
+ session->status = GNUNET_SCALARPRODUCT_STATUS_SUCCESS;
prepare_client_end_notification (session);
}
/**
* 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_CONSTANTS_MAX_CADET_MESSAGE_SIZE - sizeof (struct BobCryptodataMultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext))
/**
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;
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;
(2 + s->cadet_transmitted_element_count * 2)
* sizeof (struct GNUNET_CRYPTO_PaillierCiphertext),
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA);
- 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",
&a[q[i]],
&r_prime[i]));
}
+ gcry_mpi_release (tmp);
// Calculate S' = E(SUM( r_i^2 ))
tmp = compute_square_sum (rand, count);
tmp,
1,
&session->s_prime);
+ gcry_mpi_release (tmp);
// Calculate S = E(SUM( (r_i + b_i)^2 ))
for (i = 0; i < count; i++)
tmp,
1,
&session->s);
+ gcry_mpi_release (tmp);
session->r = r;
session->r_prime = r_prime;
// release rand, b and a
for (i = 0; i < count; i++)
gcry_mpi_release (rand[i]);
- gcry_mpi_release (tmp);
GNUNET_free (session->e_a);
session->e_a = NULL;
GNUNET_free (p);
CADET response(s) */
transmit_cryptographic_reply (s);
}
+ GNUNET_CADET_receive_done (s->cadet->channel);
return GNUNET_OK;
}
return;
case GNUNET_SET_STATUS_DONE:
s->intersection_op = NULL;
- s->intersection_set = NULL;
+ GNUNET_break (NULL == s->intersection_set);
+ GNUNET_CADET_receive_done (s->cadet->channel);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Finished intersection, %d items remain\n",
GNUNET_CONTAINER_multihashmap_size (s->intersected_elements));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Set intersection failed!\n");
s->intersection_op = NULL;
- s->intersection_set = NULL;
- s->active = GNUNET_SYSERR;
+ if (NULL != s->intersection_set)
+ {
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
+ }
+ s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
prepare_client_end_notification (s);
return;
default:
GNUNET_SET_RESULT_REMOVED,
&cb_intersection_element_removed,
s);
- GNUNET_SET_commit (s->intersection_op,
- s->intersection_set);
+ if (GNUNET_OK !=
+ GNUNET_SET_commit (s->intersection_op,
+ s->intersection_set))
+ {
+ GNUNET_break (0);
+ s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
+ prepare_client_end_notification (s);
+ return;
+ }
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
}
in = GNUNET_new (struct CadetIncomingSession);
in->peer = *initiator;
in->channel = channel;
+ in->cadet_mq = GNUNET_CADET_mq_create (in->channel);
return in;
}
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;
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) ||
}
s = GNUNET_new (struct BobServiceSession);
- s->active = GNUNET_YES;
+ s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE;
s->client = client;
s->client_mq = GNUNET_MQ_queue_for_server_client (client);
s->total = total_count;