Upgrade dependencies
All checks were successful
/ test (pull_request) Successful in 1m15s

This commit is contained in:
2026-02-16 19:52:47 +01:00
parent ab33fe3670
commit 124f6a21a3
4 changed files with 13 additions and 28 deletions

View File

@@ -7,18 +7,9 @@ interface KDF {
fun hashInto(value: ByteArray, salt: ByteArray, destination: ByteArray, destinationOffset: Int = 0)
fun hashInto(value: ByteArray, salt: ByteArray, destination: UByteArray, destinationOffset: Int = 0) =
hashInto(value, salt, destination.asByteArray(), destinationOffset)
fun hashInto(value: UByteArray, salt: UByteArray, destination: ByteArray, destinationOffset: Int = 0) =
hashInto(value.asByteArray(), salt.asByteArray(), destination, destinationOffset)
fun hashInto(value: UByteArray, salt: UByteArray, destination: UByteArray, destinationOffset: Int = 0) =
hashInto(value.asByteArray(), salt.asByteArray(), destination.asByteArray(), destinationOffset)
fun hash(value: ByteArray, salt: ByteArray): ByteArray =
ByteArray(bytes).also { hashInto(value, salt, it) }
fun hash(value: UByteArray, salt: UByteArray): UByteArray =
UByteArray(bytes).also { hashInto(value, salt, it) }
fun hash(value: ByteArray, salt: ByteArray): ByteArray {
val result = ByteArray(bytes)
hashInto(value, salt, result)
return result
}
}

View File

@@ -19,8 +19,6 @@ class PBKDF2(
private val hmac = HMAC(function)
override fun hashInto(value: ByteArray, salt: ByteArray, destination: ByteArray, destinationOffset: Int) {
val buffer = ByteArray(hmac.bytes)
for (iteration in 1..bytes.ceilDiv(hmac.bytes)) {
val offset = (iteration - 1) * hmac.bytes
val block = minOf(bytes - offset, hmac.bytes)
@@ -29,7 +27,7 @@ class PBKDF2(
salt.copyInto(s)
iteration.copyInto(s, salt.size)
hmac.hashInto(value, s, buffer)
val buffer = hmac.hash(value, s)
buffer.copyInto(destination, destinationOffset + offset, endIndex = block)
repeat(iterations - 1) {
hmac.hashInto(value, buffer, buffer)