* @param iv initialization vector to use
* @param in ciphertext
* @param out plaintext
- * @param size size of in/out
- * @return GNUNET_OK on success
+ * @param size size of @a in / @a out
+ * @return #GNUNET_OK on success
*/
static int
do_decrypt (struct GSC_KeyExchangeInfo *kx,
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# key exchanges initiated"), 1,
GNUNET_NO);
- kx = GNUNET_malloc (sizeof (struct GSC_KeyExchangeInfo));
+ kx = GNUNET_new (struct GSC_KeyExchangeInfo);
kx->peer = *pid;
kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
GNUNET_CONTAINER_DLL_insert (kx_head,
GNUNET_CRYPTO_hash (pid, sizeof (struct GNUNET_PeerIdentity), &h1);
GNUNET_CRYPTO_hash (&GSC_my_identity, sizeof (struct GNUNET_PeerIdentity), &h2);
+ kx->status = KX_STATE_KEY_SENT;
if (0 < GNUNET_CRYPTO_hash_cmp (&h1,
&h2))
{
/* peer with "lower" identity starts KX, otherwise we typically end up
with both peers starting the exchange and transmit the 'set key'
message twice */
- kx->status = KX_STATE_KEY_SENT;
send_key (kx);
}
+ else
+ {
+ /* peer with "higher" identity starts a delayed KX, if the "lower" peer
+ * does not start a KX since he sees no reasons to do so */
+ kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &set_key_retry_task, kx);
+ }
return kx;
}