newKey

Generates a new random symmetric key for use with the dir algorithm.

The returned EncryptionKey is an EncryptionKey.EncryptionKeyPair usable for both encryption and decryption since dir uses the same key for both operations.

Return

an EncryptionKey wrapping the generated key bytes.

Parameters

keySize

the size of the key to generate in bits. Must match the Content Encryption Algorithm's required key size (e.g. 128, 192, or 256 bits). Defaults to 256 bits.

keyId

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


suspend fun EncryptionAlgorithm.OAEPBased.newKey(keyId: String? = null, keySize: BinarySize = 2048.bits, publicExponent: BigInt = 65537.toBigInt(), cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): EncryptionKey.EncryptionKeyPair(source)

Generates a new RSA-OAEP key pair for use with this algorithm.

The returned EncryptionKey is an EncryptionKey.EncryptionKeyPair containing both the public and private key, usable for encryption and decryption.

Return

an EncryptionKey wrapping the generated RSA.OAEP key pair.

Parameters

keyId

optional key ID to associate with the generated key pair. Defaults to null.

keySize

the RSA modulus size in bits. Defaults to 2048 bits.

publicExponent

the RSA public exponent. Defaults to 65537.

cryptographyProvider

the provider used to perform key generation.


suspend fun SigningAlgorithm.MACBased.newKey(keyId: String? = null, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningKeyPair(source)

Generates a new random HMAC key for use with this algorithm.

The returned SigningKey is a SigningKey.SigningKeyPair usable for both signing and verification since HMAC uses a single symmetric key.

Return

a SigningKey wrapping the generated HMAC.Key.

Parameters

keyId

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

cryptographyProvider

the provider used to perform key generation.


suspend fun SigningAlgorithm.PKCS1Based.newKey(keyId: String? = null, keySize: BinarySize = 2048.bits, publicExponent: BigInt = 65537.toBigInt(), cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningKeyPair(source)

Generates a new RSA PKCS#1 v1.5 key pair for use with this algorithm.

The returned SigningKey is a SigningKey.SigningKeyPair containing both the public and private key, usable for signing and verification.

Return

a SigningKey wrapping the generated RSA.PKCS1 key pair.

Parameters

keyId

optional key ID to associate with the generated key pair. Defaults to null.

keySize

the RSA modulus size in bits. Defaults to 2048 bits.

publicExponent

the RSA public exponent. Defaults to 65537.

cryptographyProvider

the provider used to perform key generation.


suspend fun SigningAlgorithm.PSSBased.newKey(keyId: String? = null, keySize: BinarySize = 2048.bits, publicExponent: BigInt = 65537.toBigInt(), cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningKeyPair(source)

Generates a new RSA PSS key pair for use with this algorithm.

The returned SigningKey is a SigningKey.SigningKeyPair containing both the public and private key, usable for signing and verification.

Return

a SigningKey wrapping the generated RSA.PSS key pair.

Parameters

keyId

optional key ID to associate with the generated key pair. Defaults to null.

keySize

the RSA modulus size in bits. Defaults to 2048 bits.

publicExponent

the RSA public exponent. Defaults to 65537.

cryptographyProvider

the provider used to perform key generation.


suspend fun SigningAlgorithm.ECDSABased.newKey(keyId: String? = null, cryptographyProvider: CryptographyProvider = CryptographyProvider.Default): SigningKey.SigningKeyPair(source)

Generates a new ECDSA key pair for use with this algorithm.

The returned SigningKey is a SigningKey.SigningKeyPair containing both the public and private key, usable for signing and verification.

Return

a SigningKey wrapping the generated ECDSA key pair.

Parameters

keyId

optional key ID to associate with the generated key pair. Defaults to null.

cryptographyProvider

the provider used to perform key generation.