This commit is contained in:
@@ -36,7 +36,7 @@ open class Keccak(
|
||||
intArrayOf(27, 20, 39, 8, 14),
|
||||
)
|
||||
|
||||
override fun hashInto(value: ByteArray, destination: ByteArray) {
|
||||
override fun hashInto(value: ByteArray, destination: ByteArray, destinationOffset: Int) {
|
||||
val input = pad(value)
|
||||
val state = LongArray(25)
|
||||
val w = LongArray(block / 8)
|
||||
@@ -48,7 +48,7 @@ open class Keccak(
|
||||
absorb(state, input, i, w)
|
||||
permute(state, b, c, d)
|
||||
}
|
||||
squeeze(state, b, c, d, destination)
|
||||
squeeze(state, b, c, d, destination, destinationOffset)
|
||||
}
|
||||
|
||||
private fun pad(value: ByteArray): ByteArray {
|
||||
@@ -67,7 +67,14 @@ open class Keccak(
|
||||
}
|
||||
}
|
||||
|
||||
private fun squeeze(state: LongArray, b: LongArray, c: LongArray, d: LongArray, destination: ByteArray) {
|
||||
private fun squeeze(
|
||||
state: LongArray,
|
||||
b: LongArray,
|
||||
c: LongArray,
|
||||
d: LongArray,
|
||||
destination: ByteArray,
|
||||
destinationOffset: Int,
|
||||
) {
|
||||
val buffer = ByteArray(8)
|
||||
val threshold = rate / 8
|
||||
|
||||
@@ -81,7 +88,7 @@ open class Keccak(
|
||||
|
||||
val length = minOf(bytes - consumed, 8)
|
||||
state[i].copyInto(buffer, order = LITTLE_ENDIAN)
|
||||
buffer.copyInto(destination, consumed, endIndex = length)
|
||||
buffer.copyInto(destination, destinationOffset + consumed, endIndex = length)
|
||||
|
||||
consumed += length
|
||||
i++
|
||||
|
||||
Reference in New Issue
Block a user