This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Description
There is a bug in Sha512Random.split(1) exposed by the following test.
@Test fun split_One() {
val k1 = RandomKey()
val k2 = k1.split(1)[0];
val k3 = k2.split(1)[0];
}
The bug is in these lines:
override fun split(n: Int): List<Sha512Random> {
if (hasBeenUsed && !permitsReuse)
throw IllegalStateException("RandomKey instance has already been used.")
hasBeenUsed = true
// No need to split if n==1
if (n == 1) return listOf(this)
The code invalidates this and then returns it as if it is valid.