forked from sergeych/crypto2
fix #5 Just created container is decrypted and can be used to add keys, etc.
This commit is contained in:
1 parent
c0317dda47
commit
a1561bc280
3 files changed
+86
-39
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.sergeych.crypto2.*
|
||||
import kotlin.test.*
|
||||
|
||||
@@ -12,9 +14,9 @@ class ContainerTest {
|
||||
val data = "sergeych, ohm many.".encodeToUByteArray()
|
||||
|
||||
val c = Container.createWith(data, syk1)
|
||||
assertFalse { c.isDecrypted }
|
||||
assertTrue { c.isDecrypted }
|
||||
val c1 = Container.decode(c.encoded)
|
||||
assertFalse { c.isDecrypted }
|
||||
assertFalse { c1.isDecrypted }
|
||||
assertIs<Container.Single>(c)
|
||||
|
||||
assertNull(c1.decryptWith(syk2))
|
||||
@@ -33,9 +35,9 @@ class ContainerTest {
|
||||
val data = "sergeych, ohm many.".encodeToUByteArray()
|
||||
|
||||
val c = Container.createWith(data, p1.secretKey to p2.publicKey)
|
||||
assertFalse { c.isDecrypted }
|
||||
assertTrue { c.isDecrypted }
|
||||
val c1 = Container.decode(c.encoded)
|
||||
assertFalse { c.isDecrypted }
|
||||
assertFalse { c1.isDecrypted }
|
||||
assertIs<Container.Single>(c)
|
||||
|
||||
assertNull(c1.decryptWith(p3.secretKey))
|
||||
@@ -54,9 +56,10 @@ class ContainerTest {
|
||||
val data = "sergeych, ohm many.".encodeToUByteArray()
|
||||
|
||||
val c = Container.create(data) { key(p2.publicKey) }
|
||||
assertFalse { c.isDecrypted }
|
||||
assertTrue { c.isDecrypted }
|
||||
val c1 = Container.decode(c.encoded)
|
||||
assertFalse { c.isDecrypted }
|
||||
println(Json.encodeToString(c1))
|
||||
assertFalse { c1.isDecrypted }
|
||||
assertIs<Container.Single>(c)
|
||||
|
||||
assertNull(c1.decryptWith(p3.secretKey))
|
||||
|
||||
Reference in new issue
Block a user