Make WordPress Core


Ignore:
Timestamp:
12/09/2019 04:44:58 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Update sodium_compat to v1.12.1.

This includes a speedup for signature verification on most platforms and bugfixes for 32-bit platforms.

Props paragoninitiativeenterprises, lukaswaudentio.
Merges [46858] to the 5.3 branch.
Fixes #48371.

Location:
branches/5.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

  • branches/5.3/src/wp-includes/sodium_compat/src/Core/BLAKE2b.php

    r45344 r46859  
    8989        $l = ($x[1] + $y[1]) & 0xffffffff;
    9090        return self::new64(
    91             $x[0] + $y[0] + (
     91            (int) ($x[0] + $y[0] + (
    9292                ($l < $x[1]) ? 1 : 0
    93             ),
    94             $l
     93            )),
     94            (int) $l
    9595        );
    9696    }
     
    133133        }
    134134        return self::new64(
    135             (int) ($x[0] ^ $y[0]),
    136             (int) ($x[1] ^ $y[1])
     135            (int) (($x[0] ^ $y[0]) & 0xffffffff),
     136            (int) (($x[1] ^ $y[1]) & 0xffffffff)
    137137        );
    138138    }
     
    300300    protected static function context()
    301301    {
    302         $ctx    = new SplFixedArray(5);
     302        $ctx    = new SplFixedArray(6);
    303303        $ctx[0] = new SplFixedArray(8);   // h
    304304        $ctx[1] = new SplFixedArray(2);   // t
     
    306306        $ctx[3] = new SplFixedArray(256); // buf
    307307        $ctx[4] = 0;                      // buflen
     308        $ctx[5] = 0;                      // last_node (uint8_t)
    308309
    309310        for ($i = 8; $i--;) {
     
    551552     * @param SplFixedArray|null $key
    552553     * @param int $outlen
     554     * @param SplFixedArray|null $salt
     555     * @param SplFixedArray|null $personal
    553556     * @return SplFixedArray
    554557     * @throws SodiumException
     
    560563     * @psalm-suppress MixedArrayOffset
    561564     */
    562     public static function init($key = null, $outlen = 64)
    563     {
     565    public static function init(
     566        $key = null,
     567        $outlen = 64,
     568        $salt = null,
     569        $personal = null
     570    ) {
    564571        self::pseudoConstructor();
    565572        $klen = 0;
     
    579586
    580587        $p = new SplFixedArray(64);
     588        // Zero our param buffer...
    581589        for ($i = 64; --$i;) {
    582590            $p[$i] = 0;
     
    588596        $p[3] = 1;       // depth
    589597
     598        if ($salt instanceof SplFixedArray) {
     599            // salt: [32] through [47]
     600            for ($i = 0; $i < 16; ++$i) {
     601                $p[32 + $i] = (int) $salt[$i];
     602            }
     603        }
     604        if ($personal instanceof SplFixedArray) {
     605            // personal: [48] through [63]
     606            for ($i = 0; $i < 16; ++$i) {
     607                $p[48 + $i] = (int) $personal[$i];
     608            }
     609        }
     610
    590611        $ctx[0][0] = self::xor64(
    591612            $ctx[0][0],
    592613            self::load64($p, 0)
    593614        );
     615        if ($salt instanceof SplFixedArray || $personal instanceof SplFixedArray) {
     616            // We need to do what blake2b_init_param() does:
     617            for ($i = 1; $i < 8; ++$i) {
     618                $ctx[0][$i] = self::xor64(
     619                    $ctx[0][$i],
     620                    self::load64($p, $i << 3)
     621                );
     622            }
     623        }
    594624
    595625        if ($klen > 0 && $key instanceof SplFixedArray) {
     
    602632            }
    603633            self::update($ctx, $block, 128);
     634            $ctx[4] = 128;
    604635        }
    605636
     
    694725        ));
    695726        # uint8_t last_node;
    696         return $str . "\x00";
     727        return $str . self::intToChr($ctx[5]) . str_repeat("\x00", 23);
    697728    }
    698729
     
    747778        $ctx[3] = self::stringToSplFixedArray(self::substr($string, 96, 256));
    748779
    749 
    750780        # uint8_t buf[2 * 128];
    751781        $int = 0;
Note: See TracChangeset for help on using the changeset viewer.