From 8d590fac31d5b37b892ea76852da029bb01cdbed Mon Sep 17 00:00:00 2001 From: Ben Davis Date: Mon, 18 Jul 2016 14:26:07 -0500 Subject: [PATCH] Fix for "Invalid key type: integer" MWCryptHash::hmac requires a string, but mt_rand() returns an integer. This issue resulted in an uncaught exception in a fresh installation of mediawiki. Imported from https://github.com/wikimedia/mediawiki/pull/55 Change-Id: Idccf5f230bfc2de30357b03c78c51cdad4839515 --- includes/utils/MWCryptRand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils/MWCryptRand.php b/includes/utils/MWCryptRand.php index f3d72e834e..dd3ea1b87e 100644 --- a/includes/utils/MWCryptRand.php +++ b/includes/utils/MWCryptRand.php @@ -324,7 +324,7 @@ class MWCryptRand { ": Falling back to using a pseudo random state to generate randomness.\n" ); } while ( strlen( $buffer ) < $bytes ) { - $buffer .= MWCryptHash::hmac( $this->randomState(), mt_rand() ); + $buffer .= MWCryptHash::hmac( $this->randomState(), strval( mt_rand() ) ); // This code is never really cryptographically strong, if we use it // at all, then set strong to false. $this->strong = false; -- 2.20.1