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

Get the right order of salts generation #11

Open
sebastiaandegeus opened this issue Nov 15, 2016 · 3 comments
Open

Get the right order of salts generation #11

sebastiaandegeus opened this issue Nov 15, 2016 · 3 comments

Comments

@sebastiaandegeus
Copy link
Owner

sebastiaandegeus commented Nov 15, 2016

  • random_int() php7 function
  • wp salts api 1.1
  • generate_password()

See:
wordpress/wp-admin/setup-config.php
https://github.com/szepeviktor/wordpress-plugin-construction/blob/master/wp-safe-salt.php

@szepeviktor
Copy link

szepeviktor commented Nov 15, 2016

password_generate function

Did you mean wp_generate_password()?

BTW My function uses openssl_random_pseudo_bytes()

WP core: https://github.com/WordPress/WordPress/blob/master/wp-admin/setup-config.php#L285-L314

@sebastiaandegeus
Copy link
Owner Author

Yes sorry, that's what I meant.

In my opinion we should stick to the official WordPress code for generating any random string for salts. Unfortunately they haven't put this code into easily usable functions or a class or even a library so that makes it a bit more difficult to use.

See:
https://github.com/WordPress/WordPress/blob/master/wp-admin/setup-config.php#L285

It's a bit of a mess. It's in the middle of a script that outputs a bunch of stuff.
I'm not looking forward to duplicating that code and then be responsible for updating it when it changes in the WordPress core.

There is also this inside the WordPress core:
https://github.com/WordPress/WordPress/blob/dd6da701b286579819cd6aa518aa2d7018efd759/wp-includes/random_compat/random.php
That add backwards compatibility for php5.

The function you use is considered last resort:
"openssl_random_pseudo_bytes() (absolute last resort)"
https://github.com/WordPress/WordPress/blob/dd6da701b286579819cd6aa518aa2d7018efd759/wp-includes/random_compat/random.php#L68

I assume the 1.1 Salts API uses the best method for generating these random strings. So that would still be the safest and best way of generating the salts until the core developers decide to put that random_int code into something reusable.

@szepeviktor
Copy link

You may open a core ticket to move that piece of code into a function.

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

No branches or pull requests

2 participants