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

Not installable without ARGON2 support #122

Closed
bendavies opened this issue Feb 12, 2021 · 14 comments
Closed

Not installable without ARGON2 support #122

bendavies opened this issue Feb 12, 2021 · 14 comments
Assignees
Labels
Type: Enhancement Most issues will probably ask for additions or changes.

Comments

@bendavies
Copy link

Is your feature request related to a problem? Please describe.
Hi there,

This library is not install-able unless argon2 support has been compiled into php.

Otherwise, we will receive:

PHP Fatal error:  Uncaught Error: Undefined constant 'PASSWORD_ARGON2I'

Describe the solution you'd like
Would you be open to conditionally supporting the argon2 password hashing, only if argon 2 support is available?

I want to use the iter/arr methods of this library - i don't really care about not having argon2 support.

Describe alternatives you've considered
compile in argon2 support before requiring psl.

@bendavies bendavies added the Type: Enhancement Most issues will probably ask for additions or changes. label Feb 12, 2021
@azjezz
Copy link
Owner

azjezz commented Feb 12, 2021

Hm, i thought ext-sodium ( which is required by this library ) + php >= 7.4 would mean argon is enabled by default ( https://wiki.php.net/rfc/sodium.argon.hash ) 🤔

what method did you use to install PHP? are you building it yourself?

@bendavies
Copy link
Author

bendavies commented Feb 12, 2021

it doesn't come with sodium, no.
php needs to be compiled with --with-password-argon2 which i'm doing with https://phpbrew.github.io/phpbrew/

@bendavies
Copy link
Author

i've recompiled anyway, so feel free to close.
but it may be nice to handle this failure a bit more nicely than a fatal

@azjezz
Copy link
Owner

azjezz commented Feb 16, 2021

This definitely needs to be handled in a nicer way, i will leave it open until i figure out how to do so.

However, the official PHP build should contain support for argon2 if it contains sodium extension, so this is probably an issue that only people compiling their own PHP binaries will face.

@rauanmayemir
Copy link

This is hitting me on CI and re/building PHP is not something I would want to do unless I really need argon2.

@azjezz
Copy link
Owner

azjezz commented Apr 22, 2021

i will try finding a fix later this week, as for now, PRs are welcome :)

@weirdan
Copy link
Contributor

weirdan commented May 4, 2021

However, the official PHP build should contain support for argon2

Is that a thing though? I thought PHP project did not provide any builds whatsoever apart from their Windows builds. And distro builds can vary a lot.

@azjezz
Copy link
Owner

azjezz commented May 4, 2021

thought PHP project did not provide any builds whatsoever apart from their Windows builds.

no, you can find tarballs here: https://www.php.net/downloads

tho, i personally build my own binaries but with all almost all options enabled.

@weirdan
Copy link
Contributor

weirdan commented May 4, 2021

no, you can find tarballs

Tarballs are not builds, so that actually a 'yes' 😉

@azjezz
Copy link
Owner

azjezz commented May 4, 2021

ah, yea.

but i still can't figure out how people compile PHP with ext-sodium ( which is required in composer.json ), but without argon2, since PHP 7.4, ext-sodium provides a fallback mechanism for argon2 when PHP is compiled without libargon ( RFC: https://wiki.php.net/rfc/sodium.argon.hash )

@azjezz
Copy link
Owner

azjezz commented May 4, 2021

okay, it seems PHP does this only with libsodium newer than 9.6 ( https://github.com/php/php-src/pull/4012/files#diff-3fe4027560fd299248af1dc1efe04287cc2b6418e8f01755c05c9db64b668b1eR646-R650 ), so now i'm wonder if require ext-sodium ^9.2 is really a good solution here...

@weirdan
Copy link
Contributor

weirdan commented May 4, 2021

In my case it turned out I was using different PHP binaries for installation and run time (phpenv can cause funny problems sometimes), so it's no longer an issue for me.

@azjezz
Copy link
Owner

azjezz commented Jan 8, 2022

This issue has been fixed in 2.0.0, fixing it in 1.9 will result in BC breaks, so there's nothing can be done.

@azjezz azjezz closed this as completed Jan 8, 2022
@supermavster
Copy link

Thanks for all comments I have an idea:

In base of this post Link

This algorithm is only available if PHP has been compiled with Argon2 support. - password_hash

If you want to use it whenever it is available, I would recommend to check with defined or else fallback to a default algorithm.

if(defined('PASSWORD_ARGON2ID')) {
    $hash = password_hash('password123', PASSWORD_ARGON2ID, array('time_cost' => 10, 'memory_cost' => '2048k', 'threads' => 6));
} else {
    $hash = password_hash('password123', PASSWORD_DEFAULT, array('time_cost' => 10, 'memory_cost' => '2048k', 'threads' => 6));
}

so if change the PASSWORD_ARGON2ID to PASSWORD_DEFAULT in the file:

azjezz/psl/src/Psl/Password/constants.php

all the process for the new version pass the all the test in the code?

it's only an idea :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

No branches or pull requests

5 participants