rasmus Fri, 08 Jan 2010 09:43:14 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293253
Log: Worked with Samy Kamkar to improve LCG entropy. Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/standard/lcg.c U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/standard/lcg.c U php/php-src/trunk/ext/standard/lcg.c Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2010-01-08 09:32:23 UTC (rev 293252) +++ php/php-src/branches/PHP_5_2/NEWS 2010-01-08 09:43:14 UTC (rev 293253) @@ -11,6 +11,8 @@ - Fixed build of mysqli with MySQL 5.5.0-m2. (Andrey) +- Improved LCG entropy (Rasmus, Samy Kamkar) + - Fixed bug #50680 (strtotime() does not support eighth ordinal number). (Ilia) - Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16). (Rob) Modified: php/php-src/branches/PHP_5_2/ext/standard/lcg.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/standard/lcg.c 2010-01-08 09:32:23 UTC (rev 293252) +++ php/php-src/branches/PHP_5_2/ext/standard/lcg.c 2010-01-08 09:43:14 UTC (rev 293253) @@ -78,7 +78,7 @@ struct timeval tv; if (gettimeofday(&tv, NULL) == 0) { - LCG(s1) = tv.tv_sec ^ (~tv.tv_usec); + LCG(s1) = tv.tv_sec ^ (tv.tv_usec<<11); } else { LCG(s1) = 1; } @@ -88,6 +88,11 @@ LCG(s2) = (long) getpid(); #endif + /* Add entropy to s2 by calling gettimeofday() again */ + if (gettimeofday(&tv, NULL) == 0) { + LCG(s2) ^= (tv.tv_usec<<11); + } + LCG(seeded) = 1; } Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-01-08 09:32:23 UTC (rev 293252) +++ php/php-src/branches/PHP_5_3/NEWS 2010-01-08 09:43:14 UTC (rev 293253) @@ -7,6 +7,7 @@ - Added missing host validation for HTTP urls inside FILTER_VALIDATE_URL. (Ilia) - Added stream_resolve_include_path(). (Mikko) +- Improved LCG entropy (Rasmus, Samy Kamkar) - Fixed bug #50680 (strtotime() does not support eighth ordinal number). (Ilia) Modified: php/php-src/branches/PHP_5_3/ext/standard/lcg.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/lcg.c 2010-01-08 09:32:23 UTC (rev 293252) +++ php/php-src/branches/PHP_5_3/ext/standard/lcg.c 2010-01-08 09:43:14 UTC (rev 293253) @@ -78,7 +78,7 @@ struct timeval tv; if (gettimeofday(&tv, NULL) == 0) { - LCG(s1) = tv.tv_sec ^ (~tv.tv_usec); + LCG(s1) = tv.tv_sec ^ (tv.tv_usec<<11); } else { LCG(s1) = 1; } @@ -88,6 +88,11 @@ LCG(s2) = (long) getpid(); #endif + /* Add entropy to s2 by calling gettimeofday() again */ + if (gettimeofday(&tv, NULL) == 0) { + LCG(s2) ^= (tv.tv_usec<<11); + } + LCG(seeded) = 1; } /* }}} */ Modified: php/php-src/trunk/ext/standard/lcg.c =================================================================== --- php/php-src/trunk/ext/standard/lcg.c 2010-01-08 09:32:23 UTC (rev 293252) +++ php/php-src/trunk/ext/standard/lcg.c 2010-01-08 09:43:14 UTC (rev 293253) @@ -78,7 +78,7 @@ struct timeval tv; if (gettimeofday(&tv, NULL) == 0) { - LCG(s1) = tv.tv_sec ^ (~tv.tv_usec); + LCG(s1) = tv.tv_sec ^ (tv.tv_usec<<11); } else { LCG(s1) = 1; } @@ -88,6 +88,11 @@ LCG(s2) = (long) getpid(); #endif + /* Add entropy to s2 by calling gettimeofday() again */ + if (gettimeofday(&tv, NULL) == 0) { + LCG(s2) ^= (tv.tv_usec<<11); + } + LCG(seeded) = 1; } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php