Skip to content

arc4random_buf on OpenBSD for random bytes instead of opening /dev/arandom #1769

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

Closed
wants to merge 2 commits into from
Closed

arc4random_buf on OpenBSD for random bytes instead of opening /dev/arandom #1769

wants to merge 2 commits into from

Conversation

iwanluijks
Copy link

In the php_session_create_id function a file descriptor is opened to the configured session.entropy_file by default, on non-Windows OSs and OSs that don't have an entropy_file available at compile time.
This is effectively described in the comments above session.entropy_file:

; On systems that don't have /dev/urandom but do have /dev/arandom, this will default to /dev/arandom
; If neither are found at compile time, the default is no entropy file.
; On windows, setting the entropy_length setting will activate the
; Windows random source (using the CryptoAPI)

In OpenBSD however, there is no need for this, as the arc4random functions are available as a fast random source, generating high quality pseudo-random number streams.
This eliminates the usage of a file descriptor on these systems.

The idea herein is to extend the comments with an extra line:

; On OpenBSD, setting the entropy_length setting will use arc4random instead

…n unnecessary file descriptor for randomization.
@weltling
Copy link
Contributor

Could you please rewrite this patch using php_random_bytes() which is available since 7.0 and already takes care about these platform details?

Thanks.

@iwanluijks
Copy link
Author

Great suggestion, that also cleans up the ugly mess of code in the php_create_session_id. I'll get back with a pull request when it is ready.

@jpauli
Copy link
Member

jpauli commented Jul 11, 2016

Thank you for resubmitting a PR according to what has been said.
Closing now

@jpauli jpauli closed this Jul 11, 2016
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.

3 participants