src/library/sodium_compat/src/Crypto.php 1 location
|
@@ 824-835 (lines=12) @@
|
| 821 |
|
* @return void |
| 822 |
|
* @throws Error |
| 823 |
|
*/ |
| 824 |
|
protected static function scalarmult_throw_if_zero($q) |
| 825 |
|
{ |
| 826 |
|
$d = 0; |
| 827 |
|
for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) { |
| 828 |
|
$d |= ParagonIE_Sodium_Core_Util::chrToInt($q[$i]); |
| 829 |
|
} |
| 830 |
|
|
| 831 |
|
/* branch-free variant of === 0 */ |
| 832 |
|
if (-(1 & (($d - 1) >> 8))) { |
| 833 |
|
throw new Error('Zero public key is not allowed'); |
| 834 |
|
} |
| 835 |
|
} |
| 836 |
|
|
| 837 |
|
/** |
| 838 |
|
* XSalsa20-Poly1305 authenticated symmetric-key encryption. |
src/library/sodium_compat/src/Crypto32.php 1 location
|
@@ 809-820 (lines=12) @@
|
| 806 |
|
* @return void |
| 807 |
|
* @throws Error |
| 808 |
|
*/ |
| 809 |
|
protected static function scalarmult_throw_if_zero($q) |
| 810 |
|
{ |
| 811 |
|
$d = 0; |
| 812 |
|
for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) { |
| 813 |
|
$d |= ParagonIE_Sodium_Core32_Util::chrToInt($q[$i]); |
| 814 |
|
} |
| 815 |
|
|
| 816 |
|
/* branch-free variant of === 0 */ |
| 817 |
|
if (-(1 & (($d - 1) >> 8))) { |
| 818 |
|
throw new Error('Zero public key is not allowed'); |
| 819 |
|
} |
| 820 |
|
} |
| 821 |
|
|
| 822 |
|
/** |
| 823 |
|
* XSalsa20-Poly1305 authenticated symmetric-key encryption. |