From: Fabio Scotoni <34964387+fscoto@users.noreply.github.com> Date: Mon, 2 Mar 2020 07:03:20 +0000 (+0100) Subject: crypto_key_exchange example overhaul X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c9c7c6356e41ddedb49aab248bc5ac8b2c9b3c84;p=Monocypher.git crypto_key_exchange example overhaul Just adds arc4random_buf(). --- diff --git a/doc/man/man3/crypto_key_exchange.3monocypher b/doc/man/man3/crypto_key_exchange.3monocypher index 9bfd3fd..1875fd7 100644 --- a/doc/man/man3/crypto_key_exchange.3monocypher +++ b/doc/man/man3/crypto_key_exchange.3monocypher @@ -10,7 +10,7 @@ .\" .\" Copyright (c) 2017-2019 Loup Vaillant .\" Copyright (c) 2017-2018 Michael Savage -.\" Copyright (c) 2017, 2019 Fabio Scotoni +.\" Copyright (c) 2017, 2019-2020 Fabio Scotoni .\" All rights reserved. .\" .\" @@ -40,7 +40,7 @@ .\" .\" ---------------------------------------------------------------------------- .\" -.\" Written in 2017-2019 by Loup Vaillant, Michael Savage and Fabio Scotoni +.\" Written in 2017-2020 by Loup Vaillant, Michael Savage and Fabio Scotoni .\" .\" To the extent possible under law, the author(s) have dedicated all copyright .\" and related neighboring rights to this software to the public domain @@ -50,7 +50,7 @@ .\" with this software. If not, see .\" .\" -.Dd December 12, 2019 +.Dd March 2, 2020 .Dt CRYPTO_KEY_EXCHANGE 3MONOCYPHER .Os .Sh NAME @@ -115,10 +115,20 @@ Protocols should instead be designed in such a way that no such check is necessary, namely by authenticating the other party or exchanging keys over a trusted channel. .Sh EXAMPLES +The following examples assume the existence of +.Fn arc4random_buf , +which fills the given buffer with cryptographically secure random bytes. +If +.Fn arc4random_buf +does not exist on your system, see +.Xr intro 3monocypher +for advice about how to generate cryptographically secure random bytes. +.Pp Generate a public key from a randomly generated secret key: .Bd -literal -offset indent uint8_t sk[32]; /* Random secret key */ uint8_t pk[32]; /* Public key */ +arc4random_buf(sk, 32); crypto_key_exchange_public_key(pk, sk); /* Wipe secrets if they are no longer needed */ crypto_wipe(sk, 32);