Skip to content

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

Closed
iwanluijks wants to merge 2 commits intophp:masterfrom
iwanluijks:php-session-create-id-arc4random
Closed

arc4random_buf on OpenBSD for random bytes instead of opening /dev/arandom#1769
iwanluijks wants to merge 2 commits intophp:masterfrom
iwanluijks:php-session-create-id-arc4random

Conversation

@iwanluijks
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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