From: t3sserakt Date: Wed, 22 Jan 2020 17:30:53 +0000 (+0100) Subject: added logic for checking the peer that created a connection with monotonic time X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5bd6288c9418b86501dc9a948b10356dd3064d8f;p=oweals%2Fgnunet.git added logic for checking the peer that created a connection with monotonic time --- diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index 91c716609..67c76755b 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h @@ -85,10 +85,16 @@ struct GNUNET_CADET_ConnectionCreateMessage uint32_t options GNUNET_PACKED; /** - * Infomation of known tunnel state to keep two peers synced. (xrs,t3ss) - * FIXME: find better var name. + * 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) */ - int tunnel_up; + struct GNUNET_TIME_Absolute monotime; + + /** + * We sign the monotime. The receiving peer can check the signature, to verify + * the sending peer. + */ + struct GNUNET_CRYPTO_EddsaSignature monotime_sig; /** * ID of the connection diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index de304aed7..a6c3e51d4 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -622,11 +622,11 @@ send_create (void *cls) // check for tunnel state and define tunnel_up (xrs,t3ss) t = GCP_get_tunnel (cc->destination, GNUNET_YES); - if (NULL != t) + if (NULL != t && (GCT_get_estate(t) == CADET_TUNNEL_KEY_UNINITIALIZED) && + (GCT_alice_or_betty (GCP_get_id(cc->destination)) == GNUNET_NO)) { - create_msg->tunnel_up = (GCT_get_estate(t) == CADET_TUNNEL_KEY_UNINITIALIZED) && - (GCT_alice_or_betty (GCP_get_id(cc->destination)) == GNUNET_NO) - ? GNUNET_NO : GNUNET_YES; + create_msg->monotime = GNUNET_TIME_absolute_get_monotonic(we_need_config_handle_here); + create_msg->monotime_sig = create_monotime_sig(create_msg->monotime); } pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index 595392875..7fc131114 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c @@ -826,7 +826,7 @@ 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 ((GNUNET_NO == msg->tunnel_up) && + if ((NULL != msg->monotime) && check_monotime_sig(msg) (CADET_TUNNEL_KEY_OK == GCT_get_estate(t))) { GCT_change_estate (t, CADET_TUNNEL_KEY_UNINITIALIZED);