Re: Re: Improving mt_rand() seed

From: Date: Sat, 21 Jan 2017 14:40:58 +0000
Subject: Re: Re: Improving mt_rand() seed
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-97912@lists.php.net to get a copy of this message
> > > Anyway, unusable CSPRNG is very unlikely to happen. I may just use > > UNEXPECTED macro for the if branch. > > > > I changed my mind due to comment for uniqid() CSPRNG usage. > > IMO, there is no benefit for CSPRNG failure fallback. We shouldn't add > fackback for every CSPRNG usage. Right, we absolutely should not. Most usages of a CSPRNG require a CSPRNG, while mt_rand and uniqid do not, so it's a different case here. > It's just does not make sense. Are we > going to add poor fallbacks for every CSPRNG usage? I strongly against it. > > CSPRNG failure is like BUS error, i.e. hardware error. CSPRNG shouldn't > fail with healthy hardware/OS. Therefore, we should not add poor fallback > code for it. A CSPRNG is not necessarily a hardware error. PHP might run on weird platforms, no? 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? Regards, Niklas

« previous php.internals (#97912) next »