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 Blake2s(
)
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 (0x01010000 or bytes)
var t = 0U
var t = 0
for (i in input.indices step block) {
t += minOf(length - t, 64UL).toUInt()
t += minOf(length - t, 64).toInt()
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 Blake2s(
}
}
private fun compress(h: IntArray, block: ByteArray, t: UInt, last: Boolean) {
private fun compress(h: IntArray, block: ByteArray, t: Int, last: Boolean) {
val m = block.toIntArray()
val v = IntArray(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.toInt()
v[12] = v[12] xor t
if (last) v[14] = v[14].inv()
repeat(10) { r ->