#include "platform.h"
#include "gnunet_util_lib.h"
#include "cadet.h"
+#include "gnunet-service-cadet_peer.h"
#ifdef __cplusplus
*/
uint32_t options GNUNET_PACKED;
+ /**
+ * This flag indicates the peer sending the connection create
+ * meassage likes to trigger a KX handshake.
+ */
+ int has_monotime;
+
/**
* This monotonic time is set, if a peer likes to trigger a KX, but is not
* the peer that should start the KX. (xrs,t3ss)
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_signatures.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_channel.h"
#include "gnunet-service-cadet_paths.h"
CADET_CONNECTION_READY
};
-struct CadetConnectionCreatePS
-{
-
- /**
- * Purpose is #GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR
- */
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
- /**
- * Time at the initiator when generating the signature.
- *
- * Note that the receiver MUST IGNORE the absolute time, and only interpret
- * the value as a mononic time and reject "older" values than the last one
- * observed. This is necessary as we do not want to require synchronized
- * clocks and may not have a bidirectional communication channel.
- *
- * Even with this, there is no real guarantee against replay achieved here,
- * unless the latest timestamp is persisted. Persistence should be
- * provided via PEERSTORE if possible.
- */
- struct GNUNET_TIME_AbsoluteNBO monotonic_time;
-
-}
-
/**
* Low-level connection to a destination.
*/
int
-set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage * msg,
- struct GNUNET_TIME_Absolute monotime)
+set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage * msg)
{
- struct GNUNET_CRYPTO_EddsaPrivateKey *key;
- struct CCCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
+ struct GNUNET_CRYPTO_EddsaPrivateKey *key;
+ struct GNUNET_TIME_Absolute monotime;
+ struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
.purpose.size = htonl (sizeof(cp)),
.monotonic_time = GNUNET_TIME_absolute_hton (monotime)};
if (NULL != t && (GCT_get_estate(t) == CADET_TUNNEL_KEY_UNINITIALIZED) &&
(GCT_alice_or_betty (GCP_get_id(cc->destination)) == GNUNET_NO))
{
+ create_msg->has_monotime = GNUNET_YES;
create_msg->monotime = GNUNET_TIME_absolute_get_monotonic(cfg);
- create_msg->monotime_sig = create_monotime_sig(create_msg->monotime);
+ GNUNET_assert (GNUNET_OK == set_monotime_sig(create_msg));
}
pids = (struct GNUNET_PeerIdentity *) &create_msg[1];
GCC_handle_kx_auth (struct CadetConnection *cc,
const struct
GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg);
+struct CadetConnectionCreatePS
+{
+
+ /**
+ * Purpose is #GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+ /**
+ * Time at the initiator when generating the signature.
+ *
+ * Note that the receiver MUST IGNORE the absolute time, and only interpret
+ * the value as a mononic time and reject "older" values than the last one
+ * observed. This is necessary as we do not want to require synchronized
+ * clocks and may not have a bidirectional communication channel.
+ *
+ * Even with this, there is no real guarantee against replay achieved here,
+ * unless the latest timestamp is persisted. Persistence should be
+ * provided via PEERSTORE if possible.
+ */
+ struct GNUNET_TIME_AbsoluteNBO monotonic_time;
+
+};
/**
* Performance metrics for a connection.
t = GCP_get_tunnel (sender, GNUNET_YES);
// Check for CADET state in case the other side has lost the tunnel (xrs,t3ss)
- if ((NULL != msg->monotime) && GNUNET_YES == GCP_check_monotime(origin, msg->monotime) && GNUNET_OK == check_monotime_sig(origin, &msg)
- (CADET_TUNNEL_KEY_OK == GCT_get_estate(t)))
+ if ((GNUNET_YES == msg->has_monotime) &&
+ (GNUNET_YES == GCP_check_monotime(origin, msg->monotime)) &&
+ ( GNUNET_OK == GCP_check_monotime_sig(&origin, &msg)) &&
+ (CADET_TUNNEL_KEY_OK == GCT_get_estate(t)))
{
GCT_change_estate (t, CADET_TUNNEL_KEY_UNINITIALIZED);
}
* to take a break if we have some connections and have searched a lot (?))
*/
#include "platform.h"
+#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_signatures.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_dht.h"
-#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet_paths.h"
#include "gnunet-service-cadet_tunnels.h"
*/
#define MAX_OOO_QUEUE_SIZE 100
-
/**
* Data structure used to track whom we have to notify about changes
* to our message queue.
env);
}
-/*
- * FIXME: documentation here
- */
-static int
-check_monotime_sig (struct CadetPeer peer,
- const struct GNUNET_CADET_ConnectionCreateMessage *msg)
-{
-
- struct CCCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
- .purpose.size = htonl (sizeof(cp)),
- .monotonic_time = sender_monotonic_time};
-
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR,
- &cp.purpose,
- msg->monotime_sig,
- &peer->pid->public_key))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
/*
* FIXME: comment
*/
* FIXME: comment
*/
int
-GCP_check_monotime (struct CadetPeer *peer, GNUNET_TIME_Absolute monotime)
+GCP_check_monotime (struct CadetPeer *peer, struct GNUNET_TIME_Absolute monotime)
{
- if (monotime.abs_value_us > peer.last_connection_create.abs_value_us)
+
+ if (monotime.abs_value_us > *(&peer->last_connection_create.abs_value_us))
return GNUNET_YES;
return GNUNET_NO;
}
+/*
+ * FIXME: documentation here
+ */
+int
+GCP_check_monotime_sig (struct CadetPeer *peer, struct GNUNET_CADET_ConnectionCreateMessage *msg)
+{
+ //struct CadetPeer *peer;
+ //const struct GNUNET_CADET_ConnectionCreateMessage *msg;
+
+ struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
+ .purpose.size = htonl (sizeof(cp)),
+ .monotonic_time = &msg->monotime};
+
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR,
+ &cp.purpose,
+ &msg->monotime_sig,
+ &peer->pid.public_key))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
/* end of gnunet-service-cadet-new_peer.c */
GCP_set_mq (struct CadetPeer *cp,
struct GNUNET_MQ_Handle *mq);
-static int
-check_monotime_sig (struct CadetPeer peer,
- const struct GNUNET_CADET_ConnectionCreateMessage *msg);
+int
+GCP_check_monotime_sig (struct CadetPeer *peer, struct GNUNET_CADET_ConnectionCreateMessage *msg);
void
GCP_update_monotime (struct CadetPeer *cp);
-struct GNUNET_TIME_Absolute
-GCP_get_monotime (struct CadetPeer *cp);
+int
+GCP_check_monotime (struct CadetPeer *peer,
+ struct GNUNET_TIME_Absolute monotime);
#endif