SignFunction

An incremental signing function that accumulates data and produces a signature on finalization.

Data is fed via update and the signature is obtained by calling one of the finalization methods: signIntoByteArray, signToByteArray, or sign. After finalization, the function can be reset and reused, or closed to release resources.

Obtained via SignatureGenerator.createSignFunction.

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
open fun sign(): ByteString

Finalizes the signature computation and returns the result as a ByteString.

Link copied to clipboard
abstract fun signIntoByteArray(destination: ByteArray, destinationOffset: Int = 0): Int

Finalizes the signature computation and writes the result into destination starting at destinationOffset, and returns the number of bytes written.

Link copied to clipboard
abstract fun signToByteArray(): ByteArray

Finalizes the signature computation and returns the result as a new ByteArray.

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.