Some public keys force the shared key to a known constant.
.Fn crypto_key_exchange
returns -1 if it detects such a public key, otherwise it returns 0.
-This happens with some illegitimate public keys.
+This never happens with legitimate public keys.
.Pp
.Sy The return value has been deprecated .
.Fn crypto_key_exchange
const uint8_t their_pk [32]; /* Their public key */
const uint8_t your_sk [32]; /* Your secret key */
uint8_t shared_key[32]; /* Shared session key */
-if (crypto_key_exchange(shared_key, your_sk, their_pk) != 0) {
- /* Their public key is malicious. */
- /* The exchange must be aborted. */
-}
+crypto_key_exchange(shared_key, your_sk, their_pk);
/* Wipe secrets if they are no longer needed */
crypto_wipe(your_sk, 32);
.Ed
const uint8_t their_pk [32]; /* Their public key */
const uint8_t your_sk [32]; /* Your secret key */
uint8_t shared_secret[32]; /* Shared secret (NOT a key) */
-if (crypto_x25519(shared_secret, your_sk, their_pk) != 0) {
- /* Their public key is malicious. */
- /* The exchange must be aborted. */
-}
+crypto_x25519(shared_secret, your_sk, their_pk;
/* Wipe secrets if they are no longer needed */
crypto_wipe(your_sk, 32);