forked from sergeych/crypto2
seal now allows up to 45s in future to tolerate some time difference
This commit is contained in:
1 parent
242cc7d0f5
commit
7fa3ab1ca8
2 files changed
+3
-2
No files matched your search
@@ -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")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user