Re: Improving mt_rand() seed

From: Date: Thu, 02 Feb 2017 13:54:23 +0000
Subject: Re: Improving mt_rand() seed
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-98120@lists.php.net to get a copy of this message
On 2 Feb 2017, at 8:24, Christoph M. Becker wrote:
On 02.02.2017 at 12:51, Yasuo Ohgaki wrote:
Although users must never do this, but there are codes that generate random password/access key by mt_rand().
There is also code that stores clear text passwords. How would you prevent that? IMHO, if users don't care to read the docs[1], it's their fault, and we shouldn't waste our time to fix their bugs. [1] <http://php.net/manual/en/function.mt-rand.php>
We cannot fix these bugs without making mt_rand a CSPRNG, which means it is no longer mt_rand. All we can do is mitigate the problem (to some unknowable extent) by seeding mt_rand from php_random_bytes. I don't care if we do this or not so long as the change is simple and BC, i.e. 32-bit seed that falls back to something else if php_random_bytes fails. Tom

« previous php.internals (#98120) next »