Skip to content
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

Make Util/KeyAlgorithm/DefaultAlgorithm guarantee $len bytes of output even in edge cases. #273

Merged
merged 1 commit into from Dec 9, 2014

Conversation

sarciszewski
Copy link
Contributor

Prevent edge-case whereby, if the majority of base64_encode($bytes) consists of / or + characters, the resulting key will be shorter and less unpredictable (due to a smaller keyspace) than anticipated.

As a result, the $len * 2 hack has been removed. Although it is highly probable that $len * 2 will stop most edge cases from occurring, it does not actually guarantee the end result will be at least 40 characters long.

Prevent edge-case whereby, if the majority of `base64_encode($bytes)` consists of `/` or `+` characters, the resulting key will be shorter and less unpredictable (due to a smaller keyspace) than anticipated.

As a result, the `$len * 2` hack has been removed. Although it is highly probable that `$len * 2` will stop most edge cases from occurring, it does not actually guarantee the end result will be at least 40 characters long.
@alexbilbie
Copy link
Contributor

Nice spot, thanks!

alexbilbie added a commit that referenced this pull request Dec 9, 2014
Make Util/KeyAlgorithm/DefaultAlgorithm guarantee $len bytes of output even in edge cases.
@alexbilbie alexbilbie merged commit 0ce7ecb into thephpleague:master Dec 9, 2014
@sarciszewski sarciszewski deleted the patch-1 branch December 9, 2014 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants