Update kotlin to 1.9.10, update library versions, use latest libsodium stable, clean up Deps, remove deprecated targets, change PasswordHash str related functions to use String
This commit is contained in:
parent
b32821e13e
commit
194994f5b2
19
CHANGELOG.md
19
CHANGELOG.md
@ -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)
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
|
||||||
|
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()
|
||||||
|
@ -15,16 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
object Versions {
|
object Versions {
|
||||||
val kotlinCoroutines = "1.7.0-Beta"
|
val kotlinCoroutines = "1.7.3"
|
||||||
val kotlin = "1.9.0"
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1656,17 +1656,17 @@ launch-editor@^2.6.0:
|
|||||||
picocolors "^1.0.0"
|
picocolors "^1.0.0"
|
||||||
shell-quote "^1.7.3"
|
shell-quote "^1.7.3"
|
||||||
|
|
||||||
libsodium-sumo@^0.7.0:
|
libsodium-sumo@^0.7.13:
|
||||||
version "0.7.9"
|
version "0.7.13"
|
||||||
resolved "https://registry.yarnpkg.com/libsodium-sumo/-/libsodium-sumo-0.7.9.tgz#dff3d6144849e30d9b9a7bf628d28243f1c49102"
|
resolved "https://registry.yarnpkg.com/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz#533b97d2be44b1277e59c1f9f60805978ac5542d"
|
||||||
integrity sha512-DcfJ57zlSlcmQU4s8KOX78pT0zKx5S9RLi0oyDuoIgm4K95+VNSaOidK/y9lUK4lxft14PtTPjoBy8tmLk1TDQ==
|
integrity sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==
|
||||||
|
|
||||||
libsodium-wrappers-sumo@0.7.9:
|
libsodium-wrappers-sumo@0.7.13:
|
||||||
version "0.7.9"
|
version "0.7.13"
|
||||||
resolved "https://registry.yarnpkg.com/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.9.tgz#d15a346870c8e339baf1518f06b0ddccfa1e1046"
|
resolved "https://registry.yarnpkg.com/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz#a33aea845a0bb56db067548f04feba28c730ab8e"
|
||||||
integrity sha512-XLgLkqY973PngrRElbjOH0y7bJKYEfMWVpWPmW5iuhBjO6zXvHYQWtN52MVEeie/h98ZXN1Aw9BE+GzxQVAfLg==
|
integrity sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
libsodium-sumo "^0.7.0"
|
libsodium-sumo "^0.7.13"
|
||||||
|
|
||||||
loader-runner@^4.2.0:
|
loader-runner@^4.2.0:
|
||||||
version "4.3.0"
|
version "4.3.0"
|
||||||
|
@ -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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
@ -83,7 +83,7 @@ android {
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
android() {
|
androidTarget() {
|
||||||
publishLibraryVariants("release", "debug")
|
publishLibraryVariants("release", "debug")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,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 {
|
||||||
@ -133,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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -171,13 +162,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iosArm32() {
|
|
||||||
binaries {
|
|
||||||
framework {
|
|
||||||
optimized = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iosSimulatorArm64() {
|
iosSimulatorArm64() {
|
||||||
binaries {
|
binaries {
|
||||||
framework {
|
framework {
|
||||||
@ -237,13 +222,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watchosX86() {
|
|
||||||
binaries {
|
|
||||||
framework {
|
|
||||||
optimized = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
watchosSimulatorArm64() {
|
watchosSimulatorArm64() {
|
||||||
binaries {
|
binaries {
|
||||||
framework {
|
framework {
|
||||||
@ -351,9 +330,6 @@ kotlin {
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
val linux32Bit = setOf(
|
|
||||||
"" // "linuxArm32Hfp"
|
|
||||||
)
|
|
||||||
|
|
||||||
//iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86
|
//iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86
|
||||||
val macos64Bit = setOf(
|
val macos64Bit = setOf(
|
||||||
@ -377,10 +353,10 @@ kotlin {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val watchosArm = setOf(
|
val watchosArm = setOf(
|
||||||
"watchosArm32", "watchosArm64"
|
"watchosArm64"
|
||||||
)
|
)
|
||||||
val watchosSimulator = setOf(
|
val watchosSimulator = setOf(
|
||||||
"watchosX86", "watchosSimulatorArm64"
|
"watchosSimulatorArm64"
|
||||||
)
|
)
|
||||||
|
|
||||||
targets.withType<KotlinNativeTarget> {
|
targets.withType<KotlinNativeTarget> {
|
||||||
@ -408,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(
|
||||||
@ -640,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)
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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(
|
||||||
|
@ -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()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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()
|
||||||
)
|
)
|
||||||
|
@ -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()
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ kotlin {
|
|||||||
"windows" -> mingwX64("native")
|
"windows" -> mingwX64("native")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
android()
|
androidTarget()
|
||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
jvm()
|
jvm()
|
||||||
js(IR) {
|
js(IR) {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 0c5ac65576f67c41cb72802d46d5f12394ea48d6
|
Subproject commit ac6d3909eb0cf3d211b8137c6408ca64dd7b97b3
|
Loading…
x
Reference in New Issue
Block a user