#include "gnunet_protocols.h"
#include "core.h"
+/**
+ * Enable expensive (and possibly problematic for privacy!) logging of KX.
+ */
+#define DEBUG_KX 0
/**
* How long do we wait for SET_KEY confirmation initially?
uint32_t seed)
{
static const char ctx[] = "authentication key";
-
+#if DEBUG_KX
struct GNUNET_HashCode sh;
- GNUNET_CRYPTO_hash (skey, sizeof (*skey), &sh);
+
+ GNUNET_CRYPTO_hash (skey,
+ sizeof (*skey),
+ &sh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deriving Auth key from SKEY %s and seed %u\n",
GNUNET_h2s (&sh),
(unsigned int) seed);
+#endif
GNUNET_CRYPTO_hmac_derive_key (akey,
skey,
&seed, sizeof (seed),
const struct GNUNET_PeerIdentity *identity)
{
static const char ctx[] = "initialization vector";
-
+#if DEBUG_KX
struct GNUNET_HashCode sh;
- GNUNET_CRYPTO_hash (skey, sizeof (*skey), &sh);
+
+ GNUNET_CRYPTO_hash (skey,
+ sizeof (*skey),
+ &sh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deriving IV from SKEY %s and seed %u for peer %s\n",
GNUNET_h2s (&sh),
(unsigned int) seed,
GNUNET_i2s (identity));
+#endif
GNUNET_CRYPTO_symmetric_derive_iv (iv,
skey,
&seed, sizeof (seed),
const struct GNUNET_PeerIdentity *identity)
{
static const char ctx[] = "pong initialization vector";
-
+#if DEBUG_KX
struct GNUNET_HashCode sh;
- GNUNET_CRYPTO_hash (skey, sizeof (*skey), &sh);
+
+ GNUNET_CRYPTO_hash (skey,
+ sizeof (*skey),
+ &sh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deriving PONG IV from SKEY %s and seed %u/%u for %s\n",
GNUNET_h2s (&sh),
(unsigned int) seed,
(unsigned int) challenge,
GNUNET_i2s (identity));
+#endif
GNUNET_CRYPTO_symmetric_derive_iv (iv,
skey,
&seed, sizeof (seed),
struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
{
static const char ctx[] = "aes key generation vector";
-
+#if DEBUG_KX
struct GNUNET_HashCode sh;
- GNUNET_CRYPTO_hash (skey, sizeof (*skey), &sh);
+
+ GNUNET_CRYPTO_hash (skey,
+ sizeof (*skey),
+ &sh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deriving AES Keys for %s to %s from %s\n",
GNUNET_i2s (sender),
GNUNET_i2s2 (receiver),
GNUNET_h2s (key_material));
+#endif
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
ctx, sizeof (ctx),
key_material, sizeof (struct GNUNET_HashCode),
GNUNET_NO);
/* the following is too sensitive to write to log files by accident,
so we require manual intervention to get this one... */
-#if 0
+#if DEBUG_KX
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypted %u bytes for `%s' using key %u, IV %u\n",
(unsigned int) size,
GNUNET_NO);
/* the following is too sensitive to write to log files by accident,
so we require manual intervention to get this one... */
-#if 0
+#if DEBUG_KX
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted %u bytes from `%s' using key %u, IV %u\n",
(unsigned int) size,
GNUNET_NO);
return;
}
+#if DEBUG_KX
{
struct GNUNET_HashCode eh;
GNUNET_i2s (kx->peer),
kx->status);
}
+#endif
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# valid ephemeral keys received"),
1,
kx->retry_set_key_task = NULL;
}
/* always update sender status in SET KEY message */
+#if DEBUG_KX
{
struct GNUNET_HashCode hc;
GNUNET_i2s (kx->peer),
kx->status);
}
+#endif
current_ekm.sender_status = htonl ((int32_t) (kx->status));
env = GNUNET_MQ_msg_copy (¤t_ekm.header);
GNUNET_MQ_send (kx->mq,
&ph->sequence_number,
&em->sequence_number,
used - ENCRYPTED_HEADER_SIZE));
+#if DEBUG_KX
{
struct GNUNET_HashCode hc;
(unsigned int) (used - ENCRYPTED_HEADER_SIZE),
GNUNET_i2s (kx->peer));
}
+#endif
derive_auth_key (&auth_key,
&kx->encrypt_key,
ph->iv_seed);
&em->sequence_number,
used - ENCRYPTED_HEADER_SIZE,
&em->hmac);
+#if DEBUG_KX
{
struct GNUNET_HashCode hc;
GNUNET_h2s (&hc),
GNUNET_h2s2 (&em->hmac));
}
+#endif
kx->has_excess_bandwidth = GNUNET_NO;
GNUNET_MQ_send (kx->mq,
env);
}
/* validate hash */
+#if DEBUG_KX
{
struct GNUNET_HashCode hc;
(unsigned int) (size - ENCRYPTED_HEADER_SIZE),
GNUNET_i2s (kx->peer));
}
-
+#endif
derive_auth_key (&auth_key,
&kx->decrypt_key,
m->iv_seed);
&m->sequence_number,
size - ENCRYPTED_HEADER_SIZE,
&ph);
+#if DEBUG_KX
{
struct GNUNET_HashCode hc;
GNUNET_h2s (&hc),
GNUNET_h2s2 (&m->hmac));
}
+#endif
if (0 != memcmp (&ph,
&m->hmac,
sizeof (struct GNUNET_HashCode)))