From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96125 invoked by alias); 13 Aug 2018 20:12:04 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 94881 invoked by uid 89); 13 Aug 2018 20:12:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=daemon, H*i:u4ani2J2X, H*i:CAE4aFAk, H*i:sk:8YAEv4P X-HELO: mail-yw1-f67.google.com Received: from mail-yw1-f67.google.com (HELO mail-yw1-f67.google.com) (209.85.161.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Aug 2018 20:12:01 +0000 Received: by mail-yw1-f67.google.com with SMTP id l9-v6so14530783ywc.11; Mon, 13 Aug 2018 13:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4ZNtAiJ6BRmFJ+mI+WGPUNjfVsLDyubSOpx9XVNMLDE=; b=AKH/XEJR8SORUIqWha2EUl3qcx1sArmjxT0qS14Wx9H9bOUEoTE+4S4Ej27T1qZ5By Ne5m33Bi8Y+pTk1RjnPzknJy5LP0wYDD4CBecQE3hJiPvzJphCV03OVgSAapSEN87N5A wBM9XhIw/qTDmHk9xy6PYe4OPoGIqNrCJbULWqMdkQ5wR8+eBf5g2T/RILPzwTYAWhxN 5/pwvoNq+kypx0Tj3fGB+a1XFQLV+Bl1Fi6JCvDWIT3TkGtc6V73RN4GUS373TmUJVJ6 cgX6fZC4ymaejL2/txtS9HY0J7EahwbWdJku8iosXdHqn++QQ5QfQOFArowFsVwWffAd gHiQ== MIME-Version: 1.0 Received: by 2002:a81:484e:0:0:0:0:0 with HTTP; Mon, 13 Aug 2018 13:11:59 -0700 (PDT) In-Reply-To: References: <20180803131903.24303-1-blomqvist.janne@gmail.com> From: Janne Blomqvist Date: Mon, 13 Aug 2018 20:12:00 -0000 Message-ID: Subject: Re: [PATCH] Use getentropy() for seeding PRNG To: Fritz Reese Cc: Jakub Jelinek , fortran , gcc-patches , paulkoning@comcast.net Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00058.txt.bz2 On Mon, Aug 13, 2018 at 5:36 PM, Fritz Reese wrote: > On Fri, Aug 3, 2018 at 9:19 AM Janne Blomqvist > wrote: > > > > The getentropy function, found on Linux, OpenBSD, and recently also > > FreeBSD, can be used to get random bytes to initialize the PRNG. It > > is similar to the traditional way of reading from /dev/urandom, but > > being a system call rather than a special file, it doesn't suffer from > > problems like running out of file descriptors, or failure when running > > in a container where /dev/urandom is not available. > > > > Regtested on x86_64-pc-linux-gnu, Ok for trunk? > > Actually, getentropy() is similar to reading from /dev/random, where > getrandom() is similar to reading from /dev/urandom. No, getentropy is similar to getrandom with the flags argument == 0. Which is similar to reading /dev/urandom, except that just after boot if enough entropy hasn't yet been gathered, it may block instead of returning some not-quite-random data. But once it has been initialized, it will never block again. I agree that reading from /dev/random is overkill, but this patch isn't doing the equivalent of that. > Since the > original behavior of getosrandom() is to read from /dev/urandom, I > think it is better to use getrandom() for consistent semantics. > > Furthermore, getentropy() may block to achieve an appropriate degree > of randomness, since it is intended for secure use. The only time this might happen is just after boot, after that the entropy never drains (in contrast to /dev/random). So unless you're planning to write an init daemon in Fortran, this shouldn't matter. -- Janne Blomqvist