AuthenticatedCipher

Combines AuthenticatedEncryptor and AuthenticatedDecryptor for authenticated encryption with associated data (AEAD).

The authentication tag is appended to the ciphertext: encrypt returns ciphertext || tag, and decrypt expects ciphertext || tag.

For IV support, see IvAuthenticatedCipher.

Inheritors

Functions

Link copied to clipboard
open suspend fun decrypt(ciphertext: ByteArray, associatedData: ByteArray?): ByteArray

Decrypts the given ciphertext with optional associatedData and returns the resulting plaintext as a ByteArray.

open suspend fun decrypt(ciphertext: ByteString, associatedData: ByteString?): ByteString

Decrypts the given ciphertext with optional associatedData and returns the resulting plaintext as a ByteString.

open suspend fun decrypt(ciphertext: ByteArray): ByteArray

Decrypts the given ciphertext and returns the resulting plaintext as a ByteArray.

open suspend fun decrypt(ciphertext: ByteString): ByteString

Decrypts the given ciphertext and returns the resulting plaintext as a ByteString.

Link copied to clipboard
abstract fun decryptBlocking(ciphertext: ByteArray, associatedData: ByteArray?): ByteArray

Decrypts the given ciphertext with optional associatedData and returns the resulting plaintext as a ByteArray.

open fun decryptBlocking(ciphertext: ByteString, associatedData: ByteString?): ByteString

Decrypts the given ciphertext with optional associatedData and returns the resulting plaintext as a ByteString.

open fun decryptBlocking(ciphertext: ByteArray): ByteArray

Decrypts the given ciphertext and returns the resulting plaintext as a ByteArray.

open fun decryptBlocking(ciphertext: ByteString): ByteString

Decrypts the given ciphertext and returns the resulting plaintext as a ByteString.

Link copied to clipboard
abstract fun decryptingSink(plaintext: RawSink, associatedData: ByteArray?): RawSink
open fun decryptingSink(plaintext: RawSink, associatedData: ByteString?): RawSink

Returns a RawSink that decrypts data as it is written, sending the resulting plaintext to plaintext, with optional associatedData.

open fun decryptingSink(plaintext: RawSink): RawSink

Returns a RawSink that decrypts data as it is written, sending the resulting plaintext to plaintext. Write ciphertext to the returned sink, and plaintext will be forwarded to plaintext.

Link copied to clipboard
abstract fun decryptingSource(ciphertext: RawSource, associatedData: ByteArray?): RawSource
open fun decryptingSource(ciphertext: RawSource, associatedData: ByteString?): RawSource

Returns a RawSource that decrypts data as it is read from the given ciphertext source with optional associatedData.

open fun decryptingSource(ciphertext: RawSource): RawSource

Returns a RawSource that decrypts data as it is read from the given ciphertext source. The resulting source produces plaintext on reads.

Link copied to clipboard
open suspend fun encrypt(plaintext: ByteArray, associatedData: ByteArray?): ByteArray

Encrypts the given plaintext with optional associatedData and returns the resulting ciphertext as a ByteArray.

open suspend fun encrypt(plaintext: ByteString, associatedData: ByteString?): ByteString

Encrypts the given plaintext with optional associatedData and returns the resulting ciphertext as a ByteString.

open suspend fun encrypt(plaintext: ByteArray): ByteArray

Encrypts the given plaintext and returns the resulting ciphertext as a ByteArray.

open suspend fun encrypt(plaintext: ByteString): ByteString

Encrypts the given plaintext and returns the resulting ciphertext as a ByteString.

Link copied to clipboard
abstract fun encryptBlocking(plaintext: ByteArray, associatedData: ByteArray?): ByteArray

Encrypts the given plaintext with optional associatedData and returns the resulting ciphertext as a ByteArray.

open fun encryptBlocking(plaintext: ByteString, associatedData: ByteString?): ByteString

Encrypts the given plaintext with optional associatedData and returns the resulting ciphertext as a ByteString.

open fun encryptBlocking(plaintext: ByteArray): ByteArray

Encrypts the given plaintext and returns the resulting ciphertext as a ByteArray.

open fun encryptBlocking(plaintext: ByteString): ByteString

Encrypts the given plaintext and returns the resulting ciphertext as a ByteString.

Link copied to clipboard
abstract fun encryptingSink(ciphertext: RawSink, associatedData: ByteArray?): RawSink
open fun encryptingSink(ciphertext: RawSink, associatedData: ByteString?): RawSink

Returns a RawSink that encrypts data as it is written, sending the resulting ciphertext to ciphertext, with optional associatedData.

open fun encryptingSink(ciphertext: RawSink): RawSink

Returns a RawSink that encrypts data as it is written, sending the resulting ciphertext to ciphertext. Write plaintext to the returned sink, and ciphertext will be forwarded to ciphertext.

Link copied to clipboard
abstract fun encryptingSource(plaintext: RawSource, associatedData: ByteArray?): RawSource
open fun encryptingSource(plaintext: RawSource, associatedData: ByteString?): RawSource

Returns a RawSource that encrypts data as it is read from the given plaintext source with optional associatedData.

open fun encryptingSource(plaintext: RawSource): RawSource

Returns a RawSource that encrypts data as it is read from the given plaintext source. The resulting source produces ciphertext on reads.