You are here

public static function ParagonIE_Sodium_Core_BLAKE2b::rotr64 in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php \ParagonIE_Sodium_Core_BLAKE2b::rotr64()

@internal You should not use this directly from another application

@psalm-suppress MixedAssignment

Parameters

SplFixedArray $x:

int $c:

Return value

SplFixedArray

1 call to ParagonIE_Sodium_Core_BLAKE2b::rotr64()
ParagonIE_Sodium_Core_BLAKE2b::G in vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php
@internal You should not use this directly from another application

File

vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php, line 148

Class

ParagonIE_Sodium_Core_BLAKE2b
Class ParagonIE_Sodium_Core_BLAKE2b

Code

public static function rotr64($x, $c) {
  if ($c >= 64) {
    $c %= 64;
  }
  if ($c >= 32) {

    /** @var int $tmp */
    $tmp = $x[0];
    $x[0] = $x[1];
    $x[1] = $tmp;
    $c -= 32;
  }
  if ($c === 0) {
    return $x;
  }
  $l0 = 0;
  $c = 64 - $c;
  if ($c < 32) {

    /** @var int $h0 */
    $h0 = (int) $x[0] << $c | ((int) $x[1] & (1 << $c) - 1 << 32 - $c) >> 32 - $c;

    /** @var int $l0 */
    $l0 = (int) $x[1] << $c;
  }
  else {

    /** @var int $h0 */
    $h0 = (int) $x[1] << $c - 32;
  }
  $h1 = 0;
  $c1 = 64 - $c;
  if ($c1 < 32) {

    /** @var int $h1 */
    $h1 = (int) $x[0] >> $c1;

    /** @var int $l1 */
    $l1 = (int) $x[1] >> $c1 | ((int) $x[0] & (1 << $c1) - 1) << 32 - $c1;
  }
  else {

    /** @var int $l1 */
    $l1 = (int) $x[0] >> $c1 - 32;
  }
  return self::new64($h0 | $h1, $l0 | $l1);
}