MediaWiki
master
|
Public Member Functions | |
realGenerate ($bytes, $forceStrong=false) | |
realGenerateHex ($chars, $forceStrong=false) | |
realWasStrong () | |
Static Public Member Functions | |
static | generate ($bytes, $forceStrong=false) |
Generate a run of (ideally) cryptographically random data and return it in raw binary form. More... | |
static | generateHex ($chars, $forceStrong=false) |
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format. More... | |
static | wasStrong () |
Return a boolean indicating whether or not the source used for cryptographic random bytes generation in the previously run generate* call was cryptographically strong. More... | |
Public Attributes | |
const | MIN_ITERATIONS = 1000 |
Minimum number of iterations we want to make in our drift calculations. More... | |
const | MSEC_PER_BYTE = 0.5 |
Number of milliseconds we want to spend generating each separate byte of the final generated bytes. More... | |
Protected Member Functions | |
driftHash ($data) | |
Randomly hash data while mixing in clock drift data for randomness. More... | |
initialRandomState () | |
Initialize an initial random state based off of whatever we can find. More... | |
randomState () | |
Return a rolling random state initially build using data from unstable sources. More... | |
Static Protected Member Functions | |
static | singleton () |
Publicly exposed static methods. More... | |
Protected Attributes | |
$strong = null | |
A boolean indicating whether the previous random generation was done using cryptographically strong random number generator or not. More... | |
Static Protected Attributes | |
static | $singleton = null |
Singleton instance for public use. More... | |
Definition at line 27 of file MWCryptRand.php.
|
protected |
Randomly hash data while mixing in clock drift data for randomness.
string | $data | The data to randomly hash. |
Definition at line 145 of file MWCryptRand.php.
References $buffer, MWCryptHash\hash(), MWCryptHash\hashLength(), and wfDebug().
Referenced by randomState().
|
static |
Generate a run of (ideally) cryptographically random data and return it in raw binary form.
You can use MWCryptRand::wasStrong() if you wish to know if the source used was cryptographically strong.
int | $bytes | The number of bytes of random data to generate |
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. |
Definition at line 403 of file MWCryptRand.php.
Referenced by EncryptedPassword\crypt(), Pbkdf2Password\crypt(), BcryptPassword\crypt(), MWCryptHKDF\getSaltUsingCache(), realGenerateHex(), MediaWiki\Session\Session\setSecret(), MediaWiki\Session\SessionTest\testSecrets(), and EncryptedPassword\update().
|
static |
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
You can use MWCryptRand::wasStrong() if you wish to know if the source used was cryptographically strong.
int | $chars | The number of hex chars of random data to generate |
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. |
Definition at line 419 of file MWCryptRand.php.
Referenced by UIDGenerator\__construct(), User\confirmationToken(), MWSaltedPassword\crypt(), Installer\doGenerateKeys(), PasswordFactory\generateRandomPasswordString(), MediaWiki\Session\SessionManager\generateSessionId(), Pingback\getOrCreatePingbackId(), MediaWiki\Session\Session\getSecretKeys(), MediaWiki\Session\Session\getToken(), User\getToken(), AuthManagerSpecialPage\handleReauthBeforeExecute(), UIDGenerator\newUUIDv4(), User\resetTokenFromOption(), BotPassword\save(), User\setToken(), and ApiRevisionDeleteTest\setUp().
|
protected |
Initialize an initial random state based off of whatever we can find.
Definition at line 56 of file MWCryptRand.php.
References $files, $path, $wgSecretKey, as, global, serialize(), wfHostname(), and wfWikiID().
Referenced by randomState().
|
protected |
Return a rolling random state initially build using data from unstable sources.
Definition at line 191 of file MWCryptRand.php.
References driftHash(), MWCryptHash\hash(), and initialRandomState().
Referenced by realGenerate().
MWCryptRand::realGenerate | ( | $bytes, | |
$forceStrong = false |
|||
) |
Definition at line 220 of file MWCryptRand.php.
References $buffer, MWCryptHash\hmac(), randomState(), wfDebug(), and wfGetAllCallers().
MWCryptRand::realGenerateHex | ( | $chars, | |
$forceStrong = false |
|||
) |
MWCryptRand::realWasStrong | ( | ) |
|
staticprotected |
Publicly exposed static methods.
Return a singleton instance of MWCryptRand
Definition at line 372 of file MWCryptRand.php.
|
static |
Return a boolean indicating whether or not the source used for cryptographic random bytes generation in the previously run generate* call was cryptographically strong.
Definition at line 387 of file MWCryptRand.php.
Referenced by Installer\doGenerateKeys().
|
staticprotected |
Singleton instance for public use.
Definition at line 44 of file MWCryptRand.php.
|
protected |
A boolean indicating whether the previous random generation was done using cryptographically strong random number generator or not.
Definition at line 50 of file MWCryptRand.php.
Referenced by realWasStrong().
const MWCryptRand::MIN_ITERATIONS = 1000 |
Minimum number of iterations we want to make in our drift calculations.
Definition at line 31 of file MWCryptRand.php.
const MWCryptRand::MSEC_PER_BYTE = 0.5 |
Number of milliseconds we want to spend generating each separate byte of the final generated bytes.
This is used in combination with the hash length to determine the duration we should spend doing drift calculations.
Definition at line 39 of file MWCryptRand.php.