From aecad37e64fdc4dcb55d9c541cb5df95ed8e0b6a Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Sun, 24 May 2020 09:46:35 +0200 Subject: [PATCH] Adding sample project --- jvmSample/build.gradle.kts | 27 -- .../classes/JvmSample$Companion.class | Bin 1130 -> 0 bytes .../out/production/classes/JvmSample.class | Bin 709 -> 0 bytes .../classes/META-INF/jvmSample.kotlin_module | Bin 20 -> 0 bytes .../test/classes/JvmTest$testNothing$1.class | Bin 1022 -> 0 bytes jvmSample/out/test/classes/JvmTest.class | Bin 3791 -> 0 bytes .../classes/META-INF/jvmSample.kotlin_module | Bin 20 -> 0 bytes jvmSample/src/main/kotlin/JvmSample.kt | 28 -- jvmSample/src/test/kotlin/JvmTest.kt | 66 --- multiplatform-crypto/build.gradle.kts | 12 +- .../gradle/wrapper/gradle-wrapper.properties | 21 - .../keyderivation/argon2/ArgonMatrix.kt | 5 + .../com/ionspin/kotlin/crypto/ReadmeTest.kt | 2 +- sample/build.gradle.kts | 448 ++++++++++++++++++ .../ionspin/kotlin/crypto/sample/Sample.kt | 5 + .../ionspin/kotlin/crypto/sample/Runner.kt | 28 ++ .../ionspin/kotlin/bignum/integer/Placeholder | 0 settings.gradle.kts | 2 +- 18 files changed, 494 insertions(+), 150 deletions(-) delete mode 100644 jvmSample/build.gradle.kts delete mode 100644 jvmSample/out/production/classes/JvmSample$Companion.class delete mode 100644 jvmSample/out/production/classes/JvmSample.class delete mode 100644 jvmSample/out/production/classes/META-INF/jvmSample.kotlin_module delete mode 100644 jvmSample/out/test/classes/JvmTest$testNothing$1.class delete mode 100644 jvmSample/out/test/classes/JvmTest.class delete mode 100644 jvmSample/out/test/classes/META-INF/jvmSample.kotlin_module delete mode 100644 jvmSample/src/main/kotlin/JvmSample.kt delete mode 100644 jvmSample/src/test/kotlin/JvmTest.kt delete mode 100644 multiplatform-crypto/gradle/wrapper/gradle-wrapper.properties create mode 100644 sample/build.gradle.kts create mode 100644 sample/src/commonMain/kotlin/com/ionspin/kotlin/crypto/sample/Sample.kt create mode 100644 sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt create mode 100644 sample/src/linuxTest/kotlin/com/ionspin/kotlin/bignum/integer/Placeholder diff --git a/jvmSample/build.gradle.kts b/jvmSample/build.gradle.kts deleted file mode 100644 index 196d1b7..0000000 --- a/jvmSample/build.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -plugins { - kotlin("jvm") -} - -group = "com.ionspin.kotlin" -version = "unspecified" - -repositories { - maven("https://dl.bintray.com/kotlin/kotlin-eap") - mavenCentral() -} - -dependencies { - implementation(kotlin("stdlib-jdk8")) - implementation(project(path = ":multiplatform-crypto")) - testImplementation(kotlin(Deps.Jvm.test)) - testImplementation(kotlin(Deps.Jvm.testJUnit)) -} - -tasks { - compileKotlin { - kotlinOptions.jvmTarget = "1.8" - } - compileTestKotlin { - kotlinOptions.jvmTarget = "1.8" - } -} \ No newline at end of file diff --git a/jvmSample/out/production/classes/JvmSample$Companion.class b/jvmSample/out/production/classes/JvmSample$Companion.class deleted file mode 100644 index 887c55545175f1fe213c4bcd6b3111b1e3a3e4d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1130 zcmb7DOH&g;5dLQKWQ-ERL%>%A)DV!6_(G#rVSuVYK+0G-$ibR~5tr=FQoEZJ-g5GX zc=DEb?dw>EF8HiGL-@I=O#fvJR}tn2Vv-@7D%Bm|GF9fVX=kXAbd|6&Yx09=Sbo7#p6@nl zzT<8Sw=P|($6;vV=v-|Od~bK63`_r~#xQb9*p|N77rvl24Z9hj0Wp09^#Sr#J3g8L zs}njlwcj9XKg+PvZY8)eX>cRnZgC^34THB^(UZ@C$#yGeEVEaUsB!WoO#aPqJTPr6 z2T#6+Lzzq<%z_g^o9`vm)&!4T_*mg+RtV8Pj!48tW;$(@E>mF`UT)FxCZYvf4OUKlY{aXcHNx-ZYeN+OlGL zCJC)7T0r4b$U~Oq5Y&%@0Bt}BVfuDSbKYJnwWsMkk?4J_j^-S5iVtGoQ{82DCafqA-|Jhe9XLNc2?m(&M? zADyR5JUg3R%&k1j^7J~#6Vl(Jx;NoY^$uRYv diff --git a/jvmSample/out/production/classes/JvmSample.class b/jvmSample/out/production/classes/JvmSample.class deleted file mode 100644 index 227d1109866398d8492610212c7665e33b746177..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 709 zcmYLG%We}f6g{5Fb2`v8r6u7J3KU3-#E^;=t&kuHF(?IzqDUw!XJWv~jHenq5zBlF zE4GM5C6G|mB_D;jPMdUd?0fF(`1tR?Uw;5R!9#}fn@MuSljB$v!5At-KH)*k)#u<{ ze<&hTgv(GkkV=|o3~qC$>m!eXha8FwIrBwohLz58%05HsAd1iH%k4Bd=1QiDVdJ7` zdr4FIT4$6RY6uR6;R9|saZWOENg=b4vjF1ybB^S&5k+66Vz)R&$|_sspKv z$P|x*m*Nv2$EKYsZL)D>((I6DBa!W&*>lT716w|PTq?uC9R`27;L*sCZ|!s-7*;z{ ziMQjVFR~B39}`pUq!Ew1Jd-v)C;d<qja1_;+3=w_4i|CWFop!OX_&8 zRBE^(!!=s8IybkjZk1TK=-Kpng!d>4=p-kQ-#tO;$2@(X(58V+JRtPX3Q&eeQ3)%{ z<{IYT0{=G}AK3|R|HNH81H?B8J?d=GLLYVPQ0!nEyL7%L{xVHj?ZFLE39%NUiuFZQ g4RHk<{9 diff --git a/jvmSample/out/test/classes/JvmTest$testNothing$1.class b/jvmSample/out/test/classes/JvmTest$testNothing$1.class deleted file mode 100644 index 2511c332e7d00a74b80f5a58e85de0ee77711ee0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1022 zcmZ`%TTc@~6#iygx@Egci`+#(t=gip1@YR31PH`6wL~FJgr{k{z|h^_Sf0XgeQcM$ZlRcO3d~EBqMlo(+ z022&pySBZvT3g>Bv(luk#^l`j8ecjgZ}E^*Ce7<6=ysSANhLs7BgPU8tWDlqp>U0? z)*{37>2caPJvOv#hE(?ScuFg==f=mymKZV>E`9mV^P_-zq>OrR5FK|Z+IRUT z?qf`KKBm@ZnV7=JAX!w%=$%<;hcw~3-=aGhstW1UBCp|ec6h@jWVq@#xm)KQq5K|b z+EO~5b(aT$Lwg+BkWJSQ=&jM#n^!yi?UorfVY=(yDrMog5~%I+>bJoM7@3SyU5O|Hj8DuD;B7Xm3tX z`i!MB(f}S4tQt5YOyCLmNor*QPs!4dz_VCCK$-L!F{i2dYkNr8n6WWy(~#HCy*V2< Za8rrAja#_A2NvKC3KS1e3@{%c{RgPt)nNbt diff --git a/jvmSample/out/test/classes/JvmTest.class b/jvmSample/out/test/classes/JvmTest.class deleted file mode 100644 index 69b089b80e9468e7f1ef4bc1234989fddcc0c235..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3791 zcmbVPXzF7V_{r}ZllqF$4Db(G$N2L zaocp?_q|Qrrir`PZEf1*NqO?I{n)>d5B(KM&mBofexM&}9%gj!x#ymHmiL@{=AZBV z{cQka_$z~OX|23q)EohfA#zJw)8Zw~T8TeXxMk=>^)ejItyY|pX~k#PtA=fs4a?C= zd8b%13sY5dlA+5X0rM5-rfID(cn60TNmQ<4uf%WFEz^l}`NS5Yqw-q0S~3KLXgX6V zS2fG5SPW8bdu?EwJQ+q8!Xb$0X4tn2gMhtcfYmrSj2;LgB8ZZ>rcnbOiVY+M^fCn1 z`TWAv{LC!F0e&dg?O`@Lc0Ue;AfbBoR%oFhf*xDGPSp7$_RcTD{~jTpY}`U7dGqa@=Ig%m3r3Nws53BRZ2qi(wqa zF%d`5&(PD<7wZmQ8fLfC<8t zP62T2y6#l$rbWI%l^c}Bq=*cjWIzyS7$)>eInIr#5_DT8+8b4;5??hoiiG4fjT;+p zs1={$+AVBU37t=qTJAJu78$a+N0mfSn#N2BQ#i+veiSJw0p}S4PnwiRWYdG)aI*tR z6rN77wD7fq@6qk*#HwjIhHYu3__+qUXW9Xp)9h8lc42xEs)!4?M8>$THwYqwE{JlN z<16z75Ld&xW0oiw1mB#=>(Uj@sdA`a#8nZ`BG1s<=A79^t$=F``PW1nufn*2=R|w}OH@ocC3Xn>5P_ts74wc}Q$`Q& z5*c-7SJ5BAM@4)XlrLVbNcfUEx3)6-xiEATyRZoI)SkAv4WCe%jkd$7QUJ69FRLb5 z)TYne)a<7Pu&ua0u|6DhfxpOO~wa|1`yJo%Bsb=fQ$qwIj9`}FK zI|2K!pr+2dm&N3+WwAr4?SNKL6=C6dhTFQ9934v}M)k~cW_euEwTTHOGn&rm$zmp< zq?N>|p{K_*eKfJ0PNpZ86Nt{KZIJ*m_Bc+!|iW|Tx~d_qs8Gs?12(3P=d zDy`{-f|1UoGs!WfSV-#06!B%WWMNz{j80@GQd%Yms*DHPacbx|T{laV8UpGZ>2#H? z;RPz!3))JyKZp%V9IaY4ECNidGZIY$cOtDRk804z@Nq8f69m{+22hj-cWxoxmvEc& ze(IrSAiq&_jIw~w5M(QLLc7%Puvv*;p}Wf=9Sp5ZyFZK1h43;y-^%5O83cTh?&~Vw zQR0_=rx`8WQ<{GnUlH*oe3kAKlg?svrz8i=0c{{w)~d1AoxRItGT>+{4R;JAX`f10 zqCqW-?ifY#Vq=98XD2%7p4#3@CeoO4u5o}$w~a>m!!Z6xofBEvqbMVAKA0?gWTsKSLd{9lQ*ndmSNA7c%wwiV!l$hb>qCrh4(fl=Zr#qWp>>$tQy_e)Uq_i ztJd0%1CWG=Jj?&Q)Ds3E(EPVF`vv^e835`%?75G9>>lJT9P+VEJmz~Vc*E;mnDd?) z$+=_S!n{}U#pZ_jk5}=>Ht~cK@G3%VMDj^~DX@vy^*@m?4}M4Q$6dk4>97Graf14> z6V#ZUqz36EhVcaD^ALVdeEp=-Fs+dICh@iuPc%rMyQ# zn0AAOqUq?k5P3QxKh@*I8Kqa*myKq7NXx@VZf@c!MUs2usI*V&l_Vj0HhT6RW?6QB z_CU5TD=P<;L&{<0NcL#<*qgX;Lp~-Sm5xYa{xSSilk7wpavfOal zmkqp$XK%L?IiI_sWsKVcCQ0FL$xm-~X2^Y~kh>Zbi>-p~RS%vB(*UhCLs3vc5O5 zcH;roqc7gaCu8*7$EUM?uM)V2FUbD;_!@V<7k{Mpd3fH(x6w~=7H~np4_WgOu;>oC ze?gx7G5s^f`~s%7C&a+Xz_=U8tLP=x7(J&cKykuRf>4vB%_$1jC`Rb3=`_+rRcI7L z5fd<}>%9A3jxd(NKj`^4J?~OG`XA~=gE;F3o(ekd(#Ofy@eOnnXE(lyZ($GdJVvU2 zht7GIAoE=sc}d<{9 diff --git a/jvmSample/src/main/kotlin/JvmSample.kt b/jvmSample/src/main/kotlin/JvmSample.kt deleted file mode 100644 index 7adc01c..0000000 --- a/jvmSample/src/main/kotlin/JvmSample.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -/** - * Created by Ugljesa Jovanovic - * ugljesa.jovanovic@ionspin.com - * on 19-May-2020 - */ -class JvmSample { - companion object { - fun nothing() { - println("Nothing") - } - } -} \ No newline at end of file diff --git a/jvmSample/src/test/kotlin/JvmTest.kt b/jvmSample/src/test/kotlin/JvmTest.kt deleted file mode 100644 index 9babc83..0000000 --- a/jvmSample/src/test/kotlin/JvmTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -@file:Suppress("EXPERIMENTAL_UNSIGNED_LITERALS", "EXPERIMENTAL_API_USAGE") - -import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2 -import com.ionspin.kotlin.crypto.keyderivation.argon2.ArgonType -import org.jetbrains.annotations.TestOnly -import org.junit.Test -import kotlin.test.assertTrue - -/* - * 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. - */ - -/** - * Created by Ugljesa Jovanovic - * ugljesa.jovanovic@ionspin.com - * on 19-May-2020 - */ -@ExperimentalStdlibApi -class JvmTest { - - @Test - fun testNothing() { - JvmSample.nothing() - assertTrue { true } - val arr = ubyteArrayOf(0U) - val bla = ubyteArrayOf(1U) - arr.copyInto(bla) - - } - - @Test - fun argon2StringExample() { - val argon2Instance = Argon2( - password = "Password", - salt = "RandomSalt", - parallelism = 4, - tagLength = 64U, - requestedMemorySize = 25U * 1024U, //Travis build on mac fails with higher values - numberOfIterations = 4, - key = "", - associatedData = "", - argonType = ArgonType.Argon2id - ) - val tag = argon2Instance.derive() - val tagString = tag.map { it.toString(16).padStart(2, '0') }.joinToString(separator = "") - val expectedTagString = "ca134003c9f9f76ca8869359c1d9065603ec54ac30f5158f06af647cacaef2c1c3e" + - "c71e81960278c0596febc64125acbbe5959146db1c128199a1b7cb38982a9" - println("Tag: ${tagString}") -// assertEquals(tagString, expectedTagString) - - } - - -} \ No newline at end of file diff --git a/multiplatform-crypto/build.gradle.kts b/multiplatform-crypto/build.gradle.kts index 0017c04..2c6dde2 100644 --- a/multiplatform-crypto/build.gradle.kts +++ b/multiplatform-crypto/build.gradle.kts @@ -105,7 +105,7 @@ kotlin { linuxX64("linux") { binaries { staticLib { - + optimized = true } } } @@ -130,14 +130,14 @@ kotlin { iosX64("ios") { binaries { framework { - + optimized = true } } } iosArm64("ios64Arm") { binaries { framework { - + optimized = true } } } @@ -145,14 +145,14 @@ kotlin { iosArm32("ios32Arm") { binaries { framework { - + optimized = true } } } macosX64() { binaries { framework { - + optimized = true } } } @@ -162,7 +162,7 @@ kotlin { mingwX64() { binaries { staticLib { - + optimized = true } } } diff --git a/multiplatform-crypto/gradle/wrapper/gradle-wrapper.properties b/multiplatform-crypto/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e501ab5..0000000 --- a/multiplatform-crypto/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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. -# - -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file diff --git a/multiplatform-crypto/src/commonMain/kotlin/com/ionspin/kotlin/crypto/keyderivation/argon2/ArgonMatrix.kt b/multiplatform-crypto/src/commonMain/kotlin/com/ionspin/kotlin/crypto/keyderivation/argon2/ArgonMatrix.kt index f663888..904c048 100644 --- a/multiplatform-crypto/src/commonMain/kotlin/com/ionspin/kotlin/crypto/keyderivation/argon2/ArgonMatrix.kt +++ b/multiplatform-crypto/src/commonMain/kotlin/com/ionspin/kotlin/crypto/keyderivation/argon2/ArgonMatrix.kt @@ -25,6 +25,9 @@ import com.ionspin.kotlin.crypto.util.xor * or a UByteArray block */ interface ArgonBlockPointer { + companion object { + private val _emitLongArray : LongArray = longArrayOf(1L,2L) + } val blockStartPosition: Int fun pointerArithmetic(block : (Int, Int) -> Int) : ArgonBlockPointer @@ -47,6 +50,8 @@ interface ArgonBlockPointer { fun getAsUByteArray() : UByteArray } +fun ArgonBlockPointer._emitLongArray() : LongArray = longArrayOf(0,1) + fun ArgonBlockPointer.getRowOfULongsForMixing(rowIndex: Int) : ULongArray { // Each row has 16 unsigned longs (16 ulongs * 8 bytes = 128 bytes) -- Argon2 considers this as 2 word unsigned // numbers, so strictly speaking argon representation is 8 * 8 matrix of 2 word unsigned numbers (registers diff --git a/multiplatform-crypto/src/commonTest/kotlin/com/ionspin/kotlin/crypto/ReadmeTest.kt b/multiplatform-crypto/src/commonTest/kotlin/com/ionspin/kotlin/crypto/ReadmeTest.kt index 5267924..aeae03a 100644 --- a/multiplatform-crypto/src/commonTest/kotlin/com/ionspin/kotlin/crypto/ReadmeTest.kt +++ b/multiplatform-crypto/src/commonTest/kotlin/com/ionspin/kotlin/crypto/ReadmeTest.kt @@ -138,7 +138,7 @@ class ReadmeTest { salt = "RandomSalt", parallelism = 1, tagLength = 64U, - requestedMemorySize = 4096U, //Travis build on mac fails with higher values + requestedMemorySize = 4096U, numberOfIterations = 100, key = "", associatedData = "", diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts new file mode 100644 index 0000000..7fef86b --- /dev/null +++ b/sample/build.gradle.kts @@ -0,0 +1,448 @@ +/* + * 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 com.moowork.gradle.node.task.NodeTask +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 + +plugins { + kotlin(PluginsDeps.multiplatform) + id (PluginsDeps.mavenPublish) + id (PluginsDeps.signing) + id (PluginsDeps.node) version Versions.nodePlugin + id (PluginsDeps.dokka) version Versions.dokkaPlugin +} + +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 = "com.ionspin.kotlin" +version = "0.0.4-SNAPSHOT" + +val ideaActive = System.getProperty("idea.active") == "true" + +fun getHostOsName(): String { + val target = System.getProperty("os.name") + if (target == "Linux") return "linux" + if (target.startsWith("Windows")) return "windows" + if (target.startsWith("Mac")) return "macos" + return "unknown" +} + +kotlin { + val hostOsName = getHostOsName() + if (ideaActive) { + when(hostOsName) { + "linux" -> linuxX64("native") + "macos" -> macosX64("native") + "windows" -> mingwX64("native") + } + } + if (hostOsName == "linux") { + 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 { +// +// testTask { +// useKarma { +// useChrome() +// } +// } +// } + nodejs { + testTask { + useMocha() { + timeout = "10s" + } + } + } + + } + linuxX64("linux") { + + binaries { + + executable { + println("Optimized: $optimized") + optimized = true + } + } + } + //Not supported in coroutines at the moment +// linuxArm32Hfp() { +// binaries { +// staticLib { +// } +// } +// } + //Not supported in coroutines at the moment +// linuxArm64() { +// binaries { +// staticLib { +// } +// } +// } + + } + + if (hostOsName == "macos") { + iosX64("ios") { + binaries { + framework { + + } + } + } + iosArm64("ios64Arm") { + binaries { + framework { + + } + } + } + + iosArm32("ios32Arm") { + binaries { + framework { + + } + } + } + macosX64() { + binaries { + framework { + + } + } + } + } + if (hostOsName == "windows") { + + mingwX64() { + binaries { + staticLib { + + } + } + } + } +// No coroutines support for mingwX86 +// mingwX86() { +// binaries { +// staticLib { +// +// } +// } +// } + + + println(targets.names) + + sourceSets { + val commonMain by getting { + dependencies { + implementation(kotlin(Deps.Common.stdLib)) + implementation(kotlin(Deps.Common.test)) + implementation(Deps.Common.coroutines) + implementation(Deps.Common.kotlinBigNum) + implementation(project(":multiplatform-crypto")) + } + } + val commonTest by getting { + dependencies { + implementation(kotlin(Deps.Common.test)) + implementation(kotlin(Deps.Common.testAnnotation)) + } + } + + val nativeMain = if (ideaActive) { + val nativeMain by getting { + dependsOn(commonMain) + dependencies { + implementation(Deps.Native.coroutines) + } + } + nativeMain + } else { + val nativeMain by creating { + dependsOn(commonMain) + dependencies { + implementation(Deps.Native.coroutines) + } + } + nativeMain + } + val nativeTest = if (ideaActive) { + val nativeTest by getting { + dependsOn(commonTest) + dependencies { + implementation(Deps.Native.coroutines) + } + } + nativeTest + } else { + val nativeTest by creating { + dependsOn(commonTest) + dependencies { + implementation(Deps.Native.coroutines) + } + } + nativeTest + } + + if (hostOsName == "linux") { + val jvmMain by getting { + dependencies { + implementation(kotlin(Deps.Jvm.stdLib)) + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + implementation(Deps.Jvm.coroutinesCore) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + implementation(Deps.Jvm.coroutinesTest) + implementation(kotlin(Deps.Jvm.reflection)) + } + } + val jsMain by getting { + dependencies { + implementation(kotlin(Deps.Js.stdLib)) + implementation(Deps.Js.coroutines) + } + } + val jsTest by getting { + dependencies { + implementation(Deps.Js.coroutines) + implementation(kotlin(Deps.Js.test)) + } + } + val linuxMain by getting { + dependsOn(nativeMain) + } + val linuxTest by getting { + dependsOn(nativeTest) + } + //Not supported in coroutines at the moment +// val linuxArm32HfpMain by getting { +// dependsOn(nativeMain) +// } +// +// val linuxArm32HfpTest by getting { +// dependsOn(nativeTest) +// } + +// val linuxArm64Main by getting { +// dependsOn(nativeMain) +// } +// +// val linuxArm64Test by getting { +// dependsOn(nativeTest) +// } + + } + + if (hostOsName == "macos") { + + val iosMain by getting { + dependsOn(nativeMain) + } + val iosTest by getting { + dependsOn(nativeTest) + } + + val ios64ArmMain by getting { + dependsOn(nativeMain) + } + val ios64ArmTest by getting { + dependsOn(nativeTest) + } + + val ios32ArmMain by getting { + dependsOn(nativeMain) + } + val ios32ArmTest by getting { + dependsOn(nativeTest) + } + + val macosX64Main by getting { + dependsOn(nativeMain) + } + val macosX64Test by getting { + dependsOn(nativeTest) + } + } + +// Coroutines don't support mingwx86 yet +// val mingwX86Main by getting { +// dependsOn(commonMain) +// dependencies { +// implementation(Deps.Native.coroutines) +// } +// } + +// val mingwX86Test by getting { +// dependsOn(commonTest) +// } +// + if (hostOsName == "windows") { + val mingwX64Main by getting { + dependsOn(commonMain) + dependencies { + implementation(Deps.Native.coroutines) + } + } + + val mingwX64Test by getting { + dependsOn(commonTest) + } + } + + + all { + languageSettings.enableLanguageFeature("InlineClasses") + } + } + + +} + + + +task("copyPackageJson") { + dependsOn("compileKotlinJs") + println("Copying package.json from $projectDir/core/src/jsMain/npm") + from ("$projectDir/src/jsMain/npm") + println("Node modules dir ${node.nodeModulesDir}") + into ("${node.nodeModulesDir}") +} + +tasks { + + + create("javadocJar") { + dependsOn(dokka) + archiveClassifier.set("javadoc") + from(dokka.get().outputDirectory) + } + + dokka { + println ("Dokka !") + impliedPlatforms = mutableListOf("Common") + kotlinTasks { + listOf() + } + sourceRoot { + println ("Common !") + path = "/home/ionspin/Projects/Future/kotlin-multiplatform-crypto/crypto/src/commonMain" //TODO remove static path! + platforms = listOf("Common") + } + } + if (getHostOsName() == "linux") { + + val npmInstall by getting + val compileKotlinJs by getting(AbstractCompile::class) + val compileTestKotlinJs by getting(Kotlin2JsCompile::class) + + val jvmTest by getting(Test::class) { + testLogging { + events("PASSED", "FAILED", "SKIPPED") + } + } + + val linuxTest 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 + } + } + } + +} + + + + + + + + diff --git a/sample/src/commonMain/kotlin/com/ionspin/kotlin/crypto/sample/Sample.kt b/sample/src/commonMain/kotlin/com/ionspin/kotlin/crypto/sample/Sample.kt new file mode 100644 index 0000000..383b3f7 --- /dev/null +++ b/sample/src/commonMain/kotlin/com/ionspin/kotlin/crypto/sample/Sample.kt @@ -0,0 +1,5 @@ +package com.ionspin.kotlin.crypto.sample + +class Sample { + +} \ No newline at end of file diff --git a/sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt b/sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt new file mode 100644 index 0000000..c73d720 --- /dev/null +++ b/sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt @@ -0,0 +1,28 @@ +import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2 +import com.ionspin.kotlin.crypto.keyderivation.argon2.ArgonType +import kotlin.time.ExperimentalTime +import kotlin.time.measureTime + +@ExperimentalTime +@ExperimentalStdlibApi +fun main() { + println("Test") + val argon2Instance = Argon2( + password = "Password", + salt = "RandomSalt", + parallelism = 1, + tagLength = 64U, + requestedMemorySize = 4096U, + numberOfIterations = 100, + key = "", + associatedData = "", + argonType = ArgonType.Argon2id + ) + val time = measureTime { + val tag = argon2Instance.derive() + val tagString = tag.map { it.toString(16).padStart(2, '0') }.joinToString(separator = "") + val expectedTagString = "27c61b6538ef9f4a1250f8712cac09fc4329969295f9440249437d38c1617a005c2702d76a8a59e4cda2dfba48e1132261dacdfd31296945906992ea32f1d06e" + println("Tag: ${tagString}") + } + println("Time $time") +} diff --git a/sample/src/linuxTest/kotlin/com/ionspin/kotlin/bignum/integer/Placeholder b/sample/src/linuxTest/kotlin/com/ionspin/kotlin/bignum/integer/Placeholder new file mode 100644 index 0000000..e69de29 diff --git a/settings.gradle.kts b/settings.gradle.kts index 72f8504..28fc9f8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,5 +35,5 @@ pluginManagement { enableFeaturePreview("GRADLE_METADATA") rootProject.name = "KotlinMultiplatformCrypto" include("multiplatform-crypto") -include("jvmSample") +include("sample")