implement destination offset
All checks were successful
/ test (pull_request) Successful in 27s

This commit is contained in:
2026-01-22 12:18:22 +01:00
parent b00d231da5
commit 8535476674
16 changed files with 41 additions and 34 deletions

View File

@@ -36,7 +36,7 @@ class Blake2b(
intArrayOf(10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0),
)
override fun hashInto(value: ByteArray, destination: ByteArray) {
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong()
val input = pad(value)
val h = initial.copyOf()
@@ -49,7 +49,7 @@ class Blake2b(
t += minOf(length - t, 128UL)
compress(h, input, i, m, v, t, t < 1024UL)
}
h.toByteArray(LITTLE_ENDIAN).copyInto(destination, endIndex = bytes)
h.toByteArray(LITTLE_ENDIAN).copyInto(destination, destinationOffset, endIndex = bytes)
}
private fun pad(value: ByteArray): ByteArray {

View File

@@ -36,7 +36,7 @@ class Blake2s(
intArrayOf(10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0),
)
override fun hashInto(value: ByteArray, destination: ByteArray) {
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong()
val input = pad(value)
val h = initial.copyOf()
@@ -49,7 +49,7 @@ class Blake2s(
t += minOf(length - t, 64UL).toUInt()
compress(h, input, i, m, v, t, t < 1024UL)
}
h.toByteArray(LITTLE_ENDIAN).copyInto(destination, endIndex = bytes)
h.toByteArray(LITTLE_ENDIAN).copyInto(destination, destinationOffset, endIndex = bytes)
}
private fun pad(value: ByteArray): ByteArray {