Make WordPress Core


Ignore:
Timestamp:
06/16/2021 05:28:49 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Update sodium_compat to v1.16.1.

The latest version of sodium_compat includes polyfills for new features slated to land in PHP 8.1:
https://paragonie.com/blog/2021/05/ristretto255-for-php-community

It also fixes a race condition with the autoloader that caused an "undefined constant" error on some systems:
https://github.com/paragonie/sodium_compat/issues/122

A full list of changes in this update can be found on GitHub:
https://github.com/paragonie/sodium_compat/compare/v1.14.0...v1.16.1

Follow-up to [49741].

Props paragoninitiativeenterprises, oxyrealm.
Merges [51002] to the 5.7 branch.
Fixes #53274.

Location:
branches/5.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.7

  • branches/5.7/src/wp-includes/sodium_compat/src/Core/Ed25519.php

    r48121 r51171  
    1212    const KEYPAIR_BYTES = 96;
    1313    const SEED_BYTES = 32;
     14    const SCALAR_BYTES = 32;
    1415
    1516    /**
     
    478479        return false;
    479480    }
     481
     482    /**
     483     * @param string $s
     484     * @return string
     485     * @throws SodiumException
     486     */
     487    public static function scalar_complement($s)
     488    {
     489        $t_ = self::L . str_repeat("\x00", 32);
     490        sodium_increment($t_);
     491        $s_ = $s . str_repeat("\x00", 32);
     492        ParagonIE_Sodium_Compat::sub($t_, $s_);
     493        return self::sc_reduce($t_);
     494    }
     495
     496    /**
     497     * @return string
     498     * @throws SodiumException
     499     */
     500    public static function scalar_random()
     501    {
     502        do {
     503            $r = ParagonIE_Sodium_Compat::randombytes_buf(self::SCALAR_BYTES);
     504            $r[self::SCALAR_BYTES - 1] = self::intToChr(
     505                self::chrToInt($r[self::SCALAR_BYTES - 1]) & 0x1f
     506            );
     507        } while (
     508            !self::check_S_lt_L($r) || ParagonIE_Sodium_Compat::is_zero($r)
     509        );
     510        return $r;
     511    }
     512
     513    /**
     514     * @param string $s
     515     * @return string
     516     * @throws SodiumException
     517     */
     518    public static function scalar_negate($s)
     519    {
     520        $t_ = self::L . str_repeat("\x00", 32) ;
     521        $s_ = $s . str_repeat("\x00", 32) ;
     522        ParagonIE_Sodium_Compat::sub($t_, $s_);
     523        return self::sc_reduce($t_);
     524    }
     525
     526    /**
     527     * @param string $a
     528     * @param string $b
     529     * @return string
     530     * @throws SodiumException
     531     */
     532    public static function scalar_add($a, $b)
     533    {
     534        $a_ = $a . str_repeat("\x00", 32);
     535        $b_ = $b . str_repeat("\x00", 32);
     536        ParagonIE_Sodium_Compat::add($a_, $b_);
     537        return self::sc_reduce($a_);
     538    }
     539
     540    /**
     541     * @param string $x
     542     * @param string $y
     543     * @return string
     544     * @throws SodiumException
     545     */
     546    public static function scalar_sub($x, $y)
     547    {
     548        $yn = self::scalar_negate($y);
     549        return self::scalar_add($x, $yn);
     550    }
    480551}
Note: See TracChangeset for help on using the changeset viewer.