Fix multiple bugs in EncryptedPassword
authorTim Starling <tstarling@wikimedia.org>
Mon, 14 Nov 2016 10:04:30 +0000 (21:04 +1100)
committerTim Starling <tstarling@wikimedia.org>
Tue, 15 Nov 2016 04:15:24 +0000 (15:15 +1100)
commit6dbb8f2d787266078a803065c7483a8e7ca15d29
tree4101a2cac23843e1b3552c95b135578cbabf42ab
parent2cf145a4a332ea02e36e286afbb0f6b267ad3f37
Fix multiple bugs in EncryptedPassword

* openssl_decrypt() expects the encrypted string you give it to be the
  exact one that came out of openssl_encrypt(), it doesn't expect you to
  pre-decode the base64 encoding. So don't do that.
* Use the same IV when re-encrypting the underlying hash for comparison.
* Check the return value of OpenSSL functions, and report meaningful
  error messages, for sysadmin convenience and to avoid e.g. giving all
  users the same hash if an invalid cipher method was chosen (which was
  the previous behaviour).
* Fix EncryptedPassword::update(). Tested it with eval.php since there
  doesn't seem to be any callers.

Change-Id: I3a39de152d0329f93d16aa4ed43faf08f665b8e2
includes/password/EncryptedPassword.php