-
-
Notifications
You must be signed in to change notification settings - Fork 234
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 support for libargon2 #64
Conversation
Question 1. Extension check names can be overwritten, but only the name can be changed. For example, If there is more than one extension like this, I think we can add a method to override the check command. |
Question 2. The libsodium library seems to contain some argon2 code, causing conflicts, but directly using the password-argon2 extension with the libsodium library may also have some linking issues. Perhaps the patch code is still needed in the end. |
Unfortunately, the PHP official website has stated that the argon library of libsodium cannot be used. php.net. It is caused by php itself (at least it looks like this for now). Overall, there are two solutions available.
|
Thank you for the in-depth analysis of this. I'm not really sure how common the combination of sodium and argon2 password hashing is, but I stumbled upon this as I was trying to replicate the "default" PHP setup when installing PHP via brew. This does include sodium and argon2. I agree - patching libargon2 seems to be the "easier" option in this case. |
Well, I don't know much about the architecture of the libargon2 project, so it may take some time to read the source code to avoid potential bugs caused by simply changing the name. Some symbols may not be changed directly. PHP installed via homebrew is a dynamically linked binary, and the code of the two libraries is not included in the PHP binary file, they can dynamically call the linked library as needed. static-php-cli just adds all of required library archives. For now I have tried this PR on linux, same issue, and even more symbol conflicts. This should require a fork project to achieve, because this piece of patch code is theoretically not part of static-php-cli. And in view of the fact that this part may need to modify a lot of code, this PR can be used as solution 1 to temporarily solve the problem. |
I have forked libargon2 and patched the source files so that there are no duplicate symbols. I don't really know what to use as the extension check name though, as password-argon2 does not get registered as a custom extension. It also does not show up in Maybe it would be good to be able to skip this for extensions - we could still add a sanity check to ensure successful compilation. |
I have two ways:
$name = $ext->getDistName();
if ($name !== null) {
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $name . '"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check');
}
}
// class Extension { }
/**
* Sanity check for extension
* Basically check if "--ri" can be used to get extension info
* You can override this method to do more checks
*
* @param string $binary Compiled binary path
* @return bool
*/
public function check(string $binary): bool
{
[$ret] = shell()->execWithResult("{$binary} --ri \"{$this->getDistName()}\"", false);
return $ret === 0;
} // class xxx extends Extension
public function check(string $binary): bool
{
// We can choose whether to check `--ri`
if (!parent::check($binary)) {
return false;
}
// TODO: Do more check with independent test file, but how?
return true;
}
Which one do you think is better? Or a more reasonable solution? |
# Conflicts: # config/lib.json # config/source.json
I introduced the The issue has not been formally addressed for a long time. But now everything is working fine, and if there's nothing else to add, it's time to merge. 🎉 |
This looks good to me now, I'm already using this for Laravel Herd since its launch 👍 |
96d702b
to
339c03a
Compare
As a fresh Herd user, thanks for all your work on this @mpociot and @crazywhalecc. |
This PR is my attempt to add libargon2 support.
I have only tested this on macOS so far and there are two issues where I could use some help:
php --ri password-argon2
fails.sodium,password-argon-2
) the linker throws the following errors:When building PHP only with
password-argon-2
this works fine.Tasks after merging