summaryrefslogtreecommitdiffstats
path: root/Core/Encoder/Pbkdf2PasswordEncoder.php
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2013-10-10 15:12:30 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2013-10-10 15:12:30 +0200
commitb6d302f1f0f1235aa376c180dcd289f38b3df70e (patch)
tree676aa0d8ce931531f31494da3f65a2d8f12bb967 /Core/Encoder/Pbkdf2PasswordEncoder.php
parent5d889265454c4b094e894a14f0d9b4687fa644e1 (diff)
parent41cbe3694a5332d7e5bdb285c81bbfe23f31a220 (diff)
downloadsymfony-security-b6d302f1f0f1235aa376c180dcd289f38b3df70e.zip
symfony-security-b6d302f1f0f1235aa376c180dcd289f38b3df70e.tar.gz
symfony-security-b6d302f1f0f1235aa376c180dcd289f38b3df70e.tar.bz2
Merge branch '2.2' into 2.3v2.3.6
* 2.2: bumped Symfony version to 2.2.10 updated VERSION for 2.2.9 update CONTRIBUTORS for 2.2.9 updated CHANGELOG for 2.2.9 [Security] limited the password length passed to encoders assets:install command should mirror .dotfiles (.htaccess) PoFileDumper - PO headers removed whitespaces Conflicts: src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php
Diffstat (limited to 'Core/Encoder/Pbkdf2PasswordEncoder.php')
-rw-r--r--Core/Encoder/Pbkdf2PasswordEncoder.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/Core/Encoder/Pbkdf2PasswordEncoder.php b/Core/Encoder/Pbkdf2PasswordEncoder.php
index 4f37ba3..8a5a958 100644
--- a/Core/Encoder/Pbkdf2PasswordEncoder.php
+++ b/Core/Encoder/Pbkdf2PasswordEncoder.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\Security\Core\Encoder;
+use Symfony\Component\Security\Core\Exception\BadCredentialsException;
+
/**
* Pbkdf2PasswordEncoder uses the PBKDF2 (Password-Based Key Derivation Function 2).
*
@@ -54,6 +56,10 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder
*/
public function encodePassword($raw, $salt)
{
+ if ($this->isPasswordTooLong($raw)) {
+ throw new BadCredentialsException('Invalid password.');
+ }
+
if (!in_array($this->algorithm, hash_algos(), true)) {
throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm));
}
@@ -72,7 +78,7 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder
*/
public function isPasswordValid($encoded, $raw, $salt)
{
- return $this->comparePasswords($encoded, $this->encodePassword($raw, $salt));
+ return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt));
}
private function hashPbkdf2($algorithm, $password, $salt, $iterations, $length = 0)