VerifyFunction

An incremental verification function that accumulates data and checks a signature on finalization.

Data is fed via update and verification is performed by calling one of the finalization methods:

  • tryVerify — returns false if the signature does not match.

  • verify — throws an exception if the signature does not match.

After finalization, the function can be reset and reused, or closed to release resources.

Obtained via SignatureVerifier.createVerifyFunction.

Functions

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
abstract fun reset()

Resets the accumulated state, allowing this function to be reused for a new operation without creating a new instance.

Link copied to clipboard
abstract fun tryVerify(signature: ByteArray, startIndex: Int = 0, endIndex: Int = signature.size): Boolean
open fun tryVerify(signature: ByteString, startIndex: Int = 0, endIndex: Int = signature.size): Boolean

Checks whether the signature (or its subrange from startIndex to endIndex) is valid for the data fed so far. Returns true if the signature is valid, false otherwise.

Link copied to clipboard
open fun update(source: RawSource)

Reads all available data from the source and feeds it into this function.

abstract fun update(source: ByteArray, startIndex: Int = 0, endIndex: Int = source.size)

Feeds data from the source byte array into this function. Only the portion from startIndex (inclusive) to endIndex (exclusive) is processed.

open fun update(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size)

Feeds data from the source byte string into this function. Only the portion from startIndex (inclusive) to endIndex (exclusive) is processed.

Link copied to clipboard
open fun updatingSink(sink: RawSink): RawSink

Returns a RawSink wrapper around the given sink that feeds all data written through it into this function as a side effect. Useful for writing data to a sink while simultaneously computing a hash or signature.

Link copied to clipboard

Returns a RawSource wrapper around the given source that feeds all data read through it into this function as a side effect. Useful for processing data from a source while simultaneously computing a hash or signature.

Link copied to clipboard
abstract fun verify(signature: ByteArray, startIndex: Int = 0, endIndex: Int = signature.size)
open fun verify(signature: ByteString, startIndex: Int = 0, endIndex: Int = signature.size)

Checks whether the signature (or its subrange from startIndex to endIndex) is valid for the data fed so far. Throws an exception if the signature is not valid.