public static function ParagonIE_Sodium_Core32_Int64::ctSelect in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/paragonie/sodium_compat/src/Core32/Int64.php \ParagonIE_Sodium_Core32_Int64::ctSelect()
@psalm-suppress MixedInferredReturnType
Parameters
ParagonIE_Sodium_Core32_Int64 $A:
ParagonIE_Sodium_Core32_Int64 $B:
Return value
array<int, ParagonIE_Sodium_Core32_Int64>
Throws
SodiumException
TypeError
1 call to ParagonIE_Sodium_Core32_Int64::ctSelect()
- ParagonIE_Sodium_Core32_Int64::mulInt64 in vendor/
paragonie/ sodium_compat/ src/ Core32/ Int64.php - @psalm-suppress MixedAssignment
File
- vendor/
paragonie/ sodium_compat/ src/ Core32/ Int64.php, line 290
Class
- ParagonIE_Sodium_Core32_Int64
- Class ParagonIE_Sodium_Core32_Int64
Code
public static function ctSelect(ParagonIE_Sodium_Core32_Int64 $A, ParagonIE_Sodium_Core32_Int64 $B) {
$a = clone $A;
$b = clone $B;
/** @var int $aNeg */
$aNeg = $a->limbs[0] >> 15 & 1;
/** @var int $bNeg */
$bNeg = $b->limbs[0] >> 15 & 1;
/** @var int $m */
$m = -($aNeg & $bNeg) | 1;
/** @var int $swap */
$swap = $bNeg & ~$aNeg;
/** @var int $d */
$d = -$swap;
/*
if ($bNeg && !$aNeg) {
$a = clone $int;
$b = clone $this;
} elseif($bNeg && $aNeg) {
$a = $this->mulInt(-1);
$b = $int->mulInt(-1);
}
*/
$x = $a
->xorInt64($b)
->mask64($d, $d);
return array(
$a
->xorInt64($x)
->mulInt($m),
$b
->xorInt64($x)
->mulInt($m),
);
}