Merge pull request #15 from ionspin/1.5.31-new-targets-updated-libsodium

1.5.31 new targets updated libsodium
This commit is contained in:
Ugljesa Jovanovic 2021-09-24 19:16:41 +02:00 committed by GitHub
commit 725c95c397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 108 additions and 551 deletions

View File

@ -5,7 +5,7 @@
# Libsodium bindings for Kotlin Multiplatform
Libsodium bindings project uses libsodium c sources and libsodium.js to provide a kotlin multiplatform wrapper library for libsodium.
Libsodium bindings project uses libsodium c sources and libsodium.js to provide a kotlin multiplatform wrapper library for libsodium. The library is feature complete and usable.
## Warning
While this library is just a wrapper around the well known Libsodium library it still comes with high potential of introducing new
@ -121,7 +121,7 @@ At the moment you should refer to original libsodium documentation for instructi
## Supported native platforms
Currently supported native platforms:
Currently supported native platforms (Apple Silicon is supported since 0.8.5) :
|Platform| Supported |
|--------|------------------|
@ -129,14 +129,18 @@ Currently supported native platforms:
|Linux Arm 64| :heavy_check_mark: |
|Linux Arm 32| :x: |
|macOS X86 64| :heavy_check_mark: |
|macOS Arm 64 (Apple Silicon)| :heavy_check_mark: |
|iOS x86 64 | :heavy_check_mark: |
|iOS Arm 64 | :heavy_check_mark: |
|iOS Arm 32 | :heavy_check_mark: |
|iOS Simulator Arm 64 (Apple Silicon)| :heavy_check_mark: |
|watchOS X86 32 | :heavy_check_mark: |
|watchOS Arm 64(_32) | :heavy_check_mark: |
|watchOS Arm 32 | :heavy_check_mark: |
|watchOS Simulator Arm 64 (Apple Silicon)| :heavy_check_mark: |
|tvOS X86 64 | :heavy_check_mark: |
|tvOS Arm 64 | :heavy_check_mark: |
|tvOS Simulator Arm 64 (Apple Silicon)| :heavy_check_mark: |
|minGW X86 64| :heavy_check_mark: |
|minGW X86 32| :x: |
@ -150,8 +154,8 @@ Java Windows dll is from https://download.libsodium.org/libsodium/releases/libso
### TODO:
- Improve documentation
- Running tests on Android
- LobsodiumUtil `unpad` and `fromBase64` native implementations use a nasty hack to support shared native sourceset. The hack either needs to be removed and replaced with another solution or additional safeguards need to be added.
- Complete exposing libsodium constants
- Build MSVC so it's binaries are completely equal
- Find a better way of fetching Konan dependencies than having a dummy project.
### Building

View File

@ -40,7 +40,6 @@ object Versions {
object ReleaseInfo {
val group = "com.ionspin.kotlin"
val version = "0.1.0-SNAPSHOT"
val bindingsVersion = "0.8.5-SNAPSHOT"
}
@ -138,6 +137,12 @@ object Deps {
}
object AndroidPluginConfiguration {
val sdkVersion = 31
val targetVersion = 31
val minVersion = 24
}
object PluginsDeps {
val kotlinSerializationPlugin = "plugin.serialization"

View File

@ -15,6 +15,7 @@ fi
./makeLinuxArm64.sh
#now we can do the delegated build
cd ..
# TODO collect static libraries from mac and windows build and include them in jvm resources automatically
#build libsodium bindings
./gradlew multiplatform-crypto-libsodium-bindings:build

View File

@ -4,8 +4,7 @@ set -e
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIosWatchosTvos.sh
./makeMacosIosWatchosTvos.sh
#now we can do the delegated build
cd ..
set +e
set +e

View File

@ -1,17 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:iosArm32MainKlibrary multiplatform-crypto-libsodium-bindings:iosArm32TestKlibrary \
multiplatform-crypto-libsodium-bindings:iosArm64MainKlibrary multiplatform-crypto-libsodium-bindings:iosArm64TestKlibrary \
multiplatform-crypto-libsodium-bindings:iosX64MainKlibrary multiplatform-crypto-libsodium-bindings:iosX64TestKlibrary
./gradlew multiplatform-crypto-libsodium-bindings:iosX64Test
set +e

View File

@ -1,14 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:macosX64MainKlibrary multiplatform-crypto-libsodium-bindings:macosX64TestKlibrary
./gradlew multiplatform-crypto-libsodium-bindings:macosX64Test
set +e

View File

@ -1,14 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeTvos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:tvosArm64MainKlibrary multiplatform-crypto-libsodium-bindings:tvosArm64TestKlibrary \
multiplatform-crypto-libsodium-bindings:tvosX64MainKlibrary multiplatform-crypto-libsodium-bindings:tvosX64TestKlibrary
./gradlew multiplatform-crypto-libsodium-bindings:tvosX64Test
set +e

View File

@ -1,15 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeWatchos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:watchosArm32MainKlibrary multiplatform-crypto-libsodium-bindings:watchosArm32TestKlibrary \
multiplatform-crypto-libsodium-bindings:watchosArm64MainKlibrary multiplatform-crypto-libsodium-bindings:watchosArm64TestKlibrary \
multiplatform-crypto-libsodium-bindings:watchosX86MainKlibrary multiplatform-crypto-libsodium-bindings:watchosX86TestKlibrary
./gradlew multiplatform-crypto-libsodium-bindings:watchosX86Test
set +e

View File

@ -4,10 +4,9 @@ set -e
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIosWatchosTvos.sh
./makeMacosIosWatchosTvos.sh
#now we can do the delegated build
cd ..
#libsodium bindings
./gradlew multiplatform-crypto-libsodium-bindings:build
./gradlew multiplatform-crypto-libsodium-bindings:build -x multiplatform-crypto-libsodium-bindings:iosSimulatorArm64Test -x multiplatform-crypto-libsodium-bindings:tvosSimulatorArm64Test -x multiplatform-crypto-libsodium-bindings:watchosSimulatorArm64Test
set +e

View File

@ -1,15 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:publishIosArm32PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishIosArm64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishIosX64PublicationToSnapshotRepository
set +e

View File

@ -1,12 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:publishMacosX64PublicationToSnapshotRepository
set +e

View File

@ -1,14 +0,0 @@
set -e
#!/bin/sh
#this will hopefully download all konan dependancies that we use in the build scripts
./gradlew multiplatform-crypto-api:build
#now let's build linux deps
cd sodiumWrapper
./makeWatchos.sh
#now we can do the delegated build of ios and macos libraries
cd ..
./gradlew multiplatform-crypto-libsodium-bindings:publishWatchosArm32PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishWatchosArm64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishWatchosX86PublicationToSnapshotRepository
set +e

View File

@ -1,15 +1,20 @@
set -e
#!/bin/sh
./gradlew multiplatform-crypto-libsodium-bindings:publishMacosX64PublicationToSnapshotRepository
./gradlew multiplatform-crypto-libsodium-bindings:publishMacosX64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishMacosArm64PublicationToSnapshotRepository
./gradlew multiplatform-crypto-libsodium-bindings:publishIosArm32PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishIosArm64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishIosX64PublicationToSnapshotRepository
multiplatform-crypto-libsodium-bindings:publishIosX64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishIosSimulatorArm64PublicationToSnapshotRepository
./gradlew multiplatform-crypto-libsodium-bindings:publishWatchosArm32PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishWatchosArm64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishWatchosX86PublicationToSnapshotRepository
multiplatform-crypto-libsodium-bindings:publishWatchosX86PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishWatchosSimulatorArm64PublicationToSnapshotRepository
./gradlew multiplatform-crypto-libsodium-bindings:publishTvosArm64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishTvosX64PublicationToSnapshotRepository
multiplatform-crypto-libsodium-bindings:publishTvosX64PublicationToSnapshotRepository \
multiplatform-crypto-libsodium-bindings:publishTvosSimulatorArm64PublicationToSnapshotRepository
set +e

View File

@ -1,288 +1 @@
[![Build Status](https://travis-ci.com/ionspin/kotlin-multiplatform-crypto.svg?branch=master)](https://travis-ci.com/ionspin/kotlin-multiplatform-crypto)
![Maven Central](https://img.shields.io/maven-central/v/com.ionspin.kotlin/multiplatform-crypto.svg)
# Kotlin Multiplatform Crypto Library
Kotlin Multiplatform Crypto is a library for various cryptographic applications.
The library comes in two flavors `multiplatform-crypto` and `multiplatform-crypto-delegated`.
* `multiplatform-crypto` contains pure kotlin implementations, is not reviewed, should be considered unsafe and only
for prototyping or experimentation purposes.
* `multiplatform-crypto-delegated` relies on platform specific implementations, mostly libsodium, but care should still be taken that the kotlin code is not reviewed or proven safe.
APIs of both variants are identical.
### Table of contents
1. [Supported platforms](#supported-platforms-by-variant)
2. [API](#api)
3. TODO
## Supported platforms by variant
|Platform|Pure variant| Delegated variant|
|--------|------------|------------------|
|Linux X86 64| :heavy_check_mark: | :heavy_check_mark: |
|Linux Arm 64| :heavy_check_mark: | :heavy_check_mark: |
|Linux Arm 32| :heavy_check_mark: | :x: |
|macOS X86 64| :heavy_check_mark: | :heavy_check_mark: |
|iOS x86 64 | :heavy_check_mark: | :heavy_check_mark: |
|iOS Arm 64 | :heavy_check_mark: | :heavy_check_mark: |
|iOS Arm 32 | :heavy_check_mark: | :heavy_check_mark: |
|watchOS X86 32 | :heavy_check_mark: | :heavy_check_mark: |
|watchOS Arm 64(_32) | :heavy_check_mark: | :heavy_check_mark: |
|watchos Arm 32 | :heavy_check_mark: | :heavy_check_mark: |
|tvOS X86 64 | :heavy_check_mark: | :heavy_check_mark: |
|tvOS Arm 64 | :heavy_check_mark: | :heavy_check_mark: |
|minGW X86 64| :heavy_check_mark: | :heavy_check_mark: |
|minGW X86 32| :x: | :x: |
## Sample project
The library includes sample project that shows usage on different platforms
- NOTE: Currently only linux, macOs and windows are included.
## Notes & Roadmap
**The API will move fast and break often until v1.0**
Next steps:
- Expand API (ECC, Signing ...)
## Should I use this in production?
**NO.**
The library is under HEAVY development. Until development is done it will not be reviewed and therefore it shouldn't be used.
Contributions are still welcome!
## Why?
This is an experimental implementation, mostly for expanding personal understanding of cryptography.
It's not peer reviewed, not guaranteed to be bug free, and not guaranteed to be secure.
## API for Pure and Delegated flavours
### Hashing functions
* Blake2b
* SHA512
* SHA256
### Key Derivation
* Argon2
### Authenticated symmetric encryption (AEAD)
* XChaCha20-Poly1305
### Delegated flavor dependancy table
The following table describes which library is used for particular cryptographic primitive
| Primitive | JVM | JS | Native |
| ----------|-----|----|--------|
| Blake2b | LazySodium | libsodium.js | libsodium |
| SHA256 | LazySodium | libsodium.js | libsodium |
| SHA512 | LazySodium | libsodium.js | libsodium |
| XChaCha20-Poly1305 | LazySodium | libsodium.js | libsodium |
## Integration
NOTE: Latest version of the library is built with Kotlin 1.4-M2 and therefore only SNAPSHOT variant is available. Next
stable version will be released when Kotlin 1.4. is released
#### Gradle
Kotlin
```kotlin
implementation("com.ionspin.kotlin:multiplatform-crypto:0.1.0")
or
implementation("com.ionspin.kotlin:multiplatform-crypto-delegated:0.1.0")
```
#### Snapshot builds
```kotlin
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
implementation("com.ionspin.kotlin:multiplatform-crypto:0.1.0-SNAPSHOT")
```
## Usage
### Helper functions
All API take `UByteArray` as message/key/nonce/etc parameter. For convenience when working with strings we provide
`String.enocdeToUbyteArray()` extensions function, and `UByteArray.toHexString` extension function.
More convenience functions will be added.
### Hashes
Hashes are provided in two versions, "stateless", usually the companion object of the hash,
which takes the data to be hashed in one go, and "updatable" which can be fed data in chunks.
#### Blake2b
You can use Blake 2b in two modes
##### Stateless version
You need to deliver the complete data that is to be hashed in one go
```kotlin
val input = "abc"
val result = Crypto.Blake2b.stateless(input.encodeToUByteArray())
```
Result is returned as a `UByteArray`
##### Updatable instance version
You can create an instance and feed the data by using `update(input : UByteArray)` call. Once all data is supplied,
you should call `digest()`.
If you want to use Blake2b with a key, you should supply it when creating the `Blake2b` instance.
```kotlin
val test = "abc"
val key = "key"
val blake2b = Crypto.Blake2b.updateable(key.encodeToUByteArray())
blake2b.update(test.encodeToUByteArray())
val result = blake2b.digest().toHexString()
```
After digest is called, the instance is reset and can be reused (Keep in mind key stays the same for the particular instance).
#### SHA2 (SHA256 and SHA512)
##### Stateless version
You need to deliver the complete data that is to be hashed in one go. You can either provide the `UByteArray` as input
or `String`. Result is always returned as `UByteArray` (At least in verision 0.0.1)
```kotlin
val input = "abc"
val result = Crypto.Sha256.stateless(input.encodeToUByteArray())
```
```kotlin
val input ="abc"
val result = Crypto.Sha512.stateless(input.encodeToUByteArray())
```
Result is returned as a `UByteArray`
##### Updateable version
Or you can use the updatable instance version
```kotlin
val sha256 = Crypto.Sha256.updateable()
sha256.update("abc".encodeToUByteArray())
val result = sha256.digest()
```
```kotlin
val sha512 = Crypto.Sha512.updateable()
sha512.update("abc".encodeToUByteArray())
val result = sha512.digest()
```
### Key derivation
#### Argon2
NOTE: This implementation is tested against KAT generated by reference Argon2 implementation, which does not follow
specification completely. See this issue https://github.com/P-H-C/phc-winner-argon2/issues/183
```kotlin
val argon2Instance = Argon2(
password = "Password",
salt = "RandomSalt",
parallelism = 8,
tagLength = 64U,
requestedMemorySize = 256U, //4GB
numberOfIterations = 4U,
key = "",
associatedData = "",
argonType = ArgonType.Argon2id
)
val tag = argon2Instance.derive()
val tagString = tag.map { it.toString(16).padStart(2, '0') }.joinToString(separator = "")
val expectedTagString = "c255e3e94305817d5e09a7c771e574e3a81cc78fef5da4a9644b6df0" +
"0ba1c9b424e3dd0ce7e600b1269b14c84430708186a8a60403e1bfbda935991592b9ff37"
println("Tag: ${tagString}")
assertEquals(tagString, expectedTagString)
```
### Symmetric encryption (OUTDATED, won't be exposed in next release, no counterpart in delegated flavor - 0.1.1)
#### AES
Aes is available with CBC and CTR mode through `AesCbc` and `AesCtr` classes/objects.
Similarly to hashes you can either use stateless or updateable version.
Initialization vector, or counter states are chosen by the SDK automaticaly, and returned alongside encrypted data
##### Stateless AesCbc and AesCtr
AesCtr
```kotlin
val keyString = "4278b840fb44aaa757c1bf04acbe1a3e"
val key = AesKey.Aes128Key(keyString)
val plainText = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710"
val encryptedDataAndInitializationVector = AesCtr.encrypt(key, plainText.hexStringToUByteArray())
val decrypted = AesCtr.decrypt(
key,
encryptedDataAndInitializationVector.encryptedData,
encryptedDataAndInitializationVector.initialCounter
)
plainText == decrypted.toHexString()
```
AesCbc
```kotlin
val keyString = "4278b840fb44aaa757c1bf04acbe1a3e"
val key = AesKey.Aes128Key(keyString)
val plainText = "3c888bbbb1a8eb9f3e9b87acaad986c466e2f7071c83083b8a557971918850e5"
val encryptedDataAndInitializationVector = AesCbc.encrypt(key, plainText.hexStringToUByteArray())
val decrypted = AesCbc.decrypt(
key,
encryptedDataAndInitializationVector.encryptedData,
encryptedDataAndInitializationVector.initilizationVector
)
plainText == decrypted.toHexString()
```
## Libsodium bindings
* Under development
This is just used to get kotlin to download appropriate konan tools.

View File

@ -32,7 +32,7 @@ repositories {
mavenCentral()
}
group = ReleaseInfo.group
version = ReleaseInfo.version
version = "0.1" //Irrelevant
val ideaActive = System.getProperty("idea.active") == "true"
@ -83,105 +83,30 @@ kotlin {
}
}
runningOnLinuxArm64 {
}
runningOnLinuxArm32 {
}
runningOnMacos {
iosX64() {
binaries {
framework {
optimized = true
}
}
}
iosArm64() {
binaries {
framework {
optimized = true
}
}
}
iosArm32() {
binaries {
framework {
optimized = true
}
}
}
iosX64()
iosArm64()
iosArm32()
iosSimulatorArm64()
macosX64() {
binaries {
framework {
optimized = true
}
}
}
macosX64()
macosArm64()
tvosX64() {
binaries {
framework {
optimized = true
}
}
}
tvosX64()
tvosArm64()
tvosSimulatorArm64()
tvosArm64() {
binaries {
framework {
optimized = true
}
}
}
watchosArm64() {
binaries {
framework {
optimized = true
}
}
}
watchosArm32() {
binaries {
framework {
optimized = true
}
}
}
watchosX86() {
binaries {
framework {
optimized = true
}
}
}
watchosArm64()
watchosArm32()
watchosX86()
watchosSimulatorArm64()
}
runningOnWindows {
mingwX64() {
binaries {
staticLib {
optimized = true
}
}
}
mingwX86() {
binaries {
staticLib {
}
}
}
mingwX64()
mingwX86()
}

View File

@ -58,10 +58,10 @@ version = ReleaseInfo.bindingsVersion
val ideaActive = isInIdea()
println("Idea active: $ideaActive")
android {
compileSdkVersion(29)
compileSdkVersion(AndroidPluginConfiguration.sdkVersion)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
minSdkVersion(AndroidPluginConfiguration.minVersion)
targetSdkVersion(AndroidPluginConfiguration.sdkVersion)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@ -156,6 +156,7 @@ kotlin {
}
println("Configuring macos targets")
iosX64() {
binaries {
framework {
@ -170,7 +171,6 @@ kotlin {
}
}
}
iosArm32() {
binaries {
framework {
@ -178,23 +178,7 @@ kotlin {
}
}
}
macosX64() {
binaries {
framework {
optimized = true
}
}
compilations.getByName("main") {
val libsodiumCinterop by cinterops.creating {
defFile(projectRef.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${projectRef.rootDir}/sodiumWrapper/static-macos-x86-64/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${projectRef.rootDir}/sodiumWrapper/static-macos-x86-64/lib/libsodium.a"
)
}
}
tvosX64() {
iosSimulatorArm64() {
binaries {
framework {
optimized = true
@ -202,6 +186,28 @@ kotlin {
}
}
macosX64() {
binaries {
framework {
optimized = true
}
}
}
macosArm64() {
binaries {
framework {
optimized = true
}
}
}
tvosX64() {
binaries {
framework {
optimized = true
}
}
}
tvosArm64() {
binaries {
framework {
@ -209,6 +215,13 @@ kotlin {
}
}
}
tvosSimulatorArm64() {
binaries {
framework {
optimized = true
}
}
}
watchosArm64() {
binaries {
@ -217,7 +230,6 @@ kotlin {
}
}
}
watchosArm32() {
binaries {
framework {
@ -225,7 +237,6 @@ kotlin {
}
}
}
watchosX86() {
binaries {
framework {
@ -233,6 +244,14 @@ kotlin {
}
}
}
watchosSimulatorArm64() {
binaries {
framework {
optimized = true
}
}
}
println("Configuring Mingw targets")
mingwX64() {
binaries {
@ -309,13 +328,13 @@ kotlin {
//iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86
val macos64Bit = setOf(
"macosX64"
"macosX64", "macosArm64"
)
val iosArm = setOf(
"iosArm64", "iosArm32"
)
val iosSimulator = setOf(
"iosX64"
"iosX64", "iosSimulatorArm64"
)
val mingw64Bit = setOf(
"mingwX64"
@ -325,14 +344,14 @@ kotlin {
"tvosArm64"
)
val tvosSimulator = setOf(
"tvosX64"
"tvosX64", "tvosSimulatorArm64"
)
val watchosArm = setOf(
"watchosArm32", "watchosArm64"
)
val watchosSimulator = setOf(
"watchosX86"
"watchosX86", "watchosSimulatorArm64"
)
targets.withType<KotlinNativeTarget> {
@ -365,6 +384,14 @@ kotlin {
}
if (macos64Bit.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting macos cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(projectRef.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${projectRef.rootDir}/sodiumWrapper/static-macos/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${projectRef.rootDir}/sodiumWrapper/static-macos/lib/libsodium.a"
)
}
//All ioses share the same static library
if (iosArm.contains(this@withType.name)) {

View File

@ -15,7 +15,7 @@ actual object LibsodiumInitializer {
private fun loadLibrary() : JnaLibsodiumInterface {
val libraryFile = when {
Platform.isMac() -> {
SharedLibraryLoader.get().load("dynamic-macos-x86-64.dylib", JnaLibsodiumInterface::class.java)
SharedLibraryLoader.get().load("dynamic-macos.dylib", JnaLibsodiumInterface::class.java)
}
Platform.isLinux() -> {
if (Platform.isARM()) {

View File

@ -366,11 +366,11 @@ kotlin {
}
android {
compileSdkVersion(29)
compileSdkVersion(AndroidPluginConfiguration.sdkVersion)
defaultConfig {
applicationId = "com.ionspin.kotlin.crypto.sample"
minSdkVersion(21)
targetSdkVersion(29)
minSdkVersion(AndroidPluginConfiguration.minVersion)
targetSdkVersion(AndroidPluginConfiguration.sdkVersion)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"

View File

@ -1,3 +1,4 @@
./configureMacos64.sh
cd libsodium
./dist-build/apple-xcframework.sh
@ -7,6 +8,7 @@ mkdir ../static-watchos
mkdir ../static-watchos-simulators
mkdir ../static-tvos
mkdir ../static-tvos-simulators
mkdir ../static-macos
cp -R ./libsodium-apple/ios/lib ../static-ios/lib
cp -R ./libsodium-apple/ios/include ../static-ios
@ -21,4 +23,7 @@ cp -R ./libsodium-apple/watchos-simulators/include ../static-watchos-simulators
cp -R ./libsodium-apple/tvos/lib ../static-tvos/lib
cp -R ./libsodium-apple/tvos/include ../static-tvos
cp -R ./libsodium-apple/tvos-simulators/lib ../static-tvos-simulators/lib
cp -R ./libsodium-apple/tvos-simulators/include ../static-tvos-simulators
cp -R ./libsodium-apple/tvos-simulators/include ../static-tvos-simulators
cp -R ./libsodium-apple/macos/lib ../static-macos/lib
cp -R ./libsodium-apple/macos/include ../static-macos

View File

@ -1,5 +0,0 @@
#!/bin/sh
./configureMacos64.sh
make -j32 -C libsodium clean
make -j32 -C libsodium
make -j32 -C libsodium install

View File

@ -1,11 +0,0 @@
cd libsodium
./autogen.sh -s -f
./configure --prefix=$PREFIX "$@"
./dist-build/tvos.sh
mkdir ../static-tvos
cp -R ./libsodium-tvos/lib ../static-tvos/lib
cp -R ./libsodium-tvos/include ../static-tvos/include
rm -r ./libsodium-tvos/

View File

@ -1,9 +0,0 @@
cd libsodium
./autogen.sh -s -f
./configure --prefix=$PREFIX "$@"
./dist-build/watchos.sh
mkdir ../static-watchos
cp -R ./libsodium-watchos/lib ../static-watchos/lib
cp -R ./libsodium-watchos/include ../static-watchos/include
rm -r ./libsodium-watchos/