AesCipherDataSink


@UnstableApi
class AesCipherDataSink : DataSink


A wrapping DataSink that encrypts the data being consumed.

Summary

Public constructors

AesCipherDataSink(secretKey: ByteArray!, wrappedDataSink: DataSink!)

Create an instance whose write methods have the side effect of overwriting the input data.

AesCipherDataSink(
    secretKey: ByteArray!,
    wrappedDataSink: DataSink!,
    scratch: ByteArray?
)

Create an instance whose write methods are free of side effects.

Public functions

Unit

Closes the sink.

Unit
open(dataSpec: DataSpec!)

Opens the sink to consume the specified data.

Unit
write(buffer: ByteArray!, offset: Int, length: Int)

Consumes the provided data.

Public constructors

AesCipherDataSink

AesCipherDataSink(secretKey: ByteArray!, wrappedDataSink: DataSink!)

Create an instance whose write methods have the side effect of overwriting the input data. Use this constructor for maximum efficiency in the case that there is no requirement for the input data arrays to remain unchanged.

Parameters
secretKey: ByteArray!

The key data.

wrappedDataSink: DataSink!

The wrapped DataSink.

AesCipherDataSink

AesCipherDataSink(
    secretKey: ByteArray!,
    wrappedDataSink: DataSink!,
    scratch: ByteArray?
)

Create an instance whose write methods are free of side effects. Use this constructor when the input data arrays are required to remain unchanged.

Parameters
secretKey: ByteArray!

The key data.

wrappedDataSink: DataSink!

The wrapped DataSink.

scratch: ByteArray?

Scratch space. Data is encrypted into this array before being written to the wrapped DataSink. It should be of appropriate size for the expected writes. If a write is larger than the size of this array the write will still succeed, but multiple cipher calls will be required to complete the operation. If null then encryption will overwrite the input data.

Public functions

close

fun close(): Unit

Closes the sink.

Note: This method must be called even if the corresponding call to open threw an IOException. See open for more details.

Throws
java.io.IOException

If an error occurs closing the sink.

open

fun open(dataSpec: DataSpec!): Unit

Opens the sink to consume the specified data.

Note: If an IOException is thrown, callers must still call close to ensure that any partial effects of the invocation are cleaned up.

Parameters
dataSpec: DataSpec!

Defines the data to be consumed.

Throws
java.io.IOException

If an error occurs opening the sink.

write

fun write(buffer: ByteArray!, offset: Int, length: Int): Unit

Consumes the provided data.

Parameters
buffer: ByteArray!

The buffer from which data should be consumed.

offset: Int

The offset of the data to consume in buffer.

length: Int

The length of the data to consume, in bytes.

Throws
java.io.IOException

If an error occurs writing to the sink.