summaryrefslogtreecommitdiffstats
path: root/Core/Encoder/Pbkdf2PasswordEncoder.php
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2013-10-10 08:30:51 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2013-10-10 14:05:52 +0200
commit41cbe3694a5332d7e5bdb285c81bbfe23f31a220 (patch)
tree48b09420b041421ce1ee3e35d21d98ab11e7d793 /Core/Encoder/Pbkdf2PasswordEncoder.php
parente3a08775fbfb1062167a56e3c5f606b3300d40a8 (diff)
downloadsymfony-security-41cbe3694a5332d7e5bdb285c81bbfe23f31a220.zip
symfony-security-41cbe3694a5332d7e5bdb285c81bbfe23f31a220.tar.gz
symfony-security-41cbe3694a5332d7e5bdb285c81bbfe23f31a220.tar.bz2
[Security] limited the password length passed to encodersv2.2.9
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 656545f..511a161 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)