summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-02 03:52:23 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-02 03:52:23 +0200
commit77520caad8302266537e87104f6496040fc98bb4 (patch)
treeb4cb2d8eb098ab4c0f8223ce9774e90ca93f799d
parent7836725abdfa6c30d02b9280526d5373e4466e69 (diff)
downloadfastd-77520caad8302266537e87104f6496040fc98bb4.tar
fastd-77520caad8302266537e87104f6496040fc98bb4.zip
ecfxp: don't send refresh handshakes from both sidesv0.1
-rw-r--r--src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
index 3c4b0f6..df94d14 100644
--- a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
+++ b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
@@ -154,21 +154,25 @@ static inline void increment_nonce(uint8_t nonce[NONCEBYTES]) {
}
}
-static inline bool is_session_valid(fastd_context *ctx, protocol_session *session) {
+static inline bool is_session_valid(fastd_context *ctx, const protocol_session *session) {
return timespec_after(&session->valid_till, &ctx->now);
}
-static inline bool is_session_zero(fastd_context *ctx, protocol_session *session) {
+static inline bool is_session_zero(fastd_context *ctx, const protocol_session *session) {
return (session->valid_till.tv_sec == 0);
}
+static inline bool is_session_initiator(const protocol_session *session) {
+ return (session->send_nonce[0] & 1);
+}
+
static inline void check_session_refresh(fastd_context *ctx, fastd_peer *peer) {
protocol_session *session = &peer->protocol_state->session;
- if (!session->refreshing && timespec_after(&ctx->now, &session->refresh_after)) {
+ if (is_session_initiator(session) && !session->refreshing && timespec_after(&ctx->now, &session->refresh_after)) {
pr_debug(ctx, "refreshing session with %P", peer);
session->refreshing = true;
- fastd_task_schedule_handshake(ctx, peer, fastd_rand(ctx, 0, 10000));
+ fastd_task_schedule_handshake(ctx, peer, 0);
}
}
@@ -417,10 +421,6 @@ static void establish(fastd_context *ctx, fastd_peer *peer, const fastd_peer_con
protocol_send(ctx, peer, fastd_buffer_alloc(0, protocol_min_encrypt_head_space(ctx), 0));
}
-static inline bool is_session_initiator(const protocol_session *session) {
- return (session->send_nonce[0] & 1);
-}
-
static void finish_handshake(fastd_context *ctx, fastd_peer *peer, const fastd_handshake *handshake) {
pr_debug(ctx, "finishing handshake with %P...", peer);