Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97981 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39899 invoked from network); 27 Jan 2017 02:53:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jan 2017 02:53:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:43148] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/E4-28703-626BA885 for ; Thu, 26 Jan 2017 21:53:28 -0500 Received: (qmail 68032 invoked by uid 89); 27 Jan 2017 02:53:22 -0000 Received: from unknown (HELO mail-wm0-f50.google.com) (yohgaki@ohgaki.net@74.125.82.50) by 0 with ESMTPA; 27 Jan 2017 02:53:22 -0000 Received: by mail-wm0-f50.google.com with SMTP id c85so98376193wmi.1 for ; Thu, 26 Jan 2017 18:53:22 -0800 (PST) X-Gm-Message-State: AIkVDXIGck1vylNjCD04SNGynE4iZVr5VDXR/Hjj0iSdZ5vUGfr+wyUG5tU3IgpBpZz/iwj6pbF/X3V+R8D5Og== X-Received: by 10.28.230.194 with SMTP id e63mr1107111wmi.25.1485485595864; Thu, 26 Jan 2017 18:53:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.195.12.8 with HTTP; Thu, 26 Jan 2017 18:52:34 -0800 (PST) In-Reply-To: References: <71c26cd6df6f59e76dafd31647852c2e@koti.fimnet.fi> <142a3537a99809cf23d78e0eaadc3aef@gmail.com> <7a359bb08b0ad8b046534c15492cec91@gmail.com> <8cfe7a3ea5a05fc3e5347e9af848ada0@gmail.com> Date: Fri, 27 Jan 2017 11:52:34 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Leigh Cc: Niklas Keller , =?UTF-8?Q?Lauri_Kentt=C3=A4?= , Nikita Popov , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1147c82442bd2805470a9125 Subject: Re: [PHP-DEV] Re: Improving mt_rand() seed From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1147c82442bd2805470a9125 Content-Type: text/plain; charset=UTF-8 Hi Leigh, On Sun, Jan 22, 2017 at 6:40 PM, Leigh wrote: > On Sat, 21 Jan 2017 at 14:41 Niklas Keller wrote: > >> Anyway, the "issue" with mt_rand is not the seed being predictable but >> the internal state being recoverable from the output. But mt_rand is >> predictable by design, so why should we even seed it with a CSPRNG by >> default? >> >> >> For the record, when I was making RNG changes for 7.1, I did look at the > mt_rand seed mechanism, and decided it was _good enough_ for the purposes > of mt_rand. > > State recovery can actually be done with as few as 624 sequential outputs, > you will never be able to get away from that. Even with a fully CSPRNG > generated state, if an attacker gets 624 outputs after the state is > twisted, the RNG is compromised. > Nice comment! Since mt_rand is predictable PRNG, there is possibility to be known to attackers always. What I would like to change is - there is only 2^32 initial states Think of a code that generates "random password string" from mt_rand. (We know nobody should do this, but there are many codes do this) If password is alpha numeric+#$ and 10 chars long, there could be 64^10 = 2^60 patterns with pure random. but with current mt_rand could generate only 2^32 patterns due to mt_rand() limited state. This is a lot less random than it could be. Hardening mt_rand() w/o salt value beneficial to general mt_rand() usage also. i.e. PHP app runs short periods of time and only use beginning of MT rand cycle. More than 99% random cycle is wasted currently. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1147c82442bd2805470a9125--