forked from openwallet-foundation/askar
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: All tests passing on all platforms
Signed-off-by: KolbyRKunz <[email protected]>
- Loading branch information
1 parent
58dbe2d
commit a7307d8
Showing
7 changed files
with
509 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package askar | ||
|
||
import aries_askar.AskarKeyAlg | ||
import askar.crypto.Jwk | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
@Serializable | ||
class ProtectedJson(val alg: String, val enc: String, val apu: String, val apv: String, val epk: Jwk) { | ||
|
||
constructor(alg: String, enc: AskarKeyAlg, apu: String, apv: String, epk: Jwk) : this(alg, enc.name, apu, apv, epk) | ||
|
||
override fun toString(): String { | ||
return Json.encodeToString(this) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
//import askar.crypto.CryptoBox | ||
//import askar.crypto.Key | ||
//import askar.enums.KeyAlgs | ||
//import kotlinx.cinterop.toKString | ||
//import kotlin.test.Test | ||
//import kotlin.test.assertEquals | ||
// | ||
//class CryptoBoxTest { | ||
// | ||
// @Test | ||
// fun seal() { | ||
// val x25519Key = Key.generate(KeyAlgs.X25519) | ||
// | ||
// val message = "foobar" | ||
// val sealed = CryptoBox.seal(x25519Key, message) | ||
// | ||
// val opened = CryptoBox.sealOpen(x25519Key, sealed) | ||
// assertEquals(message, opened.toKString()) | ||
// | ||
// x25519Key.handle().free() | ||
// } | ||
//} | ||
import aries_askar.AskarKeyAlg | ||
import askar.crypto.CryptoBox | ||
import askar.crypto.Key | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class CryptoBoxTest { | ||
|
||
@Test | ||
fun seal() { | ||
val x25519Key = Key.generate(AskarKeyAlg.X25519) | ||
|
||
val message = "foobar" | ||
val sealed = CryptoBox.seal(x25519Key, message) | ||
|
||
val opened = CryptoBox.sealOpen(x25519Key, sealed) | ||
assertEquals(message, opened.decodeToString()) | ||
|
||
x25519Key.handle().destroy() | ||
} | ||
} |
Oops, something went wrong.