[wp-trac] [WordPress Trac] #47186: At least one function in /wp-includes/sodium_compat/src/Core32 times out on 32 bit servers
WordPress Trac
noreply at wordpress.org
Thu May 9 19:01:39 UTC 2019
#47186: At least one function in /wp-includes/sodium_compat/src/Core32 times out on
32 bit servers
-------------------------------+-------------------------------------------
Reporter: lovingboth | Owner: paragoninitiativeenterprises
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 5.2.1
Component: Upgrade/Install | Version: 5.2
Severity: normal | Resolution:
Keywords: needs-testing | Focuses:
has-patch |
-------------------------------+-------------------------------------------
Comment (by paragoninitiativeenterprises):
@lovingboth:
> Or you could use a faster, albeit theoretically slightly less secure,
algorithm in the first place. Was using SHA512 hashes tested? That's
native in PHP for all versions WordPress supports.
SHA512 isn't even in the same universe as Ed25519. See
https://paragonie.com/blog/2015/08/you-wouldnt-base64-a-password-
cryptography-decoded for more information. We tried to make the basic
classifications of cryptographic algorithms easy to understand with that
article.
To be explicit:
* SHA512 is a hash function, that can be almost-trivially used as a
building block for **symmetric authentication** protocols (i.e. HMAC)
* Ed25519 is an **asymmetric authentication** digital signature algorithm
They have completely different security properties. In fact, Ed25519 uses
SHA512 internally for different steps.
You can't just replace Ed25519 with the SHA512. That would be like trying
to build a house with bacon. I like bacon, but I'm not about to trust my
family's life in its structural integrity.
@lovingboth:
> Apologies if this sounds somewhat pointed, but the number of hours I
have had to spend over this in the last couple of days is not small.
I understand your frustration. You're not the only one expending hours on
this problem. It took me a month and a half of almost non-stop development
to get Curve25519 field arithmetic to work on 32-bit ''at all', and that
was just the up-front development time.
I had been taking great efforts over the past year to make it faster, but
it clearly wasn't adequate.
@lovingboth:
> Ah, so it's a known problem with the library that was added to WordPress
core without, as far as I can see, ever seeing how many WP users are
running on 32-bit systems.
It's a known problem that's ''extremely'' challenging to solve, and
''almost nobody'' runs PHP in general in production on 32-bit systems
where they can't ''also'' install PHP extensions via PECL, so it's not one
that gets a lot of attention.
In fact, when I raised this issue on Twitter, I had this response:
https://twitter.com/_francislavoie/status/1126541694617440256
> Is there actually enough people still on 32bit for that to be worth the
time?
Until now, the answer to their question was flatly, "No".
Most people who run 32-bit PHP have been perfectly content with `pecl
install sodium` as a solution, to date. I suppose that's the curse of
early adopters: They tend to be more technical.
----
Anyway! Misunderstandings aside, I'm releasing a new version of
sodium_compat this evening, which introduces a 9x to 10x speedup when you
set `ParagonIE_Sodium_Compat::$fastMult = true;` on 32-bit systems.
https://github.com/paragonie/sodium_compat/pull/86
For Ed25519 signature verification, we automatically set this
(temporarily) to `true` since there are no cryptographic secrets that can
be leaked from integer multiplication in this context.
In other words: You can anticipate a significant speed-up that won't, in
this specific context, even theoretically harm security.
A patch for WordPress will be provided as soon as I'm confident the
changes are non-breaking and `v1.9.2` is tagged. This will be safe to
release in `5.2.1`.
If you'd like to help test this in the meantime, simply copy
`src/Core32/Int64.php` from the official `v1.9.2` release over the one
WordPress provides and see if the runtime is acceptable on your machine.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47186#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list