ecdhDeriveSharedSecret()

Generates a shared secret based on the key pair for an ECDH key exchange.

Synopsis

int ecdhDeriveSharedSecret(int keyPairId, blob &peerPublicKey, blob &sharedSecret)

Parameters

Parameter Meaning
keyPairId The key pair Id, generated with ecdhReleaseKeyPair().
peerPublicKey The public key, extracted with ecdhGetPublicKey().
sharedSecret Stores the shared secret.

Return value

The function returns 0 on success.

Error

In case of an error, an exception is thrown.

Description

Generates a shared secret based on the key pair with given ID, using the public key transferred from the peer as second argument. The shared secret will be stored in the third argument. If done correctly, the shared secret will be the same for both peers. Instead of using the secret directly, it should be hashed with cryptoHash() to achieve a better distribution of the generated data (for this, both peers need to use the same algorithm).

Anmerkung: The name of the ECDH curve to use can be configured with the already existing config entry [allSections] ECDHCurve.

Assignment

Communication functions

Availability

CTRL