summaryrefslogtreecommitdiffstats
path: root/src/protocols
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-01-20 23:47:41 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-01-20 23:47:41 +0100
commiteece4529cbc27eb8266cd9f47cf84c0d0a6b742a (patch)
tree8d33bfdf766c8ff2579c3f2c0de621af82aeb956 /src/protocols
parent972dd90499fd19fcd2c31cf15bb26231d0a862aa (diff)
downloadfastd-eece4529cbc27eb8266cd9f47cf84c0d0a6b742a.tar
fastd-eece4529cbc27eb8266cd9f47cf84c0d0a6b742a.zip
handshake: delay method parsing until the sender key has been handled
Otherwise fastd won't use the correct peer group's method list for handshakes incoming on generic sockets.
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h2
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
index b24593c..25e7bb3 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
@@ -109,7 +109,7 @@ void fastd_protocol_ec25519_fhmqvc_reset_peer_state(fastd_peer_t *peer);
void fastd_protocol_ec25519_fhmqvc_free_peer_state(fastd_peer_t *peer);
void fastd_protocol_ec25519_fhmqvc_handshake_init(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer);
-void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, const fastd_handshake_t *handshake, const fastd_method_info_t *method);
+void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, const fastd_handshake_t *handshake);
#ifdef WITH_DYNAMIC_PEERS
void fastd_protocol_ec25519_fhmqvc_handle_verify_return(fastd_peer_t *peer, fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, const fastd_method_info_t *method, const void *protocol_data, bool ok);
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index 4d03725..8e3c67a 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -627,7 +627,7 @@ static inline fastd_peer_t * add_dynamic(UNUSED fastd_socket_t *sock, const fast
/** Handles a received handshake packet */
void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr,
- fastd_peer_t *peer, const fastd_handshake_t *handshake, const fastd_method_info_t *method) {
+ fastd_peer_t *peer, const fastd_handshake_t *handshake) {
fastd_protocol_ec25519_fhmqvc_maintenance();
if (!has_field(handshake, RECORD_SENDER_KEY, PUBLICKEYBYTES)) {
@@ -676,6 +676,8 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const
}
}
+ const fastd_method_info_t *method = fastd_handshake_get_method(peer, handshake);
+
#ifdef WITH_DYNAMIC_PEERS
if (fastd_peer_is_dynamic(peer)) {
if (!handle_dynamic(sock, local_addr, remote_addr, peer, handshake, method))
@@ -701,6 +703,11 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const
return;
}
+ if (!method) {
+ fastd_handshake_send_error(sock, local_addr, remote_addr, peer, handshake, REPLY_UNACCEPTABLE_VALUE, RECORD_METHOD_LIST);
+ return;
+ }
+
if (!has_field(handshake, RECORD_RECIPIENT_KEY, PUBLICKEYBYTES)) {
pr_debug("recived handshake reply without recipient key from %P[%I]", peer, remote_addr);
return;