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

Commit

Permalink
Changed the default cost of bcrypt to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Dec 5, 2013
1 parent 447b652 commit 666619c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion library/Zend/Crypt/Password/Bcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ class Bcrypt implements PasswordInterface

/**
* @var string
*
* Changed from 14 to 10 to prevent possibile DOS attacks
* due to the high computational time
* @see http://timoh6.github.io/2013/11/26/Aggressive-password-stretching.html
*/
protected $cost = '14';
protected $cost = '10';

/**
* @var string
Expand Down
4 changes: 2 additions & 2 deletions tests/ZendTest/Crypt/Password/BcryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setUp()
} else {
$this->prefix = '$2a$';
}
$this->bcryptPassword = $this->prefix . '14$MTIzNDU2Nzg5MDEyMzQ1NeWUUefVlefsTbFhsbqKFv/vPSZBrSFVm';
$this->bcryptPassword = $this->prefix . '10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y';
}

public function testConstructByOptions()
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testPasswordWith8bitCharacter()
$this->bcrypt->setSalt($this->salt);

if (version_compare(PHP_VERSION, '5.3.7') >= 0) {
$this->assertEquals('$2y$14$MTIzNDU2Nzg5MDEyMzQ1NexAbOIUHkG6Ra.TK9QxHOVUhDxOe4dkW',
$this->assertEquals('$2y$10$MTIzNDU2Nzg5MDEyMzQ1NemFdU/4JOrNpxMym09Mbp0m4hKTgfQo.',
$this->bcrypt->create($password));
} else {
$this->setExpectedException('Zend\Crypt\Password\Exception\RuntimeException',
Expand Down

0 comments on commit 666619c

Please sign in to comment.