Working arm 64 libsodium integration
This commit is contained in:
parent
e026d1405d
commit
d11d4e7fb0
@ -27,5 +27,5 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M1")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M2")
|
||||
}
|
||||
|
@ -15,15 +15,15 @@
|
||||
*/
|
||||
|
||||
object Versions {
|
||||
val kotlinCoroutines = "1.3.5-native-mt-arm-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||
val kotlin = "1.4-M1"
|
||||
val kotlinSerialization = "0.20.0-1.4-M1"
|
||||
val atomicfu = "0.14.3-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||
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 atomicfu = "0.14.3-M2-2-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||
val nodePlugin = "1.3.0"
|
||||
val dokkaPlugin = "0.9.18"
|
||||
val taskTreePlugin = "1.5"
|
||||
|
||||
val kotlinBigNumVersion = "0.1.6-SNAPSHOT"
|
||||
val kotlinBigNumVersion = "0.1.6-1.4-M2-SNAPSHOT"
|
||||
|
||||
|
||||
}
|
||||
@ -40,7 +40,7 @@ object Deps {
|
||||
val test = "test-common"
|
||||
val testAnnotation = "test-annotations-common"
|
||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core-common:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core:${Versions.kotlinCoroutines}"
|
||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Versions.kotlinSerialization}"
|
||||
val atomicfu = "com.ionspin.kotlin.atomicfu:atomicfu:${Versions.atomicfu}"
|
||||
|
||||
@ -54,7 +54,7 @@ object Deps {
|
||||
val stdLib = "stdlib-js"
|
||||
val test = "test-js"
|
||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core-js:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core:${Versions.kotlinCoroutines}"
|
||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.kotlinSerialization}"
|
||||
|
||||
object Npm {
|
||||
@ -80,13 +80,13 @@ object Deps {
|
||||
object iOs {
|
||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core:${Versions.kotlinCoroutines}"
|
||||
}
|
||||
|
||||
object Native {
|
||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
||||
val coroutines = "com.ionspin.kotlin.coroutines:kotlinx-coroutines-core:${Versions.kotlinCoroutines}"
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,5 +20,6 @@ kotlin.code.style=official
|
||||
kotlin.js.compiler=ir
|
||||
#kotlin.js.experimental.generateKotlinExternals=true
|
||||
#kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
kotlin.native.disableCompilerDaemon=true
|
||||
|
||||
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -16,6 +16,6 @@
|
||||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -44,20 +44,7 @@ kotlin {
|
||||
runningOnLinuxx86_64 {
|
||||
jvm()
|
||||
js {
|
||||
compilations {
|
||||
this.forEach {
|
||||
it.compileKotlinTask.kotlinOptions.sourceMap = true
|
||||
it.compileKotlinTask.kotlinOptions.moduleKind = "commonjs"
|
||||
it.compileKotlinTask.kotlinOptions.metaInfo = true
|
||||
|
||||
if (it.name == "main") {
|
||||
it.compileKotlinTask.kotlinOptions.main = "call"
|
||||
}
|
||||
println("Compilation name ${it.name} set")
|
||||
println("Destination dir ${it.compileKotlinTask.destinationDir}")
|
||||
}
|
||||
}
|
||||
browser {
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false //Until I sort out testing on travis
|
||||
useKarma {
|
||||
|
@ -22,10 +22,37 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
||||
|
||||
override fun digest(): UByteArray {
|
||||
val result = sodium_init()
|
||||
println("Sodium init $result")
|
||||
println("Sodium init")
|
||||
println(result)
|
||||
val inputString = "test"
|
||||
val hashLength = 64
|
||||
val key : String? = null
|
||||
val result2 = allocEverything(inputString, key, hashLength)
|
||||
val result2String = result2.toHexString()
|
||||
println(result2String)
|
||||
return ubyteArrayOf(0U)
|
||||
}
|
||||
|
||||
fun allocEverything(inputString: String, key: String?, hashLength: Int) : UByteArray {
|
||||
val res = memScoped {
|
||||
val result = allocArray<UByteVar>(hashLength)
|
||||
println("Alloced: $result")
|
||||
crypto_generichash(
|
||||
result,
|
||||
hashLength.toULong(),
|
||||
inputString.encodeToByteArray().toUByteArray().toCValues(),
|
||||
inputString.length.toULong(),
|
||||
key?.run { this.encodeToByteArray().toUByteArray().toCValues() },
|
||||
key?.length?.toULong() ?: 0UL
|
||||
)
|
||||
println("Result: $result")
|
||||
UByteArray(hashLength) {
|
||||
result[it]
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
override fun digestString(): String {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
@ -34,6 +61,8 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
||||
@Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
|
||||
actual object Blake2bStateless : Blake2bStatelessInterface {
|
||||
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
|
||||
// return allocEverything(inputString, key, hashLength)
|
||||
println("Input $inputString, ${key ?: "null"}, $hashLength")
|
||||
val hashResult = UByteArray(MAX_HASH_BYTES)
|
||||
val hashResultPinned = hashResult.pin()
|
||||
crypto_generichash(
|
||||
@ -49,6 +78,9 @@ actual object Blake2bStateless : Blake2bStatelessInterface {
|
||||
return hashResult
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
||||
val hashResult = UByteArray(MAX_HASH_BYTES)
|
||||
|
||||
|
@ -52,19 +52,6 @@ kotlin {
|
||||
runningOnLinuxx86_64 {
|
||||
jvm()
|
||||
js {
|
||||
compilations {
|
||||
this.forEach {
|
||||
it.compileKotlinTask.kotlinOptions.sourceMap = true
|
||||
it.compileKotlinTask.kotlinOptions.moduleKind = "commonjs"
|
||||
it.compileKotlinTask.kotlinOptions.metaInfo = true
|
||||
|
||||
if (it.name == "main") {
|
||||
it.compileKotlinTask.kotlinOptions.main = "call"
|
||||
}
|
||||
println("Compilation name ${it.name} set")
|
||||
println("Destination dir ${it.compileKotlinTask.destinationDir}")
|
||||
}
|
||||
}
|
||||
//Until I figure out how to run headless chrome on travis
|
||||
// browser {
|
||||
//
|
||||
|
@ -9,6 +9,10 @@ fun main() {
|
||||
println("Test")
|
||||
// Blake
|
||||
val blake = Blake2bDelegated()
|
||||
println("Result ${blake.digest()}")
|
||||
println("Result: ${Blake2bStateless.digest("test")}")
|
||||
val res = blake.digest()
|
||||
println("Result of res")
|
||||
// println(res)
|
||||
val staticRes = Blake2bStateless.digest("test")
|
||||
println("Result:")
|
||||
println(staticRes)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user