From: Matt Armstrong <matt@rfc20.org>
To: Paul Eggert <eggert@cs.ucla.edu>, Stefan Kangas <stefankangas@gmail.com>
Cc: 58472@debbugs.gnu.org
Subject: bug#58472: [PATCH] Make `message-unique-id' less prone to collisions
Date: Mon, 17 Oct 2022 11:40:54 -0700 [thread overview]
Message-ID: <87ilki70p5.fsf@rfc20.org> (raw)
In-Reply-To: <cf192c87-5a72-9da1-759b-f9d3053d0d38@cs.ucla.edu>
Paul Eggert <eggert@cs.ucla.edu> writes:
> I've been looking into this and have several patches along these lines.
> None of them address message-unique-id directly yet (I plan to tackle
> this soon) but they do address the general problem area. The basic idea
> is to use a new make-nonce primitive.
I like it.
> ---
> doc/lispref/numbers.texi | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
> index fdcda328d8..c1a1349d1a 100644
> --- a/doc/lispref/numbers.texi
> +++ b/doc/lispref/numbers.texi
>
> -If @var{limit} is a string, it means to choose a new seed based on the
> -string's contents.
> +If you need a random nonce for cryptographic purposes, @code{(random
> +t)} is typically not the best approach, as it can adversely affect other
> +parts of your program that benefit from reproducible results, and it can
> +leave information about the nonce scattered about Emacs's internal state.
Mention the new `make-nonce'?
With respect to "cryptographic purposes" how about mentioning that
`random' itself is potentially seeded from a cryptographically weak
source and makes no promise to use a PRNG suitable for cryptography? If
I'm right about those two assertions, I think they are important to
mention.
> diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
> index cf961e9e7c..0f3e0ae213 100644
> --- a/doc/lispref/strings.texi
> +++ b/doc/lispref/strings.texi
> @@ -455,6 +455,18 @@ Creating Strings
> Remove the final newline, if any, from @var{string}.
> @end defun
>
> +@defun make-nonce length &optional function
> +Return a newly created random string of length @var{length}.
> +The string is unibyte, with bytes taken from system entropy,
> +and with each string value equally likely.
> +
> +If @var{function} is given, call it with the newly created string as
> +an argument and return the value that @var{function} returns.
> +When the function exits, overwrite the string's random contents with
> +unspecified bytes, to lessen information leakage in insecure code.
> +The string's contents are therefore valid only during the function call.
> +@end defun
First question I'll have as a reader: what happens if the system has low
entropy? Does this block? Signal an error?
next prev parent reply other threads:[~2022-10-17 18:40 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 16:07 bug#58472: [PATCH] Make `message-unique-id' less prone to collisions Stefan Kangas
2022-10-12 18:08 ` Paul Eggert
2022-10-13 2:46 ` Stefan Kangas
2022-10-13 4:53 ` Matt Armstrong
2022-10-13 12:10 ` Stefan Kangas
2022-10-13 16:35 ` Matt Armstrong
2022-10-13 16:38 ` Paul Eggert
2022-10-14 9:22 ` Stefan Kangas
2022-10-13 16:21 ` Paul Eggert
2022-10-14 9:22 ` Stefan Kangas
2022-10-16 7:32 ` Stefan Kangas
2022-10-16 17:05 ` Stefan Kangas
2022-10-16 15:19 ` Matt Armstrong
2022-10-16 16:49 ` Stefan Kangas
2022-10-17 6:17 ` Matt Armstrong
2022-10-17 7:30 ` Paul Eggert
2022-10-17 8:14 ` Stefan Kangas
2022-10-17 8:23 ` Eli Zaretskii
2022-10-17 18:47 ` Matt Armstrong
2022-10-17 8:16 ` Eli Zaretskii
2022-10-17 8:29 ` Lars Ingebrigtsen
2022-10-17 8:34 ` Eli Zaretskii
2022-10-17 9:30 ` Stefan Kangas
2022-10-17 11:22 ` Lars Ingebrigtsen
2022-10-17 15:40 ` Stefan Kangas
2022-11-25 1:26 ` Stefan Kangas
2022-10-17 18:40 ` Matt Armstrong [this message]
2022-10-18 1:38 ` Paul Eggert
2022-10-18 14:05 ` Eli Zaretskii
2022-10-13 11:45 ` Lars Ingebrigtsen
2022-10-13 12:10 ` Stefan Kangas
2022-10-13 19:15 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilki70p5.fsf@rfc20.org \
--to=matt@rfc20.org \
--cc=58472@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).