Merge pull request #38 from ionspin/kotlin-1.9.0

Kotlin 1.9.10
This commit is contained in:
Ugljesa Jovanovic 2023-09-23 14:38:33 +02:00 committed by GitHub
commit 4a96c32418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 1214 additions and 2861 deletions

View File

@ -1,10 +1,27 @@
## Descriptive changelog ## Descriptive changelog
(All dates are DD.MM.YYYY) (All dates are DD.MM.YYYY)
#### 0.8.9-SNAPSHOT - Current development snapshot #### 0.9.1-SNAPSHO - current development snapshot
#### 0.9.0-SNAPSHOT - 23.9.2023
- Breaking changes:
- PasswordHash.str now returns String
- PasswordHash.strNeedsRehash and PasswordHash.strVerify now take String type for `passwordHash` parameter
- Update to latest stable build of libsodium
- Update to kotlin 1.9.10
- Targets deprecated by kotlin 1.9.10 and therefore removed from this library:
- iosArm32
- watchosX86
- wasm32
- mingwX86
- linuxArm32Hfp
#### 0.8.9-SNAPSHOT - 26.3.2023
- Update to latest stable build of libsodium - Update to latest stable build of libsodium
- Update to kotlin 1.8.10 - Update to kotlin 1.8.10
#### 0.8.8 - 9.10.2022 #### 0.8.8 - 9.10.2022
- Fix for missing mingw target in published library modules.xml (#29) - Fix for missing mingw target in published library modules.xml (#29)

View File

@ -17,6 +17,12 @@
buildscript { buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
classpath("com.android.tools.build:gradle:7.2.2")
classpath ("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20")
}
repositories { repositories {
mavenCentral() mavenCentral()
google() google()

View File

@ -28,9 +28,9 @@ repositories {
} }
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
implementation("com.android.tools.build:gradle:7.2.2") implementation("com.android.tools.build:gradle:7.2.2")
implementation ("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10") implementation ("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20")
} }
System.setProperty("PROJECT_PATH", project.projectDir.parentFile.toString()) System.setProperty("PROJECT_PATH", project.projectDir.parentFile.toString())

View File

@ -15,16 +15,14 @@
*/ */
object Versions { object Versions {
val kotlinCoroutines = "1.7.0-Beta" val kotlinCoroutines = "1.7.3"
val kotlin = "1.8.10" val kotlin = "1.9.10"
val kotlinSerialization = "1.5.0" val kotlinSerialization = "1.6.0"
val kotlinSerializationPlugin = kotlin val kotlinSerializationPlugin = kotlin
val nodePlugin = "1.3.0"
val dokkaPlugin = kotlin
val taskTreePlugin = "1.5" val taskTreePlugin = "1.5"
val kotlinBigNumVersion = "0.3.7" val kotlinBigNumVersion = "0.3.7"
val jna = "5.13.0" val jna = "5.13.0"
val kotlinPoet = "1.6.0"
val sampleLibsodiumBindings = "0.8.8-SNAPSHOT" val sampleLibsodiumBindings = "0.8.8-SNAPSHOT"
val ktor = "1.3.2" val ktor = "1.3.2"
val timber = "4.7.1" val timber = "4.7.1"
@ -61,27 +59,14 @@ object Deps {
object Js { object Js {
object JsVersions {
val react = "17.0.2-pre.218-kotlin-1.5.21"
val reactNpm = "17.0.2"
val styled = "5.3.0-pre.218-kotlin-1.5.21"
val styledNpm = "5.3.0"
}
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 serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.kotlinSerialization}" val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.kotlinSerialization}"
val ktorClient = "io.ktor:ktor-client-js:${Versions.ktor}"
val ktorClientSerialization = "io.ktor:ktor-client-serialization-js:${Versions.ktor}"
val ktorClientWebSockets = "io.ktor:ktor-client-websockets-js:${Versions.ktor}"
object Npm { object Npm {
val libsodium = Pair("libsodium-wrappers-sumo", "0.7.9") val libsodiumWrappers = Pair("libsodium-wrappers-sumo", "0.7.13")
//val libsodiumWrappers = Pair("libsodium-wrappers-sumo", "file:${getProjectPath()}/multiplatform-crypto-delegated/libsodium-wrappers-sumo-0.7.6.tgz")
val libsodiumWrappers = Pair("libsodium-wrappers-sumo", "0.7.9")
} }
@ -92,13 +77,10 @@ object Deps {
val test = "test" val test = "test"
val testJUnit = "test-junit" val testJUnit = "test-junit"
val reflection = "reflect" val reflection = "reflect"
val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlinCoroutines}"
val coroutinesjdk8 = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.kotlinCoroutines}"
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlinSerialization}" val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlinSerialization}"
val coroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.kotlinCoroutines}" val coroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.kotlinCoroutines}"
val kotlinPoet = "com.squareup:kotlinpoet:${Versions.kotlinPoet}"
val resourceLoader = "com.goterl:resource-loader:${Versions.resourceLoader}" val resourceLoader = "com.goterl:resource-loader:${Versions.resourceLoader}"
object Delegated { object Delegated {
@ -119,9 +101,7 @@ object Deps {
object Android { object Android {
val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.kotlinCoroutines}" val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.kotlinCoroutines}"
val ktorClientOkHttp = "io.ktor:ktor-client-okhttp:${Versions.ktor}"
val ktorClient = "io.ktor:ktor-client-android:${Versions.ktor}"
val ktorClientSerialization = "io.ktor:ktor-client-serialization-jvm:${Versions.ktor}"
val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlinSerialization}" val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlinSerialization}"
val timber = "com.jakewharton.timber:timber:${Versions.timber}" val timber = "com.jakewharton.timber:timber:${Versions.timber}"
val jna = "net.java.dev.jna:jna:${Versions.jna}@aar" val jna = "net.java.dev.jna:jna:${Versions.jna}@aar"
@ -135,7 +115,6 @@ object Deps {
object AndroidPluginConfiguration { object AndroidPluginConfiguration {
val sdkVersion = 31 val sdkVersion = 31
val targetVersion = 31
val minVersion = 24 val minVersion = 24
} }

File diff suppressed because it is too large Load Diff

View File

@ -17,9 +17,7 @@
@file:Suppress("UnstableApiUsage") @file:Suppress("UnstableApiUsage")
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
import org.jetbrains.dokka.Platform
plugins { plugins {
kotlin(PluginsDeps.multiplatform) kotlin(PluginsDeps.multiplatform)
@ -74,20 +72,12 @@ kotlin {
} }
} }
linuxArm32Hfp() {
binaries {
staticLib {
}
}
}
} }
runningOnMacos { runningOnMacos {
iosX64() iosX64()
iosArm64() iosArm64()
iosArm32()
iosSimulatorArm64() iosSimulatorArm64()
macosX64() macosX64()
@ -99,13 +89,11 @@ kotlin {
watchosArm64() watchosArm64()
watchosArm32() watchosArm32()
watchosX86()
watchosSimulatorArm64() watchosSimulatorArm64()
} }
runningOnWindows { runningOnWindows {
mingwX64() mingwX64()
mingwX86()
} }
@ -163,10 +151,6 @@ kotlin {
dependsOn(commonMain) dependsOn(commonMain)
} }
val watchosX86Main by getting {
dependsOn(commonMain)
}
val watchosArm64Main by getting { val watchosArm64Main by getting {
dependsOn(commonMain) dependsOn(commonMain)
} }

View File

@ -56,10 +56,10 @@ version = ReleaseInfo.bindingsVersion
val ideaActive = isInIdea() val ideaActive = isInIdea()
println("Idea active: $ideaActive") println("Idea active: $ideaActive")
android { android {
compileSdkVersion(AndroidPluginConfiguration.sdkVersion) compileSdk = AndroidPluginConfiguration.sdkVersion
defaultConfig { defaultConfig {
minSdkVersion(AndroidPluginConfiguration.minVersion) minSdk = AndroidPluginConfiguration.minVersion
targetSdkVersion(AndroidPluginConfiguration.sdkVersion) targetSdk = AndroidPluginConfiguration.sdkVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@ -73,13 +73,17 @@ android {
sourceSets.getByName("main") { sourceSets.getByName("main") {
// jniLibs.srcDir("src/androidMain/libs") // jniLibs.srcDir("src/androidMain/libs")
} }
lint {
abortOnError = false
}
} }
kotlin { kotlin {
val hostOsName = getHostOsName() val hostOsName = getHostOsName()
android() { androidTarget() {
publishLibraryVariants("release", "debug") publishLibraryVariants("release", "debug")
} }
@ -89,7 +93,7 @@ kotlin {
println("Configuring Linux X86-64 targets") println("Configuring Linux X86-64 targets")
js(IR) { js {
browser { browser {
testTask { testTask {
useKarma { useKarma {
@ -129,15 +133,6 @@ kotlin {
} }
} }
} }
// 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
} }
} }
@ -167,13 +162,7 @@ kotlin {
} }
} }
} }
iosArm32() {
binaries {
framework {
optimized = true
}
}
}
iosSimulatorArm64() { iosSimulatorArm64() {
binaries { binaries {
framework { framework {
@ -233,13 +222,7 @@ kotlin {
} }
} }
} }
watchosX86() {
binaries {
framework {
optimized = true
}
}
}
watchosSimulatorArm64() { watchosSimulatorArm64() {
binaries { binaries {
framework { framework {
@ -347,16 +330,13 @@ kotlin {
"" ""
} }
) )
val linux32Bit = setOf(
"" // "linuxArm32Hfp"
)
//iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86 //iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64
val macos64Bit = setOf( val macos64Bit = setOf(
"macosX64", "macosArm64" "macosX64", "macosArm64"
) )
val iosArm = setOf( val iosArm = setOf(
"iosArm64", "iosArm32" "iosArm64",
) )
val iosSimulator = setOf( val iosSimulator = setOf(
"iosX64", "iosSimulatorArm64" "iosX64", "iosSimulatorArm64"
@ -373,10 +353,10 @@ kotlin {
) )
val watchosArm = setOf( val watchosArm = setOf(
"watchosArm32", "watchosArm64" "watchosArm64", "watchosArm32"
) )
val watchosSimulator = setOf( val watchosSimulator = setOf(
"watchosX86", "watchosSimulatorArm64" "watchosSimulatorArm64"
) )
targets.withType<KotlinNativeTarget> { targets.withType<KotlinNativeTarget> {
@ -404,14 +384,7 @@ kotlin {
) )
} }
} }
if (linux32Bit.contains(this@withType.name)) {
defaultSourceSet.dependsOn(
createWorkaroundNativeMainSourceSet(
this@withType.name,
nativeDependencies
)
)
}
if (macos64Bit.contains(this@withType.name)) { if (macos64Bit.contains(this@withType.name)) {
defaultSourceSet.dependsOn( defaultSourceSet.dependsOn(
createWorkaroundNativeMainSourceSet( createWorkaroundNativeMainSourceSet(
@ -557,7 +530,7 @@ kotlin {
} }
} }
val androidTest by getting { val androidUnitTest by getting {
dependencies { dependencies {
} }
} }
@ -636,10 +609,6 @@ kotlin {
dependsOn(commonMain) dependsOn(commonMain)
} }
val watchosX86Main by getting {
dependsOn(commonMain)
}
val watchosArm64Main by getting { val watchosArm64Main by getting {
dependsOn(commonMain) dependsOn(commonMain)
} }
@ -672,6 +641,7 @@ kotlin {
languageSettings.enableLanguageFeature("InlineClasses") languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
languageSettings.optIn("kotlin.ExperimentalStdlibApi") languageSettings.optIn("kotlin.ExperimentalStdlibApi")
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
} }
} }

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) IonSpin UG Ugljesa Jovanovic 2021-2022
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ionspin.common.client">
</manifest>

View File

@ -55,7 +55,7 @@ expect object PasswordHash {
* and other data stores. No extra information has to be stored in order to verify the password. * and other data stores. No extra information has to be stored in order to verify the password.
* The function returns 0 on success and -1 if it didn't complete successfully. * The function returns 0 on success and -1 if it didn't complete successfully.
*/ */
fun str(password: String, opslimit: ULong, memlimit: Int): UByteArray fun str(password: String, opslimit: ULong, memlimit: Int): String
/** /**
* Check if a password verification string str matches the parameters opslimit and memlimit, and the current default algorithm. * Check if a password verification string str matches the parameters opslimit and memlimit, and the current default algorithm.
@ -63,13 +63,13 @@ expect object PasswordHash {
* The function returns 0 if the parameters already match the given ones. * The function returns 0 if the parameters already match the given ones.
* It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in. * It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in.
*/ */
fun strNeedsRehash(passwordHash: UByteArray, opslimit: ULong, memlimit: Int): Int fun strNeedsRehash(passwordHash: String, opslimit: ULong, memlimit: Int): Int
/** /**
* his function verifies that str is a valid password verification string (as generated by crypto_pwhash_str()) for passwd whose length is passwdlen. * his function verifies that str is a valid password verification string (as generated by crypto_pwhash_str()) for passwd whose length is passwdlen.
* str has to be zero-terminated. * str has to be zero-terminated.
* It returns 0 if the verification succeeds, and -1 on error. * It returns 0 if the verification succeeds, and -1 on error.
*/ */
fun strVerify(passwordHash: UByteArray, password: String): Boolean fun strVerify(passwordHash: String, password: String): Boolean
} }

View File

@ -6,6 +6,7 @@ import com.ionspin.kotlin.crypto.util.runTest
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
import kotlin.test.assertTrue import kotlin.test.assertTrue
import kotlin.test.fail
/** /**
* Created by Ugljesa Jovanovic * Created by Ugljesa Jovanovic

View File

@ -44,7 +44,7 @@ class PasswordHashTest {
crypto_pwhash_OPSLIMIT_MIN, crypto_pwhash_OPSLIMIT_MIN,
crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_MEMLIMIT_MIN
) )
println("Hashed password for storage: ${hashedPassword.toHexString()}") println("Hashed password for storage: ${hashedPassword}")
assertTrue { assertTrue {
PasswordHash.strVerify( PasswordHash.strVerify(

View File

@ -45,7 +45,7 @@ actual object PasswordHash {
* and other data stores. No extra information has to be stored in order to verify the password. * and other data stores. No extra information has to be stored in order to verify the password.
* The function returns 0 on success and -1 if it didn't complete successfully. * The function returns 0 on success and -1 if it didn't complete successfully.
*/ */
actual fun str(password: String, opslimit: ULong, memlimit: Int): UByteArray { actual fun str(password: String, opslimit: ULong, memlimit: Int): String {
if (opslimit > UInt.MAX_VALUE) { if (opslimit > UInt.MAX_VALUE) {
throw RuntimeException("Javascript doesnt support more than ${UInt.MAX_VALUE} for opslimit") throw RuntimeException("Javascript doesnt support more than ${UInt.MAX_VALUE} for opslimit")
} }
@ -53,7 +53,7 @@ actual object PasswordHash {
password.encodeToUByteArray().toUInt8Array(), password.encodeToUByteArray().toUInt8Array(),
opslimit.toUInt(), opslimit.toUInt(),
memlimit.toUInt() memlimit.toUInt()
).encodeToUByteArray() )
} }
/** /**
@ -63,7 +63,7 @@ actual object PasswordHash {
* It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in. * It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in.
*/ */
actual fun strNeedsRehash( actual fun strNeedsRehash(
passwordHash: UByteArray, passwordHash: String,
opslimit: ULong, opslimit: ULong,
memlimit: Int memlimit: Int
): Int { ): Int {
@ -72,7 +72,7 @@ actual object PasswordHash {
} }
return if ( return if (
getSodium().crypto_pwhash_str_needs_rehash( getSodium().crypto_pwhash_str_needs_rehash(
passwordHash.asByteArray().decodeToString(), passwordHash,
opslimit.toUInt(), opslimit.toUInt(),
memlimit.toUInt() memlimit.toUInt()
) )
@ -88,9 +88,9 @@ actual object PasswordHash {
* str has to be zero-terminated. * str has to be zero-terminated.
* It returns 0 if the verification succeeds, and -1 on error. * It returns 0 if the verification succeeds, and -1 on error.
*/ */
actual fun strVerify(passwordHash: UByteArray, password: String): Boolean { actual fun strVerify(passwordHash: String, password: String): Boolean {
return getSodium().crypto_pwhash_str_verify( return getSodium().crypto_pwhash_str_verify(
passwordHash.asByteArray().decodeToString(), passwordHash,
password.encodeToUByteArray().toUInt8Array() password.encodeToUByteArray().toUInt8Array()
) )
} }

View File

@ -1108,7 +1108,7 @@ interface JnaLibsodiumInterface : Library {
// int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES], // int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
// unsigned long long opslimit, size_t memlimit) // unsigned long long opslimit, size_t memlimit)
fun crypto_pwhash_str_needs_rehash( fun crypto_pwhash_str_needs_rehash(
output: ByteArray, output: String,
opslimit: Long, opslimit: Long,
memlimit: Long memlimit: Long
) : Int ) : Int
@ -1116,7 +1116,7 @@ interface JnaLibsodiumInterface : Library {
// const char * const passwd, // const char * const passwd,
// unsigned long long passwdlen) // unsigned long long passwdlen)
fun crypto_pwhash_str_verify( fun crypto_pwhash_str_verify(
hash: ByteArray, hash: String,
password: String, password: String,
passwordLength: Long passwordLength: Long
) : Int ) : Int

View File

@ -1,7 +1,6 @@
package com.ionspin.kotlin.crypto.pwhash package com.ionspin.kotlin.crypto.pwhash
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
import com.sun.jna.NativeLong
actual object PasswordHash { actual object PasswordHash {
/** /**
@ -46,7 +45,7 @@ actual object PasswordHash {
* and other data stores. No extra information has to be stored in order to verify the password. * and other data stores. No extra information has to be stored in order to verify the password.
* The function returns 0 on success and -1 if it didn't complete successfully. * The function returns 0 on success and -1 if it didn't complete successfully.
*/ */
actual fun str(password: String, opslimit: ULong, memlimit: Int): UByteArray { actual fun str(password: String, opslimit: ULong, memlimit: Int): String {
val output = ByteArray(crypto_pwhash_STRBYTES) val output = ByteArray(crypto_pwhash_STRBYTES)
sodiumJna.crypto_pwhash_str( sodiumJna.crypto_pwhash_str(
output, output,
@ -55,7 +54,7 @@ actual object PasswordHash {
opslimit.toLong(), opslimit.toLong(),
memlimit.toLong() memlimit.toLong()
) )
return output.asUByteArray() return output.decodeToString()
} }
/** /**
@ -65,12 +64,12 @@ actual object PasswordHash {
* It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in. * It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in.
*/ */
actual fun strNeedsRehash( actual fun strNeedsRehash(
passwordHash: UByteArray, passwordHash: String,
opslimit: ULong, opslimit: ULong,
memlimit: Int memlimit: Int
): Int { ): Int {
return sodiumJna.crypto_pwhash_str_needs_rehash( return sodiumJna.crypto_pwhash_str_needs_rehash(
passwordHash.asByteArray(), passwordHash,
opslimit.toLong(), opslimit.toLong(),
memlimit.toLong() memlimit.toLong()
) )
@ -81,9 +80,9 @@ actual object PasswordHash {
* str has to be zero-terminated. * str has to be zero-terminated.
* It returns 0 if the verification succeeds, and -1 on error. * It returns 0 if the verification succeeds, and -1 on error.
*/ */
actual fun strVerify(passwordHash: UByteArray, password: String): Boolean { actual fun strVerify(passwordHash: String, password: String): Boolean {
val result = sodiumJna.crypto_pwhash_str_verify( val result = sodiumJna.crypto_pwhash_str_verify(
passwordHash.asByteArray(), passwordHash,
password, password,
password.length.toLong() password.length.toLong()
) )

View File

@ -18,6 +18,6 @@ class JnaLibraryLoaderTest {
LibsodiumInitializer.initialize() LibsodiumInitializer.initialize()
val version = sodiumJna.sodium_version_string() val version = sodiumJna.sodium_version_string()
println("Got loaded sodium version: $version") println("Got loaded sodium version: $version")
assertEquals("1.0.18", version) assertEquals("1.0.19", version)
} }
} }

View File

@ -4,7 +4,6 @@ import com.ionspin.kotlin.crypto.util.toPtr
import kotlinx.cinterop.addressOf import kotlinx.cinterop.addressOf
import kotlinx.cinterop.convert import kotlinx.cinterop.convert
import kotlinx.cinterop.pin import kotlinx.cinterop.pin
import kotlinx.cinterop.toCValues
import libsodium.crypto_pwhash import libsodium.crypto_pwhash
import libsodium.crypto_pwhash_str import libsodium.crypto_pwhash_str
import libsodium.crypto_pwhash_str_needs_rehash import libsodium.crypto_pwhash_str_needs_rehash
@ -61,7 +60,7 @@ actual object PasswordHash {
* and other data stores. No extra information has to be stored in order to verify the password. * and other data stores. No extra information has to be stored in order to verify the password.
* The function returns 0 on success and -1 if it didn't complete successfully. * The function returns 0 on success and -1 if it didn't complete successfully.
*/ */
actual fun str(password: String, opslimit: ULong, memlimit: Int): UByteArray { actual fun str(password: String, opslimit: ULong, memlimit: Int): String {
val output = ByteArray(crypto_pwhash_STRBYTES) val output = ByteArray(crypto_pwhash_STRBYTES)
val outputPinned = output.pin() val outputPinned = output.pin()
crypto_pwhash_str( crypto_pwhash_str(
@ -73,7 +72,7 @@ actual object PasswordHash {
) )
outputPinned.unpin() outputPinned.unpin()
return output.asUByteArray() return output.decodeToString()
} }
/** /**
@ -83,12 +82,12 @@ actual object PasswordHash {
* It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in. * It returns -1 on error. If it happens, applications may want to compute a correct hash the next time the user logs in.
*/ */
actual fun strNeedsRehash( actual fun strNeedsRehash(
passwordHash: UByteArray, passwordHash: String,
opslimit: ULong, opslimit: ULong,
memlimit: Int memlimit: Int
): Int { ): Int {
val result = crypto_pwhash_str_needs_rehash( val result = crypto_pwhash_str_needs_rehash(
passwordHash.asByteArray().toCValues(), passwordHash,
opslimit, opslimit,
memlimit.convert() memlimit.convert()
) )
@ -102,9 +101,9 @@ actual object PasswordHash {
* str has to be zero-terminated. * str has to be zero-terminated.
* It returns 0 if the verification succeeds, and -1 on error. * It returns 0 if the verification succeeds, and -1 on error.
*/ */
actual fun strVerify(passwordHash: UByteArray, password: String): Boolean { actual fun strVerify(passwordHash: String, password: String): Boolean {
val result = crypto_pwhash_str_verify( val result = crypto_pwhash_str_verify(
passwordHash.asByteArray().toCValues(), passwordHash,
password, password,
password.length.convert() password.length.convert()
) )

View File

@ -24,7 +24,6 @@ import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
plugins { plugins {
kotlin(PluginsDeps.multiplatform) kotlin(PluginsDeps.multiplatform)
id(PluginsDeps.kapt)
id(PluginsDeps.androidApplication) id(PluginsDeps.androidApplication)
id(PluginsDeps.mavenPublish) id(PluginsDeps.mavenPublish)
id(PluginsDeps.signing) id(PluginsDeps.signing)
@ -56,7 +55,7 @@ kotlin {
"windows" -> mingwX64("native") "windows" -> mingwX64("native")
} }
} }
android() androidTarget()
runningOnLinuxx86_64 { runningOnLinuxx86_64 {
jvm() jvm()
js(IR) { js(IR) {
@ -208,7 +207,7 @@ kotlin {
// implementation("androidx.compose:compose-runtime:$composeDevVersion") // implementation("androidx.compose:compose-runtime:$composeDevVersion")
} }
} }
val androidTest by getting { val androidUnitTest by getting {
dependencies { dependencies {
implementation(kotlin(Deps.Jvm.test)) implementation(kotlin(Deps.Jvm.test))
implementation(kotlin(Deps.Jvm.testJUnit)) implementation(kotlin(Deps.Jvm.testJUnit))
@ -396,6 +395,11 @@ android {
} }
} }
lint {
abortOnError = false
}
// buildFeatures { // buildFeatures {
// // Enables Jetpack Compose for this module // // Enables Jetpack Compose for this module
// this.compose = true // this.compose = true

View File

@ -6,8 +6,6 @@ package com.ionspin.kotlin.crypto.sample
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
import com.ionspin.kotlin.crypto.TmpAccessor
import com.ionspin.kotlin.crypto.box.Box import com.ionspin.kotlin.crypto.box.Box
import com.ionspin.kotlin.crypto.box.BoxCorruptedOrTamperedDataException import com.ionspin.kotlin.crypto.box.BoxCorruptedOrTamperedDataException
import com.ionspin.kotlin.crypto.box.crypto_box_NONCEBYTES import com.ionspin.kotlin.crypto.box.crypto_box_NONCEBYTES
@ -15,7 +13,6 @@ import com.ionspin.kotlin.crypto.hash.Hash
import com.ionspin.kotlin.crypto.util.decodeFromUByteArray import com.ionspin.kotlin.crypto.util.decodeFromUByteArray
import com.ionspin.kotlin.crypto.util.encodeToUByteArray import com.ionspin.kotlin.crypto.util.encodeToUByteArray
import com.ionspin.kotlin.crypto.util.toHexString import com.ionspin.kotlin.crypto.util.toHexString
import kotlinx.android.synthetic.main.activity_main.*
import java.lang.StringBuilder import java.lang.StringBuilder
import kotlin.random.Random import kotlin.random.Random
import kotlin.random.nextUBytes import kotlin.random.nextUBytes
@ -45,7 +42,7 @@ class MainActivity : AppCompatActivity() {
} catch (exception : Exception) { } catch (exception : Exception) {
builder.appendLine("And caught tamper") builder.appendLine("And caught tamper")
} }
helloWorldTextView.setText(builder.toString())
} }
} }

View File

@ -0,0 +1,7 @@
config.resolve = {
fallback: {
fs: false,
path: false,
crypto: false,
},
};

@ -1 +1 @@
Subproject commit 0c5ac65576f67c41cb72802d46d5f12394ea48d6 Subproject commit 49c37e8f604b493af51d05721e4ac69f180cf925