1.2.0 release #6

Merged
Infendro merged 5 commits from develop into main 2026-02-19 10:55:12 +00:00
4 changed files with 13 additions and 28 deletions
Showing only changes of commit 124f6a21a3 - Show all commits

View File

@@ -31,18 +31,14 @@ kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.mac)
implementation(libs.hash)
implementation(libs.bytes)
implementation(libs.hash)
implementation(libs.mac)
}
commonTest.dependencies {
implementation(libs.test)
}
}
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.ExperimentalUnsignedTypes")
}
}
publishing.repositories {

View File

@@ -1,16 +1,16 @@
[versions]
infendro = "1.1.0"
kotlin = "2.3.0"
mac = "1.3.0"
hash = "1.5.1"
bytes = "1.3.4"
bytes = "1.4.0"
hash = "1.6.0"
mac = "1.4.0"
[plugins]
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
[libraries]
mac = { module = "com.infendro:mac", version.ref = "mac" }
hash = { module = "com.infendro:hash", version.ref = "hash" }
bytes = { module = "com.infendro:bytes", version.ref = "bytes" }
hash = { module = "com.infendro:hash", version.ref = "hash" }
mac = { module = "com.infendro:mac", version.ref = "mac" }
test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }

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)