refactoring signing keys
This commit is contained in:
1 parent
e619b45485
commit
7042e41d70
23 files changed
+221
-76
No files matched your search
@@ -2,7 +2,7 @@ import com.ionspin.kotlin.crypto.secretbox.SecretBox
|
||||
import com.ionspin.kotlin.crypto.util.decodeFromUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto.*
|
||||
import net.sergeych.crypto2.*
|
||||
import net.sergeych.utools.pack
|
||||
import net.sergeych.utools.unpack
|
||||
import kotlin.test.*
|
||||
@@ -11,11 +11,11 @@ class KeysTest {
|
||||
@Test
|
||||
fun testCreationAndMap() = runTest {
|
||||
initCrypto()
|
||||
val (stk,pbk) = Key.Signing.pair()
|
||||
val (stk,pbk) = SigningKey.Secret.pair()
|
||||
|
||||
val x = mapOf( stk to "STK!", pbk to "PBK!")
|
||||
assertEquals("STK!", x[stk])
|
||||
val s1 = Key.Signing(stk.packed)
|
||||
val s1 = SigningKey.Secret(stk.packed)
|
||||
assertEquals(stk, s1)
|
||||
assertEquals("STK!", x[s1])
|
||||
assertEquals("PBK!", x[pbk])
|
||||
@@ -27,8 +27,8 @@ class KeysTest {
|
||||
|
||||
data1[0] = 0x01u
|
||||
assertFalse(s.verify(data1))
|
||||
val p2 = Key.Signing.pair()
|
||||
val p3 = Key.Signing.pair()
|
||||
val p2 = SigningKey.Secret.pair()
|
||||
val p3 = SigningKey.Secret.pair()
|
||||
|
||||
val ms = SignedBox(data, s1) + p2.signing
|
||||
|
||||
@@ -36,8 +36,8 @@ class KeysTest {
|
||||
val ms1 = unpack<SignedBox>(pack(ms))
|
||||
assertContentEquals(data, ms1.message)
|
||||
assertTrue(pbk in ms1)
|
||||
assertTrue(p2.verifying in ms1)
|
||||
assertTrue(p3.verifying !in ms1)
|
||||
assertTrue(p2.aPublic in ms1)
|
||||
assertTrue(p3.aPublic !in ms1)
|
||||
|
||||
assertThrows<IllegalSignatureException> {
|
||||
unpack<SignedBox>(pack(ms).also { it[3] = 1u })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.datetime.Instant
|
||||
import net.sergeych.crypto.initCrypto
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.kiloparsec.Transport
|
||||
import net.sergeych.utools.nowToSeconds
|
||||
import net.sergeych.utools.pack
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto.createContrail
|
||||
import net.sergeych.crypto.initCrypto
|
||||
import net.sergeych.crypto.isValidContrail
|
||||
import net.sergeych.crypto2.createContrail
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.crypto2.isValidContrail
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
|
||||
@@ -4,8 +4,8 @@ import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.channels.SendChannel
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto.Key
|
||||
import net.sergeych.crypto.initCrypto
|
||||
import net.sergeych.crypto2.SigningKey
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.kiloparsec.*
|
||||
import net.sergeych.mp_logger.Log
|
||||
import kotlin.test.*
|
||||
@@ -162,7 +162,7 @@ class TransportTest {
|
||||
val cmdPing by command<String, String>()
|
||||
val cmdPush by command<String, String>()
|
||||
val cmdGetToken by command<Unit, UByteArray>()
|
||||
val cmdGetClientId by command<Unit, Key.Verifying?>()
|
||||
val cmdGetClientId by command<Unit, SigningKey.Public?>()
|
||||
val cmdChainCallServer1 by command<String, String>()
|
||||
val cmdChainCallClient1 by command<String, String>()
|
||||
val cmdChainCallServer2 by command<String, String>()
|
||||
@@ -171,8 +171,8 @@ class TransportTest {
|
||||
// Log.defaultLevel = Log.Level.DEBUG
|
||||
val (d1, d2) = createTestDevice()
|
||||
|
||||
val serverId = Key.Signing.pair()
|
||||
val clientId = Key.Signing.pair()
|
||||
val serverId = SigningKey.Secret.pair()
|
||||
val clientId = SigningKey.Secret.pair()
|
||||
|
||||
val serverInterface = KiloInterface<String>().apply {
|
||||
on(cmdPing) {
|
||||
|
||||
Reference in new issue
Block a user