Package-level declarations

Types

Link copied to clipboard
sealed interface AuthCapability<K : KeyType>

Defines whether a cipher is authenticated or not

Link copied to clipboard
abstract class BlockCipher<A : AuthCapability<K>, I : NonceTrait, K : KeyType>(    val mode: BlockCipher.ModeOfOperation,     val blockSize: BitLength) : SymmetricEncryptionAlgorithm<A, I, K>

Marker interface indicating a block cipher. Purely informational

Link copied to clipboard

A generic ciphertext object, referencing the algorithm it was created by.

Link copied to clipboard
sealed interface KeyType
Link copied to clipboard

Typealias defining the signature of the lambda for processing the MAC output into an auth tag.

Link copied to clipboard

Typealias defining the signature of the lambda for defining a custom MAC input calculation scheme.

Link copied to clipboard
sealed interface NonceTrait

Marker, indicating whether a symmetric encryption algorithms requires or prohibits the use of a nonce/IV

Link copied to clipboard
sealed interface SealedBox<A : AuthCapability<out K>, I : NonceTrait, K : KeyType>

Represents symmetrically encrypted data in a structured manner. Construct using SymmetricEncryptionAlgorithm.sealedBoxFrom

Link copied to clipboard
sealed class SealedBoxBuilder<A : AuthCapability<out K>, I : NonceTrait, out K : KeyType>

SealedBox builder from algorithm

Link copied to clipboard
Link copied to clipboard

Marker interface indicating a block cipher. Purely informational

Link copied to clipboard
sealed interface SymmetricEncryptionAlgorithm<out A : AuthCapability<out K>, out I : NonceTrait, out K : KeyType> : Identifiable

Base interface for every symmetric encryption algorithm. A Symmetric encryption algorithm is characterised by:

Link copied to clipboard
sealed interface SymmetricKey<A : AuthCapability<out K>, I : NonceTrait, K : KeyType>

Symmetric encryption key. Can only be used for the specified algorithm.

Properties

Link copied to clipboard
Link copied to clipboard

The default dedicated mac output transform as per RFC 7518, taking the first authTagSize many bytes of the MAC output as auth tag.

Link copied to clipboard

The default dedicated mac input calculation as per RFC 7518, authenticating all inputs: AAD || IV || Ciphertext || AAD Length, where AAD_length is a 64 bit big-endian representation of the aad length in bits

Link copied to clipboard
Link copied to clipboard

The dedicated MAC key bytes, if present.

Link copied to clipboard
Link copied to clipboard

Creates a SealedBoxBuilder matching this algorithm's characteristics:

Link copied to clipboard

The actual encryption key bytes

Functions

Link copied to clipboard
fun <A : AuthCapability.Authenticated<out K>, K : KeyType> SealedBoxBuilder.WithNonce.Having<A, K>.from(    encryptedData: ByteArray,     authTag: ByteArray): KmmResult<SealedBox<A, NonceTrait.Required, K>>

Creates a SealedBox matching the characteristics of the underlying SealedBoxBuilder.algorithm. Use this function to load external encrypted data for decryption. Returns a KmmResult purely for the sake of consistency, even though this operation will always success

Creates a SealedBox matching the characteristics of the underlying SealedBoxBuilder.algorithm. Use this function to load external encrypted data for decryption. Returns a KmmResult purely for the sake of consistency

@JvmName(name = "fromAuthenticatedGeneric")
fun SealedBoxBuilder.Without.Authenticated<AuthCapability.Authenticated<*>, *>.from(    encryptedData: ByteArray,     authTag: ByteArray): KmmResult<SealedBox<AuthCapability.Authenticated<*>, NonceTrait.Without, *>>
@JvmName(name = "fromAuthenticatedWihtKeyType")
fun <K : KeyType> SealedBoxBuilder.Without.Authenticated<AuthCapability.Authenticated<out K>, K>.from(    encryptedData: ByteArray,     authTag: ByteArray): KmmResult<SealedBox<AuthCapability.Authenticated<out K>, NonceTrait.Without, K>>

Creates a SealedBox matching the characteristics of the underlying SealedBoxBuilder.algorithm. Use this function to load external encrypted data for decryption.

Link copied to clipboard
@JvmName(name = "hasDedicatedMacAlias")
fun <I : NonceTrait> SymmetricEncryptionAlgorithm<*, I, *>.hasDedicatedMac(): Boolean

Use to smart-cast this algorithm

Link copied to clipboard

Use to smart cast

Link copied to clipboard

Use to smart-cast this sealed box

Link copied to clipboard

Use to smart-cast this sealed box

@JvmName(name = "isAuthenticatedAlias")
fun <I : NonceTrait, K : KeyType> SymmetricEncryptionAlgorithm<*, I, K>.isAuthenticated(): Boolean

Use to smart-cast this algorithm

Use to smart cast

Link copied to clipboard
@JvmName(name = "isBlockCipherAlias")
fun <A : AuthCapability<out K>, I : NonceTrait, K : KeyType> SymmetricEncryptionAlgorithm<A, I, K>.isBlockCipher(): Boolean

Use to smart-cast this algorithm

Link copied to clipboard

Use to smart-cast this algorithm

Use to smart cast

Link copied to clipboard
@JvmName(name = "isStreamCipherAlias")
fun <A : AuthCapability<out K>, I : NonceTrait, K : KeyType> SymmetricEncryptionAlgorithm<A, I, K>.isStreamCipher(): Boolean

Use to smart-cast this algorithm

Link copied to clipboard

Creates a SymmetricKey from the specified secretKey. Returns KmmResult.failure in case the provided bytes don't match SymmetricEncryptionAlgorithm.keySize

Creates a SymmetricKey from the specified encryptionKey and macKey. Returns KmmResult.failure in case the provided bytes don't match SymmetricEncryptionAlgorithm.keySize or the specified macKey is empty.

Link copied to clipboard

Generates a fresh random key for this algorithm.

Generates a fresh random key for this algorithm. macKeyLength can be specified to override preferredMacKeyLength.

Link copied to clipboard

Generates a new random nonce matching the Nonce size of this algorithm. You typically don't want to use this, but have your nonces auto-generated during the encryption process

Link copied to clipboard
@JvmName(name = "requiresNonceAlias")
fun <A : AuthCapability<out K>, K : KeyType> SymmetricEncryptionAlgorithm<A, *, K>.requiresNonce(): Boolean

Use to smart-cast this algorithm

Use to smart cast