parsePrivateKey

suspend fun EncryptionAlgorithm.OAEPBased.parsePrivateKey(key: ByteArray, keyId: String? = null, format: RSA.PrivateKey.Format = RSA.PrivateKey.Format.PEM, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): EncryptionKey.DecryptionOnlyKey(source)

Decodes an RSA-OAEP private key from a ByteArray for use with this algorithm.

The returned EncryptionKey is an EncryptionKey.DecryptionOnlyKey that can decrypt tokens but cannot encrypt them.

Return

an EncryptionKey wrapping the decoded RSA.OAEP.PrivateKey.

Parameters

key

the private key material to decode.

keyId

optional key ID to associate with the decoded key. Defaults to null.

format

the format in which key is encoded. Defaults to RSA.PrivateKey.Format.PEM.

cryptographyProvider

the provider used to perform key decoding.


suspend fun SigningAlgorithm.PKCS1Based.parsePrivateKey(key: ByteArray, keyId: String? = null, format: RSA.PrivateKey.Format = RSA.PrivateKey.Format.PEM, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningOnlyKey(source)

Decodes an RSA PKCS#1 v1.5 private key from a ByteArray for use with this algorithm.

The returned SigningKey is a SigningKey.SigningOnlyKey that can produce signatures but cannot verify them.

Return

a SigningKey wrapping the decoded RSA.PKCS1.PrivateKey.

Parameters

key

the private key material to decode.

keyId

optional key ID to associate with the decoded key. Defaults to null.

format

the format in which key is encoded. Defaults to RSA.PrivateKey.Format.PEM.

cryptographyProvider

the provider used to perform key decoding.


suspend fun SigningAlgorithm.PSSBased.parsePrivateKey(key: ByteArray, keyId: String? = null, format: RSA.PrivateKey.Format = RSA.PrivateKey.Format.PEM, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningOnlyKey(source)

Decodes an RSA PSS private key from a ByteArray for use with this algorithm.

The returned SigningKey is a SigningKey.SigningOnlyKey that can produce signatures but cannot verify them.

Return

a SigningKey wrapping the decoded RSA.PSS.PrivateKey.

Parameters

key

the private key material to decode.

keyId

optional key ID to associate with the decoded key. Defaults to null.

format

the format in which key is encoded. Defaults to RSA.PrivateKey.Format.PEM.

cryptographyProvider

the provider used to perform key decoding.


suspend fun SigningAlgorithm.ECDSABased.parsePrivateKey(key: ByteArray, keyId: String? = null, format: EC.PrivateKey.Format = EC.PrivateKey.Format.RAW, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningOnlyKey(source)

Decodes an ECDSA private key from a ByteArray for use with this algorithm.

The returned SigningKey is a SigningKey.SigningOnlyKey that can produce signatures but cannot verify them.

Return

a SigningKey wrapping the decoded ECDSA.PrivateKey.

Parameters

key

the private key material to decode.

keyId

optional key ID to associate with the decoded key. Defaults to null.

format

the format in which key is encoded. Defaults to EC.PrivateKey.Format.RAW.

cryptographyProvider

the provider used to perform key decoding.