wppaste
WordPress

ParagonIE_Sodium_Core_ChaCha20

Source
wp-includes/sodium_compat/src/Core/ChaCha20.php:10
Class ParagonIE_Sodium_Core_ChaCha20

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).

Methods · 7

Source code

class ParagonIE_Sodium_Core_ChaCha20 extends ParagonIE_Sodium_Core_Util{    /**     * Bitwise left rotation     *     * @internal You should not use this directly from another application     *     * @param int $v     * @param int $n     * @return int     */    public static function rotate($v, $n)    {        $v &= 0xffffffff;        $n &= 31;        return (int) (            0xffffffff & (                ($v << $n)                    |                ($v >> (32 - $n))            )        );    }     /**     * The ChaCha20 quarter round function. Works on four 32-bit integers.     *     * @internal You should not use this directly from another application     *     * @param int $a     * @param int $b     * @param int $c     * @param int $d     * @return array<int, int>     */    protected static function quarterRound($a, $b, $c, $d)    {        # a = PLUS(a,b); d = ROTATE(XOR(d,a),16);        /** @var int $a */        $a = ($a + $b) & 0xffffffff;        $d = self::rotate($d ^ $a, 16);         # c = PLUS(c,d); b = ROTATE(XOR(b,c),12);        /** @var int $c */        $c = ($c + $d) & 0xffffffff;        $b = self::rotate($b ^ $c, 12);         # a = PLUS(a,b); d = ROTATE(XOR(d,a), 8);        /** @var int $a */        $a = ($a + $b) & 0xffffffff;        $d = self::rotate($d ^ $a, 8);         # c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);        /** @var int $c */        $c = ($c + $d) & 0xffffffff;        $b = self::rotate($b ^ $c, 7);        return array((int) $a, (int) $b, (int) $c, (int) $d);    }     /**     * @internal You should not use this directly from another application     *     * @param ParagonIE_Sodium_Core_ChaCha20_Ctx $ctx     * @param string $message     *     * @return string     * @throws TypeError     * @throws SodiumException     */    public static function encryptBytes(        ParagonIE_Sodium_Core_ChaCha20_Ctx $ctx,        $message = ''    ) {        $bytes = self::strlen($message);         /*        j0 = ctx->input[0];        j1 = ctx->input[1];        j2 = ctx->input[2];        j3 = ctx->input[3];

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/ChaCha20.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.