-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible #34140
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
952a067
to
34a02ee
Compare
PR rebased on 4.3 |
34a02ee
to
2f673ca
Compare
…swords when possible
2f673ca
to
799a2ea
Compare
Thank you @nicolas-grekas. |
…alidate passwords when possible (nicolas-grekas) This PR was merged into the 4.3 branch. Discussion ---------- [Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - sodium implementations are always faster, let's use them when possible. This also allows validating argon2 passwords when bcrypt is configured as the main one, making migrations possible. Commits ------- 799a2ea [Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible
@@ -45,7 +45,7 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos | |||
throw new \InvalidArgumentException('$cost must be in the range of 4-31.'); | |||
} | |||
|
|||
$this->algo = \defined('PASSWORD_ARGON2I') ? max(PASSWORD_DEFAULT, \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : PASSWORD_ARGON2I) : PASSWORD_DEFAULT; | |||
$this->algo = \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : (\defined('PASSWORD_ARGON2I') ? PASSWORD_ARGON2I : PASSWORD_BCRYPT); |
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.
your plan initially was to always be at least as good as PASSWORD_DEFAULT
, even if PHP upgrades it. Is this plan gone ?
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.
yes, the plan is gone: in 7.4, PASSWORD_DEFAULT === null
and other PASSWORD_*
consts are strings; this makes it too difficult to maintain the plan.
sodium implementations are always faster, let's use them when possible. This also allows validating argon2 passwords when bcrypt is configured as the main one, making migrations possible.