From 6785e06f2b062616d190b043a18fd40826b21043 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 25 Apr 2014 03:39:56 +0200 Subject: handshake: simplify fastd_handshake_new_reply This will hopefully lead to an async verify implementation... --- src/handshake.c | 4 ++-- src/handshake.h | 2 +- src/protocols/ec25519_fhmqvc/handshake.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/handshake.c b/src/handshake.c index 2cb6cc3..d0d6016 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -143,8 +143,8 @@ fastd_buffer_t fastd_handshake_new_init(size_t tail_space) { return new_handshake(1, NULL, !conf.secure_handshakes, tail_space); } -fastd_buffer_t fastd_handshake_new_reply(const fastd_handshake_t *handshake, const fastd_method_info_t *method, bool with_method_list, size_t tail_space) { - fastd_buffer_t buffer = new_handshake(handshake->type+1, method, with_method_list, tail_space); +fastd_buffer_t fastd_handshake_new_reply(uint8_t type, const fastd_method_info_t *method, bool with_method_list, size_t tail_space) { + fastd_buffer_t buffer = new_handshake(type, method, with_method_list, tail_space); fastd_handshake_add_uint8(&buffer, RECORD_REPLY_CODE, 0); return buffer; } diff --git a/src/handshake.h b/src/handshake.h index a401c2a..7b5ebf3 100644 --- a/src/handshake.h +++ b/src/handshake.h @@ -78,7 +78,7 @@ struct fastd_handshake { fastd_buffer_t fastd_handshake_new_init(size_t tail_space); -fastd_buffer_t fastd_handshake_new_reply(const fastd_handshake_t *handshake, const fastd_method_info_t *method, bool with_method_list, size_t tail_space); +fastd_buffer_t fastd_handshake_new_reply(uint8_t type, const fastd_method_info_t *method, bool with_method_list, size_t tail_space); void fastd_handshake_handle(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, fastd_buffer_t buffer); diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c index 7e893c8..37c753f 100644 --- a/src/protocols/ec25519_fhmqvc/handshake.c +++ b/src/protocols/ec25519_fhmqvc/handshake.c @@ -268,13 +268,13 @@ static void clear_shared_handshake_key(const fastd_peer_t *peer) { } static void respond_handshake(const fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, - const handshake_key_t *handshake_key, const aligned_int256_t *peer_handshake_key, const fastd_handshake_t *handshake, const fastd_method_info_t *method) { + const handshake_key_t *handshake_key, const aligned_int256_t *peer_handshake_key, const fastd_method_info_t *method) { pr_debug("responding handshake with %P[%I]...", peer, remote_addr); if (!update_shared_handshake_key(peer, handshake_key, peer_handshake_key)) return; - fastd_buffer_t buffer = fastd_handshake_new_reply(handshake, method, true, 4*(4+PUBLICKEYBYTES) + 2*(4+HASHBYTES)); + fastd_buffer_t buffer = fastd_handshake_new_reply(2, method, true, 4*(4+PUBLICKEYBYTES) + 2*(4+HASHBYTES)); fastd_handshake_add(&buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, &conf.protocol_config->key.public); fastd_handshake_add(&buffer, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES, &peer->protocol_config->public_key); @@ -334,7 +334,7 @@ static void finish_handshake(fastd_socket_t *sock, const fastd_peer_address_t *l &peer->protocol_config->public_key, &sigma, compat ? NULL : shared_handshake_key.w, handshake_key->serial)) return; - fastd_buffer_t buffer = fastd_handshake_new_reply(handshake, method, false, 4*(4+PUBLICKEYBYTES) + 2*(4+HASHBYTES)); + fastd_buffer_t buffer = fastd_handshake_new_reply(3, method, false, 4*(4+PUBLICKEYBYTES) + 2*(4+HASHBYTES)); fastd_handshake_add(&buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, &conf.protocol_config->key.public); fastd_handshake_add(&buffer, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES, &peer->protocol_config->public_key); @@ -599,7 +599,7 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const peer->last_handshake_response_timeout = fastd_in_seconds(conf.min_handshake_interval); peer->last_handshake_response_address = *remote_addr; - respond_handshake(sock, local_addr, remote_addr, peer, &ctx.protocol_state->handshake_key, &peer_handshake_key, handshake, method); + respond_handshake(sock, local_addr, remote_addr, peer, &ctx.protocol_state->handshake_key, &peer_handshake_key, method); return; } -- cgit v1.2.3