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:
14 files changed
+76
-123
No files matched your search
+2
-2
@@ -1108,7 +1108,7 @@ interface JnaLibsodiumInterface : Library {
|
||||
// int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
|
||||
// unsigned long long opslimit, size_t memlimit)
|
||||
fun crypto_pwhash_str_needs_rehash(
|
||||
output: ByteArray,
|
||||
output: String,
|
||||
opslimit: Long,
|
||||
memlimit: Long
|
||||
) : Int
|
||||
@@ -1116,7 +1116,7 @@ interface JnaLibsodiumInterface : Library {
|
||||
// const char * const passwd,
|
||||
// unsigned long long passwdlen)
|
||||
fun crypto_pwhash_str_verify(
|
||||
hash: ByteArray,
|
||||
hash: String,
|
||||
password: String,
|
||||
passwordLength: Long
|
||||
) : Int
|
||||
|
||||
+6
-7
@@ -1,7 +1,6 @@
|
||||
package com.ionspin.kotlin.crypto.pwhash
|
||||
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
|
||||
import com.sun.jna.NativeLong
|
||||
|
||||
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.
|
||||
* 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)
|
||||
sodiumJna.crypto_pwhash_str(
|
||||
output,
|
||||
@@ -55,7 +54,7 @@ actual object PasswordHash {
|
||||
opslimit.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.
|
||||
*/
|
||||
actual fun strNeedsRehash(
|
||||
passwordHash: UByteArray,
|
||||
passwordHash: String,
|
||||
opslimit: ULong,
|
||||
memlimit: Int
|
||||
): Int {
|
||||
return sodiumJna.crypto_pwhash_str_needs_rehash(
|
||||
passwordHash.asByteArray(),
|
||||
passwordHash,
|
||||
opslimit.toLong(),
|
||||
memlimit.toLong()
|
||||
)
|
||||
@@ -81,9 +80,9 @@ actual object PasswordHash {
|
||||
* str has to be zero-terminated.
|
||||
* 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(
|
||||
passwordHash.asByteArray(),
|
||||
passwordHash,
|
||||
password,
|
||||
password.length.toLong()
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user