hash_equals: leak less information about length

[email protected] (Kévin Dunglas)
Newsgroups php.internals
Message-ID <CAOv1iQYUW6N4SMmVQqxsSBVpePe8OzOwgo1D35uFNB2PzSigHQ@mail.gmail.com>
Hi,

I've submitted a PR to make the hash_equals function leak less information
about compared strings' lengths (benchmark and use cases available in
comments): https://github.com/php/php-src/pull/792

Trying to hide length is needed to replace Symfony and Joomla PHP
implementations by hash_equals (when available).

The idea:
- clearly advert in the documentation that this function can potentially
leak lengths
- Try to make it harder for an attacker by using a robuster implementation.

If there there is an agreement to use this kind of implementation, I'll
rework the PR to use some tricks from the CPython one (
https://github.com/python/cpython/blob/c7688b44387d116522ff53c0927169db45969f0e/Modules/_operator.c#L175
- use of volatile and no modulo).

Best regards,
-- 
Kévin Dunglas

http://dunglas.fr
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.