From 2d7593995ee888da709e21051c4566b3740ef7f2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 16:32:48 +0200 Subject: [ticket/12352] Add driver for woltlab community framework 2 passwords PHPBB3-12352 --- phpBB/phpbb/passwords/driver/bcrypt_wcf2.php | 91 ++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 phpBB/phpbb/passwords/driver/bcrypt_wcf2.php (limited to 'phpBB/phpbb/passwords') diff --git a/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php b/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php new file mode 100644 index 0000000000..636fe74789 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php @@ -0,0 +1,91 @@ +bcrypt = $bcrypt; + $this->helper = $helper; + } + + /** + * @inheritdoc + */ + public function get_prefix() + { + return self::PREFIX; + } + + /** + * @inheritdoc + */ + public function is_legacy() + { + return true; + } + + /** + * @inheritdoc + */ + public function hash($password, $user_row = '') + { + // Do not support hashing + return false; + } + + /** + * @inheritdoc + */ + public function check($password, $hash, $user_row = array()) + { + if (empty($hash)) + { + return false; + } + else + { + $salt = substr($hash, 0, 29); + + if (strlen($salt) != 29) + { + return false; + } + // Works for standard WCF 2.x, i.e. WBB4 and similar + return $hash === $this->bcrypt->hash($this->bcrypt->hash($password, $salt), $salt); + } + } + + /** + * @inheritdoc + */ + public function get_settings_only($hash, $full = false) + { + return false; + } +} -- cgit v1.2.1