Skip to content

Commit 6eaec4f

Browse files
[Security/Core] cleanup Argon2-related code
1 parent 67af93f commit 6eaec4f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,14 @@ private function addEncodersSection(ArrayNodeDefinition $rootNode)
410410
->max(31)
411411
->defaultNull()
412412
->end()
413-
->scalarNode('memory_cost')->defaultNull()->end()
414-
->scalarNode('time_cost')->defaultNull()->end()
413+
->integerNode('memory_cost')
414+
->min(10 * 1024)
415+
->defaultNull()
416+
->end()
417+
->integerNode('time_cost')
418+
->min(3)
419+
->defaultNull()
420+
->end()
415421
->scalarNode('threads')
416422
->defaultNull()
417423
->setDeprecated('The "%path%.%node%" configuration key has no effect since Symfony 4.3 and will be removed in 5.0.')

src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
3333
$opsLimit = $opsLimit ?? max(6, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE : 6);
3434
$memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024);
3535

36-
if (2 > $opsLimit) {
37-
throw new \InvalidArgumentException('$opsLimit must be 2 or greater.');
36+
if (3 > $opsLimit) {
37+
throw new \InvalidArgumentException('$opsLimit must be 3 or greater.');
3838
}
3939

4040
if (10 * 1024 > $memLimit) {

src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function __construct(int $opsLimit = null, int $memLimit = null)
3737
$this->opsLimit = $opsLimit ?? max(6, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE : 6);
3838
$this->memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 2014);
3939

40-
if (2 > $this->opsLimit) {
41-
throw new \InvalidArgumentException('$opsLimit must be 2 or greater.');
40+
if (3 > $this->opsLimit) {
41+
throw new \InvalidArgumentException('$opsLimit must be 3 or greater.');
4242
}
4343

4444
if (10 * 1024 > $this->memLimit) {
@@ -48,10 +48,6 @@ public function __construct(int $opsLimit = null, int $memLimit = null)
4848

4949
public static function isSupported(): bool
5050
{
51-
if (class_exists('ParagonIE_Sodium_Compat') && method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) {
52-
return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available();
53-
}
54-
5551
return \function_exists('sodium_crypto_pwhash_str') || \extension_loaded('libsodium');
5652
}
5753

0 commit comments

Comments
 (0)