Xof
sealed class Xof<A : XofAlgorithm>(val delegate: A) : Algorithm, Copyable<Xof<A>> , Resettable, Updatable(source)
Extendable-Output Function (i.e. XOF)
FIPS PUB 202 introduced XOFs where output for certain cryptographic functions can be variable in length. This is an implementation which provides such functionality.
e.g.
val xof = SHAKE128.xOf()
xof.update(Random.Default.nextBytes(500))
val out1 = ByteArray(64)
val out2 = ByteArray(out1.size * 2)
xof.use(resetXof = false) { read(out1); read(out2) }
val out3 = ByteArray(out1.size)
val out4 = ByteArray(out2.size)
val reader = xof.reader()
reader.read(out3)
reader.use { read(out4, 0, out4.size) }
assertContentEquals(out1, out3)
assertContentEquals(out2, out4)
Content copied to clipboard
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf