summaryrefslogtreecommitdiffstats
path: root/src/method_xsalsa20_poly1305.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/method_xsalsa20_poly1305.c')
-rw-r--r--src/method_xsalsa20_poly1305.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/method_xsalsa20_poly1305.c b/src/method_xsalsa20_poly1305.c
index d0d31f4..395f322 100644
--- a/src/method_xsalsa20_poly1305.c
+++ b/src/method_xsalsa20_poly1305.c
@@ -129,6 +129,14 @@ static bool method_session_want_refresh(fastd_context_t *ctx, fastd_method_sessi
return timespec_after(&ctx->now, &session->refresh_after);
}
+static void method_session_superseded(fastd_context_t *ctx, fastd_method_session_state_t *session) {
+ struct timespec valid_max = ctx->now;
+ valid_max.tv_sec += ctx->conf->key_valid_old;
+
+ if (timespec_after(&session->valid_till, &valid_max))
+ session->valid_till = valid_max;
+}
+
static void method_session_free(fastd_context_t *ctx UNUSED, fastd_method_session_state_t *session) {
if(session) {
secure_memzero(session, sizeof(fastd_method_session_state_t));
@@ -231,6 +239,7 @@ const fastd_method_t fastd_method_xsalsa20_poly1305 = {
.session_is_valid = method_session_is_valid,
.session_is_initiator = method_session_is_initiator,
.session_want_refresh = method_session_want_refresh,
+ .session_superseded = method_session_superseded,
.session_free = method_session_free,
.encrypt = method_encrypt,