diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-06 13:12:58 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-06 13:12:58 +0000 |
commit | 478edf9bbe5c1a82a410ff8302c892d6d585d2e6 (patch) | |
tree | 8ea11abf818d9b0ec2da9f74017e0f969b425135 /src/mesh/gnunet-service-mesh_tunnel.c | |
parent | 31257dd5764706625ca42df8e536e8c7bb755b1a (diff) | |
download | gnunet-478edf9bbe5c1a82a410ff8302c892d6d585d2e6.tar.gz gnunet-478edf9bbe5c1a82a410ff8302c892d6d585d2e6.zip |
- encrypt-then-MAC
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index bce2812e5..be44e495b 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -802,7 +802,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
802 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED); | 802 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED); |
803 | msg->iv = iv; | 803 | msg->iv = iv; |
804 | GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size); | 804 | GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size); |
805 | t_hmac (t, message, size, iv, GNUNET_YES, &msg->hmac); | 805 | t_hmac (t, &msg[1], size, iv, GNUNET_YES, &msg->hmac); |
806 | msg->header.size = htons (sizeof (struct GNUNET_MESH_Encrypted) + size); | 806 | msg->header.size = htons (sizeof (struct GNUNET_MESH_Encrypted) + size); |
807 | 807 | ||
808 | if (NULL == c) | 808 | if (NULL == c) |
@@ -1652,11 +1652,11 @@ GMT_handle_encrypted (struct MeshTunnel3 *t, | |||
1652 | struct GNUNET_HashCode hmac; | 1652 | struct GNUNET_HashCode hmac; |
1653 | 1653 | ||
1654 | decrypted_size = t_decrypt (t, cbuf, &msg[1], payload_size, msg->iv); | 1654 | decrypted_size = t_decrypt (t, cbuf, &msg[1], payload_size, msg->iv); |
1655 | t_hmac (t, cbuf, payload_size, msg->iv, GNUNET_NO, &hmac); | 1655 | t_hmac (t, &msg[1], payload_size, msg->iv, GNUNET_NO, &hmac); |
1656 | if (0 != memcmp (&hmac, &msg->hmac, sizeof (struct GNUNET_HashCode))) | 1656 | if (0 != memcmp (&hmac, &msg->hmac, sizeof (struct GNUNET_HashCode))) |
1657 | { | 1657 | { |
1658 | /* checksum failed */ | 1658 | /* checksum failed */ |
1659 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1659 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1660 | "Failed checksum validation for a message on tunnel `%s'\n", | 1660 | "Failed checksum validation for a message on tunnel `%s'\n", |
1661 | GMT_2s (t)); | 1661 | GMT_2s (t)); |
1662 | GNUNET_STATISTICS_update (stats, "# wrong HMAC", 1, GNUNET_NO); | 1662 | GNUNET_STATISTICS_update (stats, "# wrong HMAC", 1, GNUNET_NO); |