1.6.0 release #9

Merged
Infendro merged 3 commits from develop into main 2026-02-14 20:28:32 +00:00
13 changed files with 91 additions and 91 deletions
Showing only changes of commit cb3ff7ec6c - Show all commits

View File

@@ -1,7 +1,7 @@
[versions] [versions]
infendro = "1.1.0" infendro = "1.1.0"
kotlin = "2.3.0" kotlin = "2.3.0"
bytes = "1.3.3" bytes = "1.4.0"
[plugins] [plugins]
infendro = { id = "com.infendro.plugin", version.ref = "infendro" } infendro = { id = "com.infendro.plugin", version.ref = "infendro" }

View File

@@ -1,7 +1,7 @@
package com.infendro.hash.blake package com.infendro.hash.blake
import com.infendro.bytes.intarray.copyInto import com.infendro.bytes.intarray.copyInto
import com.infendro.bytes.ulong.copyInto import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -20,13 +20,13 @@ object `Blake-224` : HashFunction {
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
var t = 0U var t = 0
for (i in input.indices step block) { for (i in input.indices step block) {
t += minOf(length - t, 512UL).toUInt() t += minOf(length - t, 512).toInt()
val block = input.sliceArray(i..<(i + block)) val block = input.sliceArray(i..<(i + block))
`Blake-256`.compress(h, block, t) `Blake-256`.compress(h, block, t)
} }
@@ -34,12 +34,12 @@ object `Blake-224` : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 9).align(block) val size = (value.size + 9).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }

View File

@@ -2,7 +2,7 @@ package com.infendro.hash.blake
import com.infendro.bytes.bytearray.toIntArray import com.infendro.bytes.bytearray.toIntArray
import com.infendro.bytes.intarray.copyInto import com.infendro.bytes.intarray.copyInto
import com.infendro.bytes.ulong.copyInto import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -45,13 +45,13 @@ object `Blake-256` : HashFunction {
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
var t = 0U var t = 0
for (i in input.indices step block) { for (i in input.indices step block) {
t += minOf(length - t, 512UL).toUInt() t += minOf(length - t, 512).toInt()
val block = input.sliceArray(i..<(i + block)) val block = input.sliceArray(i..<(i + block))
compress(h, block, t) compress(h, block, t)
} }
@@ -59,23 +59,23 @@ object `Blake-256` : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 10).align(block) val size = (value.size + 10).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
it[size - 9] = 0x01 it[size - 9] = 0x01
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }
internal fun compress(h: IntArray, block: ByteArray, t: UInt) { internal fun compress(h: IntArray, block: ByteArray, t: Int) {
val m = block.toIntArray() val m = block.toIntArray()
val v = IntArray(16) val v = IntArray(16)
for (i in 0..<8) v[i] = h[i] for (i in 0..<8) v[i] = h[i]
for (i in 0..<4) v[i + 8] = c[i] for (i in 0..<4) v[i + 8] = c[i]
for (i in 0..<2) v[i + 12] = c[i + 4] xor t.toInt() for (i in 0..<2) v[i + 12] = c[i + 4] xor t
for (i in 0..<2) v[i + 14] = c[i + 6] for (i in 0..<2) v[i + 14] = c[i + 6]
repeat(14) { r -> repeat(14) { r ->

View File

@@ -1,7 +1,7 @@
package com.infendro.hash.blake package com.infendro.hash.blake
import com.infendro.bytes.long.copyInto
import com.infendro.bytes.longarray.copyInto import com.infendro.bytes.longarray.copyInto
import com.infendro.bytes.ulong.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -20,13 +20,13 @@ object `Blake-384` : HashFunction {
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
var t = 0UL var t = 0L
for (i in input.indices step block) { for (i in input.indices step block) {
t += minOf(length - t, 1024UL) t += minOf(length - t, 1024)
val block = input.sliceArray(i..<(i + block)) val block = input.sliceArray(i..<(i + block))
`Blake-512`.compress(h, block, t) `Blake-512`.compress(h, block, t)
} }
@@ -34,12 +34,12 @@ object `Blake-384` : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 17).align(block) val size = (value.size + 17).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }

View File

@@ -1,8 +1,8 @@
package com.infendro.hash.blake package com.infendro.hash.blake
import com.infendro.bytes.bytearray.toLongArray import com.infendro.bytes.bytearray.toLongArray
import com.infendro.bytes.long.copyInto
import com.infendro.bytes.longarray.copyInto import com.infendro.bytes.longarray.copyInto
import com.infendro.bytes.ulong.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -45,13 +45,13 @@ object `Blake-512` : HashFunction {
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
var t = 0UL var t = 0L
for (i in input.indices step block) { for (i in input.indices step block) {
t += minOf(length - t, 1024UL) t += minOf(length - t, 1024)
val block = input.sliceArray(i..<(i + block)) val block = input.sliceArray(i..<(i + block))
compress(h, block, t) compress(h, block, t)
} }
@@ -59,23 +59,23 @@ object `Blake-512` : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 18).align(block) val size = (value.size + 18).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
it[size - 17] = 0x01 it[size - 17] = 0x01
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }
internal fun compress(h: LongArray, block: ByteArray, t: ULong) { internal fun compress(h: LongArray, block: ByteArray, t: Long) {
val m = block.toLongArray() val m = block.toLongArray()
val v = LongArray(16) val v = LongArray(16)
for (i in 0..<8) v[i] = h[i] for (i in 0..<8) v[i] = h[i]
for (i in 0..<4) v[i + 8] = c[i] for (i in 0..<4) v[i + 8] = c[i]
for (i in 0..<2) v[i + 12] = c[i + 4] xor t.toLong() for (i in 0..<2) v[i + 12] = c[i + 4] xor t
for (i in 0..<2) v[i + 14] = c[i + 6] for (i in 0..<2) v[i + 14] = c[i + 6]
repeat(16) { r -> repeat(16) { r ->

View File

@@ -37,18 +37,18 @@ class Blake2b(
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() val length = value.size.toLong()
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
h[0] = h[0] xor (0x01010000L or bytes.toLong()) h[0] = h[0] xor (0x01010000L or bytes.toLong())
var t = 0UL var t = 0L
for (i in input.indices step block) { for (i in input.indices step block) {
t += minOf(length - t, 128UL) t += minOf(length - t, 128)
val block = input.sliceArray(i..<(i + block)) 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 { 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 m = block.toLongArray()
val v = LongArray(16) val v = LongArray(16)
for (i in 0..<8) v[i] = h[i] for (i in 0..<8) v[i] = h[i]
for (i in 0..<8) v[i + 8] = initial[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() if (last) v[14] = v[14].inv()
repeat(12) { r -> repeat(12) { r ->

View File

@@ -37,18 +37,18 @@ class Blake2s(
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
val length = value.size.toULong() val length = value.size.toLong()
val input = pad(value) val input = pad(value)
val h = initial.copyOf() val h = initial.copyOf()
h[0] = h[0] xor (0x01010000 or bytes) h[0] = h[0] xor (0x01010000 or bytes)
var t = 0U var t = 0
for (i in input.indices step block) { 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)) 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 { 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 m = block.toIntArray()
val v = IntArray(16) val v = IntArray(16)
for (i in 0..<8) v[i] = h[i] for (i in 0..<8) v[i] = h[i]
for (i in 0..<8) v[i + 8] = initial[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() if (last) v[14] = v[14].inv()
repeat(10) { r -> repeat(10) { r ->

View File

@@ -20,12 +20,12 @@ open class Keccak(
get() = rate get() = rate
private val rc = longArrayOf( private val rc = longArrayOf(
+0x0000000000000001L, +0x0000000000008082L, -0x7fffffffffff7f76L, -0x7fffffff7fff8000L, +0x0000000000000001, +0x0000000000008082, -0x7fffffffffff7f76, -0x7fffffff7fff8000,
+0x000000000000808bL, +0x0000000080000001L, -0x7fffffff7fff7f7fL, -0x7fffffffffff7ff7L, +0x000000000000808b, +0x0000000080000001, -0x7fffffff7fff7f7f, -0x7fffffffffff7ff7,
+0x000000000000008aL, +0x0000000000000088L, +0x0000000080008009L, +0x000000008000000aL, +0x000000000000008a, +0x0000000000000088, +0x0000000080008009, +0x000000008000000a,
+0x000000008000808bL, -0x7fffffffffffff75L, -0x7fffffffffff7f77L, -0x7fffffffffff7ffdL, +0x000000008000808b, -0x7fffffffffffff75, -0x7fffffffffff7f77, -0x7fffffffffff7ffd,
-0x7fffffffffff7ffeL, -0x7fffffffffffff80L, +0x000000000000800aL, -0x7fffffff7ffffff6L, -0x7fffffffffff7ffe, -0x7fffffffffffff80, +0x000000000000800a, -0x7fffffff7ffffff6,
-0x7fffffff7fff7f7fL, -0x7fffffffffff7f80L, +0x0000000080000001L, -0x7fffffff7fff7ff8L, -0x7fffffff7fff7f7f, -0x7fffffffffff7f80, +0x0000000080000001, -0x7fffffff7fff7ff8,
) )
private val rotation = arrayOf( private val rotation = arrayOf(
@@ -53,7 +53,7 @@ open class Keccak(
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = domain it[value.size] = domain
it[size - 1] = 0x80U.toByte() it[size - 1] = -0x80
} }
} }

View File

@@ -3,7 +3,7 @@ package com.infendro.hash.md
import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN
import com.infendro.bytes.bytearray.toIntArray import com.infendro.bytes.bytearray.toIntArray
import com.infendro.bytes.intarray.copyInto import com.infendro.bytes.intarray.copyInto
import com.infendro.bytes.ulong.copyInto import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -61,18 +61,18 @@ object MD5 : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 9).align(block) val size = (value.size + 9).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8, order = LITTLE_ENDIAN) length.copyInto(it, size - 8, order = LITTLE_ENDIAN)
} }
} }
private fun process(h: IntArray, block: ByteArray) { private fun process(h: IntArray, block: ByteArray) {
val w = block.toIntArray(LITTLE_ENDIAN) val w = block.toIntArray(order = LITTLE_ENDIAN)
val v = h.copyOf() val v = h.copyOf()
repeat(64) { i -> repeat(64) { i ->

View File

@@ -2,7 +2,7 @@ package com.infendro.hash.sha1
import com.infendro.bytes.bytearray.copyInto import com.infendro.bytes.bytearray.copyInto
import com.infendro.bytes.intarray.copyInto import com.infendro.bytes.intarray.copyInto
import com.infendro.bytes.ulong.copyInto import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -36,12 +36,12 @@ object SHA1 : HashFunction {
} }
private fun pad(value: ByteArray): ByteArray { private fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 9).align(block) val size = (value.size + 9).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }

View File

@@ -2,7 +2,7 @@ package com.infendro.hash.sha2
import com.infendro.bytes.bytearray.copyInto import com.infendro.bytes.bytearray.copyInto
import com.infendro.bytes.intarray.copyInto import com.infendro.bytes.intarray.copyInto
import com.infendro.bytes.ulong.copyInto import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -43,12 +43,12 @@ object `SHA-256` : HashFunction {
} }
internal fun pad(value: ByteArray): ByteArray { internal fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 9).align(block) val size = (value.size + 9).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }

View File

@@ -11,10 +11,10 @@ object `SHA-384` : HashFunction {
get() = 128 get() = 128
private val initial = longArrayOf( private val initial = longArrayOf(
-0x344462a23efa6128L, +0x629a292a367cd507L, -0x344462a23efa6128, +0x629a292a367cd507,
-0x6ea6fea5cf8f22e9L, +0x152fecd8f70e5939L, -0x6ea6fea5cf8f22e9, +0x152fecd8f70e5939,
+0x67332667ffc00b31L, -0x714bb57897a7eaefL, +0x67332667ffc00b31, -0x714bb57897a7eaef,
-0x24f3d1f29b067059L, +0x47b5481dbefa4fa4L, -0x24f3d1f29b067059, +0x47b5481dbefa4fa4,
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {

View File

@@ -1,8 +1,8 @@
package com.infendro.hash.sha2 package com.infendro.hash.sha2
import com.infendro.bytes.bytearray.copyInto import com.infendro.bytes.bytearray.copyInto
import com.infendro.bytes.long.copyInto
import com.infendro.bytes.longarray.copyInto import com.infendro.bytes.longarray.copyInto
import com.infendro.bytes.ulong.copyInto
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.hash.util.align import com.infendro.hash.util.align
@@ -14,33 +14,33 @@ object `SHA-512` : HashFunction {
get() = 128 get() = 128
private val initial = longArrayOf( private val initial = longArrayOf(
+0x6a09e667f3bcc908L, -0x4498517a7b3558c5L, +0x6a09e667f3bcc908, -0x4498517a7b3558c5,
+0x3c6ef372fe94f82bL, -0x5ab00ac5a0e2c90fL, +0x3c6ef372fe94f82b, -0x5ab00ac5a0e2c90f,
+0x510e527fade682d1L, -0x64fa9773d4c193e1L, +0x510e527fade682d1, -0x64fa9773d4c193e1,
+0x1f83d9abfb41bd6bL, +0x5be0cd19137e2179L, +0x1f83d9abfb41bd6b, +0x5be0cd19137e2179,
) )
private val c = longArrayOf( private val c = longArrayOf(
+0x428a2f98d728ae22L, +0x7137449123ef65cdL, -0x4a3f043013b2c4d1L, -0x164a245a7e762444L, +0x428a2f98d728ae22, +0x7137449123ef65cd, -0x4a3f043013b2c4d1, -0x164a245a7e762444,
+0x3956c25bf348b538L, +0x59f111f1b605d019L, -0x6dc07d5b50e6b065L, -0x54e3a12a25927ee8L, +0x3956c25bf348b538, +0x59f111f1b605d019, -0x6dc07d5b50e6b065, -0x54e3a12a25927ee8,
-0x27f855675cfcfdbeL, +0x12835b0145706fbeL, +0x243185be4ee4b28cL, +0x550c7dc3d5ffb4e2L, -0x27f855675cfcfdbe, +0x12835b0145706fbe, +0x243185be4ee4b28c, +0x550c7dc3d5ffb4e2,
+0x72be5d74f27b896fL, -0x7f214e01c4e9694fL, -0x6423f958da38edcbL, -0x3e640e8b3096d96cL, +0x72be5d74f27b896f, -0x7f214e01c4e9694f, -0x6423f958da38edcb, -0x3e640e8b3096d96c,
-0x1b64963e610eb52eL, -0x1041b879c7b0da1dL, +0x0fc19dc68b8cd5b5L, +0x240ca1cc77ac9c65L, -0x1b64963e610eb52e, -0x1041b879c7b0da1d, +0x0fc19dc68b8cd5b5, +0x240ca1cc77ac9c65,
+0x2de92c6f592b0275L, +0x4a7484aa6ea6e483L, +0x5cb0a9dcbd41fbd4L, +0x76f988da831153b5L, +0x2de92c6f592b0275, +0x4a7484aa6ea6e483, +0x5cb0a9dcbd41fbd4, +0x76f988da831153b5,
-0x67c1aead11992055L, -0x57ce3992d24bcdf0L, -0x4ffcd8376704dec1L, -0x40a680384110f11cL, -0x67c1aead11992055, -0x57ce3992d24bcdf0, -0x4ffcd8376704dec1, -0x40a680384110f11c,
-0x391ff40cc257703eL, -0x2a586eb86cf558dbL, +0x06ca6351e003826fL, +0x142929670a0e6e70L, -0x391ff40cc257703e, -0x2a586eb86cf558db, +0x06ca6351e003826f, +0x142929670a0e6e70,
+0x27b70a8546d22ffcL, +0x2e1b21385c26c926L, +0x4d2c6dfc5ac42aedL, +0x53380d139d95b3dfL, +0x27b70a8546d22ffc, +0x2e1b21385c26c926, +0x4d2c6dfc5ac42aed, +0x53380d139d95b3df,
+0x650a73548baf63deL, +0x766a0abb3c77b2a8L, -0x7e3d36d1b812511aL, -0x6d8dd37aeb7dcac5L, +0x650a73548baf63de, +0x766a0abb3c77b2a8, -0x7e3d36d1b812511a, -0x6d8dd37aeb7dcac5,
-0x5d40175eb30efc9cL, -0x57e599b443bdcfffL, -0x3db4748f2f07686fL, -0x3893ae5cf9ab41d0L, -0x5d40175eb30efc9c, -0x57e599b443bdcfff, -0x3db4748f2f07686f, -0x3893ae5cf9ab41d0,
-0x2e6d17e62910ade8L, -0x2966f9dbaa9a56f0L, -0x0bf1ca7aa88edfd6L, +0x106aa07032bbd1b8L, -0x2e6d17e62910ade8, -0x2966f9dbaa9a56f0, -0x0bf1ca7aa88edfd6, +0x106aa07032bbd1b8,
+0x19a4c116b8d2d0c8L, +0x1e376c085141ab53L, +0x2748774cdf8eeb99L, +0x34b0bcb5e19b48a8L, +0x19a4c116b8d2d0c8, +0x1e376c085141ab53, +0x2748774cdf8eeb99, +0x34b0bcb5e19b48a8,
+0x391c0cb3c5c95a63L, +0x4ed8aa4ae3418acbL, +0x5b9cca4f7763e373L, +0x682e6ff3d6b2b8a3L, +0x391c0cb3c5c95a63, +0x4ed8aa4ae3418acb, +0x5b9cca4f7763e373, +0x682e6ff3d6b2b8a3,
+0x748f82ee5defb2fcL, +0x78a5636f43172f60L, -0x7b3787eb5e0f548eL, -0x7338fdf7e59bc614L, +0x748f82ee5defb2fc, +0x78a5636f43172f60, -0x7b3787eb5e0f548e, -0x7338fdf7e59bc614,
-0x6f410005dc9ce1d8L, -0x5baf9314217d4217L, -0x41065c084d3986ebL, -0x398e870d1c8dacd5L, -0x6f410005dc9ce1d8, -0x5baf9314217d4217, -0x41065c084d3986eb, -0x398e870d1c8dacd5,
-0x35d8c13115d99e64L, -0x2e794738de3f3df9L, -0x15258229321f14e2L, -0x0a82b08011912e88L, -0x35d8c13115d99e64, -0x2e794738de3f3df9, -0x15258229321f14e2, -0x0a82b08011912e88,
+0x06f067aa72176fbaL, +0x0a637dc5a2c898a6L, +0x113f9804bef90daeL, +0x1b710b35131c471bL, +0x06f067aa72176fba, +0x0a637dc5a2c898a6, +0x113f9804bef90dae, +0x1b710b35131c471b,
+0x28db77f523047d84L, +0x32caab7b40c72493L, +0x3c9ebe0a15c9bebcL, +0x431d67c49c100d4cL, +0x28db77f523047d84, +0x32caab7b40c72493, +0x3c9ebe0a15c9bebc, +0x431d67c49c100d4c,
+0x4cc5d4becb3e42b6L, +0x597f299cfc657e2aL, +0x5fcb6fab3ad6faecL, +0x6c44198c4a475817L, +0x4cc5d4becb3e42b6, +0x597f299cfc657e2a, +0x5fcb6fab3ad6faec, +0x6c44198c4a475817,
) )
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) { override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
@@ -55,12 +55,12 @@ object `SHA-512` : HashFunction {
} }
internal fun pad(value: ByteArray): ByteArray { internal fun pad(value: ByteArray): ByteArray {
val length = value.size.toULong() * 8UL val length = value.size * 8L
val size = (value.size + 17).align(block) val size = (value.size + 17).align(block)
return ByteArray(size).also { return ByteArray(size).also {
value.copyInto(it) value.copyInto(it)
it[value.size] = 0x80U.toByte() it[value.size] = -0x80
length.copyInto(it, size - 8) length.copyInto(it, size - 8)
} }
} }