From: Loup Vaillant Date: Wed, 18 Jul 2018 20:33:27 +0000 (+0200) Subject: Updated the examples for key exchange. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=ab86845865187e73eaf974ce9d770f48eea10b25;p=Monocypher.git Updated the examples for key exchange. Related to #102 The crypto_key_exchange() and crypto_x25519() examples no longer use the return value, which has been deprecated. Also harmonised the phrasing between the two man pages (I liked one more than the other). --- diff --git a/doc/man/man3/crypto_key_exchange.3monocypher b/doc/man/man3/crypto_key_exchange.3monocypher index d21e7b5..313b1da 100644 --- a/doc/man/man3/crypto_key_exchange.3monocypher +++ b/doc/man/man3/crypto_key_exchange.3monocypher @@ -53,7 +53,7 @@ with 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 @@ -88,10 +88,7 @@ key and their secret key.) 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 diff --git a/doc/man/man3/crypto_x25519.3monocypher b/doc/man/man3/crypto_x25519.3monocypher index 5b0f581..4dd2bbf 100644 --- a/doc/man/man3/crypto_x25519.3monocypher +++ b/doc/man/man3/crypto_x25519.3monocypher @@ -84,10 +84,7 @@ key. 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);