summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);