Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84895 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9930 invoked from network); 15 Mar 2015 20:09:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2015 20:09:40 -0000 Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:42108] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/B2-31306-307E5055 for ; Sun, 15 Mar 2015 15:09:39 -0500 Received: by mail-vc0-f170.google.com with SMTP id hq11so10870684vcb.1 for ; Sun, 15 Mar 2015 13:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=gtlKARrGXXXB87kYt+ruoVXLPCz5vKsgpqfuarYuOHY=; b=ANYYWpkXOFR3TfwuPGZZFZG3hOlRMG43wNHkJq9HbeqISjsCGtUjCzGVcgQ9yMxiE/ 83j8rvRA9WsZcYthjFoGnmDcpHzx9ueNAASQjptdjBm8hExnjmqgD3TS2sKBYTybdDnP eSjKjoaYh7vuQbEmul0vuJV3e84ZhrxXTmY7+/tO1ukanwaXxk81cIKzZXy5SvtxeJF+ b6XfIpgMheGXUQwNPVZV+ZVdmMjlxIlxdK3kxnsNZQM2Y1ya07nz/BOustU+oSsO9ywU +iDZRxBy/857qxyUTbuEvjo76dJlB+GSvGfEH1QARxxo3Mkuyy6j9lVRKnuh+snDXeiQ tHFg== MIME-Version: 1.0 X-Received: by 10.52.14.99 with SMTP id o3mr60335904vdc.39.1426450176804; Sun, 15 Mar 2015 13:09:36 -0700 (PDT) Received: by 10.52.177.7 with HTTP; Sun, 15 Mar 2015 13:09:36 -0700 (PDT) In-Reply-To: <55055F1D.2020200@beccati.com> References: <55055F1D.2020200@beccati.com> Date: Sun, 15 Mar 2015 20:09:36 +0000 Message-ID: To: Matteo Beccati Cc: Sammy Kaye Powers , PHP Internals Content-Type: multipart/alternative; boundary=20cf30334b77140f4005115950ca Subject: Re: [PHP-DEV] [RFC] [VOTE] Vote open for reliable user-land CSPRNG From: leight@gmail.com (Leigh) --20cf30334b77140f4005115950ca Content-Type: text/plain; charset=UTF-8 On 15 March 2015 at 10:29, Matteo Beccati wrote: > > I want to vote yes, but naming is something that scares me a bit. Without > any indication that it's CSPRNG, people might start using it even when > unnecessary, and I'd be worried about potential negative effects, such as > exhausting the entropy pool. It's probably more of a documentation problem, > but we know many won't read the docs and a "hint" in the function name > could help guiding users. > I wouldn't worry about exhausting the entropy pool, on systems like Linux there is kind of a feedback system where data is mixed back into the pool when you request data. You can pipe /dev/urandom into /dev/null for hours and not suffer any problems. > For example, it would be overkill to use random_int() to randomly pick the > content of a boxes at each reload of a web page, but if what I need is a > *random int*, then random_int() seems a far better choice than some obscure > rand() or mt_rand(). > Of course it would, but that's something that needs to be done through education and via the manual. I understand the concern, but I'm not sure how much I'll worry about it. Or in the poker deck example, wouldn't it be enough just to seed mt_srand > with a crypto-secure number to remove the biasing and using mt_rand to > shuffle the deck? > The biasing comes from how the result is restricted to a certain range of numbers, it's not related to the quality of the seed. We avoid that by throwing away numbers that would give a biased result, and picking a new number. The poker deck example isn't a brilliant one, because the effects of biasing become more apparent the closer you get to the maximum upper bound, but it's still important to cater for the unlikely-but-possible scenarios. --20cf30334b77140f4005115950ca--