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 })
|
||||
|
||||
Reference in new issue
Block a user