Working arm 64 libsodium integration
This commit is contained in:
parent
e026d1405d
commit
d11d4e7fb0
@ -27,5 +27,5 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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 {
|
object Versions {
|
||||||
val kotlinCoroutines = "1.3.5-native-mt-arm-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-M1"
|
val kotlin = "1.4-M2"
|
||||||
val kotlinSerialization = "0.20.0-1.4-M1"
|
val kotlinSerialization = "0.20.0-1.4-M2"
|
||||||
val atomicfu = "0.14.3-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
val atomicfu = "0.14.3-M2-2-SNAPSHOT" //NOTE: my linux arm32 and arm64 build
|
||||||
val nodePlugin = "1.3.0"
|
val nodePlugin = "1.3.0"
|
||||||
val dokkaPlugin = "0.9.18"
|
val dokkaPlugin = "0.9.18"
|
||||||
val taskTreePlugin = "1.5"
|
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 test = "test-common"
|
||||||
val testAnnotation = "test-annotations-common"
|
val testAnnotation = "test-annotations-common"
|
||||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Versions.kotlinCoroutines}"
|
// 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 serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Versions.kotlinSerialization}"
|
||||||
val atomicfu = "com.ionspin.kotlin.atomicfu:atomicfu:${Versions.atomicfu}"
|
val atomicfu = "com.ionspin.kotlin.atomicfu:atomicfu:${Versions.atomicfu}"
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ object Deps {
|
|||||||
val stdLib = "stdlib-js"
|
val stdLib = "stdlib-js"
|
||||||
val test = "test-js"
|
val test = "test-js"
|
||||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Versions.kotlinCoroutines}"
|
// 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}"
|
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.kotlinSerialization}"
|
||||||
|
|
||||||
object Npm {
|
object Npm {
|
||||||
@ -80,13 +80,13 @@ object Deps {
|
|||||||
object iOs {
|
object iOs {
|
||||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
||||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
// 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 {
|
object Native {
|
||||||
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}"
|
||||||
// val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}"
|
// 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.compiler=ir
|
||||||
#kotlin.js.experimental.generateKotlinExternals=true
|
#kotlin.js.experimental.generateKotlinExternals=true
|
||||||
#kotlin.mpp.enableGranularSourceSetsMetadata=true
|
#kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
kotlin.native.disableCompilerDaemon=true
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m
|
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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -44,19 +44,6 @@ kotlin {
|
|||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
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 {
|
testTask {
|
||||||
enabled = false //Until I sort out testing on travis
|
enabled = false //Until I sort out testing on travis
|
||||||
|
@ -22,10 +22,37 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
|||||||
|
|
||||||
override fun digest(): UByteArray {
|
override fun digest(): UByteArray {
|
||||||
val result = sodium_init()
|
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)
|
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 {
|
override fun digestString(): String {
|
||||||
TODO("not implemented yet")
|
TODO("not implemented yet")
|
||||||
}
|
}
|
||||||
@ -34,6 +61,8 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
|||||||
@Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
|
@Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
|
||||||
actual object Blake2bStateless : Blake2bStatelessInterface {
|
actual object Blake2bStateless : Blake2bStatelessInterface {
|
||||||
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
|
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 hashResult = UByteArray(MAX_HASH_BYTES)
|
||||||
val hashResultPinned = hashResult.pin()
|
val hashResultPinned = hashResult.pin()
|
||||||
crypto_generichash(
|
crypto_generichash(
|
||||||
@ -49,6 +78,9 @@ actual object Blake2bStateless : Blake2bStatelessInterface {
|
|||||||
return hashResult
|
return hashResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
||||||
val hashResult = UByteArray(MAX_HASH_BYTES)
|
val hashResult = UByteArray(MAX_HASH_BYTES)
|
||||||
|
|
||||||
|
@ -52,19 +52,6 @@ kotlin {
|
|||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
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
|
//Until I figure out how to run headless chrome on travis
|
||||||
// browser {
|
// browser {
|
||||||
//
|
//
|
||||||
|
@ -9,6 +9,10 @@ fun main() {
|
|||||||
println("Test")
|
println("Test")
|
||||||
// Blake
|
// Blake
|
||||||
val blake = Blake2bDelegated()
|
val blake = Blake2bDelegated()
|
||||||
println("Result ${blake.digest()}")
|
val res = blake.digest()
|
||||||
println("Result: ${Blake2bStateless.digest("test")}")
|
println("Result of res")
|
||||||
|
// println(res)
|
||||||
|
val staticRes = Blake2bStateless.digest("test")
|
||||||
|
println("Result:")
|
||||||
|
println(staticRes)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user