Remove coroutines
This commit is contained in:
parent
8625002ea4
commit
71ec5b7585
@ -23,7 +23,7 @@ object Versions {
|
||||
val dokkaPlugin = "0.11.0-dev-44"
|
||||
val taskTreePlugin = "1.5"
|
||||
|
||||
val kotlinBigNumVersion = "0.1.6-1.4-M2-2-SNAPSHOT"
|
||||
val kotlinBigNumVersion = "0.1.6-1.4-M2-3-SNAPSHOT"
|
||||
|
||||
val lazySodium = "4.2.6"
|
||||
val jna = "5.5.0"
|
||||
|
@ -69,7 +69,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
//Not supported in OFFICIAL coroutines at the moment
|
||||
linuxArm64() {
|
||||
binaries {
|
||||
staticLib {
|
||||
@ -77,7 +76,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
//Not supported in OFFICAL coroutines at the moment
|
||||
linuxArm32Hfp() {
|
||||
binaries {
|
||||
staticLib {
|
||||
|
@ -131,7 +131,6 @@ kotlin {
|
||||
}
|
||||
|
||||
|
||||
//Not supported in OFFICIAL coroutines at the moment (we're running a custom build)
|
||||
runningOnLinuxArm64 {
|
||||
println("Configuring Linux Arm 64 targets")
|
||||
|
||||
@ -249,7 +248,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Common.stdLib))
|
||||
implementation(kotlin(Deps.Common.test))
|
||||
implementation(Deps.Common.coroutines)
|
||||
implementation(Deps.Common.kotlinBigNum)
|
||||
api(project(Deps.Common.apiProject))
|
||||
}
|
||||
@ -262,7 +260,6 @@ kotlin {
|
||||
}
|
||||
|
||||
val nativeDependencies = independentDependencyBlock {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
|
||||
val nativeMain by creating {
|
||||
@ -281,7 +278,6 @@ kotlin {
|
||||
kotlin.setSrcDirs(emptySet<String>())
|
||||
}
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,7 +416,6 @@ kotlin {
|
||||
implementation(kotlin(Deps.Jvm.stdLib))
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesCore)
|
||||
|
||||
//lazysodium
|
||||
implementation(Deps.Jvm.Delegated.lazysodium)
|
||||
@ -431,20 +426,17 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesTest)
|
||||
implementation(kotlin(Deps.Jvm.reflection))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Js.stdLib))
|
||||
implementation(Deps.Js.coroutines)
|
||||
implementation(npm(Deps.Js.Npm.libsodiumWrappers.first, Deps.Js.Npm.libsodiumWrappers.second))
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(Deps.Js.coroutines)
|
||||
implementation(kotlin(Deps.Js.test))
|
||||
implementation(npm(Deps.Js.Npm.libsodiumWrappers.first, Deps.Js.Npm.libsodiumWrappers.second))
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ object Crypto {
|
||||
}
|
||||
|
||||
override fun createMultipartDecryptor(key: SymmetricKey, header: MultipartEncryptionHeader) : MultipartAuthenticatedDecryption {
|
||||
val decryptor = XChaCha20Poly1305Delegated(key.value, header.nonce)
|
||||
val decryptor = XChaCha20Poly1305Delegated()
|
||||
decryptor.initializeForDecryption(key.value, header.nonce)
|
||||
return MultipartAuthenticatedDecryptor(decryptor)
|
||||
}
|
||||
|
||||
@ -174,8 +175,11 @@ object Crypto {
|
||||
|
||||
class MultipartAuthenticatedEncryptor internal constructor(val key : SymmetricKey) : MultipartAuthenticatedEncryption {
|
||||
|
||||
val header = MultipartEncryptionHeader(SRNG.getRandomBytes(24))
|
||||
val primitive = XChaCha20Poly1305Delegated(key.value, header.nonce)
|
||||
val header : MultipartEncryptionHeader
|
||||
val primitive = XChaCha20Poly1305Delegated()
|
||||
init {
|
||||
header = MultipartEncryptionHeader(primitive.initializeForEncryption(key.value))
|
||||
}
|
||||
|
||||
override fun startEncryption(): MultipartEncryptionHeader {
|
||||
return header
|
||||
|
@ -6,13 +6,14 @@ package com.ionspin.kotlin.crypto.authenticated
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 14-Jun-2020
|
||||
*/
|
||||
expect class XChaCha20Poly1305Delegated constructor(key: UByteArray, nonce: UByteArray) {
|
||||
internal constructor(key: UByteArray, nonce: UByteArray, testState : UByteArray, testHeader: UByteArray)
|
||||
expect class XChaCha20Poly1305Delegated internal constructor() {
|
||||
internal constructor(key: UByteArray, testState : UByteArray, testHeader: UByteArray)
|
||||
companion object {
|
||||
fun encrypt(key: UByteArray, nonce: UByteArray, message: UByteArray, additionalData: UByteArray) : UByteArray
|
||||
fun decrypt(key: UByteArray, nonce: UByteArray, ciphertext: UByteArray, additionalData: UByteArray) : UByteArray
|
||||
}
|
||||
|
||||
fun initializeForEncryption(key: UByteArray) : UByteArray
|
||||
fun initializeForDecryption(key: UByteArray, header: UByteArray)
|
||||
fun encrypt(data: UByteArray, additionalData: UByteArray = ubyteArrayOf()) : UByteArray
|
||||
fun decrypt(data: UByteArray, additionalData: UByteArray = ubyteArrayOf()) : UByteArray
|
||||
|
||||
|
@ -209,7 +209,7 @@ class XChaCha20Poly1305Test {
|
||||
0xDEU, 0xFBU, 0x5CU, 0x7FU, 0x1CU, 0x26U, 0x32U, 0x2CU, 0x51U, 0xF6U, 0xEFU, 0xC6U, 0x34U, 0xC4U, 0xACU, 0x6CU,
|
||||
0xE8U, 0xF9U, 0x4BU, 0xABU, 0xA3U,
|
||||
)
|
||||
val xcha = XChaCha20Poly1305Delegated(key, ubyteArrayOf(), state, header)
|
||||
val xcha = XChaCha20Poly1305Delegated(key, state, header)
|
||||
val data = UByteArray(100) { 0U }
|
||||
val result = xcha.encrypt(data)
|
||||
// assertTrue {
|
||||
|
@ -22,7 +22,8 @@ class Sha256Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun statelessSimpleTest() {
|
||||
fun statelessSimpleTest() = testBlocking {
|
||||
Initializer.initialize()
|
||||
val expected = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
|
||||
val result = CryptoPrimitives.Sha256.stateless("test".encodeToUByteArray()).toHexString()
|
||||
// println("Result: $result")
|
||||
@ -32,7 +33,8 @@ class Sha256Test {
|
||||
//This is a bad test since it's not larger than one block
|
||||
//but for now I'm testing that the platform library is being correctly called
|
||||
@Test
|
||||
fun updateableSimpleTest() {
|
||||
fun updateableSimpleTest() = testBlocking {
|
||||
Initializer.initialize()
|
||||
val expected = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
|
||||
val sha256 = CryptoPrimitives.Sha256.updateable()
|
||||
sha256.update("t".encodeToUByteArray())
|
||||
|
@ -22,7 +22,8 @@ class Sha512Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun statelessSimpleTest() {
|
||||
fun statelessSimpleTest() = testBlocking {
|
||||
Initializer.initialize()
|
||||
val expected = "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67" +
|
||||
"b143732c304cc5fa9ad8e6f57f50028a8ff"
|
||||
val result = CryptoPrimitives.Sha512.stateless("test".encodeToUByteArray()).toHexString()
|
||||
@ -33,7 +34,8 @@ class Sha512Test {
|
||||
//This is a bad test since it's not larger than one block
|
||||
//but for now I'm testing that the platform library is being correctly called
|
||||
@Test
|
||||
fun updateableSimpleTest() {
|
||||
fun updateableSimpleTest() = testBlocking {
|
||||
Initializer.initialize()
|
||||
val expected = "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67" +
|
||||
"b143732c304cc5fa9ad8e6f57f50028a8ff"
|
||||
val sha512 = CryptoPrimitives.Sha512.updateable()
|
||||
|
@ -16,11 +16,20 @@
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.coroutines.startCoroutine
|
||||
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
expect fun testBlocking(block : suspend () -> Unit)
|
||||
fun testBlocking(block : suspend () -> Unit) {
|
||||
val continuation = Continuation<Unit>(EmptyCoroutineContext) {
|
||||
//Do nothing
|
||||
println("Done")
|
||||
}
|
||||
block.startCoroutine(continuation)
|
||||
}
|
||||
|
@ -44,7 +44,12 @@ interface JsSodiumInterface {
|
||||
fun crypto_aead_xchacha20poly1305_ietf_decrypt(secretNonce: Uint8Array, ciphertext: Uint8Array, additionalData: Uint8Array, nonce: Uint8Array, key: Uint8Array) : Uint8Array
|
||||
|
||||
//XChaCha20Poly1305
|
||||
//encrypt
|
||||
fun crypto_secretstream_xchacha20poly1305_init_push(header: Uint8Array) : dynamic
|
||||
fun crypto_secretstream_xchacha20poly1305_push(state: dynamic, message: Uint8Array, additionalData: Uint8Array, tag: Char) : Uint8Array
|
||||
|
||||
//decrypt
|
||||
fun crypto_secretstream_xchacha20poly1305_init_pull(header: Uint8Array, key: Uint8Array) : dynamic
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.khronos.webgl.Uint8Array
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 14-Jun-2020
|
||||
*/
|
||||
actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonce: UByteArray) {
|
||||
actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
actual companion object {
|
||||
actual fun encrypt(
|
||||
key: UByteArray,
|
||||
@ -51,16 +51,25 @@ actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonc
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
// val state =
|
||||
var state : dynamic = null
|
||||
|
||||
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
|
||||
val stateAndHeader = getSodium().crypto_secretstream_xchacha20poly1305_init_push(key.toUInt8Array())
|
||||
val state = stateAndHeader.state
|
||||
val header = stateAndHeader.header
|
||||
console.log(state)
|
||||
console.log(header)
|
||||
return header
|
||||
}
|
||||
|
||||
actual fun initializeForDecryption(key: UByteArray, header: UByteArray) {
|
||||
}
|
||||
|
||||
internal actual constructor(
|
||||
key: UByteArray,
|
||||
nonce: UByteArray,
|
||||
testState: UByteArray,
|
||||
testHeader: UByteArray
|
||||
) : this(key, nonce) {
|
||||
) : this() {
|
||||
|
||||
}
|
||||
|
||||
@ -73,4 +82,6 @@ actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonc
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,14 @@
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.promise
|
||||
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend ()-> Unit) : dynamic = GlobalScope.promise { block() }
|
||||
//
|
||||
//import kotlinx.coroutines.GlobalScope
|
||||
//import kotlinx.coroutines.promise
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Created by Ugljesa Jovanovic
|
||||
// * ugljesa.jovanovic@ionspin.com
|
||||
// * on 20-Jul-2019
|
||||
// */
|
||||
//actual fun testBlocking(block: suspend ()-> Unit) : dynamic = GlobalScope.promise { block() }
|
||||
|
@ -7,7 +7,7 @@ import com.goterl.lazycode.lazysodium.SodiumJava
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 14-Jun-2020
|
||||
*/
|
||||
actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonce: UByteArray) {
|
||||
actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
actual companion object {
|
||||
actual fun encrypt(
|
||||
key: UByteArray,
|
||||
@ -56,13 +56,19 @@ actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonc
|
||||
|
||||
internal actual constructor(
|
||||
key: UByteArray,
|
||||
nonce: UByteArray,
|
||||
testState: UByteArray,
|
||||
testHeader: UByteArray
|
||||
) : this(key, ubyteArrayOf()) {
|
||||
) : this() {
|
||||
|
||||
}
|
||||
|
||||
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
|
||||
TODO()
|
||||
}
|
||||
|
||||
actual fun initializeForDecryption(key: UByteArray, header: UByteArray) {
|
||||
}
|
||||
|
||||
actual fun encrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
@ -72,4 +78,6 @@ actual class XChaCha20Poly1305Delegated actual constructor(key: UByteArray, nonc
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,12 +16,19 @@
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.coroutines.startCoroutine
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
||||
//actual fun testBlocking(block: suspend () -> Unit) {
|
||||
// val continuation = Continuation<Unit>(EmptyCoroutineContext) {
|
||||
// println("Done")
|
||||
// }
|
||||
// block.startCoroutine(continuation)
|
||||
//
|
||||
//}
|
||||
|
@ -10,7 +10,7 @@ import platform.posix.malloc
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 14-Jun-2020
|
||||
*/
|
||||
actual class XChaCha20Poly1305Delegated actual constructor(val key: UByteArray, val nonce: UByteArray) {
|
||||
actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
actual companion object {
|
||||
actual fun encrypt(
|
||||
key: UByteArray,
|
||||
@ -61,13 +61,18 @@ actual class XChaCha20Poly1305Delegated actual constructor(val key: UByteArray,
|
||||
}
|
||||
}
|
||||
|
||||
var state =
|
||||
malloc(crypto_secretstream_xchacha20poly1305_state.size.convert())!!
|
||||
.reinterpret<crypto_secretstream_xchacha20poly1305_state>()
|
||||
.pointed
|
||||
|
||||
val header = UByteArray(crypto_secretstream_xchacha20poly1305_HEADERBYTES.toInt()) { 0U }
|
||||
|
||||
actual internal constructor(
|
||||
key: UByteArray,
|
||||
nonce: UByteArray,
|
||||
testState: UByteArray,
|
||||
testHeader: UByteArray
|
||||
) : this(key, nonce) {
|
||||
) : this() {
|
||||
val pointer = state.ptr.reinterpret<UByteVar>()
|
||||
for (i in 0 until crypto_secretstream_xchacha20poly1305_state.size.toInt()) {
|
||||
pointer[i] = testState[i]
|
||||
@ -81,14 +86,9 @@ actual class XChaCha20Poly1305Delegated actual constructor(val key: UByteArray,
|
||||
println("header after setting-----------")
|
||||
}
|
||||
|
||||
var state =
|
||||
malloc(crypto_secretstream_xchacha20poly1305_state.size.convert())!!
|
||||
.reinterpret<crypto_secretstream_xchacha20poly1305_state>()
|
||||
.pointed
|
||||
|
||||
val header = UByteArray(crypto_secretstream_xchacha20poly1305_HEADERBYTES.toInt()) { 0U }
|
||||
|
||||
init {
|
||||
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
|
||||
val pinnedHeader = header.pin()
|
||||
crypto_secretstream_xchacha20poly1305_init_push(state.ptr, pinnedHeader.addressOf(0), key.toCValues())
|
||||
println("state-----------")
|
||||
@ -97,9 +97,15 @@ actual class XChaCha20Poly1305Delegated actual constructor(val key: UByteArray,
|
||||
println("--------header-----------")
|
||||
header.hexColumsPrint()
|
||||
println("--------header-----------")
|
||||
pinnedHeader.unpin()
|
||||
return header
|
||||
}
|
||||
|
||||
actual fun initializeForDecryption(key: UByteArray, header: UByteArray) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
actual fun encrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
val ciphertextWithTag = UByteArray(data.size + crypto_secretstream_xchacha20poly1305_ABYTES.toInt())
|
||||
val ciphertextWithTagPinned = ciphertextWithTag.pin()
|
||||
@ -125,4 +131,6 @@ actual class XChaCha20Poly1305Delegated actual constructor(val key: UByteArray,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
||||
//package com.ionspin.kotlin.crypto.util
|
||||
//
|
||||
//import kotlinx.coroutines.CoroutineScope
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//
|
||||
///**
|
||||
// * Created by Ugljesa Jovanovic
|
||||
// * ugljesa.jovanovic@ionspin.com
|
||||
// * on 20-Jul-2019
|
||||
// */
|
||||
//actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
||||
|
@ -197,7 +197,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Common.stdLib))
|
||||
implementation(kotlin(Deps.Common.test))
|
||||
implementation(Deps.Common.coroutines)
|
||||
implementation(Deps.Common.kotlinBigNum)
|
||||
implementation(project(Deps.Common.apiProject))
|
||||
}
|
||||
@ -213,7 +212,6 @@ kotlin {
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
isRunningInIdea {
|
||||
kotlin.setSrcDirs(emptySet<String>())
|
||||
@ -224,7 +222,6 @@ kotlin {
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,26 +254,22 @@ kotlin {
|
||||
implementation(kotlin(Deps.Jvm.stdLib))
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesCore)
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesTest)
|
||||
implementation(kotlin(Deps.Jvm.reflection))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Js.stdLib))
|
||||
implementation(Deps.Js.coroutines)
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(Deps.Js.coroutines)
|
||||
implementation(kotlin(Deps.Js.test))
|
||||
}
|
||||
}
|
||||
@ -355,7 +348,6 @@ kotlin {
|
||||
// val mingwX86Main by getting {
|
||||
// dependsOn(commonMain)
|
||||
// dependencies {
|
||||
// implementation(Deps.Native.coroutines)
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -367,7 +359,6 @@ kotlin {
|
||||
val mingwX64Main by getting {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Ugljesa Jovanovic
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.parallelization
|
||||
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 17-May-2020
|
||||
*/
|
||||
@ExperimentalTime
|
||||
object Coroutines14 {
|
||||
fun argonParallel() : Array<UByte> {
|
||||
// val argon = Argon2()
|
||||
// argon
|
||||
println("Placeholder")
|
||||
return emptyArray()
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Ugljesa Jovanovic
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.parallelization
|
||||
|
||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.test.Test
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 17-May-2020
|
||||
*/
|
||||
@ExperimentalTime
|
||||
class CoroutinesDebugTest {
|
||||
|
||||
@Test
|
||||
fun debugTest() = testBlocking {
|
||||
Coroutines14.argonParallel()
|
||||
}
|
||||
}
|
@ -16,11 +16,19 @@
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.coroutines.startCoroutine
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
expect fun testBlocking(block : suspend () -> Unit)
|
||||
fun testBlocking(block : suspend () -> Unit) {
|
||||
val continuation = Continuation<Unit>(EmptyCoroutineContext) {
|
||||
//Do nothing
|
||||
println("Done")
|
||||
}
|
||||
block.startCoroutine(continuation)
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Ugljesa Jovanovic
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.promise
|
||||
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend ()-> Unit) : dynamic = GlobalScope.promise { block() }
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Ugljesa Jovanovic
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Ugljesa Jovanovic
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ionspin.kotlin.crypto.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 20-Jul-2019
|
||||
*/
|
||||
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
@ -143,7 +143,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Common.stdLib))
|
||||
implementation(kotlin(Deps.Common.test))
|
||||
implementation(Deps.Common.coroutines)
|
||||
implementation(Deps.Common.kotlinBigNum)
|
||||
implementation(project(":multiplatform-crypto-delegated"))
|
||||
}
|
||||
@ -159,14 +158,12 @@ kotlin {
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,26 +173,22 @@ kotlin {
|
||||
implementation(kotlin(Deps.Jvm.stdLib))
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesCore)
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Jvm.test))
|
||||
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||
implementation(Deps.Jvm.coroutinesTest)
|
||||
implementation(kotlin(Deps.Jvm.reflection))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin(Deps.Js.stdLib))
|
||||
implementation(Deps.Js.coroutines)
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(Deps.Js.coroutines)
|
||||
implementation(kotlin(Deps.Js.test))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user