Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Security] Add configuration for Argon2i encryption#26175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Security] Add configuration for Argon2i encryption#26175
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
thanks for working on this
would you mind adding some tests please?
| /** | ||
| * Argon2iPasswordEncoder constructor. | ||
| * | ||
| * @param int $memoryCost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
since this is for PHP 7.1, you can move the types to the constructor's signature, and remove the docblock altogether.
| { | ||
| if (\defined('PASSWORD_ARGON2I')) { | ||
| $this->config =array( | ||
| 'memory_cost' =>$memoryCost ?:PASSWORD_ARGON2_DEFAULT_MEMORY_COST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
?? instead of ?: (same below)
CoalaJoe commentedFeb 14, 2018
@nicolas-grekas Ready for next review. |
nicolas-grekas commentedFeb 14, 2018
SecurityBundle also needs an update, so that you can configure these settings using yaml. |
| $this->config =array( | ||
| 'memory_cost' =>$memoryCost ??PASSWORD_ARGON2_DEFAULT_MEMORY_COST, | ||
| 'time_cost' =>$timeCost ??PASSWORD_ARGON2_DEFAULT_TIME_COST, | ||
| 'threads' =>$threads ??PASSWORD_ARGON2_DEFAULT_THREADS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
we could fully-qualify these constants though (as we do inencodePasswordNative)
stof commentedFeb 14, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
is it possible to support this config when using ext-sodium on older versions too ? |
CoalaJoe commentedFeb 15, 2018
@stof There are I can't say how these 2 parameters are related to |
| ->max(31) | ||
| ->defaultValue(13) | ||
| ->end() | ||
| ->integerNode('memory_cost')->setDefaultValue(1024)->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
defaultNull instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You are right. Fixed it.
CoalaJoe commentedFeb 15, 2018
|
chalasr left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should it throw when configuring these options while they aren't supported?
| publicfunction__construct(int$memoryCost =null,int$timeCost =null,int$threads =null) | ||
| { | ||
| if (\defined('PASSWORD_ARGON2I')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
these options are used in encodePasswordNative only which is restricted to php 7.2+, we should probably have the same check here
| */ | ||
| class Argon2iPasswordEncoderextends BasePasswordEncoderimplements SelfSaltingEncoderInterface | ||
| { | ||
| private$config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the default value should bearray(), otherwisepassword_hash($raw, \PASSWORD_ARGON2I, $this->config); will throw a warning
this should cover@chalasr's comment below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks. Done.
nicolas-grekas commentedFeb 19, 2018
almost there, tests should be updated (see failures) |
CoalaJoe commentedFeb 20, 2018
@nicolas-grekas The tests should now run successfully. But the runners fail on installing the libsodium extension. Do you know why? |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
failures related to pecl.php.net being down today
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
oups sorry I voted too fast: the test suite should still pass when the libsodium is not installed, by skipping the cases that require the extension
nicolas-grekas commentedFeb 20, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I suppose you'll need to split the new functional tests in dedicated test methods, and add them the |
fabpot commentedFeb 20, 2018
Thank you@CoalaJoe. |
…oalaJoe)This PR was merged into the 4.1-dev branch.Discussion----------[Security] Add configuration for Argon2i encryption| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#26174| License | MIT| Doc PR | [#9300](symfony/symfony-docs#9300)Feedback?Current situation: Configuration only applies if argon2i is natively supported.Commits-------1300fec [Security] Add configuration for Argon2i encryption
This PR was merged into the master branch.Discussion----------Update configuration for argon2i encoderFrom:symfony/symfony#26175Commits-------a3e9bf2 Update configuration for argon2i encoder
Uh oh!
There was an error while loading.Please reload this page.
Feedback?
Current situation: Configuration only applies if argon2i is natively supported.