aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/crypto/driver/base.php4
-rw-r--r--phpBB/includes/crypto/driver/salted_md5.php31
-rw-r--r--tests/crypto/manager_test.php2
3 files changed, 9 insertions, 28 deletions
diff --git a/phpBB/includes/crypto/driver/base.php b/phpBB/includes/crypto/driver/base.php
index c913767989..c134122174 100644
--- a/phpBB/includes/crypto/driver/base.php
+++ b/phpBB/includes/crypto/driver/base.php
@@ -23,6 +23,9 @@ abstract class phpbb_crypto_driver_base implements phpbb_crypto_driver_interface
/** @var phpbb_config */
protected $config;
+ /** @var phpbb_crypto_driver_helper */
+ protected $helper;
+
/**
* Constructor of crypto driver object
*
@@ -31,6 +34,7 @@ abstract class phpbb_crypto_driver_base implements phpbb_crypto_driver_interface
public function __construct(phpbb_config $config)
{
$this->config = $config;
+ $this->helper = new phpbb_crypto_driver_helper($this);
}
/**
diff --git a/phpBB/includes/crypto/driver/salted_md5.php b/phpBB/includes/crypto/driver/salted_md5.php
index 30b510b8dc..8e1c8a0d05 100644
--- a/phpBB/includes/crypto/driver/salted_md5.php
+++ b/phpBB/includes/crypto/driver/salted_md5.php
@@ -68,7 +68,7 @@ class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
while (--$settings['count']);
$output = $settings['full'];
- $output .= _hash_encode64($hash, 16, $this->itoa);
+ $output .= $this->helper->hash_encode64($hash, 16, $this->itoa);
if (strlen($output) == 34)
{
@@ -98,28 +98,6 @@ class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
}
/**
- * Return unique id
- * @param string $extra additional entropy
- */
- protected function unique_id($extra = 'c')
- {
- static $dss_seeded = false;
-
- $val = $this->config['rand_seed'] . microtime();
- $val = md5($val);
- $this->config['rand_seed'] = md5($this->config['rand_seed'] . $val . $extra);
-
- if ($dss_seeded !== true && ($this->config['rand_seed_last_update'] < time() - rand(1,10)))
- {
- set_config('rand_seed_last_update', time(), true);
- set_config('rand_seed', $this->config['rand_seed'], true);
- $dss_seeded = true;
- }
-
- return substr($val, 4, 16);
- }
-
- /**
* Generate salt for hashing method
*
* @return string Salt for hashing method
@@ -139,11 +117,11 @@ class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
if (strlen($random) < $count)
{
$random = '';
- $random_state = unique_id();
+ $random_state = $this->helper->unique_id();
for ($i = 0; $i < $count; $i += 16)
{
- $random_state = md5(unique_id() . $random_state);
+ $random_state = md5($this->helper->unique_id() . $random_state);
$random .= pack('H*', md5($random_state));
}
$random = substr($random, 0, $count);
@@ -151,8 +129,7 @@ class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
$salt = '$H$';
$salt .= $this->itoa[min($count + 5, 30)];
- $salt .= _hash_encode64($random, 6, $this->itoa);
- var_dump($salt);
+ $salt .= $this->helper->hash_encode64($random, 6, $this->itoa);
return $salt;
}
diff --git a/tests/crypto/manager_test.php b/tests/crypto/manager_test.php
index ce6ac1684f..b2f2862e5f 100644
--- a/tests/crypto/manager_test.php
+++ b/tests/crypto/manager_test.php
@@ -48,7 +48,7 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
array('', '2y', 60),
array('crypto.driver.bcrypt_2y', '2y', 60),
array('crypto.driver.bcrypt', '2a', 60),
- //array('crypto.driver.salted_md5', '$H$', 45),
+ array('crypto.driver.salted_md5', 'H', 34),
);
}