Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83651 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56842 invoked from network); 24 Feb 2015 10:56:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 10:56:37 -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.176 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.220.176 mail-vc0-f176.google.com Received: from [209.85.220.176] ([209.85.220.176:37698] helo=mail-vc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/43-37184-4E85CE45 for ; Tue, 24 Feb 2015 05:56:37 -0500 Received: by mail-vc0-f176.google.com with SMTP id la4so9568668vcb.7 for ; Tue, 24 Feb 2015 02:56:33 -0800 (PST) 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=k4/SJuU/mfUWEG2XFBN0tKxdW9MNGGBVzAXuzLII/E8=; b=n2uQYJ593P0V4DVmrXKizdPeFx2AR+KW3/Yr7NE8HjxSGDgkfPZqbp7qD9LleY4TKv H2SplbLnxfs4sgCJHwl9vuS5/tkMp5YwUy6HZ/JrIIDaUGfNs+JsBreqEtr6kB2Sa6Va 2wGhM2WSWO5E5ZJZM1LhsK0PTEY8SSRJSUheH/rh7I6cxu86/D77fzl6f82XPget6WeR nY6zVjUPkGWnjwiA/E+Vjmt8JFoCNH4OGMf1mt6WtCuEYEyow0lZf4QVDai9vGZ1slK+ C1nMZCGM4qCsQOQKb6okYtnXsv928ppM0G+26grMGcqguVgHqASQOx+B7lEvP6RAjJiq X5ag== MIME-Version: 1.0 X-Received: by 10.52.52.136 with SMTP id t8mr14441803vdo.49.1424775393715; Tue, 24 Feb 2015 02:56:33 -0800 (PST) Received: by 10.52.4.104 with HTTP; Tue, 24 Feb 2015 02:56:33 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Feb 2015 10:56:33 +0000 Message-ID: To: Andrey Andreev Cc: Sammy Kaye Powers , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Reliable user-land CSPRNG From: leight@gmail.com (Leigh) Hi Andrey, On 24 February 2015 at 09:51, Andrey Andreev wrote: > I noticed that the patch checks for /dev/arandom availability first, > and I'm pretty sure that on systems that have it, /dev/urandom simply > redirects to /dev/urandom, so that might be a bit redundant ... Maybe > Leigh can say more about this if I'm missing something. You're absolutely right, on modern releases of systems like OpenBSD and OSX /dev/urandom is simply an alias of /dev/arandom. The problem is, I'm not an expert in _every_ version of _every_ OS, and it might not always be the case that this aliasing exists. I'd also like to think this adds an element of future-proofing. If I wish for it hard enough, maybe one day Linux in general will introduce /dev/arandom, but maybe at first /dev/urandom does not alias it until some time later. > Also, you don't need 100s of lines of code to write the same thing in > userland ... you need ~30 lines, your Facebook SDK example is just > over-complicated. I'm sure everybody will agree that this is a feature > that PHP needs, so I think you should rather focus on explaining that > it's better than leaving it to userland implementations that may screw > up a lot of details. I agree, we can make a succinct explanation that focuses on the importance of "getting it right". > And finally, a suggestion to remove the default $length value of 16 > for random_bytes() - it just happens to be what you need for i.e. an > AES-128 IV, but other than that it doesn't make sense to have a > default length. This is just a badly formatted part of the RFC. There is no default for random_bytes(). The defaults for random_int() are however +/- PHP_INT_MAX > Otherwise - great! I'm really looking forward to this, and many others > surely do as well. I've got no doubt that the RFC will pass and I > intend to write a compat package for use in pre-PHP7 environments, to > ease the new API's adoption. Thanks :)