You are here

protected static function ParagonIE_Sodium_Core_HChaCha20::hChaCha20Bytes in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/HChaCha20.php \ParagonIE_Sodium_Core_HChaCha20::hChaCha20Bytes()

Parameters

array $ctx:

Return value

string

Throws

TypeError

1 call to ParagonIE_Sodium_Core_HChaCha20::hChaCha20Bytes()
ParagonIE_Sodium_Core_HChaCha20::hChaCha20 in vendor/paragonie/sodium_compat/src/Core/HChaCha20.php

File

vendor/paragonie/sodium_compat/src/Core/HChaCha20.php, line 54

Class

ParagonIE_Sodium_Core_HChaCha20
Class ParagonIE_Sodium_Core_HChaCha20

Code

protected static function hChaCha20Bytes(array $ctx) {
  $x0 = (int) $ctx[0];
  $x1 = (int) $ctx[1];
  $x2 = (int) $ctx[2];
  $x3 = (int) $ctx[3];
  $x4 = (int) $ctx[4];
  $x5 = (int) $ctx[5];
  $x6 = (int) $ctx[6];
  $x7 = (int) $ctx[7];
  $x8 = (int) $ctx[8];
  $x9 = (int) $ctx[9];
  $x10 = (int) $ctx[10];
  $x11 = (int) $ctx[11];
  $x12 = (int) $ctx[12];
  $x13 = (int) $ctx[13];
  $x14 = (int) $ctx[14];
  $x15 = (int) $ctx[15];
  for ($i = 0; $i < 10; ++$i) {

    # QUARTERROUND( x0,  x4,  x8,  x12)
    list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12);

    # QUARTERROUND( x1,  x5,  x9,  x13)
    list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13);

    # QUARTERROUND( x2,  x6,  x10,  x14)
    list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14);

    # QUARTERROUND( x3,  x7,  x11,  x15)
    list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15);

    # QUARTERROUND( x0,  x5,  x10,  x15)
    list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15);

    # QUARTERROUND( x1,  x6,  x11,  x12)
    list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12);

    # QUARTERROUND( x2,  x7,  x8,  x13)
    list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13);

    # QUARTERROUND( x3,  x4,  x9,  x14)
    list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14);
  }
  return self::store32_le((int) ($x0 & 0xffffffff)) . self::store32_le((int) ($x1 & 0xffffffff)) . self::store32_le((int) ($x2 & 0xffffffff)) . self::store32_le((int) ($x3 & 0xffffffff)) . self::store32_le((int) ($x12 & 0xffffffff)) . self::store32_le((int) ($x13 & 0xffffffff)) . self::store32_le((int) ($x14 & 0xffffffff)) . self::store32_le((int) ($x15 & 0xffffffff));
}