Bump to 1.4-M3
This commit is contained in:
parent
71ec5b7585
commit
f5150557d6
@ -28,7 +28,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M2")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M3")
|
||||
}
|
||||
|
||||
System.setProperty("PROJECT_PATH", project.projectDir.parentFile.toString())
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
object Versions {
|
||||
val kotlinCoroutines = "1.3.5-native-mt-arm-1.4-M2-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||
val kotlin = "1.4-M2"
|
||||
val kotlinSerialization = "0.20.0-1.4-M2"
|
||||
val kotlin = "1.4-M3"
|
||||
val kotlinSerialization = "0.20.0-1.4-M3"
|
||||
val atomicfu = "0.14.3-M2-2-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||
val nodePlugin = "1.3.0"
|
||||
val dokkaPlugin = "0.11.0-dev-44"
|
||||
val taskTreePlugin = "1.5"
|
||||
|
||||
val kotlinBigNumVersion = "0.1.6-1.4-M2-3-SNAPSHOT"
|
||||
val kotlinBigNumVersion = "0.1.6-1.4-M3-1-SNAPSHOT"
|
||||
|
||||
val lazySodium = "4.2.6"
|
||||
val jna = "5.5.0"
|
||||
|
@ -117,7 +117,7 @@ object CryptoPrimitives : PrimitivesApi {
|
||||
// salt,
|
||||
// key,
|
||||
// associatedData,
|
||||
// parallelism,
|
||||
// parallelism
|
||||
// tagLength,
|
||||
// memory,
|
||||
// numberOfIterations
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ionspin.kotlin.crypto.authenticated
|
||||
|
||||
import com.ionspin.kotlin.crypto.CryptoInitializerDelegated
|
||||
import com.ionspin.kotlin.crypto.Initializer
|
||||
import com.ionspin.kotlin.crypto.hash.encodeToUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.hexColumsPrint
|
||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||
@ -184,10 +185,10 @@ class XChaCha20Poly1305Test {
|
||||
|
||||
|
||||
}
|
||||
//Missing jvm and js impl
|
||||
@Ignore
|
||||
|
||||
@Test
|
||||
fun testStreamingImpl() {
|
||||
fun testStreamingImpl() = testBlocking {
|
||||
Initializer.initialize()
|
||||
val key = UByteArray(32) { 0U}
|
||||
val state = ubyteArrayOf(
|
||||
0x2DU, 0xDBU, 0xC7U, 0xB2U, 0x03U, 0xBCU, 0xC3U, 0x22U, 0xBDU, 0x0CU, 0xBAU, 0x82U, 0xADU, 0x77U, 0x79U, 0x44U,
|
||||
@ -212,6 +213,7 @@ class XChaCha20Poly1305Test {
|
||||
val xcha = XChaCha20Poly1305Delegated(key, state, header)
|
||||
val data = UByteArray(100) { 0U }
|
||||
val result = xcha.encrypt(data)
|
||||
|
||||
// assertTrue {
|
||||
// expected.contentEquals(result)
|
||||
// }
|
||||
|
@ -29,7 +29,9 @@ import kotlin.coroutines.startCoroutine
|
||||
fun testBlocking(block : suspend () -> Unit) {
|
||||
val continuation = Continuation<Unit>(EmptyCoroutineContext) {
|
||||
//Do nothing
|
||||
println("Done")
|
||||
if (it.isFailure) {
|
||||
throw it.exceptionOrNull()!!
|
||||
}
|
||||
}
|
||||
block.startCoroutine(continuation)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ interface JsSodiumInterface {
|
||||
//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
|
||||
fun crypto_secretstream_xchacha20poly1305_push(state: dynamic, message: Uint8Array, additionalData: Uint8Array, tag: UByte) : Uint8Array
|
||||
|
||||
//decrypt
|
||||
fun crypto_secretstream_xchacha20poly1305_init_pull(header: Uint8Array, key: Uint8Array) : dynamic
|
||||
|
@ -54,15 +54,18 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
var state : dynamic = null
|
||||
|
||||
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
|
||||
println("Initializaing for encryption")
|
||||
val stateAndHeader = getSodium().crypto_secretstream_xchacha20poly1305_init_push(key.toUInt8Array())
|
||||
val state = stateAndHeader.state
|
||||
val header = stateAndHeader.header
|
||||
console.log(state)
|
||||
console.log(header)
|
||||
println("Done initializaing for encryption")
|
||||
return header
|
||||
}
|
||||
|
||||
actual fun initializeForDecryption(key: UByteArray, header: UByteArray) {
|
||||
|
||||
}
|
||||
|
||||
internal actual constructor(
|
||||
@ -70,12 +73,14 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
testState: UByteArray,
|
||||
testHeader: UByteArray
|
||||
) : this() {
|
||||
|
||||
state = getSodium().crypto_secretstream_xchacha20poly1305_init_pull(testHeader.toUInt8Array(), key.toUInt8Array())
|
||||
console.log(state)
|
||||
println("Done initializaing test state")
|
||||
}
|
||||
|
||||
actual fun encrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
// val encrypted
|
||||
TODO()
|
||||
val encrypted = getSodium().crypto_secretstream_xchacha20poly1305_push(state, data.toUInt8Array(), additionalData.toUInt8Array(), 0U)
|
||||
return encrypted.toUByteArray()
|
||||
}
|
||||
|
||||
actual fun decrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.ionspin.kotlin.crypto.authenticated
|
||||
|
||||
import com.goterl.lazycode.lazysodium.SodiumJava
|
||||
import com.goterl.lazycode.lazysodium.interfaces.SecretStream
|
||||
import com.ionspin.kotlin.crypto.util.hexColumsPrint
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
@ -54,12 +56,16 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
val state : SecretStream.State = SecretStream.State()
|
||||
val sodium = SodiumJava()
|
||||
|
||||
internal actual constructor(
|
||||
key: UByteArray,
|
||||
testState: UByteArray,
|
||||
testHeader: UByteArray
|
||||
) : this() {
|
||||
|
||||
state.k = testState.sliceArray(0 until 32).toByteArray()
|
||||
state.nonce = testState.sliceArray(32 until 44).toByteArray()
|
||||
}
|
||||
|
||||
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
|
||||
@ -70,11 +76,21 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
|
||||
}
|
||||
|
||||
actual fun encrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
val ciphertext = ByteArray(1 + data.size + 16)
|
||||
sodium.crypto_secretstream_xchacha20poly1305_push(
|
||||
state, ciphertext, null,
|
||||
data.toByteArray(), data.size.toLong(),
|
||||
additionalData.toByteArray(), additionalData.size.toLong(),
|
||||
0
|
||||
)
|
||||
return ciphertext.toUByteArray()
|
||||
}
|
||||
|
||||
actual fun decrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
val plaintext = ByteArray(data.size - 17)
|
||||
|
||||
TODO()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,9 @@ import kotlin.coroutines.startCoroutine
|
||||
fun testBlocking(block : suspend () -> Unit) {
|
||||
val continuation = Continuation<Unit>(EmptyCoroutineContext) {
|
||||
//Do nothing
|
||||
println("Done")
|
||||
if (it.isFailure) {
|
||||
throw it.exceptionOrNull()!!
|
||||
}
|
||||
}
|
||||
block.startCoroutine(continuation)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user