aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_peer.c
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2020-06-05 16:37:10 +0200
committert3sserakt <t3ss@posteo.de>2020-06-05 16:37:10 +0200
commitd22eacb13eb676b5c096b47c72a3fdbdb332d5a5 (patch)
tree9be948a80a6be2c56080be8826cba747de9dce57 /src/cadet/gnunet-service-cadet_peer.c
parent59f616a3c5d8a6873de0090d0db1413c8b9c411d (diff)
downloadgnunet-d22eacb13eb676b5c096b47c72a3fdbdb332d5a5.tar.gz
gnunet-d22eacb13eb676b5c096b47c72a3fdbdb332d5a5.zip
Fixed bug #5822 by adding a monotonic time to the connection create message of a peer that want to start a KX, and the corresponding test #5823. Credits to dvn, lurchi and xrs for helpful discussions and coding.
Diffstat (limited to 'src/cadet/gnunet-service-cadet_peer.c')
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 8258881d0..0ff4d1fb8 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -31,6 +31,7 @@
31 * to take a break if we have some connections and have searched a lot (?)) 31 * to take a break if we have some connections and have searched a lot (?))
32 */ 32 */
33#include "platform.h" 33#include "platform.h"
34#include "gnunet_time_lib.h"
34#include "gnunet_util_lib.h" 35#include "gnunet_util_lib.h"
35#include "gnunet_hello_lib.h" 36#include "gnunet_hello_lib.h"
36#include "gnunet_signatures.h" 37#include "gnunet_signatures.h"
@@ -38,10 +39,10 @@
38#include "gnunet_ats_service.h" 39#include "gnunet_ats_service.h"
39#include "gnunet_core_service.h" 40#include "gnunet_core_service.h"
40#include "gnunet_statistics_service.h" 41#include "gnunet_statistics_service.h"
41#include "cadet_protocol.h" 42#include "gnunet-service-cadet_peer.h"
43#include "gnunet-service-cadet.h"
42#include "gnunet-service-cadet_connection.h" 44#include "gnunet-service-cadet_connection.h"
43#include "gnunet-service-cadet_dht.h" 45#include "gnunet-service-cadet_dht.h"
44#include "gnunet-service-cadet_peer.h"
45#include "gnunet-service-cadet_paths.h" 46#include "gnunet-service-cadet_paths.h"
46#include "gnunet-service-cadet_tunnels.h" 47#include "gnunet-service-cadet_tunnels.h"
47 48
@@ -66,7 +67,6 @@
66 */ 67 */
67#define MAX_OOO_QUEUE_SIZE 100 68#define MAX_OOO_QUEUE_SIZE 100
68 69
69
70/** 70/**
71 * Data structure used to track whom we have to notify about changes 71 * Data structure used to track whom we have to notify about changes
72 * to our message queue. 72 * to our message queue.
@@ -118,7 +118,7 @@ struct CadetPeer
118 /** 118 /**
119 * Last time we heard from this peer (currently not used!) 119 * Last time we heard from this peer (currently not used!)
120 */ 120 */
121 struct GNUNET_TIME_Absolute last_contactXXX; 121 struct GNUNET_TIME_Absolute last_connection_create;
122 122
123 /** 123 /**
124 * Array of DLLs of paths traversing the peer, organized by the 124 * Array of DLLs of paths traversing the peer, organized by the
@@ -1552,5 +1552,60 @@ GCP_send_ooo (struct CadetPeer *cp,
1552 env); 1552 env);
1553} 1553}
1554 1554
1555/*
1556 * FIXME: comment
1557 */
1558void
1559GCP_update_monotime (struct CadetPeer *peer)
1560{
1561 peer->last_connection_create = GNUNET_TIME_absolute_get_monotonic (cfg);
1562}
1563
1564/*
1565 * FIXME: comment
1566 */
1567int
1568GCP_check_and_update_monotime (struct CadetPeer *peer,
1569 struct GNUNET_TIME_AbsoluteNBO monotime)
1570{
1571
1572 struct GNUNET_TIME_Absolute mt = GNUNET_TIME_absolute_ntoh (monotime);
1573
1574 if (mt.abs_value_us > *(&peer->last_connection_create.abs_value_us))
1575 {
1576 peer->last_connection_create = mt;
1577 return GNUNET_YES;
1578 }
1579 return GNUNET_NO;
1580}
1581
1582/*
1583 * FIXME: documentation here
1584 */
1585int
1586GCP_check_monotime_sig (struct CadetPeer *peer, const struct
1587 GNUNET_CADET_ConnectionCreateMessage *msg)
1588{
1589 // struct CadetPeer *peer;
1590 // const struct GNUNET_CADET_ConnectionCreateMessage *msg;
1591
1592 struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (
1593 GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
1594 .purpose.size = htonl (sizeof(cp)),
1595 .monotonic_time = msg->monotime};
1596
1597 if (GNUNET_OK !=
1598 GNUNET_CRYPTO_eddsa_verify (
1599 GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR,
1600 &cp,
1601 &msg->monotime_sig,
1602 &peer->pid.public_key))
1603 {
1604 GNUNET_break_op (0);
1605 return GNUNET_SYSERR;
1606 }
1607 return GNUNET_OK;
1608}
1609
1555 1610
1556/* end of gnunet-service-cadet-new_peer.c */ 1611/* end of gnunet-service-cadet-new_peer.c */