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

add OpenSSL warning exception and config const, #51 #52

Closed
wants to merge 30 commits into from
Closed

add OpenSSL warning exception and config const, #51 #52

wants to merge 30 commits into from

Conversation

tom--
Copy link

@tom-- tom-- commented Oct 14, 2015

See Issue #5 and also hte discussion in #51

This branch isn't ready to merge but I needed to ask something before going on.

After writing this I found I'm not really happy with using a config const. It introduces the hazard of authoring code without knowing the value (easy mistake). It's hard to test (consts are set in PHPunit config). It's another global. And above all, it removes the caller's choice in the matter. For example, say you were writing a lib that uses some crypto that's just stupid without real randomness. The best you can do is test the const (if you remember to) and fail if it's true. Meanwhile, somewhere else in the project I might prefer OpenSSL's RNG over this. So I'm not sure the choice should be a global policy.

The options I can imagine at present

  1. const, as in this PR
  2. 2nd argument, e.g. string random_bytes ( int $length [, bool $allowOpenSsl = false ] )
  3. additional functions, e.g. string random_bytes_risky ( int $length )
  4. nothing and mention openssl_random_pseudo_bytes( $length, true ) in the exception doc

All horrible but I like 1. and 3. least. 4. is ok. 2. is probably best. But I don't have strong opinion and defer to others. Let me know what you like and I will proceed with this work.

paragonie-scott and others added 30 commits October 2, 2015 18:16
Remove redundant if statement
Use extension_loaded() instead of checking that a function exists.
Use libsodium for random bytes if it's available
Relax open_basedir restriction
@paragonie-scott paragonie-scott force-pushed the master branch 2 times, most recently from 667f430 to 99e9e83 Compare October 15, 2015 18:20
@tom-- tom-- closed this Oct 15, 2015
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.

6 participants