Compare commits
No commits in common. "7fa3ab1ca8bb4a21ffe2003b5c11e1917898141b" and "db7453fbb2e20457730169c03af379a97b1f97ae" have entirely different histories.
7fa3ab1ca8
...
db7453fbb2
@ -9,7 +9,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "net.sergeych"
|
group = "net.sergeych"
|
||||||
version = "0.7.2-SNAPSHOT"
|
version = "0.7.1-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -6,7 +6,6 @@ import net.sergeych.bipack.BipackEncoder
|
|||||||
import net.sergeych.bipack.decodeFromBipack
|
import net.sergeych.bipack.decodeFromBipack
|
||||||
import net.sergeych.crypto2.Seal.Companion.create
|
import net.sergeych.crypto2.Seal.Companion.create
|
||||||
import net.sergeych.utools.now
|
import net.sergeych.utools.now
|
||||||
import kotlin.time.Duration.Companion.seconds
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended public-key signature.
|
* Extended public-key signature.
|
||||||
@ -68,7 +67,7 @@ class Seal(
|
|||||||
*/
|
*/
|
||||||
fun verify(message: UByteArray) {
|
fun verify(message: UByteArray) {
|
||||||
val n = now()
|
val n = now()
|
||||||
if (createdAt - 45.seconds > n) throw IllegalSignatureException("signature's timestamp in the future: $createdAt / $n")
|
if (createdAt > n) throw IllegalSignatureException("signature's timestamp in the future")
|
||||||
expiresAt?.let {
|
expiresAt?.let {
|
||||||
if (n >= it) throw ExpiredSignatureException("signature expired at $it")
|
if (n >= it) throw ExpiredSignatureException("signature expired at $it")
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
import kotlinx.coroutines.test.runTest
|
|
||||||
import net.sergeych.bintools.toDump
|
|
||||||
import net.sergeych.bipack.BipackEncoder
|
|
||||||
import net.sergeych.crypto2.BinaryId
|
import net.sergeych.crypto2.BinaryId
|
||||||
import net.sergeych.crypto2.ByteChunk
|
|
||||||
import net.sergeych.crypto2.initCrypto
|
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertContentEquals
|
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class BinaryIdTest {
|
class BinaryIdTest {
|
||||||
@ -19,16 +13,4 @@ class BinaryIdTest {
|
|||||||
assertEquals(4, a.id.size)
|
assertEquals(4, a.id.size)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testByteChunkSizes() = runTest {
|
|
||||||
initCrypto()
|
|
||||||
val x = ByteChunk.random(3)
|
|
||||||
assertEquals(3, x.data.size)
|
|
||||||
assertEquals(3, x.toByteArray().size)
|
|
||||||
assertEquals(3, x.toUByteArray().size)
|
|
||||||
println(BipackEncoder.encode(x).toDump())
|
|
||||||
assertEquals(4, BipackEncoder.encode(x).size)
|
|
||||||
assertContentEquals(BipackEncoder.encode(x.toByteArray()), BipackEncoder.encode(x))
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user