Re: [PHP6] Merging rand and mt_rand()
Hi,
On 26 February 2014 08:13, Pierre Joye <[email protected]> wrote:
> Hi Rowen,
>
>
> On Sun, Feb 23, 2014 at 7:45 PM, Rouven Weßling <[email protected]> wrote:
>> Hello internals,
>>
>> there has already been a lot of talk about improving secure random number 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 an 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 separate? 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ádraic Brady
http://blog.astrumfutura.com
http://www.survivethedeepend.com
Zend Framework Community Review Team
Zend Framework PHP-FIG Representative
Thread (15 messages)