ParagonIE_Sodium_Core32_BLAKE2b::finish

Advertisement

Syntax Syntax

ParagonIE_Sodium_Core32_BLAKE2b::finish( SplFixedArray $ctx, SplFixedArray $out )

Parameters Parameters

$ctx

(Required)

$out

(Required)

Return Return

(SplFixedArray)

Source Source

File: wp-includes/sodium_compat/src/Core32/BLAKE2b.php

    public static function finish(SplFixedArray $ctx, SplFixedArray $out)
    {
        self::pseudoConstructor();
        if ($ctx[4] > 128) {
            self::increment_counter($ctx, 128);
            self::compress($ctx, $ctx[3]);
            $ctx[4] -= 128;
            if ($ctx[4] > 128) {
                throw new SodiumException('Failed to assert that buflen <= 128 bytes');
            }
            for ($i = $ctx[4]; $i--;) {
                $ctx[3][$i] = $ctx[3][$i + 128];
            }
        }

        self::increment_counter($ctx, $ctx[4]);
        $ctx[2][0] = self::new64(0xffffffff, 0xffffffff);

        for ($i = 256 - $ctx[4]; $i--;) {
            /** @var int $i */
            $ctx[3][$i + $ctx[4]] = 0;
        }

        self::compress($ctx, $ctx[3]);

        $i = (int) (($out->getSize() - 1) / 8);
        for (; $i >= 0; --$i) {
            self::store64($out, $i << 3, $ctx[0][$i]);
        }
        return $out;
    }

Advertisement

Advertisement

Leave a Reply