diff options
Diffstat (limited to 'includes/CryptRand.php')
-rw-r--r-- | includes/CryptRand.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/includes/CryptRand.php b/includes/CryptRand.php index 858eebf2..d0305d8b 100644 --- a/includes/CryptRand.php +++ b/includes/CryptRand.php @@ -79,7 +79,7 @@ class MWCryptRand { // Include some information about the filesystem's current state in the random state $files = array(); - // We know this file is here so grab some info about ourself + // We know this file is here so grab some info about ourselves $files[] = __FILE__; // We must also have a parent folder, and with the usual file structure, a grandparent @@ -106,7 +106,11 @@ class MWCryptRand { } } // The absolute filename itself will differ from install to install so don't leave it out - $state .= realpath( $file ); + if( ( $path = realpath( $file ) ) !== false ) { + $state .= $path; + } else { + $state .= $file; + } $state .= implode( '', $stat ); } else { // The fact that the file isn't there is worth at least a @@ -144,7 +148,7 @@ class MWCryptRand { /** * Randomly hash data while mixing in clock drift data for randomness * - * @param $data string The data to randomly hash. + * @param string $data The data to randomly hash. * @return String The hashed bytes * @author Tim Starling */ @@ -158,7 +162,7 @@ class MWCryptRand { $buffer = str_repeat( ' ', $bufLength ); $bufPos = 0; - // Iterate for $duration seconds or at least $minIerations number of iterations + // Iterate for $duration seconds or at least $minIterations number of iterations $iterations = 0; $startTime = microtime( true ); $currentTime = $startTime; @@ -391,7 +395,7 @@ class MWCryptRand { // We hash the random state with more salt to avoid the state from leaking // out and being used to predict the /randomness/ that follows. if ( strlen( $buffer ) < $bytes ) { - wfDebug( __METHOD__ . ": Falling back to using a pseudo random state to generate randomness.\n" ); + wfDebug( __METHOD__ . ": Falling back to using a pseudo random state to generate randomness.\n" ); } while ( strlen( $buffer ) < $bytes ) { wfProfileIn( __METHOD__ . '-fallback' ); @@ -464,8 +468,8 @@ class MWCryptRand { * You can use MWCryptRand::wasStrong() if you wish to know if the source used * was cryptographically strong. * - * @param $bytes int the number of bytes of random data to generate - * @param $forceStrong bool Pass true if you want generate to prefer cryptographically + * @param int $bytes the number of bytes of random data to generate + * @param bool $forceStrong 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. * @return String Raw binary random data @@ -480,8 +484,8 @@ class MWCryptRand { * You can use MWCryptRand::wasStrong() if you wish to know if the source used * was cryptographically strong. * - * @param $chars int the number of hex chars of random data to generate - * @param $forceStrong bool Pass true if you want generate to prefer cryptographically + * @param int $chars the number of hex chars of random data to generate + * @param bool $forceStrong 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. * @return String Hexadecimal random data |