Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Added a benchmark for the bcrypt cost parameter + fixed a unit test #26

Merged
merged 3 commits into from
May 9, 2016

Conversation

ezimuel
Copy link
Contributor

@ezimuel ezimuel commented May 6, 2016

This PR adds a benchmark function in Zend\Crypt\Password\Bcrypt to test the cost parameter on a time to target. This function can be used to choose the bcrypt cost parameter to use in your environment.

The default time to target is 0.05 seconds (50 milliseconds) that is which is a good baseline for systems handling interactive logins. On my environment: CPU Intel i5-2500 at 3.30GHz, 8 GB RAM, the result of the benchmark is cost 10 (the default value of Zend\Crypt\Password\Bcrypt and PHP).

Note: this function uses the same code reported in example 4 of password_hash() in the PHP online manual.

@ezimuel ezimuel added this to the 3.0.0 milestone May 6, 2016
@@ -44,6 +45,9 @@ public function testHas($symmetric)
public function testGet($symmetric)
{
$plugin = new SymmetricPluginManager();
if (! extension_loaded($symmetric)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extension_loaded check can be placed before new SymmetricPluginManager creation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsonasik why? The symmetric plugins are loaded only on the get() execution, not in the constructor of SymmetricPluginManager.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip the instantiation step if extension not loaded, and set expected exception, because in next line, the extension used in the tests.

Warm regards,

Abdul Malik Ikhsan

Pada 6 Mei 2016, pukul 15.44, Enrico Zimuel [email protected] menulis:

In test/SymmetricPluginManagerTest.php:

@@ -44,6 +45,9 @@ public function testHas($symmetric)
public function testGet($symmetric)
{
$plugin = new SymmetricPluginManager();

  •    if (! extension_loaded($symmetric)) {
    
    @samsonasik why? The symmetric plugins are loaded only on the get() execution, not in the constructor of SymmetricPluginManager.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsonasik ok, I will move it, not a big difference anyway.

@ezimuel
Copy link
Contributor Author

ezimuel commented May 6, 2016

@weierophinney this PR is ready for review, thanks!

@weierophinney weierophinney merged commit 7fe88ff into zendframework:develop May 9, 2016
weierophinney added a commit that referenced this pull request May 9, 2016
Added a benchmark for the bcrypt cost parameter + fixed a unit test
weierophinney added a commit that referenced this pull request May 9, 2016
weierophinney added a commit that referenced this pull request May 9, 2016
@weierophinney weierophinney self-assigned this May 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants