From 7fa3ab1ca8bb4a21ffe2003b5c11e1917898141b Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 3 Feb 2025 17:13:28 +0300 Subject: [PATCH] seal now allows up to 45s in future to tolerate some time difference --- build.gradle.kts | 2 +- src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6700b04..69abd05 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.sergeych" -version = "0.7.1-SNAPSHOT" +version = "0.7.2-SNAPSHOT" repositories { mavenCentral() diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt b/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt index c47e270..f650fd0 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt @@ -6,6 +6,7 @@ import net.sergeych.bipack.BipackEncoder import net.sergeych.bipack.decodeFromBipack import net.sergeych.crypto2.Seal.Companion.create import net.sergeych.utools.now +import kotlin.time.Duration.Companion.seconds /** * Extended public-key signature. @@ -67,7 +68,7 @@ class Seal( */ fun verify(message: UByteArray) { val n = now() - if (createdAt > n) throw IllegalSignatureException("signature's timestamp in the future") + if (createdAt - 45.seconds > n) throw IllegalSignatureException("signature's timestamp in the future: $createdAt / $n") expiresAt?.let { if (n >= it) throw ExpiredSignatureException("signature expired at $it") }