Working sodium cinterop
This commit is contained in:
1 parent
3f7df6c651
commit
cc2f392bb7
6 files changed
+22
-31
No files matched your search
@@ -22,6 +22,7 @@ import org.gradle.api.tasks.testing.logging.TestLogging
|
||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
import org.jetbrains.kotlin.konan.library.konanCommonLibraryPath
|
||||
|
||||
plugins {
|
||||
kotlin(PluginsDeps.multiplatform)
|
||||
@@ -92,11 +93,16 @@ kotlin {
|
||||
compilations.getByName("main") {
|
||||
val libsodiumCinterop by cinterops.creating {
|
||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||
// packageName("sodium")
|
||||
// includeDirs.apply {
|
||||
// allHeaders("/usr/include/sodium")
|
||||
// header("/usr/include/sodium.h")
|
||||
// }
|
||||
// linkerOpts("-lsodium")
|
||||
}
|
||||
}
|
||||
binaries {
|
||||
staticLib {
|
||||
optimized = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,7 +183,7 @@ kotlin {
|
||||
implementation(kotlin(Deps.Common.test))
|
||||
implementation(Deps.Common.coroutines)
|
||||
implementation(Deps.Common.kotlinBigNum)
|
||||
implementation(project(Deps.Common.apiProject))
|
||||
api(project(Deps.Common.apiProject))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
|
||||
+5
-3
@@ -1,6 +1,7 @@
|
||||
package com.ionspin.kotlin.crypto.hash.blake2b
|
||||
import interop.*
|
||||
import kotlinx.cinterop.*
|
||||
import libsodium.*
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
@@ -9,8 +10,7 @@ import kotlinx.cinterop.*
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: Int) : Blake2b {
|
||||
override val MAX_HASH_BYTES: Int
|
||||
get() = TODO("not implemented yet")
|
||||
override val MAX_HASH_BYTES: Int = 1024
|
||||
|
||||
override fun update(data: UByteArray) {
|
||||
TODO("not implemented yet")
|
||||
@@ -21,7 +21,9 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
||||
}
|
||||
|
||||
override fun digest(): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
val result = sodium_init()
|
||||
println("Sodium init $result")
|
||||
return ubyteArrayOf(0U)
|
||||
}
|
||||
|
||||
override fun digestString(): String {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ class Blake2bLinuxTest {
|
||||
@Test
|
||||
fun testCinterop() {
|
||||
val sodiumInitResult = sodium_init()
|
||||
// println("Sodium init $sodiumInitResult")
|
||||
println("Sodium init $sodiumInitResult")
|
||||
println("1")
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
headers = sodium.h
|
||||
headerFilter = sodium.h sodium/**
|
||||
staticLibraries = libsodium.a
|
||||
libraryPaths = /usr/lib
|
||||
compilerOpts = -Iinclude -I/usr/include
|
||||
linkerOpts = -L/usr/lib -lsodium
|
||||
libraryPaths = /home/ionspin/Projects/Future/sodiumWrapper/lib
|
||||
compilerOpts = -I/home/ionspin/Projects/Future/sodiumWrapper/include
|
||||
linkerOpts =
|
||||
Reference in new issue
Block a user