ParagonIE_Sodium_Core_ChaCha20::quarterRound

Advertisement

Summery Summery

The ChaCha20 quarter round function. Works on four 32-bit integers.

Syntax Syntax

ParagonIE_Sodium_Core_ChaCha20::quarterRound( int $a, int $b, int $c, int $d )

Parameters Parameters

$a

(int) (Required)

$b

(int) (Required)

$c

(int) (Required)

$d

(int) (Required)

Return Return

(array<int,) int>

Source Source

File: wp-includes/sodium_compat/src/Core/ChaCha20.php

    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);
    }

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.