1.5.0 release #7

Merged
Infendro merged 8 commits from develop into main 2026-01-22 11:10:57 +00:00
Showing only changes of commit 681f2146b4 - Show all commits

View File

@@ -6,11 +6,16 @@ import com.infendro.bytes.long.copyInto
import com.infendro.hash.HashFunction
import com.infendro.hash.util.ceil
abstract class Keccak(
open class Keccak(
override val bytes: Int,
private val rate: Int,
private val domain: Byte,
) : HashFunction {
init {
require(bytes > 0)
require(rate in 8..192 step 8)
}
override val block: Int
get() = rate
@@ -64,10 +69,12 @@ abstract class Keccak(
private fun squeeze(state: LongArray, b: LongArray, c: LongArray, d: LongArray, destination: ByteArray) {
val buffer = ByteArray(8)
val threshold = rate / 8
var consumed = 0
var i = 0
while (consumed < bytes) {
if (i == rate / 8) {
if (i == threshold) {
permute(state, b, c, d)
i = 0
}