wppaste
WordPress

ParagonIE_Sodium_Core_AEGIS_State256

Source
wp-includes/sodium_compat/src/Core/AEGIS/State256.php:14

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 1

$statearray<int,protected

Methods · 10

Source code

class ParagonIE_Sodium_Core_AEGIS_State256{    /** @var array<int, string> $state */    protected $state;    public function __construct()    {        $this->state = array_fill(0, 6, '');    }     /**     * @internal Only use this for unit tests!     * @return string[]     */    public function getState()    {        return array_values($this->state);    }     /**     * @param array $input     * @return self     * @throws SodiumException     *     * @internal Only for unit tests     */    public static function initForUnitTests(array $input)    {        if (count($input) < 6) {            throw new SodiumException('invalid input');        }        $state = new self();        for ($i = 0; $i < 6; ++$i) {            $state->state[$i] = $input[$i];        }        return $state;    }     /**     * @param string $key     * @param string $nonce     * @return self     */    public static function init($key, $nonce)    {        $state = new self();        $k0 = ParagonIE_Sodium_Core_Util::substr($key, 0, 16);        $k1 = ParagonIE_Sodium_Core_Util::substr($key, 16, 16);        $n0 = ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16);        $n1 = ParagonIE_Sodium_Core_Util::substr($nonce, 16, 16);         // S0 = k0 ^ n0        // S1 = k1 ^ n1        // S2 = C1        // S3 = C0        // S4 = k0 ^ C0        // S5 = k1 ^ C1        $k0_n0 = $k0 ^ $n0;        $k1_n1 = $k1 ^ $n1;        $state->state[0] = $k0_n0;        $state->state[1] = $k1_n1;        $state->state[2] = SODIUM_COMPAT_AEGIS_C1;        $state->state[3] = SODIUM_COMPAT_AEGIS_C0;        $state->state[4] = $k0 ^ SODIUM_COMPAT_AEGIS_C0;        $state->state[5] = $k1 ^ SODIUM_COMPAT_AEGIS_C1;         // Repeat(4,        //   Update(k0)        //   Update(k1)        //   Update(k0 ^ n0)        //   Update(k1 ^ n1)        // )        for ($i = 0; $i < 4; ++$i) {            $state->update($k0);            $state->update($k1);            $state->update($k0 ^ $n0);            $state->update($k1 ^ $n1);        }        return $state;    }

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/sodium_compat/src/Core/AEGIS/State256.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.