From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 15 15:18:36 2017 Received: (at submit) by debbugs.gnu.org; 15 Dec 2017 20:18:36 +0000 Received: from localhost ([127.0.0.1]:36127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePwRI-0007MM-Hb for submit@debbugs.gnu.org; Fri, 15 Dec 2017 15:18:36 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePwRG-0007Ly-Jp for submit@debbugs.gnu.org; Fri, 15 Dec 2017 15:18:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePwRA-0004mM-KP for submit@debbugs.gnu.org; Fri, 15 Dec 2017 15:18:29 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_40,PERCENT_RANDOM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52523) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePwRA-0004le-F3 for submit@debbugs.gnu.org; Fri, 15 Dec 2017 15:18:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePwR9-00082r-9G for guix-patches@gnu.org; Fri, 15 Dec 2017 15:18:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePwR4-0004bX-BD for guix-patches@gnu.org; Fri, 15 Dec 2017 15:18:27 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:40397) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePwR4-0004Xd-2s for guix-patches@gnu.org; Fri, 15 Dec 2017 15:18:22 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 931C520C2C; Fri, 15 Dec 2017 15:18:19 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Fri, 15 Dec 2017 15:18:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=date:from:in-reply-to:in-reply-to:message-id:references :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=42Q0GKr8UM3h4uGrEuXf95biEETQXAWgvixTK3TE5x0=; b=N+Rz4 DVN1JeO7crEAwGP4JO8WHx0p80EhukDe2CVJcKqeLdQzsW4x5tHjGS/zrK8Yh+CU DrDefBnD08rMeWsde9r/7HiQWH2Rn0cRDTkrJQw/Vio5JVOQEzwPB1c9JsurOp8y XZFMYgLxDbuDPoFO2mOrr4XYK2cvm4g1nhWCPA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:in-reply-to :message-id:references:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=42Q0GKr8UM3h4uGrEuXf95biEETQX AWgvixTK3TE5x0=; b=M2WSsDG/3egWp/NNwET+DJI29Yy6JV+u46Tn3Bw9NuxSV wlaECQuwhezcnmvEOSXcRRB6V1oFcrAJPL/C+2DOXDDbbzNQWXLCZ49H0TO94+Mk UyD147/hsmjzISkcmZ/DniqVp/ZUXzMc5/Y49bSCUxQlBshBRXhk7YJfRwfN6YTj 5jCsAbp6XemfodWtWGsX0LxpSwVOfnaUktrR1VebdhRmxGmhiDg63MigeHW8BZX/ BWPKrZIQ3UBX4gUTOEwNRlcLNtJUinjaVFm+zMkdX0zdYdMCAAtbXheoic9Tc8C7 akdVut9ezIhOaRHK+fiS7QKj1qpLLzmNukxhL0NBQ== X-ME-Sender: Received: from jasmine.lan (c-73-165-108-70.hsd1.pa.comcast.net [73.165.108.70]) by mail.messagingengine.com (Postfix) with ESMTPA id 5A0B87E3D4 for ; Fri, 15 Dec 2017 15:18:19 -0500 (EST) From: Leo Famulari To: guix-patches@gnu.org Subject: [PATCH 2/2] services: urandom-seed: Try using a HWRNG to seed the Linux CRNG at boot. Date: Fri, 15 Dec 2017 15:18:13 -0500 Message-Id: <228c58c205dc551d293e30441579cefe576c1649.1513369093.git.leo@famulari.name> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) * gnu/services/base.scm (urandom-seed-shepherd-service): Try to read from '/dev/hwrng' at boot, as a supplement to any saved random seed. * doc/guix.texi (Base Services): Document the new feature. --- doc/guix.texi | 4 +++- gnu/services/base.scm | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 64f73b38a..e08f264e9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10013,7 +10013,9 @@ well as in the @var{groups} field of the @var{operating-system} record. @deffn {Scheme Procedure} urandom-seed-service Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} -when rebooting. +when rebooting. This also tries to seed @file{/dev/urandom} from +@file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is +readable. @end deffn @defvr {Scheme Variable} %random-seed-file diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 291dd6325..be9e8ee36 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -516,6 +516,25 @@ stopped before 'kill' is called." (call-with-output-file "/dev/urandom" (lambda (urandom) (dump-port seed urandom)))))) + + ;; Try writing from /dev/hwrng into /dev/urandom. + ;; It seems that the file '/dev/hwrng' always exists, even + ;; when there is no hardware random number generator + ;; available. So, we handle any errors caused by a failed + ;; read. + (when (file-exists? "/dev/hwrng") + (call-with-input-file "/dev/hwrng" + (lambda (hwrng) + (let ((buf (make-bytevector 512))) + (catch #t + (lambda () + (get-bytevector-n! hwrng buf 0 512)) + ;; Silence is golden... + (lambda _ (const #f))) + (call-with-output-file "/dev/urandom" + (lambda (urandom) + (put-bytevector urandom buf))))))) + ;; Immediately refresh the seed in case the system doesn't ;; shut down cleanly. (call-with-input-file "/dev/urandom" -- 2.15.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 17 10:31:31 2017 Received: (at 29725) by debbugs.gnu.org; 17 Dec 2017 15:31:31 +0000 Received: from localhost ([127.0.0.1]:39221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQauY-00069d-PK for submit@debbugs.gnu.org; Sun, 17 Dec 2017 10:31:30 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:34250) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQauY-00069V-1m for 29725@debbugs.gnu.org; Sun, 17 Dec 2017 10:31:30 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 18A19F8E9; Sun, 17 Dec 2017 16:31:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FaYK9spyjkxh; Sun, 17 Dec 2017 16:31:32 +0100 (CET) Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 3346BF85A; Sun, 17 Dec 2017 16:31:32 +0100 (CET) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Leo Famulari Subject: Re: [bug#29725] [PATCH 2/2] services: urandom-seed: Try using a HWRNG to seed the Linux CRNG at boot. References: <228c58c205dc551d293e30441579cefe576c1649.1513369093.git.leo@famulari.name> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 27 Frimaire an 226 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 17 Dec 2017 16:31:27 +0100 In-Reply-To: <228c58c205dc551d293e30441579cefe576c1649.1513369093.git.leo@famulari.name> (Leo Famulari's message of "Fri, 15 Dec 2017 15:18:13 -0500") Message-ID: <87y3m1bcc0.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 29725 Cc: 29725@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Leo Famulari skribis: > * gnu/services/base.scm (urandom-seed-shepherd-service): Try to read from > '/dev/hwrng' at boot, as a supplement to any saved random seed. > * doc/guix.texi (Base Services): Document the new feature. Overall LGTM! > + ;; Try writing from /dev/hwrng into /dev/urandom. > + ;; It seems that the file '/dev/hwrng' always exists= , even > + ;; when there is no hardware random number generator > + ;; available. So, we handle any errors caused by a f= ailed > + ;; read. > + (when (file-exists? "/dev/hwrng") > + (call-with-input-file "/dev/hwrng" > + (lambda (hwrng) > + (let ((buf (make-bytevector 512))) > + (catch #t > + (lambda () > + (get-bytevector-n! hwrng buf 0 512)) > + ;; Silence is golden... > + (lambda _ (const #f))) > + (call-with-output-file "/dev/urandom" > + (lambda (urandom) > + (put-bytevector urandom buf))))))) If we fail to read from /dev/hwrng we may end up writing zeros to /dev/urandom (because =E2=80=98buf=E2=80=99 is left uninitialized). To address that, perhaps this could be formulated like this: (let ((buf (catch 'system-error (lambda () (call-with-input-file "/dev/hwrng" (lambda (port) (get-bytevector-n port 512)))) (const #f)))) (when buf (call-with-output-file "/dev/urandom" (lambda (urandom) (put-bytevector urandom buf))))) This also removes the need for the =E2=80=98file-exists?=E2=80=99 call. WDYT? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 18 00:30:23 2017 Received: (at 29725) by debbugs.gnu.org; 18 Dec 2017 05:30:23 +0000 Received: from localhost ([127.0.0.1]:39549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQo0N-00016B-BQ for submit@debbugs.gnu.org; Mon, 18 Dec 2017 00:30:23 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:57707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQo0L-000163-Hs for 29725@debbugs.gnu.org; Mon, 18 Dec 2017 00:30:22 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0A2C820B11; Mon, 18 Dec 2017 00:30:21 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Mon, 18 Dec 2017 00:30:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=QJq54G4K7rMShgvL2/1ZGcwAg82pghcFBuaevhubnXY=; b=Oy+Dv F1RSTXgGyVZY8kGhZWXn+LhWCqlmnE6nSvkGB1YUucYqq4RkFmh3yue6akfZ0/rO QakCeL3A4B1NMAVDHZhnK0PaBhOZrBsOGEybEDWzQwIfNfajVZ7tNY8bqUG53K/r 5ggqPXPIerBL13cZaWZQ4cwJWbhCJ3bIDBlU+g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=QJq54G4K7rMShgvL2/1ZGcwAg82pg hcFBuaevhubnXY=; b=jXUZ+gjgX68HpQx0HAzNtgLJQG5nMHMN6VdWtEg01D3zu A3G9F01o5PQQL9g4ahXt4sNLeE2EV2R8S2e8ZDXN2C/xlMT8arOpIB3OZ4tgS4Pq yLax9dsky9A1WU41kTdJ0rNarERe+EDgV8p8qb1uQitR7dXN7upybx9E7H+f2xCU lvCq49UGUmti52deAW6ZBz1vFHseisd78J8CoP2ajwYhUuw3vH/3l1M58aCe7F2f 0w1Nsyk6CPFtJekmhlzauYlHBY9nSmtzUAziSZzrTp8011MznWlBR0j9P0p8HX6o f6DGKz/JI29dghsdz9qfr74n/entj2P2u/+OWyO6Q== X-ME-Sender: Received: from localhost (unknown [172.58.225.145]) by mail.messagingengine.com (Postfix) with ESMTPA id 90BA97E219; Mon, 18 Dec 2017 00:30:20 -0500 (EST) Date: Mon, 18 Dec 2017 00:30:18 -0500 From: Leo Famulari To: Ludovic =?iso-8859-1?Q?Court=E8s?= Subject: Re: [bug#29725] [PATCH 2/2] services: urandom-seed: Try using a HWRNG to seed the Linux CRNG at boot. Message-ID: <20171218053018.GA22454@jasmine.lan> References: <228c58c205dc551d293e30441579cefe576c1649.1513369093.git.leo@famulari.name> <87y3m1bcc0.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <87y3m1bcc0.fsf@gnu.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 29725 Cc: 29725@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --AhhlLboLdkugWU4S Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 17, 2017 at 04:31:27PM +0100, Ludovic Court=C3=A8s wrote: > Leo Famulari skribis: > If we fail to read from /dev/hwrng we may end up writing zeros to > /dev/urandom (because =E2=80=98buf=E2=80=99 is left uninitialized). Right, the patch I sent wrote the buffer to urandom unconditionally. It's sloppy when the buffer is uninitialized but does no harm to the CRNG. > To address that, perhaps this could be formulated like this: >=20 > (let ((buf (catch 'system-error > (lambda () > (call-with-input-file "/dev/hwrng" > (lambda (port) > (get-bytevector-n port 512)))) > (const #f)))) > (when buf > (call-with-output-file "/dev/urandom" > (lambda (urandom) > (put-bytevector urandom buf))))) Overall I like this better. I tested it and catching system-error seems to work for the case when /dev/hwrng exists but there is nothing actually there. I noticed you used get-bytevector-n instead of get-bytevector-n!. The documentation says that the former reads "octets" while the latter reads "bytes" [0]. I guess there is no difference in practice in 2017, right? > This also removes the need for the =E2=80=98file-exists?=E2=80=99 call. I don't know what creates /dev/hwrng or under what conditions. I didn't see it in (gnu build linux-boot). Can we rely on it to exist for all the versions of Linux we support? --AhhlLboLdkugWU4S Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAlo3UmoACgkQJkb6MLrK fwguqhAAkX3fxMnEBzRaBuEUUxPS5INP0P1PAuOsI9t0FamWE1DolQhgj/olU3mi qQ1aVgRO6tabBYx0kiANqzb3DYRRB95B9YO33fZDZRokb7+qSUEjlARG7FhE2vka faw0AGLeRzPHk1/kswbX7JiZ8gZh4//JyEcQHfajlrt6PWwz3AJewfs4KU5j/J2j lgVFFw4LikooPruhLgw7h1o+v8hEUaFxubHkcgPysrI/MP3ZilnFLg4aQ/v02Xvj y/yhwZKHecI7QXwwv0Wm7w2I/R/qI5rZqn4d3LVftAl6xTTuYkCY97TuTRqxJLfU +UP6AnIH60rOUYbjMygpvKJnlaxutQItMlKHFZVHcjzdo0UOm2p/ajBZywWeq2sw Q2/LUQXLNEQJ5n7hZ0+mZH4gkylJZRLyoMXvJmdtw+AMrpXdtmc73U8u4PbTkIBU QW7WYeeIREEKwnKoeqzc5/bUExK+TAeX1qoS/E36sMPHfrIoIdfTv2LJ22+uY5wl UiGMFt3mrYyyaRgEBbM0W8zeYaqt0jsQVw1IE3QwWHiTDLN9aVPSd8eqqj4X68Kc ToxXn4FoGjfvCCe+oS7fNmpl4fjtE3qkkCi75MDyi55AlZKHhQ8/fqVQJZmCKbZA G2hIXHHhTjzBMSJgiYtPRbYSFph1ulyb/IzgK8+58M8EuBZpfJA= =x6ti -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S-- From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 18 03:06:29 2017 Received: (at 29725) by debbugs.gnu.org; 18 Dec 2017 08:06:29 +0000 Received: from localhost ([127.0.0.1]:39600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQqRR-0006jL-1o for submit@debbugs.gnu.org; Mon, 18 Dec 2017 03:06:29 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:36659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQqRP-0006jD-Ou for 29725@debbugs.gnu.org; Mon, 18 Dec 2017 03:06:28 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id BE671104B5; Mon, 18 Dec 2017 09:06:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qy9k_yhScSEQ; Mon, 18 Dec 2017 09:06:29 +0100 (CET) Received: from ribbon (unknown [193.50.110.155]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 9D8BC10045; Mon, 18 Dec 2017 09:06:29 +0100 (CET) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Leo Famulari Subject: Re: [bug#29725] [PATCH 2/2] services: urandom-seed: Try using a HWRNG to seed the Linux CRNG at boot. References: <228c58c205dc551d293e30441579cefe576c1649.1513369093.git.leo@famulari.name> <87y3m1bcc0.fsf@gnu.org> <20171218053018.GA22454@jasmine.lan> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 28 Frimaire an 226 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 18 Dec 2017 09:06:25 +0100 In-Reply-To: <20171218053018.GA22454@jasmine.lan> (Leo Famulari's message of "Mon, 18 Dec 2017 00:30:18 -0500") Message-ID: <87po7cxxxa.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 29725 Cc: 29725@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Hi, Leo Famulari skribis: > On Sun, Dec 17, 2017 at 04:31:27PM +0100, Ludovic Court=C3=A8s wrote: >> Leo Famulari skribis: >> If we fail to read from /dev/hwrng we may end up writing zeros to >> /dev/urandom (because =E2=80=98buf=E2=80=99 is left uninitialized). > > Right, the patch I sent wrote the buffer to urandom unconditionally. > It's sloppy when the buffer is uninitialized but does no harm to the > CRNG. Oh OK. >> To address that, perhaps this could be formulated like this: >>=20 >> (let ((buf (catch 'system-error >> (lambda () >> (call-with-input-file "/dev/hwrng" >> (lambda (port) >> (get-bytevector-n port 512)))) >> (const #f)))) >> (when buf >> (call-with-output-file "/dev/urandom" >> (lambda (urandom) >> (put-bytevector urandom buf))))) > > Overall I like this better. > > I tested it and catching system-error seems to work for the case when > /dev/hwrng exists but there is nothing actually there. > > I noticed you used get-bytevector-n instead of get-bytevector-n!. The > documentation says that the former reads "octets" while the latter reads > "bytes" [0]. I guess there is no difference in practice in 2017, right? There was also no different in 1970 I think. ;-) =E2=80=9COctet=E2=80=9D = is just slightly more precise, I guess. >> This also removes the need for the =E2=80=98file-exists?=E2=80=99 call. > > I don't know what creates /dev/hwrng or under what conditions. I didn't > see it in (gnu build linux-boot). Can we rely on it to exist for all the > versions of Linux we support? I guess it=E2=80=99s created by udev, I don=E2=80=99t know exactly under wh= at circumstances. I have it on my GuixSD laptop, even though it doesn=E2=80= =99t have a hardware RNG. Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 19 11:31:14 2017 Received: (at control) by debbugs.gnu.org; 19 Dec 2017 16:31:14 +0000 Received: from localhost ([127.0.0.1]:42512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRKnS-0007CQ-CY for submit@debbugs.gnu.org; Tue, 19 Dec 2017 11:31:14 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRKnP-0007CH-9F for control@debbugs.gnu.org; Tue, 19 Dec 2017 11:31:13 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 747CB20A86; Tue, 19 Dec 2017 11:31:10 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Tue, 19 Dec 2017 11:31:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=content-type:date:from:message-id:mime-version:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=OZazWXTYefzUX6MZzVCNeyxLqx bUtdcXqRJDQtwCkvo=; b=KUupMHGxfpcAq5Ar6YjoEWoTWFnxQ1Dt7yb/OkWHLC OKHWakLxDbEyFWED0BiSWgfNwBCYx/HkbBJvxCoNpDN1FHKYgaelnf1ksKVn3bd4 /S0e98WV+g7GRyTmTaolbaF/j691NhusaGMawgWOQl29zb0qZ3dTRm0oqFKVh6Oe Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=O ZazWXTYefzUX6MZzVCNeyxLqxbUtdcXqRJDQtwCkvo=; b=p0pePLhXxGmympDIa FalRQyb4ufE+zJpXu/7X52OvkIIuwprR472R3DlAXXbNGpoN/7f9hOORHU8iJkLS dorlsiu52sB5oAvT21n/+kGhZFCG9amJ4DjZXjvWp4+SkWU+ESVnFgvZBmWWI3ff jHOSvB7Eiocb78AmtmF5thmiehbrIvQjOe2953B6CLJPqz6U+z9L1eI6Q/3gXdBY KdFnX7z9QDhX/T46NvO5FGVFE7vXSv775ulcPkb50xuTYgg0IOC0ii7Vz62p0zCG I7yhi7hTu6oD1MEP+V9cALuQzsp2GBMwh0sDD5kJA/d7KRQ7E0/cuEG9rALkgb01 WHXrA== X-ME-Sender: Received: from localhost (unknown [172.58.201.81]) by mail.messagingengine.com (Postfix) with ESMTPA id C248E7E538 for ; Tue, 19 Dec 2017 11:31:09 -0500 (EST) Date: Tue, 19 Dec 2017 11:31:06 -0500 From: Leo Famulari To: control@debbugs.gnu.org Message-ID: <20171219163106.GA32288@jasmine.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: close 29725 [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [66.111.4.27 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [66.111.4.27 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: close 29725 [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [66.111.4.27 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [66.111.4.27 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid 0.0 TVD_SPACE_RATIO No description available. 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject close 29725 From unknown Tue Aug 19 02:52:16 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 17 Jan 2018 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator