summaryrefslogtreecommitdiffstats
path: root/src/protocols
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-10-31 02:35:29 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-10-31 02:35:29 +0100
commit6e7882ebd4ed84ed371739970aaaf5d37f856014 (patch)
treeef849e866d30bc2c334e60692b0050880f906ca8 /src/protocols
parent39db0b827875a70e4af41a5003dd1b9fbcfb5f37 (diff)
downloadfastd-6e7882ebd4ed84ed371739970aaaf5d37f856014.tar
fastd-6e7882ebd4ed84ed371739970aaaf5d37f856014.zip
ec25519-fhmqvc: some more refactoring
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h25
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c2
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.h59
-rw-r--r--src/protocols/ec25519_fhmqvc/state.c2
4 files changed, 61 insertions, 27 deletions
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
index c11a995..4cd7217 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
@@ -45,23 +45,6 @@ struct fastd_protocol_config {
keypair_t key;
};
-typedef struct handshake_key {
- uint64_t serial;
- struct timespec preferred_till;
- struct timespec valid_till;
-
- /* keypair used as initiator */
- keypair_t key1;
-
- /* keypair used as responder */
- keypair_t key2;
-} handshake_key_t;
-
-struct fastd_protocol_state {
- handshake_key_t prev_handshake_key;
- handshake_key_t handshake_key;
-};
-
struct fastd_protocol_peer_config {
aligned_int256_t public_key;
};
@@ -116,14 +99,6 @@ static inline void hexdump(char out[65], const unsigned char d[32]) {
}
-static inline bool is_handshake_key_valid(fastd_context_t *ctx, const handshake_key_t *handshake_key) {
- return timespec_after(&handshake_key->valid_till, &ctx->now);
-}
-
-static inline bool is_handshake_key_preferred(fastd_context_t *ctx, const handshake_key_t *handshake_key) {
- return timespec_after(&handshake_key->preferred_till, &ctx->now);
-}
-
static inline bool is_session_valid(fastd_context_t *ctx, const protocol_session_t *session) {
return (session->method && session->method->session_is_valid(ctx, session->method_state));
}
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index 43f5797..c9dbcf1 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -24,7 +24,7 @@
*/
-#include "ec25519_fhmqvc.h"
+#include "handshake.h"
#include "../../handshake.h"
diff --git a/src/protocols/ec25519_fhmqvc/handshake.h b/src/protocols/ec25519_fhmqvc/handshake.h
new file mode 100644
index 0000000..835b041
--- /dev/null
+++ b/src/protocols/ec25519_fhmqvc/handshake.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (c) 2012-2013, Matthias Schiffer <mschiffer@universe-factory.net>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#ifndef _FASTD_PROTOCOL_EC25519_FHMQVC_HANDSHAKE_H_
+#define _FASTD_PROTOCOL_EC25519_FHMQVC_HANDSHAKE_H_
+
+#include "ec25519_fhmqvc.h"
+
+
+typedef struct handshake_key {
+ uint64_t serial;
+ struct timespec preferred_till;
+ struct timespec valid_till;
+
+ /* keypair used as initiator */
+ keypair_t key1;
+
+ /* keypair used as responder */
+ keypair_t key2;
+} handshake_key_t;
+
+struct fastd_protocol_state {
+ handshake_key_t prev_handshake_key;
+ handshake_key_t handshake_key;
+};
+
+
+static inline bool is_handshake_key_valid(fastd_context_t *ctx, const handshake_key_t *handshake_key) {
+ return timespec_after(&handshake_key->valid_till, &ctx->now);
+}
+
+static inline bool is_handshake_key_preferred(fastd_context_t *ctx, const handshake_key_t *handshake_key) {
+ return timespec_after(&handshake_key->preferred_till, &ctx->now);
+}
+
+#endif /* _FASTD_PROTOCOL_EC25519_FHMQVC_HANDSHAKE_H_ */
diff --git a/src/protocols/ec25519_fhmqvc/state.c b/src/protocols/ec25519_fhmqvc/state.c
index e5ccb8d..fb00503 100644
--- a/src/protocols/ec25519_fhmqvc/state.c
+++ b/src/protocols/ec25519_fhmqvc/state.c
@@ -24,7 +24,7 @@
*/
-#include "ec25519_fhmqvc.h"
+#include "handshake.h"
static void init_protocol_state(fastd_context_t *ctx) {