calculateSharedSecret

fun calculateSharedSecret(privateKey: PrivateKey, publicKey: ByteArray): ByteArray

Calculates the shared secret based on the given public key and the local private key.

Return

Shared secret.

Parameters

privateKey

Private key.

publicKey

Public key.

Throws

if the algorithm is not supported.

if the provider is not supported.

if the key spec is invalid.

if the key is invalid.

if the key agreement is not initialized or if KeyAgreement.doPhase has not been called to supply the keys for all parties in the agreement.