adopted crypto2 0.4.*
This commit is contained in:
1 parent
38fbca955c
commit
5df6143c75
14 files changed
+46
-57
No files matched your search
@@ -1,5 +1,8 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto2.*
|
||||
import net.sergeych.crypto2.IllegalSignatureException
|
||||
import net.sergeych.crypto2.SealedBox
|
||||
import net.sergeych.crypto2.SigningSecretKey
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.kiloparsec.encodeToUByteArray
|
||||
import net.sergeych.utools.pack
|
||||
import net.sergeych.utools.unpack
|
||||
@@ -9,11 +12,11 @@ class KeysTest {
|
||||
@Test
|
||||
fun testCreationAndMap() = runTest {
|
||||
initCrypto()
|
||||
val (stk,pbk) = SigningKey.pair()
|
||||
val (stk,pbk) = SigningSecretKey.generatePair()
|
||||
|
||||
val x = mapOf( stk to "STK!", pbk to "PBK!")
|
||||
assertEquals("STK!", x[stk])
|
||||
val s1 = SigningKey.Secret(stk.packed)
|
||||
val s1 = SigningSecretKey(stk.keyBytes)
|
||||
assertEquals(stk, s1)
|
||||
assertEquals("STK!", x[s1])
|
||||
assertEquals("PBK!", x[pbk])
|
||||
@@ -25,8 +28,8 @@ class KeysTest {
|
||||
|
||||
data1[0] = 0x01u
|
||||
assertFalse(s.isValid(data1))
|
||||
val p2 = SigningKey.pair()
|
||||
val p3 = SigningKey.pair()
|
||||
val p2 = SigningSecretKey.generatePair()
|
||||
val p3 = SigningSecretKey.generatePair()
|
||||
|
||||
val ms = SealedBox(data, s1) + p2.secretKey
|
||||
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
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
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ToolsTest {
|
||||
@Test
|
||||
fun testContrails() = runTest {
|
||||
initCrypto()
|
||||
val c = createContrail(ubyteArrayOf(1u, 2u, 3u, 4u, 5u))
|
||||
assertEquals(134u, c[0])
|
||||
assertTrue { isValidContrail(c) }
|
||||
c[2] = 11u
|
||||
assertFalse { isValidContrail(c) }
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun testRemoceCmd() {
|
||||
// assertEquals("lalala", removeCmd("lalala"))
|
||||
|
||||
@@ -3,7 +3,8 @@ import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.channels.SendChannel
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto2.SigningKey
|
||||
import net.sergeych.crypto2.SigningSecretKey
|
||||
import net.sergeych.crypto2.VerifyingPublicKey
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.kiloparsec.*
|
||||
import net.sergeych.mp_logger.Log
|
||||
@@ -167,7 +168,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, SigningKey.Public?>()
|
||||
val cmdGetClientId by command<Unit, VerifyingPublicKey?>()
|
||||
val cmdChainCallServer1 by command<String, String>()
|
||||
val cmdChainCallClient1 by command<String, String>()
|
||||
val cmdChainCallServer2 by command<String, String>()
|
||||
@@ -176,8 +177,8 @@ class TransportTest {
|
||||
// Log.defaultLevel = Log.Level.DEBUG
|
||||
val (d1, d2) = createTestDevice()
|
||||
|
||||
val serverId = SigningKey.pair()
|
||||
val clientId = SigningKey.pair()
|
||||
val serverId = SigningSecretKey.generatePair()
|
||||
val clientId = SigningSecretKey.generatePair()
|
||||
|
||||
val cmdException by command<Unit, Unit>()
|
||||
val cmdRemoteExceptionTest by command<Unit, String>()
|
||||
|
||||
Reference in new issue
Block a user