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

PHP 8.0 < 8.1 -- real slow due to XChaCha20 polyfill #178

Closed
rotdrop opened this issue Mar 18, 2022 · 8 comments
Closed

PHP 8.0 < 8.1 -- real slow due to XChaCha20 polyfill #178

rotdrop opened this issue Mar 18, 2022 · 8 comments

Comments

@rotdrop
Copy link

rotdrop commented Mar 18, 2022

Hi,
thank you for this package. I'm experiencing very very bad performance on PHP 8.0 caused by the XChaCha20 polyfill.

Meanwhile I have recompile a php 8.0 package without libsodium support and installed the very latest pecl-extension from

https://github.com/jedisct1/libsodium-php.git

which has the require PHP binding sodium_crypto_stream_xchacha20_xor. With this setup things are quite fast, where "fast" means roughly 0.05 seconds for 16Mib and "slow" about 12 seconds for the same size. This is for symmetric encryption using the `File::encrypt()' method.

Without streaming (which compresses the data in chunks of 1Mib it seems), that is with the Symmetric\Crypto::encrypt() the thing is hopelessly slow (gave up) while it takes on my system roughly 5 seconds when using the hand-made bleeding edge libsodium bindings.

@paragonie-security
Copy link
Contributor

We do have plans to add the internal counter to PHP 8.2, but that obviously won't land immediately.

@rotdrop
Copy link
Author

rotdrop commented May 11, 2022

I do not know what you mean by "internal counter". The problem I am describing is that in the default configuration with PHP 8.zero the PHP poly-fill is used. This is ok when you encrypt small chunks of data, but renders Halite actually close to unusable for large amounts of data. PHP 8.zero is not dead, is it? Halite really shows extremely poor performance with PHP 8.0.

@paragonie-security
Copy link
Contributor

Oh, I misunderstood. I'll look into the problem. It should be using the standard library function by default.

@rotdrop
Copy link
Author

rotdrop commented May 11, 2022

Sorry, it can't use the standard library function because the version of the bundled libsodium (with PHP 8.zero) does not supply this function. Hence it has to use the poly-fill. As written in my first comment, in order to get the required sodium_crypto_stream_xchacha20_xor function you have to install a custom libsodium from its github repo (which implies that on some distros you have also to recompile PHP as it already comes with the "stable" version of libsodium compiled in.

@paragonie-security
Copy link
Contributor

Sorry, it can't use the standard library function because the version of the bundled libsodium (with PHP 8.zero) does not supply this function.

The easiest solution then is to upgrade to PHP 8.1, since PHP 8.0 lacks this function built-in.

@rotdrop
Copy link
Author

rotdrop commented May 22, 2022

This is not an easy solution if parts of your project do not yet fully support PHP 8.0.

AND: you advertise your Halite to be usable with PHP 8.0: In your README.md I find:

Halite 5.0 and newer | 8.0.0 | 1.0.18 | N/A (standard) | Active

However, the usability of Halite 5 with PHP 8.0 is somewhat limited due to above mentioned performance problems.

Should not this be documented at a prominent position in README.md?

@paragonie-security
Copy link
Contributor

No. We'll drop PHP 8.0 support if that makes it easier.

paragonie-security added a commit that referenced this issue May 23, 2022
@paragonie-security
Copy link
Contributor

pento pushed a commit to WordPress/wordpress-develop that referenced this issue Sep 14, 2022
The latest version of sodium_compat includes some improvements, as well as a new feature which will also be included in PHP 8.2.

* Fixed issues with the PHP autoloader:
 * [paragonie/sodium_compat#145 #145]: For WordPress, this ensures when Ed25519 is included, so too is the class it inherits from.
 * [paragonie/sodium_compat#148 #148], [paragonie/sodium_compat#149 #149]: For PHP 7.4+ with opcache preloading, this ensures the include guards don't fail.
* [paragonie/sodium_compat#144 #144]: Added `sodium_crypto_stream_xchacha20_xor_ic()`
 * See [php/php-src#8276 pull request for php-src] (merged in PHP 8.2)
 * For motivation: [paragonie/halite#178 paragonie/halite#178]

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.18.0

A full list of changes in this update can be found on GitHub:
paragonie/sodium_compat@v1.17.1...v1.18.0

Follow-up to [49741], [51002], [51591], [52988].

Props jrf, paragoninitiativeenterprises.
Fixes #56564.

git-svn-id: https://develop.svn.wordpress.org/trunk@54150 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Sep 14, 2022
The latest version of sodium_compat includes some improvements, as well as a new feature which will also be included in PHP 8.2.

* Fixed issues with the PHP autoloader:
 * [paragonie/sodium_compat#145 #145]: For WordPress, this ensures when Ed25519 is included, so too is the class it inherits from.
 * [paragonie/sodium_compat#148 #148], [paragonie/sodium_compat#149 #149]: For PHP 7.4+ with opcache preloading, this ensures the include guards don't fail.
* [paragonie/sodium_compat#144 #144]: Added `sodium_crypto_stream_xchacha20_xor_ic()`
 * See [php/php-src#8276 pull request for php-src] (merged in PHP 8.2)
 * For motivation: [paragonie/halite#178 paragonie/halite#178]

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.18.0

A full list of changes in this update can be found on GitHub:
paragonie/sodium_compat@v1.17.1...v1.18.0

Follow-up to [49741], [51002], [51591], [52988].

Props jrf, paragoninitiativeenterprises.
Fixes #56564.
Built from https://develop.svn.wordpress.org/trunk@54150


git-svn-id: http://core.svn.wordpress.org/trunk@53709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this issue Sep 14, 2022
The latest version of sodium_compat includes some improvements, as well as a new feature which will also be included in PHP 8.2.

* Fixed issues with the PHP autoloader:
 * [paragonie/sodium_compat#145 #145]: For WordPress, this ensures when Ed25519 is included, so too is the class it inherits from.
 * [paragonie/sodium_compat#148 #148], [paragonie/sodium_compat#149 #149]: For PHP 7.4+ with opcache preloading, this ensures the include guards don't fail.
* [paragonie/sodium_compat#144 #144]: Added `sodium_crypto_stream_xchacha20_xor_ic()`
 * See [php/php-src#8276 pull request for php-src] (merged in PHP 8.2)
 * For motivation: [paragonie/halite#178 paragonie/halite#178]

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.18.0

A full list of changes in this update can be found on GitHub:
paragonie/sodium_compat@v1.17.1...v1.18.0

Follow-up to [49741], [51002], [51591], [52988].

Props jrf, paragoninitiativeenterprises.
Fixes #56564.
Built from https://develop.svn.wordpress.org/trunk@54150


git-svn-id: https://core.svn.wordpress.org/trunk@53709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
whereiscodedude pushed a commit to whereiscodedude/wpss that referenced this issue Sep 18, 2022
The latest version of sodium_compat includes some improvements, as well as a new feature which will also be included in PHP 8.2.

* Fixed issues with the PHP autoloader:
 * [paragonie/sodium_compat#145 #145]: For WordPress, this ensures when Ed25519 is included, so too is the class it inherits from.
 * [paragonie/sodium_compat#148 #148], [paragonie/sodium_compat#149 #149]: For PHP 7.4+ with opcache preloading, this ensures the include guards don't fail.
* [paragonie/sodium_compat#144 #144]: Added `sodium_crypto_stream_xchacha20_xor_ic()`
 * See [php/php-src#8276 pull request for php-src] (merged in PHP 8.2)
 * For motivation: [paragonie/halite#178 paragonie/halite#178]

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.18.0

A full list of changes in this update can be found on GitHub:
paragonie/sodium_compat@v1.17.1...v1.18.0

Follow-up to [49741], [51002], [51591], [52988].

Props jrf, paragoninitiativeenterprises.
Fixes #56564.
Built from https://develop.svn.wordpress.org/trunk@54150
ootwch pushed a commit to ootwch/wordpress-develop that referenced this issue Nov 4, 2022
The latest version of sodium_compat includes some improvements, as well as a new feature which will also be included in PHP 8.2.

* Fixed issues with the PHP autoloader:
 * [paragonie/sodium_compat#145 WordPress#145]: For WordPress, this ensures when Ed25519 is included, so too is the class it inherits from.
 * [paragonie/sodium_compat#148 WordPress#148], [paragonie/sodium_compat#149 WordPress#149]: For PHP 7.4+ with opcache preloading, this ensures the include guards don't fail.
* [paragonie/sodium_compat#144 WordPress#144]: Added `sodium_crypto_stream_xchacha20_xor_ic()`
 * See [php/php-src#8276 pull request for php-src] (merged in PHP 8.2)
 * For motivation: [paragonie/halite#178 paragonie/halite#178]

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.18.0

A full list of changes in this update can be found on GitHub:
paragonie/sodium_compat@v1.17.1...v1.18.0

Follow-up to [49741], [51002], [51591], [52988].

Props jrf, paragoninitiativeenterprises.
Fixes #56564.

git-svn-id: https://develop.svn.wordpress.org/trunk@54150 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants