From: t3sserakt Date: Wed, 29 Jan 2020 16:08:26 +0000 (+0100) Subject: make it compile X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9662b744478e333dc4d105ca15c3c2fc94bc79e1;p=oweals%2Fgnunet.git make it compile --- diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index 67c76755b..b3d5ecab9 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h @@ -39,6 +39,7 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "cadet.h" +#include "gnunet-service-cadet_peer.h" #ifdef __cplusplus @@ -84,6 +85,12 @@ struct GNUNET_CADET_ConnectionCreateMessage */ 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) diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 540c430b7..40966f553 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -26,6 +26,7 @@ * @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" @@ -78,30 +79,6 @@ enum CadetConnectionState 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. */ @@ -619,11 +596,11 @@ GCC_handle_encrypted (struct CadetConnection *cc, 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)}; @@ -665,8 +642,9 @@ send_create (void *cls) 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]; diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index b05c3b72c..a9ebef567 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h @@ -182,7 +182,29 @@ void 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. diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index 11f78cba6..6c97986e7 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c @@ -825,8 +825,10 @@ handle_connection_create ( 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); } diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 55654e98a..20d2e83c1 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c @@ -31,6 +31,7 @@ * 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" @@ -42,7 +43,6 @@ #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" @@ -67,7 +67,6 @@ */ #define MAX_OOO_QUEUE_SIZE 100 - /** * Data structure used to track whom we have to notify about changes * to our message queue. @@ -1553,30 +1552,6 @@ GCP_send_ooo (struct CadetPeer *cp, 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 */ @@ -1590,11 +1565,38 @@ GCP_update_monotime (struct CadetPeer *peer) * 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 */ diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index f7e3fba2b..389914915 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h @@ -402,14 +402,14 @@ void 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