Make WordPress Core


Ignore:
Timestamp:
10/06/2025 03:46:40 PM (7 months ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Update sodium_compat to v1.23.0.

The previous version of sodium_compat was overly permissible with sodium_base642bin() when the *_NO_PADDING variants were specified, which was not compatible with ext-sodium. This has been fixed in version 1.22.0.

Version 1.23.0 includes some optimizations by replacing the array in the Curve25519 field element with 10 integer object properties instead. The result is a 7% to 12% speedup for the overall PHPUnit suite.

References:

Follow-up to [55699], [58752], [58753], [60787].

Props paragoninitiativeenterprises, SergeyBiryukov.
Fixes #64079.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sodium_compat/src/Core/Util.php

    r58752 r60905  
    182182            $left = str_pad($left, $len, "\x00", STR_PAD_RIGHT);
    183183            $right = str_pad($right, $len, "\x00", STR_PAD_RIGHT);
     184        } elseif ($leftLen !== $rightLen) {
     185            throw new SodiumException("Argument #1 and argument #2 must have the same length");
    184186        }
    185187
     
    337339     * @param bool $strictPadding
    338340     * @return string (raw binary)
    339      * @throws RangeException
     341     *
     342     * @throws SodiumException
    340343     * @throws TypeError
    341344     */
     
    355358        $hex_len = self::strlen($hexString);
    356359        $state = 0;
    357         if (($hex_len & 1) !== 0) {
    358             if ($strictPadding) {
    359                 throw new RangeException(
    360                     'Expected an even number of hexadecimal characters'
    361                 );
    362             } else {
    363                 $hexString = '0' . $hexString;
    364                 ++$hex_len;
    365             }
    366         }
    367360
    368361        $chunk = unpack('C*', $hexString);
     
    391384            $state ^= 1;
    392385        }
     386        if ($strictPadding && $state !== 0) {
     387            throw new SodiumException(
     388                'Expected an even number of hexadecimal characters'
     389            );
     390        }
    393391        return $bin;
    394392    }
     
    535533    public static function memcmp($left, $right)
    536534    {
    537         if (self::hashEquals($left, $right)) {
    538             return 0;
    539         }
    540         return -1;
     535        $e = (int) !self::hashEquals($left, $right);
     536        return 0 - $e;
    541537    }
    542538
Note: See TracChangeset for help on using the changeset viewer.