decryptWith

suspend fun JwtParserBuilder.decryptWith(algorithm: EncryptionAlgorithm.OAEPBased, jwk: Jwk.Rsa, keyId: String? = jwk.kid, cryptoProvider: CryptographyProvider = CryptographyProvider.Default): JwtParserBuilder(source)

Configures the parser to decrypt JWE tokens using an RSA OAEP private key derived from the given Jwk.Rsa JWK.

Return

this builder for chaining

Parameters

algorithm

the OAEP-based key encryption algorithm (RSA-OAEP or RSA-OAEP-256)

jwk

the RSA JWK containing the private key parameters, including d and the CRT parameters

keyId

optional key ID override; when set, the parser will only use this key if the token's kid header matches. Defaults to the JWK's own kid field.

cryptoProvider

the CryptographyProvider used to decode the key; defaults to CryptographyProvider.Default


Registers a direct (dir) SimpleKey symmetric key for JWE decryption.

Return

this builder for chaining

Parameters

algorithm

the direct key encryption algorithm (EncryptionAlgorithm.Dir)

privateKey

the SimpleKey wrapping the raw symmetric content encryption key

keyId

optional key ID to associate with this decryptor; when set, only tokens whose kid header matches will use this key. Defaults to null (matches any token).


Registers an RSA-OAEP (RSA-OAEP / RSA-OAEP-256) private key for JWE decryption.

Return

this builder for chaining

Parameters

algorithm

the OAEP-based key encryption algorithm (RSA-OAEP or RSA-OAEP-256)

privateKey

the RSA OAEP private key used to unwrap the content encryption key

keyId

optional key ID to associate with this decryptor; when set, only tokens whose kid header matches will use this key. Defaults to null (matches any token).


fun JwtParserBuilder.decryptWith(algorithm: EncryptionAlgorithm, privateKey: Key, keyId: String? = null): JwtParserBuilder(source)

Registers a raw Key for JWE token decryption using any EncryptionAlgorithm.

Prefer the strongly typed overloads (e.g. decryptWith accepting RSA.OAEP.PrivateKey or SimpleKey) when possible, as they enforce the correct key type at compile time.

Return

this builder for chaining

Parameters

algorithm

the JWE key-encryption algorithm this key is associated with

privateKey

the raw cryptography-kotlin key to decrypt tokens with; must be compatible with algorithm

keyId

optional key ID to associate with this decryptor; when set, only tokens whose kid header matches will use this key. Defaults to null (matches any token).


Registers a pre-built EncryptionKey.DecryptionOnlyKey for JWE token decryption.

The algorithm and kid are taken from key's EncryptionKey.Identifier.

Return

this builder for chaining

Parameters

key

the decryption-only encryption key to register


Registers a pre-built EncryptionKey.EncryptionKeyPair for JWE token decryption.

The algorithm and kid are taken from key's EncryptionKey.Identifier. Both the public and private key material are stored, but only the private key is used for decryption.

Return

this builder for chaining

Parameters

key

the encryption key pair to register


Registers a direct key (dir) for JWE decryption from a raw ByteArray.

Return

this builder for chaining.

Parameters

key

the raw symmetric key bytes used for direct decryption.

keyAlgorithm

the direct key encryption algorithm (EncryptionAlgorithm.Dir).

keyId

optional key ID to associate with this decryptor; when set, only tokens whose kid header matches will use this key. Defaults to null (matches any token).


Registers a direct key (dir) for JWE decryption from a UTF-8 String.

The string is converted to bytes using UTF-8 encoding before being used as the symmetric key.

Return

this builder for chaining.

Parameters

key

the symmetric key as a UTF-8 string.

keyAlgorithm

the direct key encryption algorithm (EncryptionAlgorithm.Dir).

keyId

optional key ID to associate with this decryptor; when set, only tokens whose kid header matches will use this key. Defaults to null (matches any token).