- tp.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PONG);
- tp.header.size = htons (sizeof (struct PongMessage));
- tp.iv_seed =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
- derive_pong_iv (&iv, &kx->encrypt_key, tp.iv_seed, t.challenge, &kx->peer);
- do_encrypt (kx, &iv, &tx.challenge, &tp.challenge,
- sizeof (struct PongMessage) - ((void *) &tp.challenge -
- (void *) &tp));
- GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# PONG messages created"),
- 1, GNUNET_NO);
- GSC_NEIGHBOURS_transmit (&kx->peer, &tp.header,
- GNUNET_TIME_UNIT_FOREVER_REL /* FIXME: timeout */ );
-}
-
-
-/**
- * Create a fresh SET KEY message for transmission to the other peer.
- * Also creates a new key.
- *
- * @param kx key exchange context to create SET KEY message for
- */
-static void
-setup_fresh_setkey (struct GSC_KeyExchangeInfo *kx)
-{
- struct SetKeyMessage *skm;
-
- GNUNET_CRYPTO_aes_create_session_key (&kx->encrypt_key);
- kx->encrypt_key_created = GNUNET_TIME_absolute_get ();
- skm = &kx->skm;
- skm->header.size = htons (sizeof (struct SetKeyMessage));
- skm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SET_KEY);
- skm->purpose.size =
- htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
- sizeof (struct GNUNET_TIME_AbsoluteNBO) +
- sizeof (struct GNUNET_CRYPTO_RsaEncryptedData) +
- sizeof (struct GNUNET_PeerIdentity));
- skm->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SET_KEY);
- skm->creation_time = GNUNET_TIME_absolute_hton (kx->encrypt_key_created);
- skm->target = kx->peer;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_encrypt (&kx->encrypt_key,
- sizeof (struct
- GNUNET_CRYPTO_AesSessionKey),
- kx->public_key,
- &skm->encrypted_key));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_sign (my_private_key, &skm->purpose,
- &skm->signature));
-}
-
-
-/**
- * Create a fresh PING message for transmission to the other peer.
- *
- * @param kx key exchange context to create PING for
- */
-static void
-setup_fresh_ping (struct GSC_KeyExchangeInfo *kx)
-{
- struct PingMessage pp;
- struct PingMessage *pm;
- struct GNUNET_CRYPTO_AesInitializationVector iv;
-
- pm = &kx->ping;
- pm->header.size = htons (sizeof (struct PingMessage));
- pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
- pm->iv_seed =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
- derive_iv (&iv, &kx->encrypt_key, pm->iv_seed, &kx->peer);
- pp.challenge = kx->ping_challenge;
- pp.target = kx->peer;
- do_encrypt (kx, &iv, &pp.target, &pm->target,
- sizeof (struct PingMessage) - ((void *) &pm->target -
- (void *) pm));