diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-02 03:52:23 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-02 03:52:23 +0200 |
commit | 77520caad8302266537e87104f6496040fc98bb4 (patch) | |
tree | b4cb2d8eb098ab4c0f8223ce9774e90ca93f799d /src | |
parent | 7836725abdfa6c30d02b9280526d5373e4466e69 (diff) | |
download | fastd-0.1.tar fastd-0.1.zip |
ecfxp: don't send refresh handshakes from both sidesv0.1
Diffstat (limited to 'src')
-rw-r--r-- | src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c | 16 |
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); |