Information we track per tunnel. More...
#include "gnunet_common.h"#include "gnunet_pils_service.h"#include "gnunet_scheduler_lib.h"#include "platform.h"#include "gnunet_util_lib.h"#include "gnunet_statistics_service.h"#include "cadet_protocol.h"#include "gnunet-service-cadet_channel.h"#include "gnunet-service-cadet_connection.h"#include "gnunet-service-cadet_tunnels.h"#include "gnunet-service-cadet_peer.h"#include "gnunet-service-cadet_paths.h"Go to the source code of this file.
Data Structures | |
| struct | CadetTunnelSkippedKey |
| Struct to old keys for skipped messages while advancing the Axolotl ratchet. More... | |
| struct | CadetTunnelAxolotl |
| Axolotl data, according to https://github.com/trevp/axolotl/wiki . More... | |
| struct | CadetTunnelAsync |
| Struct used to store data required for an async update AX by KX process. More... | |
| struct | CadetTunnelQueueEntry |
| Struct used to save messages in a non-ready tunnel to send once connected. More... | |
| struct | CadetTunnel |
| Struct containing all information regarding a tunnel to a peer. More... | |
| struct | EvaluationSummary |
| Closure for evaluate_connection. More... | |
| struct | ChanIterCls |
| Closure for iterate_channels_cb. More... | |
Macros | |
| #define | LOG(level, ...) GNUNET_log_from (level, "cadet-tun", __VA_ARGS__) |
| #define | MAX_UNVERIFIED_ATTEMPTS 16 |
| How often do we try to decrypt payload with unverified key material? Used to limit CPU increase upon receiving bogus KX. | |
| #define | IDLE_DESTROY_DELAY |
| How long do we wait until tearing down an idle tunnel? | |
| #define | INITIAL_KX_RETRY_DELAY |
| How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have connection-level RTT data! | |
| #define | MAX_SKIPPED_KEYS 64 |
| Maximum number of skipped keys we keep in memory per tunnel. | |
| #define | MAX_KEY_GAP 256 |
| Maximum number of keys (and thus ratchet steps) we are willing to skip before we decide this is either a bogus packet or a DoS-attempt. | |
| #define | HIGH_BIT 0x8000000 |
| #define | LOG2(level, ...) |
Typedefs | |
| typedef void(* | CadetTunnelAxolotlCallback) (void *cls, enum GNUNET_GenericReturnValue res) |
| Signature of the follow up function from an udate AX by KX. | |
Functions | |
| int | GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other) |
| Am I Alice or Betty (some call her Bob), or talking to myself? | |
| static void | mark_connection_unready (struct CadetTConnection *ct) |
| Connection ct is now unready, clear it's ready flag and move it from the ready DLL to the busy DLL. | |
| const char * | GCT_2s (const struct CadetTunnel *t) |
| Get the static string for the peer this tunnel is directed. | |
| static const char * | estate2s (enum CadetTunnelEState es) |
| Get string description for tunnel encryption state. | |
| struct CadetPeer * | GCT_get_destination (struct CadetTunnel *t) |
| Return the peer to which this tunnel goes. | |
| unsigned int | GCT_count_channels (struct CadetTunnel *t) |
| Returns the number of channels using a tunnel. | |
| static struct CadetChannel * | lookup_channel (struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn) |
| Lookup a channel by its ctn. | |
| unsigned int | GCT_count_any_connections (const struct CadetTunnel *t) |
| Counts the number of connections created for a tunnel, including busy connections. | |
| static struct CadetTConnection * | get_ready_connection (struct CadetTunnel *t) |
| Find first connection that is ready in the list of our connections. | |
| enum CadetTunnelEState | GCT_get_estate (struct CadetTunnel *t) |
| Get the encryption state of a tunnel. | |
| static void | trigger_transmissions (void *cls) |
| Called when either we have a new connection, or a new message in the queue, or some existing connection has transmission capacity. | |
| static void | new_ephemeral (struct CadetTunnelAxolotl *ax) |
| Create a new Axolotl ephemeral (ratchet) key. | |
| static void | t_hmac (const void *plaintext, size_t size, uint32_t iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *key, struct GNUNET_ShortHashCode *hmac) |
| Calculate HMAC. | |
| static void | t_ax_hmac_hash (const struct GNUNET_CRYPTO_SymmetricSessionKey *key, struct GNUNET_HashCode *hash, const void *source, unsigned int len) |
| Perform a HMAC. | |
| static void | t_hmac_derive_key (const struct GNUNET_CRYPTO_SymmetricSessionKey *key, struct GNUNET_CRYPTO_SymmetricSessionKey *out, const void *source, unsigned int len) |
| Derive a symmetric encryption key from an HMAC-HASH. | |
| static void | t_ax_encrypt (struct CadetTunnelAxolotl *ax, void *dst, const void *src, size_t size) |
| Encrypt data with the axolotl tunnel key. | |
| static void | t_ax_decrypt (struct CadetTunnelAxolotl *ax, void *dst, const void *src, size_t size) |
| Decrypt data with the axolotl tunnel key. | |
| static void | t_h_encrypt (struct CadetTunnelAxolotl *ax, struct GNUNET_CADET_TunnelEncryptedMessage *msg) |
| Encrypt header with the axolotl header key. | |
| static void | t_h_decrypt (struct CadetTunnelAxolotl *ax, const struct GNUNET_CADET_TunnelEncryptedMessage *src, struct GNUNET_CADET_TunnelEncryptedMessage *dst) |
| Decrypt header with the current axolotl header key. | |
| static void | delete_skipped_key (struct CadetTunnelAxolotl *ax, struct CadetTunnelSkippedKey *key) |
| Delete a key from the list of skipped keys. | |
| static ssize_t | try_old_ax_keys (struct CadetTunnelAxolotl *ax, void *dst, const struct GNUNET_CADET_TunnelEncryptedMessage *src, size_t size) |
| Decrypt and verify data with the appropriate tunnel key and verify that the data has not been altered since it was sent by the remote peer. | |
| static void | store_skipped_key (struct CadetTunnelAxolotl *ax, const struct GNUNET_CRYPTO_SymmetricSessionKey *HKr) |
| Delete a key from the list of skipped keys. | |
| static int | store_ax_keys (struct CadetTunnelAxolotl *ax, const struct GNUNET_CRYPTO_SymmetricSessionKey *HKr, uint32_t Np) |
| Stage skipped AX keys and calculate the message key. | |
| static ssize_t | t_ax_decrypt_and_validate (struct CadetTunnelAxolotl *ax, void *dst, const struct GNUNET_CADET_TunnelEncryptedMessage *src, size_t size) |
| Decrypt and verify data with the appropriate tunnel key and verify that the data has not been altered since it was sent by the remote peer. | |
| static int | notify_tunnel_up_cb (void *cls, uint32_t key, void *value) |
| Our tunnel became ready for the first time, notify channels that have been waiting. | |
| void | GCT_change_estate (struct CadetTunnel *t, enum CadetTunnelEState state) |
| Change the tunnel encryption state. | |
| static void | send_kx (struct CadetTunnel *t, struct CadetTConnection *ct, struct CadetTunnelAxolotl *ax) |
| Send a KX message. | |
| static void | send_kx_auth (struct CadetTunnel *t, struct CadetTConnection *ct, struct CadetTunnelAxolotl *ax, int force_reply) |
| Send a KX_AUTH message. | |
| static void | cleanup_ax (struct CadetTunnelAxolotl *ax) |
| Cleanup state used by ax. | |
| static void | update_ax_by_kx (void *cls, const struct GNUNET_HashCode *key_result) |
| Update our Axolotl key state based on the KX data we received. | |
| static void | retry_kx (void *cls) |
| Try to redo the KX or KX_AUTH handshake, if we can. | |
| static void | cont_GCT_handle_kx (void *cls, enum GNUNET_GenericReturnValue ret) |
| Continue to handle KX message. | |
| void | GCT_handle_kx (struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg) |
| Continue to handle KX message. | |
| static void | cont_GCT_handle_kx_auth (void *cls, enum GNUNET_GenericReturnValue ret) |
| Continue to handle KX_AUTH message. | |
| void | GCT_handle_kx_auth (struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg) |
| Handle KX_AUTH message. | |
| static struct GNUNET_CADET_ChannelTunnelNumber | get_next_free_ctn (struct CadetTunnel *t) |
| Compute the next free channel tunnel number for this tunnel. | |
| struct GNUNET_CADET_ChannelTunnelNumber | GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch) |
| Add a channel to a tunnel, and notify channel that we are ready for transmission if we are already up. | |
| void | GCT_connection_lost (struct CadetTConnection *ct) |
| We lost a connection, remove it from our list and clean up the connection object itself. | |
| static void | destroy_t_connection (void *cls, struct CadetTConnection *ct) |
| Clean up connection ct of a tunnel. | |
| static void | destroy_tunnel (void *cls) |
| This tunnel is no longer used, destroy it. | |
| void | GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch, struct GNUNET_CADET_ChannelTunnelNumber ctn) |
| Remove a channel from a tunnel. | |
| static int | destroy_remaining_channels (void *cls, uint32_t key, void *value) |
| Destroy remaining channels during shutdown. | |
| void | GCT_destroy_tunnel_now (struct CadetTunnel *t) |
| Destroys the tunnel t now, without delay. | |
| static void | try_send_normal_payload (struct CadetTunnel *t, struct CadetTConnection *ct) |
| Send normal payload from queue in t via connection ct. | |
| static void | connection_ready_cb (void *cls, int is_ready) |
| A connection is is_ready for transmission. | |
| static void | evaluate_connection (void *cls, struct CadetTConnection *ct) |
| Evaluate a connection, updating our summary information in cls about what kinds of connections we have. | |
| static int | consider_path_cb (void *cls, struct CadetPeerPath *path, unsigned int off) |
| Consider using the path p for the tunnel t. | |
| static void | maintain_connections_cb (void *cls) |
| Function called to maintain the connections underlying our tunnel. | |
| void | GCT_consider_path (struct CadetTunnel *t, struct CadetPeerPath *p, unsigned int off) |
| Consider using the path p for the tunnel t. | |
| static void | handle_plaintext_keepalive (void *cls, const struct GNUNET_MessageHeader *msg) |
| We got a keepalive. | |
| static int | check_plaintext_data (void *cls, const struct GNUNET_CADET_ChannelAppDataMessage *msg) |
| Check that msg is well-formed. | |
| static void | handle_plaintext_data (void *cls, const struct GNUNET_CADET_ChannelAppDataMessage *msg) |
| We received payload data for a channel. | |
| static void | handle_plaintext_data_ack (void *cls, const struct GNUNET_CADET_ChannelDataAckMessage *ack) |
| We received an acknowledgement for data we sent on a channel. | |
| static void | handle_plaintext_channel_open (void *cls, const struct GNUNET_CADET_ChannelOpenMessage *copen) |
| We have received a request to open a channel to a port from another peer. | |
| void | GCT_send_channel_destroy (struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn) |
| Send a DESTROY message via the tunnel. | |
| static void | handle_plaintext_channel_open_ack (void *cls, const struct GNUNET_CADET_ChannelOpenAckMessage *cm) |
| We have received confirmation from the target peer that the given channel could be established (the port is open). | |
| static void | handle_plaintext_channel_destroy (void *cls, const struct GNUNET_CADET_ChannelDestroyMessage *cm) |
| We received a message saying that a channel should be destroyed. | |
| static int | handle_decrypted (void *cls, const struct GNUNET_MessageHeader *msg) |
| Handles a message we decrypted, by injecting it into our message queue (which will do the dispatching). | |
| static void | decrypted_error_cb (void *cls, enum GNUNET_MQ_Error error) |
| Function called if we had an error processing an incoming decrypted message. | |
| struct CadetTunnel * | GCT_create_tunnel (struct CadetPeer *destination) |
| Create a tunnel to destination. | |
| int | GCT_add_inbound_connection (struct CadetTunnel *t, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, struct CadetPeerPath *path) |
| Add a connection to the tunnel. | |
| void | GCT_handle_encrypted (struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelEncryptedMessage *msg) |
| Handle encrypted message. | |
| struct CadetTunnelQueueEntry * | GCT_send (struct CadetTunnel *t, const struct GNUNET_MessageHeader *message, GCT_SendContinuation cont, void *cont_cls, struct GNUNET_CADET_ChannelTunnelNumber *ctn) |
| Sends an already built message on a tunnel, encrypting it and choosing the best connection if not provided. | |
| void | GCT_send_cancel (struct CadetTunnelQueueEntry *tq) |
| Cancel a previously sent message while it's in the queue. | |
| void | GCT_iterate_connections (struct CadetTunnel *t, GCT_ConnectionIterator iter, void *iter_cls) |
| Iterate over all connections of a tunnel. | |
| static int | iterate_channels_cb (void *cls, uint32_t key, void *value) |
| Helper function for GCT_iterate_channels. | |
| void | GCT_iterate_channels (struct CadetTunnel *t, GCT_ChannelIterator iter, void *iter_cls) |
| Iterate over all channels of a tunnel. | |
| static int | debug_channel (void *cls, uint32_t key, void *value) |
| Call GCCH_debug() on a channel. | |
| void | GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level) |
| Log all possible info about the tunnel state. | |
Information we track per tunnel.
FIXME:
Definition in file gnunet-service-cadet_tunnels.c.
| #define LOG | ( | level, | |
| ... | |||
| ) | GNUNET_log_from (level, "cadet-tun", __VA_ARGS__) |
Definition at line 47 of file gnunet-service-cadet_tunnels.c.
| #define MAX_UNVERIFIED_ATTEMPTS 16 |
How often do we try to decrypt payload with unverified key material? Used to limit CPU increase upon receiving bogus KX.
Definition at line 54 of file gnunet-service-cadet_tunnels.c.
| #define IDLE_DESTROY_DELAY |
How long do we wait until tearing down an idle tunnel?
Definition at line 59 of file gnunet-service-cadet_tunnels.c.
| #define INITIAL_KX_RETRY_DELAY |
How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have connection-level RTT data!
Definition at line 66 of file gnunet-service-cadet_tunnels.c.
| #define MAX_SKIPPED_KEYS 64 |
Maximum number of skipped keys we keep in memory per tunnel.
Definition at line 72 of file gnunet-service-cadet_tunnels.c.
| #define MAX_KEY_GAP 256 |
Maximum number of keys (and thus ratchet steps) we are willing to skip before we decide this is either a bogus packet or a DoS-attempt.
Definition at line 78 of file gnunet-service-cadet_tunnels.c.
| #define HIGH_BIT 0x8000000 |
| #define LOG2 | ( | level, | |
| ... | |||
| ) |
Definition at line 3780 of file gnunet-service-cadet_tunnels.c.
| typedef void(* CadetTunnelAxolotlCallback) (void *cls, enum GNUNET_GenericReturnValue res) |
Signature of the follow up function from an udate AX by KX.
| cls | closure |
| res | result |
Definition at line 264 of file gnunet-service-cadet_tunnels.c.
| int GCT_alice_or_betty | ( | const struct GNUNET_PeerIdentity * | other | ) |
Am I Alice or Betty (some call her Bob), or talking to myself?
| other | the other peer |
Definition at line 540 of file gnunet-service-cadet_tunnels.c.
References GNUNET_assert, GNUNET_break_op, GNUNET_memcmp, GNUNET_NO, GNUNET_PILS_get_identity(), GNUNET_SYSERR, GNUNET_YES, my_identity, and pils.
Referenced by GCT_handle_kx(), send_create(), send_kx(), and update_ax_by_kx().
|
static |
Connection ct is now unready, clear it's ready flag and move it from the ready DLL to the busy DLL.
| ct | connection to move to unready status |
Definition at line 566 of file gnunet-service-cadet_tunnels.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_YES, CadetTConnection::is_ready, t, and CadetTConnection::t.
Referenced by connection_ready_cb(), send_kx(), send_kx_auth(), and try_send_normal_payload().
| const char * GCT_2s | ( | const struct CadetTunnel * | t | ) |
Get the static string for the peer this tunnel is directed.
| t | Tunnel. |
Definition at line 592 of file gnunet-service-cadet_tunnels.c.
References GCP_get_id(), GNUNET_i2s(), GNUNET_snprintf(), and t.
Referenced by connection_ready_cb(), consider_path_cb(), cont_GCT_handle_kx(), cont_GCT_handle_kx_auth(), destroy_tunnel(), GCC_2s(), GCCH_bind(), GCCH_channel_local_new(), GCCH_debug(), GCP_drop_tunnel(), GCT_add_channel(), GCT_add_inbound_connection(), GCT_change_estate(), GCT_consider_path(), GCT_debug(), GCT_handle_encrypted(), GCT_handle_kx(), GCT_handle_kx_auth(), GCT_remove_channel(), GCT_send(), handle_plaintext_channel_destroy(), handle_plaintext_channel_open(), handle_plaintext_channel_open_ack(), handle_plaintext_keepalive(), maintain_connections_cb(), retry_kx(), send_keepalive(), send_kx(), send_kx_auth(), try_send_normal_payload(), and update_state().
|
static |
Get string description for tunnel encryption state.
| es | Tunnel state. |
Definition at line 614 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, and GNUNET_snprintf().
Referenced by connection_ready_cb(), GCT_change_estate(), GCT_debug(), retry_kx(), and send_kx().
| struct CadetPeer * GCT_get_destination | ( | struct CadetTunnel * | t | ) |
Return the peer to which this tunnel goes.
| t | a tunnel |
Definition at line 648 of file gnunet-service-cadet_tunnels.c.
References t.
Referenced by GCCH_2s(), GCCH_bind(), GCCH_channel_incoming_new(), get_next_free_ctn(), and timeout_closed_cb().
| unsigned int GCT_count_channels | ( | struct CadetTunnel * | t | ) |
Returns the number of channels using a tunnel.
| t | Tunnel in question. |
Definition at line 655 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CONTAINER_multihashmap32_size(), and t.
Referenced by connection_ready_cb(), destroy_tunnel(), GCT_destroy_tunnel_now(), GCT_remove_channel(), get_all_tunnels_iterator(), and retry_kx().
|
static |
Lookup a channel by its ctn.
| t | tunnel to look in |
| ctn | number of channel to find |
Definition at line 669 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_ChannelTunnelNumber::cn, CadetChannel::ctn, GNUNET_CONTAINER_multihashmap32_get(), and t.
Referenced by GCT_send(), handle_plaintext_channel_destroy(), handle_plaintext_channel_open_ack(), handle_plaintext_data(), and handle_plaintext_data_ack().
| unsigned int GCT_count_any_connections | ( | const struct CadetTunnel * | t | ) |
Counts the number of connections created for a tunnel, including busy connections.
| t | Tunnel to be counted. |
Definition at line 678 of file gnunet-service-cadet_tunnels.c.
References t.
Referenced by consider_path_cb(), GCT_debug(), get_all_tunnels_iterator(), and maintain_connections_cb().
|
static |
Find first connection that is ready in the list of our connections.
Picks ready connections round-robin.
| t | tunnel to search |
Definition at line 692 of file gnunet-service-cadet_tunnels.c.
References GNUNET_assert, GNUNET_YES, CadetTConnection::is_ready, and t.
Referenced by send_kx(), send_kx_auth(), and trigger_transmissions().
| enum CadetTunnelEState GCT_get_estate | ( | struct CadetTunnel * | t | ) |
Get the encryption state of a tunnel.
| t | Tunnel. |
Definition at line 710 of file gnunet-service-cadet_tunnels.c.
References t.
Referenced by get_all_tunnels_iterator(), handle_connection_create(), send_create(), and send_keepalive().
|
static |
Called when either we have a new connection, or a new message in the queue, or some existing connection has transmission capacity.
Looks at our message queue and if there is a message, picks a connection to send it on.
| cls | the struct CadetTunnel to process messages on |
Definition at line 2653 of file gnunet-service-cadet_tunnels.c.
References get_ready_connection(), t, and try_send_normal_payload().
Referenced by GCT_change_estate(), GCT_handle_encrypted(), and GCT_send().
|
static |
Create a new Axolotl ephemeral (ratchet) key.
| ax | key material to update |
Definition at line 737 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelAxolotl::DHRs, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_ERROR_TYPE_DEBUG, and LOG.
Referenced by GCT_create_tunnel(), and t_ax_encrypt().
|
static |
Calculate HMAC.
| plaintext | Content to HMAC. | |
| size | Size of plaintext. | |
| iv | Initialization vector for the message. | |
| key | Key to use. | |
| [out] | hmac | Destination to store the HMAC. |
Definition at line 755 of file gnunet-service-cadet_tunnels.c.
References ctx, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_hmac(), GNUNET_CRYPTO_kdf_arg_auto, GNUNET_CRYPTO_kdf_arg_string, GNUNET_memcpy, key, and size.
Referenced by GCT_send(), t_ax_decrypt_and_validate(), and try_old_ax_keys().
|
static |
Perform a HMAC.
| key | Key to use. | |
| [out] | hash | Resulting HMAC. |
| source | Source key material (data to HMAC). | |
| len | Length of source. |
Definition at line 798 of file gnunet-service-cadet_tunnels.c.
References ctx, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_hmac(), key, and source.
Referenced by t_ax_decrypt_and_validate(), t_ax_encrypt(), and t_hmac_derive_key().
|
static |
Derive a symmetric encryption key from an HMAC-HASH.
| key | Key to use for the HMAC. | |
| [out] | out | Key to generate. |
| source | Source key material (data to HMAC). | |
| len | Length of source. |
Definition at line 829 of file gnunet-service-cadet_tunnels.c.
References ctx, GNUNET_CRYPTO_hkdf_gnunet, h, key, source, and t_ax_hmac_hash().
Referenced by store_skipped_key(), t_ax_decrypt(), and t_ax_encrypt().
|
static |
Encrypt data with the axolotl tunnel key.
| ax | key material to use. |
| dst | Destination with size bytes for the encrypted data. |
| src | Source of the plaintext. Can overlap with dst, must contain size bytes |
| size | Size of the buffers at src and dst |
Definition at line 857 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelAxolotl::CKs, ctx, CadetTunnelAxolotl::DHRr, CadetTunnelAxolotl::DHRs, GNUNET_assert, GNUNET_CRYPTO_ecc_ecdh(), GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_symmetric_encrypt(), GNUNET_NO, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, CadetTunnelAxolotl::HKs, new_ephemeral(), CadetTunnelAxolotl::NHKs, CadetTunnelAxolotl::Ns, CadetTunnelAxolotl::PNs, CadetTunnelAxolotl::ratchet_allowed, CadetTunnelAxolotl::ratchet_counter, CadetTunnelAxolotl::ratchet_expiration, CadetTunnelAxolotl::ratchet_flag, ratchet_time, GNUNET_TIME_Relative::rel_value_us, CadetTunnelAxolotl::RK, size, t_ax_hmac_hash(), and t_hmac_derive_key().
Referenced by GCT_send().
|
static |
Decrypt data with the axolotl tunnel key.
| ax | key material to use. |
| dst | Destination for the decrypted data, must contain size bytes. |
| src | Source of the ciphertext. Can overlap with dst, must contain size bytes. |
| size | Size of the src and dst buffers |
Definition at line 945 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelAxolotl::CKr, GNUNET_assert, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_symmetric_decrypt(), size, and t_hmac_derive_key().
Referenced by t_ax_decrypt_and_validate().
|
static |
Encrypt header with the axolotl header key.
| ax | key material to use. | |
| [in,out] | msg | Message whose header to encrypt. |
Definition at line 986 of file gnunet-service-cadet_tunnels.c.
References GNUNET_assert, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_symmetric_encrypt(), CadetTunnelAxolotl::HKs, and msg.
Referenced by GCT_send().
|
static |
Decrypt header with the current axolotl header key.
| ax | key material to use. |
| src | Message whose header to decrypt. |
| dst | Where to decrypt header to. |
Definition at line 1016 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_TunnelEncryptedMessage::ax_header, GNUNET_assert, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_symmetric_decrypt(), CadetTunnelAxolotl::HKr, and GNUNET_CADET_AxHeader::Ns.
Referenced by t_ax_decrypt_and_validate().
|
static |
Delete a key from the list of skipped keys.
| ax | key material to delete key from. |
| key | Key to delete. |
Definition at line 1048 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, key, CadetTunnelAxolotl::skipped, CadetTunnelAxolotl::skipped_head, and CadetTunnelAxolotl::skipped_tail.
Referenced by cleanup_ax(), store_ax_keys(), and try_old_ax_keys().
|
static |
Decrypt and verify data with the appropriate tunnel key and verify that the data has not been altered since it was sent by the remote peer.
| ax | key material to use. |
| dst | Destination for the plaintext. |
| src | Source of the message. Can overlap with dst. |
| size | Size of the message. |
Definition at line 1070 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_TunnelEncryptedMessage::ax_header, delete_skipped_key(), GNUNET_assert, GNUNET_CRYPTO_hkdf_gnunet, GNUNET_CRYPTO_symmetric_decrypt(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, GNUNET_CADET_TunnelEncryptedMessage::hmac, key, LOG, N, GNUNET_CADET_AxHeader::Ns, res, size, CadetTunnelAxolotl::skipped_head, and t_hmac().
Referenced by t_ax_decrypt_and_validate().
|
static |
Delete a key from the list of skipped keys.
| ax | key material to delete from. |
| HKr | Header Key to use. |
Definition at line 1165 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelAxolotl::CKr, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_TIME_absolute_get(), CadetTunnelAxolotl::HKr, key, CadetTunnelAxolotl::Nr, CadetTunnelAxolotl::skipped, CadetTunnelAxolotl::skipped_head, CadetTunnelAxolotl::skipped_tail, and t_hmac_derive_key().
Referenced by store_ax_keys().
|
static |
Stage skipped AX keys and calculate the message key.
Stores each HK and MK for skipped messages.
| ax | key material to use |
| HKr | Header key. |
| Np | Received message number. |
Definition at line 1201 of file gnunet-service-cadet_tunnels.c.
References delete_skipped_key(), GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, LOG, MAX_KEY_GAP, MAX_SKIPPED_KEYS, CadetTunnelAxolotl::Nr, CadetTunnelAxolotl::skipped, CadetTunnelAxolotl::skipped_tail, and store_skipped_key().
Referenced by t_ax_decrypt_and_validate().
|
static |
Decrypt and verify data with the appropriate tunnel key and verify that the data has not been altered since it was sent by the remote peer.
| ax | key material to use |
| dst | Destination for the plaintext. |
| src | Source of the message. Can overlap with dst. |
| size | Size of the message. |
Definition at line 1251 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_TunnelEncryptedMessage::ax_header, CadetTunnelAxolotl::CKr, ctx, CadetTunnelAxolotl::DHRr, GNUNET_CADET_AxHeader::DHRs, CadetTunnelAxolotl::DHRs, GNUNET_CRYPTO_ecc_ecdh(), GNUNET_CRYPTO_hkdf_gnunet, GNUNET_memcmp, GNUNET_OK, GNUNET_YES, CadetTunnelAxolotl::HKr, GNUNET_CADET_TunnelEncryptedMessage::hmac, CadetTunnelAxolotl::NHKr, CadetTunnelAxolotl::Nr, GNUNET_CADET_AxHeader::Ns, GNUNET_CADET_AxHeader::PNs, CadetTunnelAxolotl::ratchet_allowed, CadetTunnelAxolotl::RK, size, store_ax_keys(), t_ax_decrypt(), t_ax_hmac_hash(), t_h_decrypt(), t_hmac(), and try_old_ax_keys().
Referenced by GCT_handle_encrypted().
|
static |
Our tunnel became ready for the first time, notify channels that have been waiting.
| cls | our tunnel, not used |
| key | unique ID of the channel, not used |
| value | the struct CadetChannel to notify |
Definition at line 1366 of file gnunet-service-cadet_tunnels.c.
References ch, GCCH_tunnel_up(), GNUNET_OK, and value.
Referenced by GCT_change_estate().
| void GCT_change_estate | ( | struct CadetTunnel * | t, |
| enum CadetTunnelEState | state | ||
| ) |
Change the tunnel encryption state.
If the encryption state changes to OK, stop the rekey task.
| t | Tunnel whose encryption state to change, or NULL. |
| state | New encryption state. |
Definition at line 1385 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_OK, estate2s(), GCT_2s(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), LOG, notify_tunnel_up_cb(), state, t, and trigger_transmissions().
Referenced by cont_GCT_handle_kx(), cont_GCT_handle_kx_auth(), GCT_handle_encrypted(), handle_connection_create(), send_kx(), and send_kx_auth().
|
static |
Send a KX message.
| t | tunnel on which to send the KX_AUTH |
| ct | Tunnel and connection on which to send the KX_AUTH, NULL if we are to find one that is ready. |
| ax | axolotl key context to use |
Definition at line 1426 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_UNINITIALIZED, CadetTConnection::cc, CadetTunnelAxolotl::DHRs, env, estate2s(), GNUNET_CADET_TunnelKeyExchangeMessage::flags, GCC_get_id(), GCC_transmit(), GCP_get_id(), GCT_2s(), GCT_alice_or_betty(), GCT_change_estate(), get_ready_connection(), GNUNET_CADET_KX_FLAG_FORCE_REPLY, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX, GNUNET_MQ_msg, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, CadetTConnection::is_ready, CadetTunnelAxolotl::kx_0, LOG, mark_connection_unready(), msg, stats, and t.
Referenced by connection_ready_cb(), GCT_handle_encrypted(), and retry_kx().
|
static |
Send a KX_AUTH message.
| t | tunnel on which to send the KX_AUTH |
| ct | Tunnel and connection on which to send the KX_AUTH, NULL if we are to find one that is ready. |
| ax | axolotl key context to use |
| force_reply | Force the other peer to reply with a KX_AUTH message (set if we would like to transmit right now, but cannot) |
Definition at line 1496 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_OK, CadetTConnection::cc, CadetTunnelAxolotl::DHRs, env, GCC_get_id(), GCC_transmit(), GCT_2s(), GCT_change_estate(), get_ready_connection(), GNUNET_CADET_KX_FLAG_FORCE_REPLY, GNUNET_CADET_KX_FLAG_NONE, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH, GNUNET_MQ_msg, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, CadetTConnection::is_ready, CadetTunnelAxolotl::kx_0, CadetTunnelAxolotl::last_ephemeral, LOG, mark_connection_unready(), msg, CadetTunnelAxolotl::RK, stats, and t.
Referenced by connection_ready_cb(), cont_GCT_handle_kx_auth(), GCT_handle_encrypted(), GCT_handle_kx(), and retry_kx().
|
static |
Cleanup state used by ax.
| ax | state to free, but not memory of ax itself |
Definition at line 1574 of file gnunet-service-cadet_tunnels.c.
References delete_skipped_key(), CadetTunnelAxolotl::DHRs, GNUNET_assert, GNUNET_CRYPTO_ecdhe_key_clear(), CadetTunnelAxolotl::kx_0, CadetTunnelAxolotl::skipped, and CadetTunnelAxolotl::skipped_head.
Referenced by cont_GCT_handle_kx_auth(), destroy_tunnel(), and GCT_handle_encrypted().
|
static |
Update our Axolotl key state based on the KX data we received.
Computes the new chain keys, and root keys, etc, and also checks whether this is a replay of the current chain.
| cls | closure using the async structure for Axolotl |
| key_result | ecdh result from the ephemeral public key of the other peer |
Definition at line 1597 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelAsync::ax, CadetTunnelAsync::cb, CadetTunnelAsync::cb_cls, CadetTunnelAxolotl::CKr, CadetTunnelAxolotl::CKs, CadetTunnelAxolotl::DHRr, CadetTunnelAsync::ecdh_op, CadetTunnelAsync::ephemeral_key, GCT_alice_or_betty(), GNUNET_break_op, GNUNET_CRYPTO_ecc_ecdh(), GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_CRYPTO_hkdf_gnunet, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_YES, CadetTunnelAxolotl::HKr, CadetTunnelAxolotl::HKs, CadetTunnelAxolotl::kx_0, CadetTunnelAxolotl::last_ephemeral, LOG, CadetTunnelAxolotl::NHKr, CadetTunnelAxolotl::NHKs, CadetTunnelAsync::peer_id, pid, GNUNET_PeerIdentity::public_key, CadetTunnelAxolotl::ratchet_expiration, CadetTunnelAxolotl::ratchet_flag, CadetTunnelAsync::ratchet_key, ratchet_time, CadetTunnelAxolotl::RK, salt, and stats.
Referenced by GCT_handle_kx(), and GCT_handle_kx_auth().
|
static |
Try to redo the KX or KX_AUTH handshake, if we can.
| cls | the struct CadetTunnel to do KX for. |
Definition at line 1728 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, estate2s(), GCT_2s(), GCT_count_channels(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_YES, LOG, send_kx(), send_kx_auth(), and t.
Referenced by connection_ready_cb(), cont_GCT_handle_kx(), cont_GCT_handle_kx_auth(), and GCT_add_channel().
|
static |
Continue to handle KX message.
| cls | closure from updating AX by KX |
| ret | result from the update call |
Definition at line 1821 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, GCP_get_id(), GCT_2s(), GCT_change_estate(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, LOG, ret, retry_kx(), stats, and t.
Referenced by GCT_handle_kx().
| void GCT_handle_kx | ( | struct CadetTConnection * | ct, |
| const struct GNUNET_CADET_TunnelKeyExchangeMessage * | msg | ||
| ) |
Continue to handle KX message.
Handle KX message that lacks authentication (and which will thus only be considered authenticated after we respond with our own KX_AUTH and finally successfully decrypt the payload).
| cls | closure from updating AX by KX |
| ret | result from the update call |
Definition at line 1870 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, cont_GCT_handle_kx(), GCC_2s(), GCP_get_id(), GCT_2s(), GCT_alice_or_betty(), GNUNET_break, GNUNET_break_op, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_PILS_cancel(), GNUNET_PILS_ecdh(), GNUNET_STATISTICS_update(), GNUNET_YES, LOG, msg, pils, send_kx_auth(), stats, t, CadetTConnection::t, and update_ax_by_kx().
Referenced by GCC_handle_kx().
|
static |
Continue to handle KX_AUTH message.
| cls | closure from updating AX by KX |
| ret | result from the update call |
Definition at line 2016 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, cleanup_ax(), GCT_2s(), GCT_change_estate(), GNUNET_assert, GNUNET_break, GNUNET_CADET_KX_FLAG_FORCE_REPLY, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_memcmp, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_at(), GNUNET_STATISTICS_update(), CadetTunnelAxolotl::kx_0, LOG, msg, ret, retry_kx(), CadetTunnelAxolotl::RK, send_kx_auth(), stats, and t.
Referenced by GCT_handle_kx_auth().
| void GCT_handle_kx_auth | ( | struct CadetTConnection * | ct, |
| const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage * | msg | ||
| ) |
Handle KX_AUTH message.
| ct | connection/tunnel combo that received encrypted message |
| msg | the key exchange message |
Definition at line 2127 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_UNINITIALIZED, cont_GCT_handle_kx_auth(), GCP_get_id(), GCT_2s(), GNUNET_break_op, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_NO, GNUNET_PILS_cancel(), GNUNET_PILS_ecdh(), GNUNET_STATISTICS_update(), LOG, msg, pils, stats, t, CadetTConnection::t, and update_ax_by_kx().
Referenced by GCC_handle_kx_auth().
|
static |
Compute the next free channel tunnel number for this tunnel.
| t | the tunnel |
Definition at line 2201 of file gnunet-service-cadet_tunnels.c.
References GCP_get_id(), GCT_get_destination(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_memcmp, GNUNET_PILS_get_identity(), HIGH_BIT, my_identity, pils, ret, and t.
Referenced by GCT_add_channel().
| struct GNUNET_CADET_ChannelTunnelNumber GCT_add_channel | ( | struct CadetTunnel * | t, |
| struct CadetChannel * | ch | ||
| ) |
Add a channel to a tunnel, and notify channel that we are ready for transmission if we are already up.
Add a channel to a tunnel.
Otherwise that notification will be done later in notify_tunnel_up_cb().
| t | Tunnel. |
| ch | Channel |
Definition at line 2244 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, ch, GNUNET_CADET_ChannelTunnelNumber::cn, GCCH_2s(), GCCH_tunnel_up(), GCT_2s(), get_next_free_ctn(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, LOG, retry_kx(), and t.
Referenced by GCCH_channel_local_new().
| void GCT_connection_lost | ( | struct CadetTConnection * | ct | ) |
We lost a connection, remove it from our list and clean up the connection object itself.
| ct | binding of connection to tunnel of the connection that was lost. |
Definition at line 2303 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, CadetTConnection::is_ready, t, and CadetTConnection::t.
Referenced by destroy_t_connection(), GCC_create_inbound(), and GCC_destroy_without_core().
|
static |
Clean up connection ct of a tunnel.
| cls | the struct CadetTunnel |
| ct | connection to clean up |
Definition at line 2332 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, CadetConnection::ct, GCC_destroy_without_tunnel(), GCT_connection_lost(), GNUNET_assert, t, and CadetTConnection::t.
Referenced by destroy_tunnel(), and maintain_connections_cb().
|
static |
This tunnel is no longer used, destroy it.
| cls | the idle tunnel |
Definition at line 2350 of file gnunet-service-cadet_tunnels.c.
References cleanup_ax(), CadetTunnelQueueEntry::cont, CadetTunnelQueueEntry::cont_cls, destroy_t_connection(), GCP_drop_tunnel(), GCT_2s(), GCT_count_channels(), GCT_iterate_connections(), GCT_send_cancel(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_MST_destroy(), GNUNET_PILS_cancel(), GNUNET_SCHEDULER_cancel(), LOG, and t.
Referenced by callback_room_connect(), connection_ready_cb(), enter_srv_room_at(), GCT_destroy_tunnel_now(), GCT_remove_channel(), and iterate_destroy_tunnels().
| void GCT_remove_channel | ( | struct CadetTunnel * | t, |
| struct CadetChannel * | ch, | ||
| struct GNUNET_CADET_ChannelTunnelNumber | ctn | ||
| ) |
Remove a channel from a tunnel.
| t | Tunnel. |
| ch | Channel |
| ctn | unique number identifying ch within t |
Definition at line 2416 of file gnunet-service-cadet_tunnels.c.
References ch, GNUNET_CADET_ChannelTunnelNumber::cn, destroy_tunnel(), GCCH_2s(), GCT_2s(), GCT_count_channels(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, IDLE_DESTROY_DELAY, LOG, and t.
Referenced by channel_destroy().
|
static |
Destroy remaining channels during shutdown.
| cls | the struct CadetTunnel of the channel |
| key | key of the channel |
| value | the struct CadetChannel |
Definition at line 2449 of file gnunet-service-cadet_tunnels.c.
References ch, GCCH_handle_remote_destroy(), GNUNET_OK, and value.
Referenced by GCT_destroy_tunnel_now().
| void GCT_destroy_tunnel_now | ( | struct CadetTunnel * | t | ) |
Destroys the tunnel t now, without delay.
Used during shutdown.
| t | tunnel to destroy |
Definition at line 2467 of file gnunet-service-cadet_tunnels.c.
References destroy_remaining_channels(), destroy_tunnel(), GCT_count_channels(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, shutting_down, and t.
Referenced by destroy_tunnels_now().
|
static |
Send normal payload from queue in t via connection ct.
Does nothing if our payload queue is empty.
| t | tunnel to send data from |
| ct | connection to use for transmission (is ready) |
Definition at line 2492 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, CadetTunnelQueueEntry::cid, CadetTunnelQueueEntry::cont, CadetTunnelQueueEntry::cont_cls, CadetTunnelQueueEntry::env, GCC_2s(), GCC_get_id(), GCC_transmit(), GCT_2s(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_YES, CadetTConnection::is_ready, LOG, mark_connection_unready(), t, and CadetTunnelQueueEntry::t.
Referenced by connection_ready_cb(), and trigger_transmissions().
|
static |
A connection is is_ready for transmission.
Looks at our message queue and if there is a message, sends it out via the connection.
| cls | the struct CadetTConnection that is is_ready |
| is_ready | GNUNET_YES if connection are now ready, GNUNET_NO if connection are no longer ready |
Definition at line 2538 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, CadetTConnection::cc, destroy_tunnel(), estate2s(), GCC_2s(), GCT_2s(), GCT_count_channels(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, IDLE_DESTROY_DELAY, CadetTConnection::is_ready, LOG, mark_connection_unready(), GNUNET_TIME_Relative::rel_value_us, retry_kx(), send_kx(), send_kx_auth(), t, CadetTConnection::t, and try_send_normal_payload().
Referenced by consider_path_cb(), and GCT_add_inbound_connection().
|
static |
Evaluate a connection, updating our summary information in cls about what kinds of connections we have.
| cls | the struct EvaluationSummary * to update |
| ct | a connection to include in the summary |
Definition at line 2726 of file gnunet-service-cadet_tunnels.c.
References CadetConnectionMetrics::age, CadetTConnection::cc, CadetConnection::ct, EvaluationSummary::duplicate, GCC_2s(), GCC_get_metrics(), GCC_get_path(), GCPP_2s(), GCPP_get_desirability(), GCPP_get_length(), GCPP_get_peer_at_offset(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX, GNUNET_MIN, GNUNET_NO, GNUNET_TIME_absolute_get_duration(), GNUNET_YES, CadetConnectionMetrics::last_use, LOG, EvaluationSummary::max_desire, EvaluationSummary::max_length, EvaluationSummary::min_desire, EvaluationSummary::min_length, CadetConnectionMetrics::num_acked_transmissions, CadetConnectionMetrics::num_successes, CadetConnection::off, EvaluationSummary::path, ps, GNUNET_TIME_Relative::rel_value_us, EvaluationSummary::worst, and EvaluationSummary::worst_score.
Referenced by consider_path_cb(), and maintain_connections_cb().
|
static |
Consider using the path p for the tunnel t.
The tunnel destination is at offset off in path p.
| cls | our tunnel |
| path | a path to our destination |
| off | offset of the destination on path path |
Definition at line 2827 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, connection_ready_cb(), CadetTConnection::created, DESIRED_CONNECTIONS_PER_TUNNEL, EvaluationSummary::duplicate, evaluate_connection(), GCC_2s(), GCC_create(), GCP_2s(), GCPP_2s(), GCPP_get_desirability(), GCPP_get_length(), GCPP_get_peer_at_offset(), GCT_2s(), GCT_count_any_connections(), GCT_iterate_connections(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_YES, LOG, EvaluationSummary::max_desire, EvaluationSummary::max_length, EvaluationSummary::min_desire, EvaluationSummary::min_length, EvaluationSummary::path, t, CadetTConnection::t, and EvaluationSummary::worst.
Referenced by GCT_consider_path(), and maintain_connections_cb().
|
static |
Function called to maintain the connections underlying our tunnel.
Tries to maintain (incl. tear down) connections for the tunnel, and if there is a significant change, may trigger transmissions.
Basically, needs to check if there are connections that perform badly, and if so eventually kill them and trigger a replacement. The strategy is to open one more connection than DESIRED_CONNECTIONS_PER_TUNNEL, and then periodically kick out the least-performing one, and then inquire for new ones.
| cls | the struct CadetTunnel |
Definition at line 2933 of file gnunet-service-cadet_tunnels.c.
References consider_path_cb(), DESIRED_CONNECTIONS_PER_TUNNEL, destroy_t_connection(), EvaluationSummary::duplicate, evaluate_connection(), GCP_iterate_paths(), GCT_2s(), GCT_count_any_connections(), GCT_iterate_connections(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_UNIT_MINUTES, LOG, maintain_connections_cb(), EvaluationSummary::max_desire, EvaluationSummary::max_length, EvaluationSummary::min_desire, EvaluationSummary::min_length, EvaluationSummary::path, t, and EvaluationSummary::worst.
Referenced by GCT_create_tunnel(), and maintain_connections_cb().
| void GCT_consider_path | ( | struct CadetTunnel * | t, |
| struct CadetPeerPath * | p, | ||
| unsigned int | off | ||
| ) |
Consider using the path p for the tunnel t.
The tunnel destination is at offset off in path p.
| t | our tunnel |
| p | a path to our destination |
| off | offset of the destination on path path |
Definition at line 2983 of file gnunet-service-cadet_tunnels.c.
References consider_path_cb(), GCPP_2s(), GCT_2s(), GNUNET_ERROR_TYPE_DEBUG, LOG, p, and t.
Referenced by GCP_path_entry_add(), and GCP_set_mq().
|
static |
We got a keepalive.
Track in statistics.
| cls | the struct CadetTunnel for which we decrypted the message |
| msg | the message we received on the tunnel |
Definition at line 3005 of file gnunet-service-cadet_tunnels.c.
References GCT_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, stats, and t.
|
static |
Check that msg is well-formed.
| cls | the struct CadetTunnel for which we decrypted the message |
| msg | the message we received on the tunnel |
Definition at line 3028 of file gnunet-service-cadet_tunnels.c.
References GNUNET_OK.
|
static |
We received payload data for a channel.
Locate the channel and process the data, or return an error if the channel is unknown.
| cls | the struct CadetTunnel for which we decrypted the message |
| msg | the message we received on the tunnel |
Definition at line 3043 of file gnunet-service-cadet_tunnels.c.
References ch, GCC_get_id(), GCCH_handle_channel_plaintext_data(), GCT_send_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, LOG, lookup_channel(), msg, GNUNET_MessageHeader::size, and t.
|
static |
We received an acknowledgement for data we sent on a channel.
Locate the channel and process it, or return an error if the channel is unknown.
| cls | the struct CadetTunnel for which we decrypted the message |
| ack | the message we received on the tunnel |
Definition at line 3078 of file gnunet-service-cadet_tunnels.c.
References ch, GNUNET_CADET_ChannelTunnelNumber::cn, GNUNET_CADET_ChannelDataAckMessage::ctn, GCC_get_id(), GCCH_handle_channel_plaintext_data_ack(), GCT_send_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, LOG, lookup_channel(), and t.
|
static |
We have received a request to open a channel to a port from another peer.
Creates the incoming channel.
| cls | the struct CadetTunnel for which we decrypted the message |
| copen | the message we received on the tunnel |
Definition at line 3111 of file gnunet-service-cadet_tunnels.c.
References ch, GNUNET_CADET_ChannelTunnelNumber::cn, GNUNET_CADET_ChannelOpenMessage::ctn, GCC_get_id(), GCCH_2s(), GCCH_channel_incoming_new(), GCCH_handle_duplicate_open(), GCT_2s(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_CADET_ChannelOpenMessage::h_port, LOG, GNUNET_CADET_ChannelOpenMessage::opt, and t.
| void GCT_send_channel_destroy | ( | struct CadetTunnel * | t, |
| struct GNUNET_CADET_ChannelTunnelNumber | ctn | ||
| ) |
Send a DESTROY message via the tunnel.
| t | the tunnel to transmit over |
| ctn | ID of the channel to destroy |
Definition at line 3159 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_ChannelTunnelNumber::cn, GNUNET_CADET_ChannelDestroyMessage::ctn, GCT_send(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY, LOG, msg, GNUNET_MessageHeader::size, t, and GNUNET_MessageHeader::type.
Referenced by GCCH_channel_local_destroy(), GCCH_handle_channel_plaintext_data(), GCCH_handle_local_ack(), handle_plaintext_channel_open_ack(), handle_plaintext_data(), and handle_plaintext_data_ack().
|
static |
We have received confirmation from the target peer that the given channel could be established (the port is open).
Tell the client.
| cls | the struct CadetTunnel for which we decrypted the message |
| cm | the message we received on the tunnel |
Definition at line 3188 of file gnunet-service-cadet_tunnels.c.
References ch, GNUNET_CADET_ChannelTunnelNumber::cn, GNUNET_CADET_ChannelOpenAckMessage::ctn, GCC_get_id(), GCCH_2s(), GCCH_handle_channel_open_ack(), GCT_2s(), GCT_send_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, LOG, lookup_channel(), GNUNET_CADET_ChannelOpenAckMessage::port, and t.
|
static |
We received a message saying that a channel should be destroyed.
Pass it on to the correct channel.
| cls | the struct CadetTunnel for which we decrypted the message |
| cm | the message we received on the tunnel |
Definition at line 3226 of file gnunet-service-cadet_tunnels.c.
References ch, GNUNET_CADET_ChannelTunnelNumber::cn, GNUNET_CADET_ChannelDestroyMessage::ctn, GCC_get_id(), GCCH_2s(), GCCH_handle_remote_destroy(), GCT_2s(), GNUNET_ERROR_TYPE_DEBUG, LOG, lookup_channel(), and t.
|
static |
Handles a message we decrypted, by injecting it into our message queue (which will do the dispatching).
| cls | the struct CadetTunnel that got the message |
| msg | the message |
Definition at line 3264 of file gnunet-service-cadet_tunnels.c.
References GNUNET_assert, GNUNET_MQ_inject_message(), GNUNET_OK, msg, and t.
Referenced by GCT_create_tunnel().
|
static |
Function called if we had an error processing an incoming decrypted message.
| cls | the struct CadetTunnel |
| error | error code |
Definition at line 3284 of file gnunet-service-cadet_tunnels.c.
References GNUNET_break_op.
Referenced by GCT_create_tunnel().
| struct CadetTunnel * GCT_create_tunnel | ( | struct CadetPeer * | destination | ) |
Create a tunnel to destination.
Must only be called from within GCP_get_tunnel().
| destination | where to create the tunnel to |
Definition at line 3299 of file gnunet-service-cadet_tunnels.c.
References decrypted_error_cb(), GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_queue_for_callbacks(), GNUNET_MST_create(), GNUNET_new, GNUNET_SCHEDULER_add_now(), handle_decrypted(), handlers, INITIAL_KX_RETRY_DELAY, maintain_connections_cb(), new_ephemeral(), and t.
Referenced by GCP_get_tunnel().
| int GCT_add_inbound_connection | ( | struct CadetTunnel * | t, |
| const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cid, | ||
| struct CadetPeerPath * | path | ||
| ) |
Add a connection to the tunnel.
| t | a tunnel |
| cid | connection identifier to use for the connection |
| path | path to use for the connection |
Definition at line 3352 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, connection_ready_cb(), CadetTConnection::created, GCC_2s(), GCC_create_inbound(), GCT_2s(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_get(), LOG, t, and CadetTConnection::t.
Referenced by handle_connection_create().
| void GCT_handle_encrypted | ( | struct CadetTConnection * | ct, |
| const struct GNUNET_CADET_TunnelEncryptedMessage * | msg | ||
| ) |
Handle encrypted message.
| ct | connection/tunnel combo that received encrypted message |
| msg | the encrypted message to decrypt |
Definition at line 3400 of file gnunet-service-cadet_tunnels.c.
References CADET_TUNNEL_KEY_AX_AUTH_SENT, CADET_TUNNEL_KEY_AX_RECV, CADET_TUNNEL_KEY_AX_SENT, CADET_TUNNEL_KEY_AX_SENT_AND_RECV, CADET_TUNNEL_KEY_OK, CADET_TUNNEL_KEY_UNINITIALIZED, cleanup_ax(), GCT_2s(), GCT_change_estate(), GNUNET_ALIGN, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MST_from_buffer(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, LOG, MAX_UNVERIFIED_ATTEMPTS, msg, send_kx(), send_kx_auth(), GNUNET_MessageHeader::size, size, stats, t, CadetTConnection::t, t_ax_decrypt_and_validate(), and trigger_transmissions().
Referenced by GCC_handle_encrypted().
| struct CadetTunnelQueueEntry * GCT_send | ( | struct CadetTunnel * | t, |
| const struct GNUNET_MessageHeader * | message, | ||
| GCT_SendContinuation | cont, | ||
| void * | cont_cls, | ||
| struct GNUNET_CADET_ChannelTunnelNumber * | ctn | ||
| ) |
Sends an already built message on a tunnel, encrypting it and choosing the best connection if not provided.
| message | Message to send. Function modifies it. |
| t | Tunnel on which this message is transmitted. |
| cont | Continuation to call once message is really sent. |
| cont_cls | Closure for cont. |
Definition at line 3575 of file gnunet-service-cadet_tunnels.c.
References GNUNET_CADET_TunnelEncryptedMessage::ax_header, CADET_TUNNEL_KEY_OK, ch, GNUNET_CADET_TunnelEncryptedMessage::cid, CadetTunnelQueueEntry::cid, CadetTunnelQueueEntry::cont, CadetTunnelQueueEntry::cont_cls, CadetChannel::ctn, GNUNET_CADET_AxHeader::DHRs, env, CadetTunnelQueueEntry::env, GCCH_is_type_to_drop(), GCT_2s(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_CADET_TunnelEncryptedMessage::hmac, LOG, lookup_channel(), GNUNET_CADET_AxHeader::Ns, GNUNET_CADET_AxHeader::PNs, GNUNET_MessageHeader::size, stats, t, CadetTunnelQueueEntry::t, t_ax_encrypt(), t_h_encrypt(), t_hmac(), and trigger_transmissions().
Referenced by GCCH_handle_local_data(), GCT_send_channel_destroy(), retry_transmission(), send_channel_data_ack(), send_channel_open(), send_keepalive(), and send_open_ack().
| void GCT_send_cancel | ( | struct CadetTunnelQueueEntry * | q | ) |
Cancel a previously sent message while it's in the queue.
ONLY can be called before the continuation given to the send function is called. Once the continuation is called, the message is no longer in the queue!
| q | Handle to the queue entry to cancel. |
Definition at line 3653 of file gnunet-service-cadet_tunnels.c.
References CadetTunnelQueueEntry::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), t, and CadetTunnelQueueEntry::t.
Referenced by channel_destroy(), destroy_tunnel(), GCC_destroy(), handle_matching_ack(), send_channel_data_ack(), send_channel_open(), and send_open_ack().
| void GCT_iterate_connections | ( | struct CadetTunnel * | t, |
| GCT_ConnectionIterator | iter, | ||
| void * | iter_cls | ||
| ) |
Iterate over all connections of a tunnel.
| t | Tunnel whose connections to iterate. |
| iter | Iterator. |
| iter_cls | Closure for iter. |
Definition at line 3673 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::next, and t.
Referenced by consider_path_cb(), destroy_tunnel(), and maintain_connections_cb().
|
static |
Helper function for GCT_iterate_channels.
| cls | the struct ChanIterCls |
| key | unused |
| value | a struct CadetChannel |
Definition at line 3724 of file gnunet-service-cadet_tunnels.c.
References ch, ctx, GNUNET_OK, and value.
Referenced by GCT_iterate_channels().
| void GCT_iterate_channels | ( | struct CadetTunnel * | t, |
| GCT_ChannelIterator | iter, | ||
| void * | iter_cls | ||
| ) |
Iterate over all channels of a tunnel.
| t | Tunnel whose channels to iterate. |
| iter | Iterator. |
| iter_cls | Closure for iter. |
Definition at line 3745 of file gnunet-service-cadet_tunnels.c.
References ctx, GNUNET_CONTAINER_multihashmap32_iterate(), ChanIterCls::iter, ChanIterCls::iter_cls, iterate_channels_cb(), and t.
|
static |
Call GCCH_debug() on a channel.
| cls | points to the log level to use |
| key | unused |
| value | the struct CadetChannel to dump |
Definition at line 3768 of file gnunet-service-cadet_tunnels.c.
References ch, GCCH_debug(), GNUNET_OK, and value.
Referenced by GCT_debug().
| void GCT_debug | ( | const struct CadetTunnel * | t, |
| enum GNUNET_ErrorType | level | ||
| ) |
Log all possible info about the tunnel state.
| t | Tunnel to debug. |
| level | Debug level to use. |
Definition at line 3791 of file gnunet-service-cadet_tunnels.c.
References CadetTConnection::cc, debug_channel(), estate2s(), GCC_debug(), GCT_2s(), GCT_count_any_connections(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_ERROR_TYPE_BULK, GNUNET_get_log_call_status(), LOG2, CadetTConnection::next, and t.