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

Bug in Sha512Random.split(1) #116

@gafter

Description

@gafter

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions