From 8fb4f913745319f40fd74566a345f3f8a4de4320 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Tue, 7 Jul 2020 20:22:08 +0200 Subject: [PATCH] Add delegated as base for future libsodium bindings, update travis yml to include it, start updating readme --- .gitignore | 4 +- .travis.yml | 2 +- README.md | 22 +- linuxBuild.sh | 2 + linuxBuildAndPublish.sh | 4 +- macBuild-mac-ios.sh | 7 + macBuild-tvos.sh | 6 +- macBuild-watchos.sh | 7 +- macBuildAndPublish-mac-ios.sh | 5 + macBuildAndPublish-tvos.sh | 3 + macBuildAndPublish-watchos.sh | 4 + .../build.gradle.kts | 660 ++++++++++++++++++ .../libsodium-wrappers-sumo-0.7.6.tgz | Bin 0 -> 15788 bytes .../ionspin/kotlin/bignum/integer/Placeholder | 0 .../ionspin/kotlin/bignum/integer/Placeholder | 0 .../src/jsMain/kotlin/libsodium.kt | 28 + .../com/ionspin/kotlin/crypto/Placeholder | 0 .../com/ionspin/kotlin/crypto/Placeholder | 0 .../com/ionspin/kotlin/crypto/Placeholder | 0 .../com/ionspin/kotlin/crypto/Placeholder | 0 .../kotlin/com/ionspin/kotlin/crypto/SRNG.kt | 44 ++ .../src/nativeInterop/cinterop/libsodium.def | 6 + settings.gradle.kts | 1 + windowsBuild-delegated.sh | 2 + windowsBuildAndPublish-delegated.sh | 5 +- 25 files changed, 799 insertions(+), 13 deletions(-) create mode 100644 multiplatform-crypto-libsodium-bindings/build.gradle.kts create mode 100644 multiplatform-crypto-libsodium-bindings/libsodium-wrappers-sumo-0.7.6.tgz create mode 100644 multiplatform-crypto-libsodium-bindings/src/iosMain/kotlin/com/ionspin/kotlin/bignum/integer/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/iosTest/kotlin/com/ionspin/kotlin/bignum/integer/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/libsodium.kt create mode 100644 multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpMain/kotlin/com/ionspin/kotlin/crypto/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpTest/kotlin/com/ionspin/kotlin/crypto/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/linuxX64Main/kotlin/com/ionspin/kotlin/crypto/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/linuxX64Test/kotlin/com/ionspin/kotlin/crypto/Placeholder create mode 100644 multiplatform-crypto-libsodium-bindings/src/mingwX64Main/kotlin/com/ionspin/kotlin/crypto/SRNG.kt create mode 100644 multiplatform-crypto-libsodium-bindings/src/nativeInterop/cinterop/libsodium.def diff --git a/.gitignore b/.gitignore index d17c8f7..3a5feb9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,9 @@ build/ /multiplatform-crypto-delegated/node_modules /multiplatform-crypto-delegated/package.json /multiplatform-crypto-delegated/package-lock.json - +/multiplatform-crypto-libsodium-bindings/node_modules +/multiplatform-crypto-libsodium-bindings/package.json +/multiplatform-crypto-libsodium-bindings/package-lock.json /sodiumWrapper/include/ /sodiumWrapper/lib/ /sodiumWrapper/ios-include/ diff --git a/.travis.yml b/.travis.yml index 112f209..6beb2bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ matrix: - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./macBuild-pure.sh; fi' - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./macBuildAndPublish-pure.sh; fi' - os: windows - name: windwos-pure + name: windows-pure language: shell jdk: openjdk12 env: diff --git a/README.md b/README.md index a3f5b73..5650e6b 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,26 @@ # Kotlin Multiplatform Crypto Library +#Note: +### Next stable release will be published after public release of Kotlin 1.4, until then API will change significantly + Kotlin Multiplatform Crypto is a library for various cryptographic applications. -The library comes in two flavors `multiplatform-crypto` and `multiplatform-crypto-delegated` +The library comes in two flavors `multiplatform-crypto` and `multiplatform-crypto-delegated`. This project also provides +direct libsodium bindings under `multiplatform-crypto-libsodium-bindings`. * `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, like libsodium, but care should still be taken that the kotlin code is not reviewed or proven safe. +* `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| |--------|------------|------------------| @@ -41,9 +50,7 @@ The library includes sample project that shows usage on different platforms **The API will move fast and break often until v1.0** Next steps: -- Expand API (AEAD, ECC ...) -- Include AES and Argon2 in new API approach -- Add primitives missing in `delegated` variant that are supported in `pure` (at the moment AES and Argon2) +- Expand API (ECC, Signing ...) ## Should I use this in production? @@ -58,7 +65,7 @@ No, but even if after being warned you decide to, then use `multiplatform-crypto 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. -## Currently supported +## API ### Hashing functions * Blake2b @@ -264,6 +271,8 @@ plainText == decrypted.toHexString() ``` +## Libsodium bindings +TODO @@ -281,4 +290,3 @@ plainText == decrypted.toHexString() - \ No newline at end of file diff --git a/linuxBuild.sh b/linuxBuild.sh index 329aeef..332984c 100755 --- a/linuxBuild.sh +++ b/linuxBuild.sh @@ -16,6 +16,8 @@ fi #now we can do the delegated build cd .. ./gradlew multiplatform-crypto-delegated:build +#build libsodium bindings +./gradlew multiplatform-crypto-libsodium-bindings:build #and finally pure build ./gradlew multiplatform-crypto:build set +e diff --git a/linuxBuildAndPublish.sh b/linuxBuildAndPublish.sh index 3df17bf..719e4d5 100755 --- a/linuxBuildAndPublish.sh +++ b/linuxBuildAndPublish.sh @@ -16,9 +16,11 @@ fi #now we can do the delegated build cd .. ./gradlew multiplatform-crypto-delegated:build +#build libsodium bindings +./gradlew multiplatform-crypto-libsodium-bindings:build #and finally pure build ./gradlew multiplatform-crypto:build ./gradlew publishJvmPublicationToSnapshotRepository publishJsPublicationToSnapshotRepository \ publishKotlinMultiplatformPublicationToSnapshotRepository publishLinuxX64PublicationToSnapshotRepository \ publishLinuxArm64PublicationToSnapshotRepository publishMetadataPublicationToSnapshotRepository -set +e \ No newline at end of file +set +e diff --git a/macBuild-mac-ios.sh b/macBuild-mac-ios.sh index 237ae0d..2956483 100755 --- a/macBuild-mac-ios.sh +++ b/macBuild-mac-ios.sh @@ -14,5 +14,12 @@ multiplatform-crypto-delegated:iosX64MainKlibrary multiplatform-crypto-delegated multiplatform-crypto-delegated:macosX64MainKlibrary multiplatform-crypto-delegated:macosX64TestKlibrary ./gradlew multiplatform-crypto-delegated:iosX64Test ./gradlew multiplatform-crypto-delegated:macosX64Test + +./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 \ +multiplatform-crypto-libsodium-bindings:macosX64MainKlibrary multiplatform-crypto-libsodium-bindings:macosX64TestKlibrary +./gradlew multiplatform-crypto-libsodium-bindings:iosX64Test +./gradlew multiplatform-crypto-libsodium-bindings:macosX64Test set +e diff --git a/macBuild-tvos.sh b/macBuild-tvos.sh index 5c6fcc7..0fbc520 100755 --- a/macBuild-tvos.sh +++ b/macBuild-tvos.sh @@ -10,4 +10,8 @@ cd .. ./gradlew multiplatform-crypto-delegated:tvosArm64MainKlibrary multiplatform-crypto-delegated:tvosArm64TestKlibrary \ multiplatform-crypto-delegated:tvosX64MainKlibrary multiplatform-crypto-delegated:tvosX64TestKlibrary ./gradlew multiplatform-crypto-delegated:tvosX64Test -set +e \ No newline at end of file + +./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 diff --git a/macBuild-watchos.sh b/macBuild-watchos.sh index 8187481..6935420 100755 --- a/macBuild-watchos.sh +++ b/macBuild-watchos.sh @@ -11,4 +11,9 @@ cd .. multiplatform-crypto-delegated:watchosArm64MainKlibrary multiplatform-crypto-delegated:watchosArm64TestKlibrary \ multiplatform-crypto-delegated:watchosX86MainKlibrary multiplatform-crypto-delegated:watchosX86TestKlibrary ./gradlew multiplatform-crypto-delegated:watchosX86Test -set +e \ No newline at end of file + +./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 diff --git a/macBuildAndPublish-mac-ios.sh b/macBuildAndPublish-mac-ios.sh index 3c9da6a..aaa92e0 100755 --- a/macBuildAndPublish-mac-ios.sh +++ b/macBuildAndPublish-mac-ios.sh @@ -12,4 +12,9 @@ cd .. multiplatform-crypto-delegated:publishIosArm64PublicationToSnapshotRepository \ multiplatform-crypto-delegated:publishIosX64PublicationToSnapshotRepository \ multiplatform-crypto-delegated:publishMacosX64PublicationToSnapshotRepository + +./gradlew multiplatform-crypto-libsodium-bindings:publishIosArm32PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishIosArm64PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishIosX64PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishMacosX64PublicationToSnapshotRepository set +e diff --git a/macBuildAndPublish-tvos.sh b/macBuildAndPublish-tvos.sh index 90ab267..9185c43 100755 --- a/macBuildAndPublish-tvos.sh +++ b/macBuildAndPublish-tvos.sh @@ -9,4 +9,7 @@ cd sodiumWrapper cd .. ./gradlew multiplatform-crypto-delegated:publishTvosArm64PublicationToSnapshotRepository \ multiplatform-crypto-delegated:publishTvosX64PublicationToSnapshotRepository + +./gradlew multiplatform-crypto-libsodium-bindings:publishTvosArm64PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishTvosX64PublicationToSnapshotRepository set +e diff --git a/macBuildAndPublish-watchos.sh b/macBuildAndPublish-watchos.sh index eee58f8..3125ec4 100755 --- a/macBuildAndPublish-watchos.sh +++ b/macBuildAndPublish-watchos.sh @@ -10,4 +10,8 @@ cd .. ./gradlew multiplatform-crypto-delegated:publishWatchosArm32PublicationToSnapshotRepository \ multiplatform-crypto-delegated:publishWatchosArm64PublicationToSnapshotRepository \ multiplatform-crypto-delegated:publishWatchosX86PublicationToSnapshotRepository + +./gradlew multiplatform-crypto-libsodium-bindings:publishWatchosArm32PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishWatchosArm64PublicationToSnapshotRepository \ +multiplatform-crypto-libsodium-bindings:publishWatchosX86PublicationToSnapshotRepository set +e diff --git a/multiplatform-crypto-libsodium-bindings/build.gradle.kts b/multiplatform-crypto-libsodium-bindings/build.gradle.kts new file mode 100644 index 0000000..257a7a9 --- /dev/null +++ b/multiplatform-crypto-libsodium-bindings/build.gradle.kts @@ -0,0 +1,660 @@ +/* + * Copyright 2019 Ugljesa Jovanovic + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +@file:Suppress("UnstableApiUsage") + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest + +plugins { + kotlin(PluginsDeps.multiplatform) + id(PluginsDeps.mavenPublish) + id(PluginsDeps.signing) + id(PluginsDeps.node) version Versions.nodePlugin + id(PluginsDeps.dokka) + id(PluginsDeps.taskTree) version Versions.taskTreePlugin +} + +val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/" + +val sonatypePassword: String? by project + +val sonatypeUsername: String? by project + +val sonatypePasswordEnv: String? = System.getenv()["SONATYPE_PASSWORD"] +val sonatypeUsernameEnv: String? = System.getenv()["SONATYPE_USERNAME"] + +repositories { + mavenCentral() + jcenter() + +} +group = ReleaseInfo.group +version = ReleaseInfo.version + +val ideaActive = isInIdea() +println("Idea active: $ideaActive") + + + +kotlin { + val hostOsName = getHostOsName() + runningOnLinuxx86_64 { + println("Configuring Linux X86-64 targets") + jvm() + js { + browser { + testTask { + isRunningInTravis { + enabled = false //Until I sort out testing on travis + } + useKarma { + useChrome() + } + } + } + nodejs { + testTask { + useMocha() { + timeout = "10s" + } + } + } + + } + linuxX64() { + compilations.getByName("main") { + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-linux-x86-64/include/") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-linux-x86-64/lib/libsodium.a" + ) + } + binaries { + staticLib { + } + } + } + + + linuxArm64() { + binaries { + staticLib { + } + } + } + // Linux 32 is using target-sysroot-2-raspberrypi which is missing getrandom and explicit_bzero in stdlib + // so konanc can't build klib because getrandom missing will cause sodium_misuse() + // ld.lld: error: undefined symbol: explicit_bzero + // >>> referenced by utils.c + // >>> libsodium_la-utils.o:(sodium_memzero) in archive /tmp/included11051337748775083797/libsodium.a + // + // ld.lld: error: undefined symbol: getrandom + // >>> referenced by randombytes_sysrandom.c + // >>> libsodium_la-randombytes_sysrandom.o:(_randombytes_linux_getrandom) in archive /tmp/included11051337748775083797/libsodium.a + +// linuxArm32Hfp() { +// binaries { +// staticLib { +// } +// } +// compilations.getByName("main") { +// val libsodiumCinterop by cinterops.creating { +// defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) +// compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-arm32/include/") +// } +// kotlinOptions.freeCompilerArgs = listOf( +// "-include-binary", "${project.rootDir}/sodiumWrapper/static-arm32/lib/libsodium.a" +// ) +// } +// } + + + } + + + runningOnLinuxArm64 { + println("Configuring Linux Arm 64 targets") + + } + + runningOnLinuxArm32 { + println("Configuring Linux Arm 32 targets") + + } + + runningOnMacos { + println("Configuring macos targets") + iosX64() { + binaries { + framework { + optimized = true + } + } + } + iosArm64() { + binaries { + framework { + optimized = true + } + } + } + + iosArm32() { + binaries { + framework { + optimized = true + } + } + } + macosX64() { + binaries { + framework { + optimized = true + } + } + compilations.getByName("main") { + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-macos-x86-64/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-macos-x86-64/lib/libsodium.a" + ) + } + } + tvosX64() { + binaries { + framework { + optimized = true + } + } + } + + tvosArm64() { + binaries { + framework { + optimized = true + } + } + } + + watchosArm64() { + binaries { + framework { + optimized = true + } + } + } + + watchosArm32() { + binaries { + framework { + optimized = true + } + } + } + + watchosX86() { + binaries { + framework { + optimized = true + } + } + } + } + runningOnWindows { + println("Configuring Mingw targets") + mingwX64() { + binaries { + staticLib { + optimized = true + } + } + compilations.getByName("main") { + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-mingw-x86-64/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-mingw-x86-64/lib/libsodium.a" + ) + } + } + } + + println(targets.names) + + sourceSets { + val commonMain by getting { + dependencies { + implementation(kotlin(Deps.Common.stdLib)) + implementation(kotlin(Deps.Common.test)) + implementation(Deps.Common.kotlinBigNum) + api(project(Deps.Common.apiProject)) + } + } + val commonTest by getting { + dependencies { + implementation(kotlin(Deps.Common.test)) + implementation(kotlin(Deps.Common.testAnnotation)) + } + } + + val nativeDependencies = independentDependencyBlock { + } + + val nativeMain by creating { + dependsOn(commonMain) + isRunningInIdea { + kotlin.setSrcDirs(emptySet()) + } + dependencies { + nativeDependencies(this) + } + } + + val nativeTest by creating { + dependsOn(commonTest) + isRunningInIdea { + kotlin.setSrcDirs(emptySet()) + } + dependencies { + } + } + + //Set up shared source sets + //linux, linuxArm32Hfp, linuxArm64 + val linux64Bit = setOf( + "linuxX64" + ) + val linuxArm64Bit = setOf( + "linuxArm64" + ) + val linux32Bit = setOf( + "" // "linuxArm32Hfp" + ) + + //iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86 + val macos64Bit = setOf( + "macosX64" + ) + val ios64Bit = setOf( + "iosArm64", "iosX64" + ) + val ios32Bit = setOf( + "iosArm32" + ) + val mingw64Bit = setOf( + "mingwX64" + ) + + val tvos64Bit = setOf( + "tvosArm64", "tvosX64" + ) + + val watchos32Bit = setOf( + "watchosX86", "watchosArm32", "watchosArm64" + ) + + targets.withType { + println("Target $name") + + compilations.getByName("main") { + if (linux64Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(nativeMain) + } + if (linuxArm64Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn( + createWorkaroundNativeMainSourceSet( + this@withType.name, + nativeDependencies + ) + ) + + compilations.getByName("main") { + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-arm64/include/") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-arm64/lib/libsodium.a" + ) + } + } + if (linux32Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + } + if (macos64Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + } + //All ioses share the same static library + if (ios64Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + println("Setting ios cinterop for $this") + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-ios/lib/libsodium.a" + ) + } + + if (ios32Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + println("Setting ios cinterop for $this") + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-ios/lib/libsodium.a" + ) + } + + if (tvos64Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + println("Setting ios cinterop for $this") + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-tvos/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-tvos/lib/libsodium.a" + ) + } + + if (watchos32Bit.contains(this@withType.name)) { + defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies)) + println("Setting ios cinterop for $this") + val libsodiumCinterop by cinterops.creating { + defFile(project.file("src/nativeInterop/cinterop/libsodium.def")) + compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-watchos/include") + } + kotlinOptions.freeCompilerArgs = listOf( + "-include-binary", "${project.rootDir}/sodiumWrapper/static-watchos/lib/libsodium.a" + ) + } + + + + } + compilations.getByName("test") { + println("Setting native test dep for $this@withType.name") + defaultSourceSet.dependsOn(nativeTest) + + + } + } + + + + + runningOnLinuxx86_64 { + println("Configuring Linux 64 Bit source sets") + val jvmMain by getting { + dependencies { + implementation(kotlin(Deps.Jvm.stdLib)) + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + + //lazysodium + implementation(Deps.Jvm.Delegated.lazysodium) + implementation(Deps.Jvm.Delegated.jna) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + implementation(kotlin(Deps.Jvm.reflection)) + } + } + val jsMain by getting { + dependencies { + implementation(kotlin(Deps.Js.stdLib)) + implementation(npm(Deps.Js.Npm.libsodiumWrappers.first, Deps.Js.Npm.libsodiumWrappers.second)) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin(Deps.Js.test)) + implementation(npm(Deps.Js.Npm.libsodiumWrappers.first, Deps.Js.Npm.libsodiumWrappers.second)) + } + } + val linuxX64Main by getting { + isRunningInIdea { + kotlin.srcDir("src/nativeMain/kotlin") + } + } + val linuxX64Test by getting { + dependsOn(nativeTest) + isRunningInIdea { + kotlin.srcDir("src/nativeTest/kotlin") + } + } + + } + + runningOnMacos { + println("Configuring Macos source sets") + val macosX64Main by getting { + dependsOn(nativeMain) + if (ideaActive) { + kotlin.srcDir("src/nativeMain/kotlin") + } + + } + val macosX64Test by getting { + dependsOn(nativeTest) + if (ideaActive) { + kotlin.srcDir("src/nativeTest/kotlin") + } + + } + + val tvosX64Main by getting { + dependsOn(commonMain) + } + + val tvosArm64Main by getting { + dependsOn(commonMain) + } + + val watchosX86Main by getting { + dependsOn(commonMain) + } + + val watchosArm64Main by getting { + dependsOn(commonMain) + } + + val watchosArm32Main by getting { + dependsOn(commonMain) + } + + } + + + if (hostOsName == "windows") { + val mingwX64Main by getting { + dependsOn(nativeMain) + if (ideaActive) { + kotlin.srcDir("src/nativeMain/kotlin") + } + } + + val mingwX64Test by getting { + dependsOn(nativeTest) + if (ideaActive) { + kotlin.srcDir("src/nativeTest/kotlin") + } + } + } + + + all { + languageSettings.enableLanguageFeature("InlineClasses") + languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes") + languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi") + } + } + + +} + + + +tasks { + + + create("javadocJar") { + dependsOn(dokka) + archiveClassifier.set("javadoc") + from(dokka.get().outputDirectory) + } + + dokka { + println("Dokka !") + } + if (getHostOsName() == "linux" && getHostArchitecture() == "x86-64") { + val jvmTest by getting(Test::class) { + testLogging { + events("PASSED", "FAILED", "SKIPPED") + } + } + + val linuxX64Test by getting(KotlinNativeTest::class) { + + testLogging { + events("PASSED", "FAILED", "SKIPPED") + showStandardStreams = true + } + } + + val jsNodeTest by getting(KotlinJsTest::class) { + testLogging { + events("PASSED", "FAILED", "SKIPPED") +// showStandardStreams = true + } + } + +// val legacyjsNodeTest by getting(KotlinJsTest::class) { +// +// testLogging { +// events("PASSED", "FAILED", "SKIPPED") +// showStandardStreams = true +// } +// } + +// val jsIrBrowserTest by getting(KotlinJsTest::class) { +// testLogging { +// events("PASSED", "FAILED", "SKIPPED") +// showStandardStreams = true +// } +// } + } + + if (getHostOsName() == "windows") { + val mingwX64Test by getting(KotlinNativeTest::class) { + + testLogging { + events("PASSED", "FAILED", "SKIPPED") + showStandardStreams = true + } + } + } + +} + + + +signing { + isRequired = false + sign(publishing.publications) +} + +publishing { + publications.withType(MavenPublication::class) { + artifact(tasks["javadocJar"]) + pom { + name.set("Kotlin Multiplatform Crypto") + description.set("Kotlin Multiplatform Crypto library") + url.set("https://github.com/ionspin/kotlin-multiplatform-crypto") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("ionspin") + name.set("Ugljesa Jovanovic") + email.set("opensource@ionspin.com") + } + } + scm { + url.set("https://github.com/ionspin/kotlin-multiplatform-crypto") + connection.set("scm:git:git://git@github.com:ionspin/kotlin-multiplatform-crypto.git") + developerConnection.set("scm:git:ssh://git@github.com:ionspin/kotlin-multiplatform-crypto.git") + + } + + } + } + repositories { + maven { + + url = uri(sonatypeStaging) + credentials { + username = sonatypeUsername ?: sonatypeUsernameEnv ?: "" + password = sonatypePassword ?: sonatypePasswordEnv ?: "" + } + } + + maven { + name = "snapshot" + url = uri(sonatypeSnapshots) + credentials { + username = sonatypeUsername ?: sonatypeUsernameEnv ?: "" + password = sonatypePassword ?: sonatypePasswordEnv ?: "" + } + } + } +} + +//configurations.forEach { +// +// if (it.name == "linuxCompileKlibraries") { +// println("Configuration name: ${it.name}") +// it.attributes { +// this.keySet().forEach { key -> +// val attribute = getAttribute(key) +// println(" |-- Attribute $key ${attribute}") +// attribute(org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations.ATTRIBUTE, "publicZ") +// } +// } +// } +//} + + diff --git a/multiplatform-crypto-libsodium-bindings/libsodium-wrappers-sumo-0.7.6.tgz b/multiplatform-crypto-libsodium-bindings/libsodium-wrappers-sumo-0.7.6.tgz new file mode 100644 index 0000000000000000000000000000000000000000..97837caa202d8ac65b43e59fc5d42a9ecb41512f GIT binary patch literal 15788 zcmV;dJyXITiwFP!000001MPi#f7>>)=>Dxw!D!DfmDaE#J5J)-QF;|eNxbzVYd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zPFDiyO`aGKz)BRp5>PkJ(~Hv?pv&j#iod!l-QYG=q??JI0&aOc`x5T}3^vPfX^sbG zGEP+&s7Yhtpb5hbGYdJ_H28NQzeEed6l~JXY#;aOl$ClB5=+*S@0=#3LH3J+0wIveIL1$dJP^V4|>HOsO!M2yS-(2kU*sSrC_fDtiKar=t;Ux@yR>Jo|&+5^YZU*LPQq_A_+upIx6c7;h2 + +external fun crypto_generichash(hashLength: Int, inputMessage: Uint8Array) : Uint8Array + +external fun crypto_hash_sha256(message: Uint8Array) : Uint8Array +external fun crypto_hash_sha512(message: Uint8Array) : Uint8Array + +external fun crypto_hash_sha256_init(): dynamic + + + + + diff --git a/multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpMain/kotlin/com/ionspin/kotlin/crypto/Placeholder b/multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpMain/kotlin/com/ionspin/kotlin/crypto/Placeholder new file mode 100644 index 0000000..e69de29 diff --git a/multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpTest/kotlin/com/ionspin/kotlin/crypto/Placeholder b/multiplatform-crypto-libsodium-bindings/src/linuxArm32HfpTest/kotlin/com/ionspin/kotlin/crypto/Placeholder new file mode 100644 index 0000000..e69de29 diff --git a/multiplatform-crypto-libsodium-bindings/src/linuxX64Main/kotlin/com/ionspin/kotlin/crypto/Placeholder b/multiplatform-crypto-libsodium-bindings/src/linuxX64Main/kotlin/com/ionspin/kotlin/crypto/Placeholder new file mode 100644 index 0000000..e69de29 diff --git a/multiplatform-crypto-libsodium-bindings/src/linuxX64Test/kotlin/com/ionspin/kotlin/crypto/Placeholder b/multiplatform-crypto-libsodium-bindings/src/linuxX64Test/kotlin/com/ionspin/kotlin/crypto/Placeholder new file mode 100644 index 0000000..e69de29 diff --git a/multiplatform-crypto-libsodium-bindings/src/mingwX64Main/kotlin/com/ionspin/kotlin/crypto/SRNG.kt b/multiplatform-crypto-libsodium-bindings/src/mingwX64Main/kotlin/com/ionspin/kotlin/crypto/SRNG.kt new file mode 100644 index 0000000..1a83ce8 --- /dev/null +++ b/multiplatform-crypto-libsodium-bindings/src/mingwX64Main/kotlin/com/ionspin/kotlin/crypto/SRNG.kt @@ -0,0 +1,44 @@ +//We'll handle SRNG through libsodium +///* +// * Copyright 2019 Ugljesa Jovanovic +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package com.ionspin.kotlin.crypto +// +//import kotlinx.cinterop.* +//import platform.windows.* +// +///** +// * Created by Ugljesa Jovanovic +// * ugljesa.jovanovic@ionspin.com +// * on 21-Sep-2019 +// */ +//actual object SRNG { +// private val advapi by lazy { LoadLibraryA("ADVAPI32.DLL")} +// +// private val advapiRandom by lazy { +// GetProcAddress(advapi, "SystemFunction036")?.reinterpret, ULong, Int>>>() ?: error("Failed getting advapi random") +// } +// +// @Suppress("EXPERIMENTAL_UNSIGNED_LITERALS") +// actual fun getRandomBytes(amount: Int): UByteArray { +// memScoped { +// val randArray = allocArray(amount) +// val pointer = randArray.getPointer(this) +// val status = advapiRandom(pointer.reinterpret(), amount.convert()) +// return UByteArray(amount) { pointer[it].toUByte() } +// } +// } +//} \ No newline at end of file diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeInterop/cinterop/libsodium.def b/multiplatform-crypto-libsodium-bindings/src/nativeInterop/cinterop/libsodium.def new file mode 100644 index 0000000..0b00392 --- /dev/null +++ b/multiplatform-crypto-libsodium-bindings/src/nativeInterop/cinterop/libsodium.def @@ -0,0 +1,6 @@ +headers = sodium.h +headerFilter = sodium.h sodium/** +#staticLibraries = libsodium.a +#libraryPaths = sodiumWrapper/lib +#compilerOpts = -I./sodiumWrapper/include +linkerOpts = \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 92e8084..085d14b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -38,5 +38,6 @@ rootProject.name = "KotlinMultiplatformCrypto" include("multiplatform-crypto-api") include("multiplatform-crypto") include("multiplatform-crypto-delegated") +include("multiplatform-crypto-libsodium-bindings") include("sample") diff --git a/windowsBuild-delegated.sh b/windowsBuild-delegated.sh index 252054b..655bb92 100755 --- a/windowsBuild-delegated.sh +++ b/windowsBuild-delegated.sh @@ -14,5 +14,7 @@ echo "completed libsodium build" #now we can do the delegated build cd .. ./gradlew multiplatform-crypto-delegated:build +#and then libsodium bindings +./gradlew multiplatform-crypto-libsodium-bindings:build set +e diff --git a/windowsBuildAndPublish-delegated.sh b/windowsBuildAndPublish-delegated.sh index 6434ff4..6432351 100755 --- a/windowsBuildAndPublish-delegated.sh +++ b/windowsBuildAndPublish-delegated.sh @@ -15,4 +15,7 @@ echo "completed libsodium build" cd .. ./gradlew multiplatform-crypto-delegated:build ./gradlew multiplatform-crypto-delegated:publishMingwX64PublicationToSnapshotRepository -set +e \ No newline at end of file + +./gradlew multiplatform-crypto-libsodium-bindings:build +./gradlew multiplatform-crypto-libsodium-bindings:publishMingwX64PublicationToSnapshotRepository +set +e