]> git.codecow.com Git - Monocypher.git/commitdiff
Updated the examples for key exchange.
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 18 Jul 2018 20:33:27 +0000 (22:33 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 18 Jul 2018 20:33:27 +0000 (22:33 +0200)
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).

doc/man/man3/crypto_key_exchange.3monocypher
doc/man/man3/crypto_x25519.3monocypher

index d21e7b576568b0a448d31b12228f55298af42c91..313b1dadb7c36c682bdcd420f7c1288aef7a00c5 100644 (file)
@@ -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
index 5b0f581ce998b054662a40066566148c4aa6e8b6..4dd2bbf067c00abbc62dd23396177db4feec0a6d 100644 (file)
@@ -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);