EncryptionKey

Represents a cryptographic key (or key pair) used for JWE encryption and/or decryption.

Instances are identified by a (EncryptionAlgorithm, optional key ID) pair captured in identifier. Depending on which key material is available, an EncryptionKey may be:

Complementary keys that share the same Identifier can be merged into an EncryptionKeyPair via mergeWith. This happens automatically when both are registered with the same co.touchlab.kjwt.model.registry.DefaultJwtProcessorRegistry.

Each subtype directly implements the appropriate processor interface (JweEncryptor, JweDecryptor, or JweProcessor) and carries the cryptographic logic for its role.

See also

Inheritors

Types

Link copied to clipboard
class DecryptionOnlyKey(val identifier: EncryptionKey.Identifier, val privateKey: Key) : EncryptionKey, JweDecryptor

A decryption-only key that holds only the private key material, implementing JweDecryptor.

Link copied to clipboard
class EncryptionKeyPair(val identifier: EncryptionKey.Identifier, val publicKey: Key, val privateKey: Key) : EncryptionKey, JweProcessor

A complete key pair that holds both public and private key material, implementing JweProcessor.

Link copied to clipboard
class EncryptionOnlyKey(val identifier: EncryptionKey.Identifier, val publicKey: Key) : EncryptionKey, JweEncryptor

An encryption-only key that holds only the public key material, implementing JweEncryptor.

Link copied to clipboard
data class Identifier(val algorithm: EncryptionAlgorithm, val keyId: String?)

Identifies an EncryptionKey within a co.touchlab.kjwt.model.registry.DefaultJwtProcessorRegistry by algorithm and optional key ID.

Properties

Link copied to clipboard
open override val algorithm: EncryptionAlgorithm
Link copied to clipboard

The algorithm and key ID that identify this key within a registry.

Link copied to clipboard
open override val keyId: String?
Link copied to clipboard
abstract val privateKey: Key

The private key material used for decryption; throws on subtypes that do not hold a private key.

Link copied to clipboard
abstract val publicKey: Key

The public key material used for encryption; throws on subtypes that do not hold a public key.

Functions

Link copied to clipboard