aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_tunnel.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-11 14:07:47 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-11 14:07:47 +0000
commit4248b31f8dd35814514b279701c2483d05c132b8 (patch)
tree65e68211ed9ad01caafd63b33d3fc1541f95640c /src/mesh/gnunet-service-mesh_tunnel.c
parentfd6abc8eccbbf839d877062ff63cab510f3ae707 (diff)
downloadgnunet-4248b31f8dd35814514b279701c2483d05c132b8.tar.gz
gnunet-4248b31f8dd35814514b279701c2483d05c132b8.zip
- fix encryption/decryption visisbility
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c131
1 files changed, 81 insertions, 50 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 634a4d7f1..51baebf9b 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -257,6 +257,48 @@ tunnel_get_connection (struct MeshTunnel3 *t, int fwd)
257} 257}
258 258
259 259
260/**
261 * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
262 * Encrypt data with the tunnel key.
263 * Make static?
264 *
265 * @param t Tunnel whose key to use.
266 * @param dst Destination for the GMT_encrypted data.
267 * @param src Source of the plaintext.
268 * @param size Size of the plaintext.
269 * @param iv Initialization Vector to use.
270 * @param fwd Is this a fwd message?
271 */
272static void
273GMT_encrypt (struct MeshTunnel3 *t,
274 void *dst, const void *src,
275 size_t size, uint64_t iv, int fwd)
276{
277 memcpy (dst, src, size);
278}
279
280
281/**
282 * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
283 * Decrypt data with the tunnel key.
284 * Make static?
285 *
286 * @param t Tunnel whose key to use.
287 * @param dst Destination for the plaintext.
288 * @param src Source of the GMT_encrypted data.
289 * @param size Size of the GMT_encrypted data.
290 * @param iv Initialization Vector to use.
291 * @param fwd Is this a fwd message?
292 */
293static void
294GMT_decrypt (struct MeshTunnel3 *t,
295 void *dst, const void *src,
296 size_t size, uint64_t iv, int fwd)
297{
298 memcpy (dst, src, size);
299}
300
301
260void 302void
261handle_data (struct MeshTunnel3 *t, 303handle_data (struct MeshTunnel3 *t,
262 const struct GNUNET_MESH_Data *msg, 304 const struct GNUNET_MESH_Data *msg,
@@ -417,9 +459,6 @@ handle_ch_destroy (struct MeshTunnel3 *t,
417 GMCH_handle_destroy (ch, msg, fwd); 459 GMCH_handle_destroy (ch, msg, fwd);
418} 460}
419 461
420/******************************************************************************/
421/******************************** API ***********************************/
422/******************************************************************************/
423 462
424/** 463/**
425 * Demultiplex by message type and call appropriate handler for a message 464 * Demultiplex by message type and call appropriate handler for a message
@@ -429,10 +468,10 @@ handle_ch_destroy (struct MeshTunnel3 *t,
429 * @param msgh Message header. 468 * @param msgh Message header.
430 * @param fwd Is this message fwd? 469 * @param fwd Is this message fwd?
431 */ 470 */
432void 471static void
433GMT_handle_decrypted (struct MeshTunnel3 *t, 472handle_GMT_decrypted (struct MeshTunnel3 *t,
434 const struct GNUNET_MessageHeader *msgh, 473 const struct GNUNET_MessageHeader *msgh,
435 int fwd) 474 int fwd)
436{ 475{
437 uint16_t type; 476 uint16_t type;
438 477
@@ -478,6 +517,40 @@ GMT_handle_decrypted (struct MeshTunnel3 *t,
478 } 517 }
479} 518}
480 519
520/******************************************************************************/
521/******************************** API ***********************************/
522/******************************************************************************/
523
524
525/**
526 * Decrypt and demultiplex by message type. Call appropriate handler
527 * for every message.
528 *
529 * @param t Tunnel this message came on.
530 * @param msgh Encrypted message.
531 * @param fwd Is this message fwd?
532 */
533void
534GMT_handle_GMT_encrypted (struct MeshTunnel3 *t,
535 const struct GNUNET_MESH_Encrypted *msg,
536 int fwd)
537{
538 size_t size = ntohs (msg->header.size);
539 size_t payload_size = size - sizeof (struct GNUNET_MESH_Encrypted);
540 char cbuf[payload_size];
541 struct GNUNET_MessageHeader *msgh;
542 unsigned int off;
543
544 GMT_decrypt (t, cbuf, &msg[1], payload_size, msg->iv, fwd);
545 off = 0;
546 while (off < payload_size)
547 {
548 msgh = (struct GNUNET_MessageHeader *) &cbuf[off];
549 handle_GMT_decrypted (t, msgh, fwd);
550 off += ntohs (msgh->size);
551 }
552}
553
481 554
482/** 555/**
483 * Cache a message to be sent once tunnel is online. 556 * Cache a message to be sent once tunnel is online.
@@ -868,48 +941,6 @@ GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p)
868 941
869 942
870/** 943/**
871 * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
872 * Encrypt data with the tunnel key.
873 * Make static?
874 *
875 * @param t Tunnel whose key to use.
876 * @param dst Destination for the encrypted data.
877 * @param src Source of the plaintext.
878 * @param size Size of the plaintext.
879 * @param iv Initialization Vector to use.
880 * @param fwd Is this a fwd message?
881 */
882void
883GMT_encrypt (struct MeshTunnel3 *t,
884 void *dst, const void *src,
885 size_t size, uint64_t iv, int fwd)
886{
887 memcpy (dst, src, size);
888}
889
890
891/**
892 * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
893 * Decrypt data with the tunnel key.
894 * Make static?
895 *
896 * @param t Tunnel whose key to use.
897 * @param dst Destination for the plaintext.
898 * @param src Source of the encrypted data.
899 * @param size Size of the encrypted data.
900 * @param iv Initialization Vector to use.
901 * @param fwd Is this a fwd message?
902 */
903void
904GMT_decrypt (struct MeshTunnel3 *t,
905 void *dst, const void *src,
906 size_t size, uint64_t iv, int fwd)
907{
908 memcpy (dst, src, size);
909}
910
911
912/**
913 * Count established (ready) connections of a tunnel. 944 * Count established (ready) connections of a tunnel.
914 * 945 *
915 * @param t Tunnel on which to count. 946 * @param t Tunnel on which to count.
@@ -1056,7 +1087,7 @@ GMT_get_next_chid (struct MeshTunnel3 *t)
1056 1087
1057 1088
1058/** 1089/**
1059 * Sends an already built message on a tunnel, encrypting it and 1090 * Sends an already built message on a tunnel, GMT_encrypting it and
1060 * choosing the best connection. 1091 * choosing the best connection.
1061 * 1092 *
1062 * @param message Message to send. Function modifies it. 1093 * @param message Message to send. Function modifies it.