https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114357
Revision: 114357
Author: tstarling
Date: 2012-03-21 10:43:36 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
MFT r114354: MWCryptRand $method parameter removal
Modified Paths:
--------------
branches/REL1_17/phase3/includes/CryptRand.php
branches/REL1_17/phase3/includes/GlobalFunctions.php
branches/REL1_17/phase3/includes/User.php
branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
Property Changed:
----------------
branches/REL1_17/phase3/includes/GlobalFunctions.php
branches/REL1_17/phase3/includes/User.php
Modified: branches/REL1_17/phase3/includes/CryptRand.php
===================================================================
--- branches/REL1_17/phase3/includes/CryptRand.php 2012-03-21 10:43:22 UTC
(rev 114356)
+++ branches/REL1_17/phase3/includes/CryptRand.php 2012-03-21 10:43:36 UTC
(rev 114357)
@@ -256,17 +256,10 @@
/**
* @see self::generate()
*/
- public function realGenerate( $bytes, $forceStrong = false, $method =
null ) {
+ public function realGenerate( $bytes, $forceStrong = false ) {
wfProfileIn( __METHOD__ );
- if ( is_string( $forceStrong ) && is_null( $method ) ) {
- // If $forceStrong is a string then it's really $method
- $method = $forceStrong;
- $forceStrong = false;
- }
- if ( !is_null( $method ) ) {
- wfDebug( __METHOD__ . ": Generating cryptographic
random bytes for $method\n" );
- }
+ wfDebug( __METHOD__ . ": Generating cryptographic random bytes
for " . wfGetAllCallers( 5 ) . "\n" );
$bytes = floor( $bytes );
static $buffer = '';
@@ -285,7 +278,6 @@
if ( function_exists( 'mcrypt_create_iv' ) ) {
wfProfileIn( __METHOD__ . '-mcrypt' );
$rem = $bytes - strlen( $buffer );
- wfDebug( __METHOD__ . ": Trying to generate
$rem bytes of randomness using mcrypt_create_iv.\n" );
$iv = mcrypt_create_iv( $rem,
MCRYPT_DEV_URANDOM );
if ( $iv === false ) {
wfDebug( __METHOD__ . ":
mcrypt_create_iv returned false.\n" );
@@ -306,7 +298,6 @@
) {
wfProfileIn( __METHOD__ . '-openssl' );
$rem = $bytes - strlen( $buffer );
- wfDebug( __METHOD__ . ": Trying to generate
$rem bytes of randomness using openssl_random_pseudo_bytes.\n" );
$openssl_bytes = openssl_random_pseudo_bytes(
$rem, $openssl_strong );
if ( $openssl_bytes === false ) {
wfDebug( __METHOD__ . ":
openssl_random_pseudo_bytes returned false.\n" );
@@ -327,7 +318,6 @@
if ( strlen( $buffer ) < $bytes && ( function_exists(
'stream_set_read_buffer' ) || $forceStrong ) ) {
wfProfileIn( __METHOD__ . '-fopen-urandom' );
$rem = $bytes - strlen( $buffer );
- wfDebug( __METHOD__ . ": Trying to generate $rem bytes
of randomness using /dev/urandom.\n" );
if ( !function_exists( 'stream_set_read_buffer' ) &&
$forceStrong ) {
wfDebug( __METHOD__ . ": Was forced to read
from /dev/urandom without control over the buffer size.\n" );
}
@@ -351,7 +341,6 @@
stream_set_read_buffer( $urandom, $rem
);
$chunk_size = $rem;
}
- wfDebug( __METHOD__ . ": Reading from
/dev/urandom with a buffer size of $chunk_size.\n" );
$random_bytes = fread( $urandom, max(
$chunk_size, $rem ) );
$buffer .= $random_bytes;
fclose( $urandom );
@@ -399,13 +388,13 @@
/**
* @see self::generateHex()
*/
- public function realGenerateHex( $chars, $forceStrong = false, $method
= null ) {
+ public function realGenerateHex( $chars, $forceStrong = false ) {
// hex strings are 2x the length of raw binary so we divide the
length in half
// odd numbers will result in a .5 that leads the generate()
being 1 character
// short, so we use ceil() to ensure that we always have enough
bytes
$bytes = ceil( $chars / 2 );
// Generate the data and then convert it to a hex string
- $hex = bin2hex( $this->generate( $bytes, $forceStrong, $method
) );
+ $hex = bin2hex( $this->generate( $bytes, $forceStrong ) );
// A bit of paranoia here, the caller asked for a specific
length of string
// here, and it's possible (eg when given an odd number) that
we may actually
// have at least 1 char more than they asked for. Just in case
they made this
@@ -449,11 +438,10 @@
* @param $forceStrong bool Pass true if you want generate to prefer
cryptographically
* strong sources of entropy even if reading
from them may steal
* more entropy from the system than optimal.
- * @param $method The calling method, for debug info. May be the second
argument if you are not using forceStrong
* @return String Raw binary random data
*/
- public static function generate( $bytes, $forceStrong = false, $method
= null ) {
- return self::singleton()->realGenerate( $bytes, $forceStrong,
$method );
+ public static function generate( $bytes, $forceStrong = false ) {
+ return self::singleton()->realGenerate( $bytes, $forceStrong );
}
/**
@@ -466,11 +454,10 @@
* @param $forceStrong bool Pass true if you want generate to prefer
cryptographically
* strong sources of entropy even if reading
from them may steal
* more entropy from the system than optimal.
- * @param $method The calling method, for debug info. May be the second
argument if you are not using forceStrong
* @return String Hexadecimal random data
*/
- public static function generateHex( $chars, $forceStrong = false,
$method = null ) {
- return self::singleton()->realGenerateHex( $chars,
$forceStrong, $method );
+ public static function generateHex( $chars, $forceStrong = false ) {
+ return self::singleton()->realGenerateHex( $chars, $forceStrong
);
}
}
Modified: branches/REL1_17/phase3/includes/GlobalFunctions.php
===================================================================
--- branches/REL1_17/phase3/includes/GlobalFunctions.php 2012-03-21
10:43:22 UTC (rev 114356)
+++ branches/REL1_17/phase3/includes/GlobalFunctions.php 2012-03-21
10:43:36 UTC (rev 114357)
@@ -3060,7 +3060,7 @@
// If built-in entropy is not enabled or not sufficient override php's
built in session id generation code
if ( !$entropyEnabled ) {
wfDebug( __METHOD__ . ": PHP's built in entropy is disabled or
not sufficient, overriding session id generation using our cryptrand source.\n"
);
- session_id( MWCryptRand::generateHex( 32, __METHOD__ ) );
+ session_id( MWCryptRand::generateHex( 32 ) );
}
}
Property changes on: branches/REL1_17/phase3/includes/GlobalFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/GlobalFunctions.php:51646
/branches/new-installer/phase3/includes/GlobalFunctions.php:43664-66004
/branches/resourceloader/phase3/includes/GlobalFunctions.php:71750
/branches/sqlite/includes/GlobalFunctions.php:58211-58321
/branches/wmf-deployment/includes/GlobalFunctions.php:53381
/trunk/phase3/includes/GlobalFunctions.php:77988,78011-78012,78014-78016,78018,78043,78046,78071,78081,78083,78099,78117,78161,78170,78172,78199,78231,78248,78259,78300,78393,78450,78506-78507,78510-78511,78531-78532,78536,78539,78544,78565,78574,78660,78679,78774,78808,78823,78886-78887,78926,78943,78946,79013,79018-79019,79034,79056,79066,79072,79115,79122,79191,79213-79214,79253,79283,79537,79678,79684,79738,79741,79745,79750,79767-79768,82000,82004,82020,82025,82038-82039,82048,82070,82081,82083,82090-82091,82095-82096,82129,82155-82156,82181,82191,82200,82203,82215,82219,82221,82253,84060
+ /branches/REL1_15/phase3/includes/GlobalFunctions.php:51646
/branches/new-installer/phase3/includes/GlobalFunctions.php:43664-66004
/branches/resourceloader/phase3/includes/GlobalFunctions.php:71750
/branches/sqlite/includes/GlobalFunctions.php:58211-58321
/branches/wmf-deployment/includes/GlobalFunctions.php:53381
/trunk/phase3/includes/GlobalFunctions.php:77988,78011-78012,78014-78016,78018,78043,78046,78071,78081,78083,78099,78117,78161,78170,78172,78199,78231,78248,78259,78300,78393,78450,78506-78507,78510-78511,78531-78532,78536,78539,78544,78565,78574,78660,78679,78774,78808,78823,78886-78887,78926,78943,78946,79013,79018-79019,79034,79056,79066,79072,79115,79122,79191,79213-79214,79253,79283,79537,79678,79684,79738,79741,79745,79750,79767-79768,82000,82004,82020,82025,82038-82039,82048,82070,82081,82083,82090-82091,82095-82096,82129,82155-82156,82181,82191,82200,82203,82215,82219,82221,82253,84060,114354
Modified: branches/REL1_17/phase3/includes/User.php
===================================================================
--- branches/REL1_17/phase3/includes/User.php 2012-03-21 10:43:22 UTC (rev
114356)
+++ branches/REL1_17/phase3/includes/User.php 2012-03-21 10:43:36 UTC (rev
114357)
@@ -797,7 +797,7 @@
// Multiply by 1.25 to get the number of hex characters we need
$length = $length * 1.25;
// Generate random hex chars
- $hex = MWCryptRand::generateHex( $length, __METHOD__ );
+ $hex = MWCryptRand::generateHex( $length );
// Convert from base 16 to base 32 to get a proper password
like string
return wfBaseConvert( $hex, 16, 32 );
}
@@ -1863,7 +1863,7 @@
global $wgSecretKey, $wgProxyKey;
$this->load();
if ( !$token ) {
- $this->mToken = MWCryptRand::generateHex(
USER_TOKEN_LENGTH, __METHOD__ );
+ $this->mToken = MWCryptRand::generateHex(
USER_TOKEN_LENGTH );
} else {
$this->mToken = $token;
}
@@ -2886,7 +2886,7 @@
return EDIT_TOKEN_SUFFIX;
} else {
if( !isset( $_SESSION['wsEditToken'] ) ) {
- $token = MWCryptRand::generateHex( 32,
__METHOD__ );
+ $token = MWCryptRand::generateHex( 32 );
$_SESSION['wsEditToken'] = $token;
} else {
$token = $_SESSION['wsEditToken'];
@@ -2905,7 +2905,7 @@
* @return \string The new random token
*/
public static function generateToken( $salt = '' ) {
- return MWCryptRand::generateHex( 32, __METHOD__ );
+ return MWCryptRand::generateHex( 32 );
}
/**
@@ -3010,7 +3010,7 @@
$now = time();
$expires = $now + 7 * 24 * 60 * 60;
$expiration =
- $token = MWCryptRand::generateHex( 32, __METHOD__ );
+ $token = MWCryptRand::generateHex( 32 );
$hash = md5( $token );
$this->load();
$this->mEmailToken = $hash;
@@ -3564,7 +3564,7 @@
if( $wgPasswordSalt ) {
if ( $salt === false ) {
- $salt = MWCryptRand::generateHex( 8, __METHOD__
);
+ $salt = MWCryptRand::generateHex( 8 );
}
return ':B:' . $salt . ':' . md5( $salt . '-' . md5(
$password ) );
} else {
Property changes on: branches/REL1_17/phase3/includes/User.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/User.php:51646
/branches/new-installer/phase3/includes/User.php:43664-66004
/branches/sqlite/includes/User.php:58211-58321
/branches/wmf-deployment/includes/User.php:53381
/trunk/phase3/includes/User.php:81675,81729,81765,81778,81812,81827,81854,81890-81894,81896-81898,81900,81955
+ /branches/REL1_15/phase3/includes/User.php:51646
/branches/new-installer/phase3/includes/User.php:43664-66004
/branches/sqlite/includes/User.php:58211-58321
/branches/wmf-deployment/includes/User.php:53381
/trunk/phase3/includes/User.php:81675,81729,81765,81778,81812,81827,81854,81890-81894,81896-81898,81900,81955,114354
Modified: branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
===================================================================
--- branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
2012-03-21 10:43:22 UTC (rev 114356)
+++ branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
2012-03-21 10:43:36 UTC (rev 114357)
@@ -1101,7 +1101,7 @@
global $wgRequest;
// Generate a token directly instead of using $user->editToken()
// because the latter reuses $_SESSION['wsEditToken']
- $wgRequest->setSessionData( 'wsLoginToken',
MWCryptRand::generateHex( 32, __METHOD__ ) );
+ $wgRequest->setSessionData( 'wsLoginToken',
MWCryptRand::generateHex( 32 ) );
}
/**
@@ -1125,7 +1125,7 @@
*/
public static function setCreateaccountToken() {
global $wgRequest;
- $wgRequest->setSessionData( 'wsCreateaccountToken',
MWCryptRand::generateHex( 32, __METHOD__ ) );
+ $wgRequest->setSessionData( 'wsCreateaccountToken',
MWCryptRand::generateHex( 32 ) );
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs