Upgrade bytes-kt
All checks were successful
/ test (pull_request) Successful in 44s

This commit is contained in:
2026-02-14 16:32:50 +01:00
parent 902cb060a1
commit cb3ff7ec6c
13 changed files with 91 additions and 91 deletions

View File

@@ -37,18 +37,18 @@ class Blake2b(
)
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong()
val length = value.size.toLong()
val input = pad(value)
val h = initial.copyOf()
h[0] = h[0] xor (0x01010000L or bytes.toLong())
var t = 0UL
var t = 0L
for (i in input.indices step block) {
t += minOf(length - t, 128UL)
t += minOf(length - t, 128)
val block = input.sliceArray(i..<(i + block))
compress(h, block, t, t < 1024UL)
compress(h, block, t, t < 1024)
}
h.toByteArray(LITTLE_ENDIAN).copyInto(destination, destinationOffset, endIndex = bytes)
h.toByteArray(order = LITTLE_ENDIAN).copyInto(destination, destinationOffset, endIndex = bytes)
}
private fun pad(value: ByteArray): ByteArray {
@@ -58,12 +58,12 @@ class Blake2b(
}
}
private fun compress(h: LongArray, block: ByteArray, t: ULong, last: Boolean) {
private fun compress(h: LongArray, block: ByteArray, t: Long, last: Boolean) {
val m = block.toLongArray()
val v = LongArray(16)
for (i in 0..<8) v[i] = h[i]
for (i in 0..<8) v[i + 8] = initial[i]
v[12] = v[12] xor t.toLong()
v[12] = v[12] xor t
if (last) v[14] = v[14].inv()
repeat(12) { r ->