Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72849 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13994 invoked from network); 27 Feb 2014 22:30:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2014 22:30:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=padraic.brady@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=padraic.brady@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.177 as permitted sender) X-PHP-List-Original-Sender: padraic.brady@gmail.com X-Host-Fingerprint: 209.85.160.177 mail-yk0-f177.google.com Received: from [209.85.160.177] ([209.85.160.177:65323] helo=mail-yk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/03-33117-A9CBF035 for ; Thu, 27 Feb 2014 17:30:51 -0500 Received: by mail-yk0-f177.google.com with SMTP id q200so2341337ykb.8 for ; Thu, 27 Feb 2014 14:30:48 -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:content-transfer-encoding; bh=Ja7pgj9CBM6zTQASH6HbCVeJtcxEUw7L6ScqtX03kgk=; b=w3na1+j7xwHP2qUNHauKdgjWVY1uTYbmv6RinaMK6MXFmdMG4gY1i7YYGCj9/NV4dP XfUlrQbJFYAcLfXeYF3Hifmil7fdveAOiZckzqq+F61gT7dQeO9R2AA6XWUL0EiX6qy3 Pfck2nnT0FNV2ZgZfuvviqmWVVczgo5H248PYAFePj8b0T4HGA/ym8JLjjBfH7wu/upV pifrsT8tGDmW7mN4urKL2zEcne6REggJnzdlyRGKJgJq5AE2ZplKfhZlujl8+rvQFSfO +f3oNYsmvxLuaJGQfvlZcRO/30GECfIlrZzcvdmVfRXw3nmavXL1wMp2QhjZJacNRok4 HyAQ== MIME-Version: 1.0 X-Received: by 10.236.130.138 with SMTP id k10mr17956439yhi.31.1393540248265; Thu, 27 Feb 2014 14:30:48 -0800 (PST) Received: by 10.170.160.69 with HTTP; Thu, 27 Feb 2014 14:30:48 -0800 (PST) In-Reply-To: References: Date: Thu, 27 Feb 2014 22:30:48 +0000 Message-ID: To: Pierre Joye Cc: =?UTF-8?Q?Rouven_We=C3=9Fling?= , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PHP6] Merging rand and mt_rand() From: padraic.brady@gmail.com (=?UTF-8?Q?P=C3=A1draic_Brady?=) Hi, On 26 February 2014 08:13, Pierre Joye wrote: > Hi Rowen, > > > On Sun, Feb 23, 2014 at 7:45 PM, Rouven We=C3=9Fling wrote: >> Hello internals, >> >> there has already been a lot of talk about improving secure random numbe= r generation for PHP6. One thing I'd like to improve as well, would be non-= secure random number generation. Here is not so much security at stake but = ease of use. >> >> The obvious solution, would be to rename mt_rand to rand and make rand a= n alias. (The same for the supporting functions mt_srand and mt_getrandmax)= . >> >> What I'm missing is the history. What was the reason to keep the separat= e? Am I missing something? Well, they do two different things so keeping them separate seems like a good idea ;). > I totally agree with your goals. There are too many ways to do the > same operations, in many areas. However I am not a fan of breaking BC > (even in small ways) without an actual big benefit. It is always easy > to remove, kill, change functions to make them "better". Adding each > single change together will make a migration to a given version almost > impossible or very painful. I would go with a soft way. > > In the case of the random functions, as I said in previous > discussions, I tend to go with a new APIs, clean, with a couple more > algorithms as well as easy to use functions for the common usages > (crypto safe or not). Anthony implemented something in userland, there > are a couple of libraries available too (in C, used by python f.e.) > providing very handy APIs. That's the way I would choose. New APIs would be preferable. Technically, there's nothing wrong with mt_rand() since it does what it says on the box. A mt_rand() function that isn't predictable using a known seed is actually broken ;). Leaking its values may have implications since the seed is vulnerable to recovery, but it already has a bad rep for use anywhere in security. Anthony's library is quite good for cases where getting a decent crypto safe random value isn't possible, but it's really something of a last resort and the thing that makes it decent is the algorithm for mixing entropy sources. Paddy -- P=C3=A1draic Brady http://blog.astrumfutura.com http://www.survivethedeepend.com Zend Framework Community Review Team Zend Framework PHP-FIG Representative