From b635fb76518e43f82565ffff9c86b4777b850204 Mon Sep 17 00:00:00 2001 From: Fabio Scotoni <34964387+fscoto@users.noreply.github.com> Date: Mon, 2 Mar 2020 08:00:58 +0100 Subject: [PATCH] crypto_hchacha20 example overhaul Just adds arc4random_buf() for the key. --- doc/man/man3/crypto_hchacha20.3monocypher | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/man/man3/crypto_hchacha20.3monocypher b/doc/man/man3/crypto_hchacha20.3monocypher index 1ae4a8f..f7fa0b3 100644 --- a/doc/man/man3/crypto_hchacha20.3monocypher +++ b/doc/man/man3/crypto_hchacha20.3monocypher @@ -10,7 +10,7 @@ .\" .\" Copyright (c) 2017-2019 Loup Vaillant .\" Copyright (c) 2017-2018 Michael Savage -.\" Copyright (c) 2019 Fabio Scotoni +.\" Copyright (c) 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_HCHACHA20 3MONOCYPHER .Os .Sh NAME @@ -92,11 +92,21 @@ X25519 shared secrets have enough entropy. .Sh RETURN VALUES This function returns nothing. .Sh EXAMPLES +The following example assumes 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 Simple hash: .Bd -literal -offset indent uint8_t key[32]; /* Must have enough entropy */ uint8_t in [16]; /* Does not have to be random */ uint8_t out[32]; /* Will be random iff the above holds */ +arc4random_buf(key, 32); crypto_hchacha20(out, key, in); /* Wipe secrets if they are no longer needed */ crypto_wipe(key, 32); -- 2.47.3