-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Made optimization on constant-time algorithm removing modulus operator #11574
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
Why is it labelled as |
// Extend strings to avoid uninitialized string offsets | ||
$tmp = $knownString; | ||
$knownString .= $userInput; | ||
$userInput .= $tmp; |
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.
this line is not needed, given we iterate over the user input length, so we will never go further (there is no modulus operator applied when accessing the userInput char in the current implementation either)
👍 |
1 similar comment
👍 |
Thank you @yosmanyga. |
…removing modulus operator (yosmanyga) This PR was merged into the 2.3 branch. Discussion ---------- [Security] Made optimization on constant-time algorithm removing modulus operator | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This fix improves the constant-time algorithm used to compare strings, as it removes the `%` operator inside the loop. Commits ------- 000bd0d Made optimization deprecating modulus operator
$knownLen = strlen($knownString); | ||
$userLen = strlen($userInput); | ||
|
||
// Extend know string to avoid uninitialized string offsets |
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.
typo
This fix improves the constant-time algorithm used to compare strings, as it removes the
%
operator inside the loop.