On 6/14/2012 6:11 AM, Anthony Ferrara wrote:
Daniel,

Stas has the right approach, not only should the methods be simplified and
platform/algorithm agnostic but have a proper salt built in (there are a
few CSPRNG implementations around), I've seen salts used from numbers to
md5's to just being skipped altogether.

Well, just to be clear, a salt does not need a CSPRNG. All it needs to
be is reasonably unique. In fact, I wouldn't make it CS, as that would
deplete the available entropy in the system for CSPRNG generation.

So in practice, a normal PRNG will suffice. With that said, mt_rand()
is not enough. It should be a moderately good PSRNG. It just doesn't
need to be CS. If mcrypt is available, DEV_URANDOM would be a good
place to get entropy.

Or, we could implement a system like I did in
https://github.com/ircmaxell/PHP-CryptLib/tree/master/lib/CryptLib/Random
that follows RFC4086: http://tools.ietf.org/html/rfc4086#section-5.2
Where it mixes together several sources of weak and moderate strength
PRNG...

This:

http://barebonescms.com/documentation/csprng/

Takes a different approach. Generate one or more stored root seeds and then use those seeds to generate as much data as is needed without risking loss of entropy. It also accepts extra entropy sources as input - even weak sources such as an incrementing integer or serialized user-submitted data - to further enhance the output.

Adding more random sources of information to PHP is a good thing. If something like what is being discussed is developed, it will merely become one more source for root seed generation. The more the merrier. Good sources of entropy are hard to come by.

One thing I would like to recommend is add to the documentation that certain functions are inappropriate for specific use cases and recommend alternative solutions. A lot of people out there think rand() and mt_rand() are suitable for security. Maybe have a specific page in the PHP documentation dedicated to covering random string and number generation and link to that page from various function pages.

--
Thomas Hruska
CubicleSoft President

Barebones CMS is a high-performance, open source content management system for web developers operating in a team environment.

An open source CubicleSoft initiative.
Your choice of a MIT or LGPL license.

http://barebonescms.com/



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to