From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 999071F55B for ; Sun, 31 May 2020 11:47:30 +0000 (UTC) Received: from localhost ([::1]:48136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfMR7-0004RW-FI for normalperson@yhbt.net; Sun, 31 May 2020 07:47:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfMR3-0004RO-GT for bug-gnulib@gnu.org; Sun, 31 May 2020 07:47:25 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([81.169.146.167]:34266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfMR1-0007O0-Gx for bug-gnulib@gnu.org; Sun, 31 May 2020 07:47:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590925640; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=BTSYrPV5X8eC81Fjf76QhEMmYvRT3kdkouTsYZ2vzjk=; b=qegNhZphoSB72XBw9fyFSKo/h2VArcw61x/PrvSDPjlCNRu37hBiQ+vZxNPl1CzmS8 BO7ms55nGQ9slooZ7sLexCVnzN38Ox7Y6II8mYdV4o+pfzMPlQYJ03NUqTGa1uazYyCX 7+n/176V83udotuzs8TE9hUsR2TQE5x0Rb11RMFcTNe4eSRvcY3+p+Kv6GcUHXjsiQAr 5oLg/XNA48B/0jI5tuJ1mE9DiQrQzq4o2mZ8uHH+61Hat2cq38AVwAsboC9xQD/6Pq8l CRuh/a/k83aWadKhtPlzEhnK4BAWBPA6qNjf5WOenGWW2KBwzQG5baoPnSG9AbSmhham pRzQ== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.9.0 DYNA|AUTH) with ESMTPSA id j03713w4VBl2Cou (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 31 May 2020 13:47:02 +0200 (CEST) From: Bruno Haible To: Paul Eggert Subject: Re: getrandom vs. crypto/gc-random Date: Sun, 31 May 2020 13:47:01 +0200 Message-ID: <12730966.iMV55M3I8i@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <4410554.e4VoEpFJVW@omega> References: <20200525193753.12395-1-eggert@cs.ucla.edu> <4410554.e4VoEpFJVW@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.167; envelope-from=bruno@clisp.org; helo=mo4-p01-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 07:23:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Josefsson , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" > 1) The list of random devices, determined through gc-random.m4. > > > To fix that, I > > am thinking that getrandom should remove its dependency on crypto/gc-random, and > > should simply use "/dev/urandom" for the nonce device without worrying about > > whether crypto/gc-random would define NAME_OF_NONCE_DEVICE to "/dev/urandom". > > This should work on all current porting targets and should simplify maintenance > > by lessening dependencies on the crypto/gc-random module, which pulls in several > > other modules that some packages won't want to bother with. > > I agree. In my testing yesterday, I found that /dev/random and /dev/urandom are > present in all modern versions of operating systems, except native Windows. > I tested: > Linux Fedora 1 OK > Linux Ubuntu 16.04 OK > Linux Ubuntu 18.04 OK > Linux Ubuntu 20.04 OK > Linux Alpine 3.9 OK > Hurd 2019 OK > GNU/kFreeBSD OK > Mac OS X 10.5 OK > Mac OS X 10.13 OK > FreeBSD 11 OK > FreeBSD 12 OK > NetBSD 7.0 OK > NetBSD 9.0 OK > OpenBSD 6.5 OK > AIX 7.1 OK > Solaris 10 OK > Solaris 11.0 OK > Solaris 11.3 OK > Solaris 11.4 OK > Solaris OpenIndiana OK > Haiku OK > Cygwin OK > Minix 3.3 OK > > Seeing this, the configure options --enable-random-device, > --enable-pseudo-random-device, --enable-nonce-device are not needed any more > - neither for gc-gnulib nor for getrandom. I won't remove them from gc-random.m4 > (since that is Simon's responsibility), but I agree with you that for getrandom > we can use the two de-facto standard device names. Done as follows. 2020-05-31 Bruno Haible getrandom: Simplify the determination of the random number devices. Suggested by Paul Eggert in . * lib/getrandom.c (NAME_OF_RANDOM_DEVICE, NAME_OF_NONCE_DEVICE): New macros. * modules/getrandom (Depends-on): Remove crypto/gc-random. diff --git a/lib/getrandom.c b/lib/getrandom.c index f20ffe0..0cc3dc3 100644 --- a/lib/getrandom.c +++ b/lib/getrandom.c @@ -27,6 +27,25 @@ #include "minmax.h" +/* These devices exist on all platforms except native Windows. */ +#if !(defined _WIN32 && ! defined __CYGWIN__) + +/* Name of a device through which the kernel returns high quality random + numbers, from an entropy pool. When the pool is empty, the call blocks + until entropy sources have added enough bits of entropy. */ +# ifndef NAME_OF_RANDOM_DEVICE +# define NAME_OF_RANDOM_DEVICE "/dev/random" +# endif + +/* Name of a device through which the kernel returns random or pseudo-random + numbers. It uses an entropy pool, but, in order to avoid blocking, adds + bits generated by a pseudo-random number generator, as needed. */ +# ifndef NAME_OF_NONCE_DEVICE +# define NAME_OF_NONCE_DEVICE "/dev/urandom" +# endif + +#endif + /* Set BUFFER (of size LENGTH) to random bytes under the control of FLAGS. Return the number of bytes written, or -1 on error. */ ssize_t diff --git a/modules/getrandom b/modules/getrandom index e94686d..8aa4be2 100644 --- a/modules/getrandom +++ b/modules/getrandom @@ -7,7 +7,6 @@ m4/getrandom.m4 Depends-on: sys_random -crypto/gc-random [test $HAVE_GETRANDOM = 0] fcntl-h [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1] minmax [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1] open [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]