Make WordPress Core


Ignore:
Timestamp:
10/06/2025 03:46:40 PM (6 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/ChaCha20/Ctx.php

    r51591 r60905  
    5151        $this->container[11] = self::load_4(self::substr($key, 28, 4));
    5252
    53         if (empty($counter)) {
    54             $this->container[12] = 0;
    55             $this->container[13] = 0;
    56         } else {
    57             $this->container[12] = self::load_4(self::substr($counter, 0, 4));
    58             $this->container[13] = self::load_4(self::substr($counter, 4, 4));
    59         }
     53        $counter = $this->initCounter($counter);
     54        $this->container[12] = self::load_4(self::substr($counter, 0, 4));
     55        $this->container[13] = self::load_4(self::substr($counter, 4, 4));
    6056        $this->container[14] = self::load_4(self::substr($iv, 0, 4));
    6157        $this->container[15] = self::load_4(self::substr($iv, 4, 4));
     
    121117            : null;
    122118    }
     119
     120    /**
     121     * Initialize (pad) a counter value.
     122     * @throws SodiumException
     123     *
     124     * @param string $ctr
     125     * @return string
     126     */
     127    public function initCounter(
     128        #[SensitiveParameter]
     129        $ctr
     130    ) {
     131        $len = self::strlen($ctr);
     132        if ($len === 0) {
     133            return str_repeat("\0", 8);
     134        }
     135        if ($len < 8) {
     136            return $ctr . str_repeat("\0", 8 - $len);
     137        }
     138        if ($len > 8) {
     139            throw new SodiumException("counter cannot be more than 8 bytes");
     140        }
     141        return $ctr;
     142    }
    123143}
Note: See TracChangeset for help on using the changeset viewer.