@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_Poly1305 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_Poly1305 extends ParagonIE_Sodium_Core32_Util |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_Poly1305 extends ParagonIE_Sodium_Core32_Util { |
|
12 | 11 | const BLOCK_SIZE = 16; |
13 | 12 | |
14 | 13 | /** |
@@ -20,8 +19,7 @@ discard block |
||
20 | 19 | * @throws SodiumException |
21 | 20 | * @throws TypeError |
22 | 21 | */ |
23 | - public static function onetimeauth($m, $key) |
|
24 | - { |
|
22 | + public static function onetimeauth($m, $key) { |
|
25 | 23 | if (self::strlen($key) < 32) { |
26 | 24 | throw new InvalidArgumentException( |
27 | 25 | 'Key must be 32 bytes long.' |
@@ -45,8 +43,7 @@ discard block |
||
45 | 43 | * @throws SodiumException |
46 | 44 | * @throws TypeError |
47 | 45 | */ |
48 | - public static function onetimeauth_verify($mac, $m, $key) |
|
49 | - { |
|
46 | + public static function onetimeauth_verify($mac, $m, $key) { |
|
50 | 47 | if (self::strlen($key) < 32) { |
51 | 48 | throw new InvalidArgumentException( |
52 | 49 | 'Key must be 32 bytes long.' |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_XSalsa20 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20 |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20 { |
|
12 | 11 | /** |
13 | 12 | * Expand a key and nonce into an xsalsa20 keystream. |
14 | 13 | * |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * @throws SodiumException |
22 | 21 | * @throws TypeError |
23 | 22 | */ |
24 | - public static function xsalsa20($len, $nonce, $key) |
|
25 | - { |
|
23 | + public static function xsalsa20($len, $nonce, $key) { |
|
26 | 24 | $ret = self::salsa20( |
27 | 25 | $len, |
28 | 26 | self::substr($nonce, 16, 8), |
@@ -43,8 +41,7 @@ discard block |
||
43 | 41 | * @throws SodiumException |
44 | 42 | * @throws TypeError |
45 | 43 | */ |
46 | - public static function xsalsa20_xor($message, $nonce, $key) |
|
47 | - { |
|
44 | + public static function xsalsa20_xor($message, $nonce, $key) { |
|
48 | 45 | return self::xorStrings( |
49 | 46 | $message, |
50 | 47 | self::xsalsa20( |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_ChaCha20 |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core32_ChaCha20 extends ParagonIE_Sodium_Core32_Util |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core32_ChaCha20 extends ParagonIE_Sodium_Core32_Util { |
|
12 | 11 | /** |
13 | 12 | * The ChaCha20 quarter round function. Works on four 32-bit integers. |
14 | 13 | * |
@@ -334,8 +333,7 @@ discard block |
||
334 | 333 | * @throws SodiumException |
335 | 334 | * @throws TypeError |
336 | 335 | */ |
337 | - public static function stream($len = 64, $nonce = '', $key = '') |
|
338 | - { |
|
336 | + public static function stream($len = 64, $nonce = '', $key = '') { |
|
339 | 337 | return self::encryptBytes( |
340 | 338 | new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce), |
341 | 339 | str_repeat("\x00", $len) |
@@ -352,8 +350,7 @@ discard block |
||
352 | 350 | * @throws SodiumException |
353 | 351 | * @throws TypeError |
354 | 352 | */ |
355 | - public static function ietfStream($len, $nonce = '', $key = '') |
|
356 | - { |
|
353 | + public static function ietfStream($len, $nonce = '', $key = '') { |
|
357 | 354 | return self::encryptBytes( |
358 | 355 | new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce), |
359 | 356 | str_repeat("\x00", $len) |
@@ -371,8 +368,7 @@ discard block |
||
371 | 368 | * @throws SodiumException |
372 | 369 | * @throws TypeError |
373 | 370 | */ |
374 | - public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
375 | - { |
|
371 | + public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
376 | 372 | return self::encryptBytes( |
377 | 373 | new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce, $ic), |
378 | 374 | $message |
@@ -390,8 +386,7 @@ discard block |
||
390 | 386 | * @throws SodiumException |
391 | 387 | * @throws TypeError |
392 | 388 | */ |
393 | - public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
394 | - { |
|
389 | + public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
395 | 390 | return self::encryptBytes( |
396 | 391 | new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce, $ic), |
397 | 392 | $message |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_HChaCha20 |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core32_HChaCha20 extends ParagonIE_Sodium_Core32_ChaCha20 |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core32_HChaCha20 extends ParagonIE_Sodium_Core32_ChaCha20 { |
|
12 | 11 | /** |
13 | 12 | * @param string $in |
14 | 13 | * @param string $key |
@@ -17,8 +16,7 @@ discard block |
||
17 | 16 | * @throws SodiumException |
18 | 17 | * @throws TypeError |
19 | 18 | */ |
20 | - public static function hChaCha20($in = '', $key = '', $c = null) |
|
21 | - { |
|
19 | + public static function hChaCha20($in = '', $key = '', $c = null) { |
|
22 | 20 | $ctx = array(); |
23 | 21 | |
24 | 22 | if ($c === null) { |
@@ -54,8 +52,7 @@ discard block |
||
54 | 52 | * @throws SodiumException |
55 | 53 | * @throws TypeError |
56 | 54 | */ |
57 | - protected static function hChaCha20Bytes(array $ctx) |
|
58 | - { |
|
55 | + protected static function hChaCha20Bytes(array $ctx) { |
|
59 | 56 | /** @var ParagonIE_Sodium_Core32_Int32 $x0 */ |
60 | 57 | $x0 = $ctx[0]; |
61 | 58 | /** @var ParagonIE_Sodium_Core32_Int32 $x1 */ |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_HSalsa20 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_HSalsa20 extends ParagonIE_Sodium_Core32_Salsa20 |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_HSalsa20 extends ParagonIE_Sodium_Core32_Salsa20 { |
|
12 | 11 | /** |
13 | 12 | * Calculate an hsalsa20 hash of a single block |
14 | 13 | * |
@@ -24,8 +23,7 @@ discard block |
||
24 | 23 | * @throws SodiumException |
25 | 24 | * @throws TypeError |
26 | 25 | */ |
27 | - public static function hsalsa20($in, $k, $c = null) |
|
28 | - { |
|
26 | + public static function hsalsa20($in, $k, $c = null) { |
|
29 | 27 | /** |
30 | 28 | * @var ParagonIE_Sodium_Core32_Int32 $x0 |
31 | 29 | * @var ParagonIE_Sodium_Core32_Int32 $x1 |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_Poly1305_State |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Util |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Util { |
|
12 | 11 | /** |
13 | 12 | * @var array<int, int> |
14 | 13 | */ |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | * @throws SodiumException |
50 | 49 | * @throws TypeError |
51 | 50 | */ |
52 | - public function __construct($key = '') |
|
53 | - { |
|
51 | + public function __construct($key = '') { |
|
54 | 52 | if (self::strlen($key) < 32) { |
55 | 53 | throw new InvalidArgumentException( |
56 | 54 | 'Poly1305 requires a 32-byte key' |
@@ -117,8 +115,7 @@ discard block |
||
117 | 115 | * @throws SodiumException |
118 | 116 | * @throws TypeError |
119 | 117 | */ |
120 | - public function update($message = '') |
|
121 | - { |
|
118 | + public function update($message = '') { |
|
122 | 119 | $bytes = self::strlen($message); |
123 | 120 | |
124 | 121 | /* handle leftover */ |
@@ -183,8 +180,7 @@ discard block |
||
183 | 180 | * @throws SodiumException |
184 | 181 | * @throws TypeError |
185 | 182 | */ |
186 | - public function blocks($message, $bytes) |
|
187 | - { |
|
183 | + public function blocks($message, $bytes) { |
|
188 | 184 | if (self::strlen($message) < 16) { |
189 | 185 | $message = str_pad($message, 16, "\x00", STR_PAD_RIGHT); |
190 | 186 | } |
@@ -334,8 +330,7 @@ discard block |
||
334 | 330 | * @throws SodiumException |
335 | 331 | * @throws TypeError |
336 | 332 | */ |
337 | - public function finish() |
|
338 | - { |
|
333 | + public function finish() { |
|
339 | 334 | /* process the remaining block */ |
340 | 335 | if ($this->leftover) { |
341 | 336 | $i = $this->leftover; |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Class ParagonIE_Sodium_Core32_SecretStream_State |
5 | 5 | */ |
6 | -class ParagonIE_Sodium_Core32_SecretStream_State |
|
7 | -{ |
|
6 | +class ParagonIE_Sodium_Core32_SecretStream_State { |
|
8 | 7 | /** @var string $key */ |
9 | 8 | protected $key; |
10 | 9 | |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | * @param string $key |
23 | 22 | * @param string|null $nonce |
24 | 23 | */ |
25 | - public function __construct($key, $nonce = null) |
|
26 | - { |
|
24 | + public function __construct($key, $nonce = null) { |
|
27 | 25 | $this->key = $key; |
28 | 26 | $this->counter = 1; |
29 | 27 | if (is_null($nonce)) { |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | /** |
37 | 35 | * @return self |
38 | 36 | */ |
39 | - public function counterReset() |
|
40 | - { |
|
37 | + public function counterReset() { |
|
41 | 38 | $this->counter = 1; |
42 | 39 | $this->_pad = str_repeat("\0", 4); |
43 | 40 | return $this; |
@@ -46,24 +43,21 @@ discard block |
||
46 | 43 | /** |
47 | 44 | * @return string |
48 | 45 | */ |
49 | - public function getKey() |
|
50 | - { |
|
46 | + public function getKey() { |
|
51 | 47 | return $this->key; |
52 | 48 | } |
53 | 49 | |
54 | 50 | /** |
55 | 51 | * @return string |
56 | 52 | */ |
57 | - public function getCounter() |
|
58 | - { |
|
53 | + public function getCounter() { |
|
59 | 54 | return ParagonIE_Sodium_Core32_Util::store32_le($this->counter); |
60 | 55 | } |
61 | 56 | |
62 | 57 | /** |
63 | 58 | * @return string |
64 | 59 | */ |
65 | - public function getNonce() |
|
66 | - { |
|
60 | + public function getNonce() { |
|
67 | 61 | if (!is_string($this->nonce)) { |
68 | 62 | $this->nonce = str_repeat("\0", 12); |
69 | 63 | } |
@@ -76,8 +70,7 @@ discard block |
||
76 | 70 | /** |
77 | 71 | * @return string |
78 | 72 | */ |
79 | - public function getCombinedNonce() |
|
80 | - { |
|
73 | + public function getCombinedNonce() { |
|
81 | 74 | return $this->getCounter() . |
82 | 75 | ParagonIE_Sodium_Core32_Util::substr($this->getNonce(), 0, 8); |
83 | 76 | } |
@@ -85,8 +78,7 @@ discard block |
||
85 | 78 | /** |
86 | 79 | * @return self |
87 | 80 | */ |
88 | - public function incrementCounter() |
|
89 | - { |
|
81 | + public function incrementCounter() { |
|
90 | 82 | ++$this->counter; |
91 | 83 | return $this; |
92 | 84 | } |
@@ -94,8 +86,7 @@ discard block |
||
94 | 86 | /** |
95 | 87 | * @return bool |
96 | 88 | */ |
97 | - public function needsRekey() |
|
98 | - { |
|
89 | + public function needsRekey() { |
|
99 | 90 | return ($this->counter & 0xffff) === 0; |
100 | 91 | } |
101 | 92 | |
@@ -103,8 +94,7 @@ discard block |
||
103 | 94 | * @param string $newKeyAndNonce |
104 | 95 | * @return self |
105 | 96 | */ |
106 | - public function rekey($newKeyAndNonce) |
|
107 | - { |
|
97 | + public function rekey($newKeyAndNonce) { |
|
108 | 98 | $this->key = ParagonIE_Sodium_Core32_Util::substr($newKeyAndNonce, 0, 32); |
109 | 99 | $this->nonce = str_pad( |
110 | 100 | ParagonIE_Sodium_Core32_Util::substr($newKeyAndNonce, 32), |
@@ -119,8 +109,7 @@ discard block |
||
119 | 109 | * @param string $str |
120 | 110 | * @return self |
121 | 111 | */ |
122 | - public function xorNonce($str) |
|
123 | - { |
|
112 | + public function xorNonce($str) { |
|
124 | 113 | $this->nonce = ParagonIE_Sodium_Core32_Util::xorStrings( |
125 | 114 | $this->getNonce(), |
126 | 115 | str_pad( |
@@ -137,8 +126,7 @@ discard block |
||
137 | 126 | * @param string $string |
138 | 127 | * @return self |
139 | 128 | */ |
140 | - public static function fromString($string) |
|
141 | - { |
|
129 | + public static function fromString($string) { |
|
142 | 130 | $state = new ParagonIE_Sodium_Core32_SecretStream_State( |
143 | 131 | ParagonIE_Sodium_Core32_Util::substr($string, 0, 32) |
144 | 132 | ); |
@@ -153,8 +141,7 @@ discard block |
||
153 | 141 | /** |
154 | 142 | * @return string |
155 | 143 | */ |
156 | - public function toString() |
|
157 | - { |
|
144 | + public function toString() { |
|
158 | 145 | return $this->key . |
159 | 146 | $this->getCounter() . |
160 | 147 | $this->nonce . |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | * These are immutable. It always returns a new instance. |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core32_Int64 |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core32_Int64 { |
|
12 | 11 | /** |
13 | 12 | * @var array<int, int> - four 16-bit integers |
14 | 13 | */ |
@@ -29,8 +28,7 @@ discard block |
||
29 | 28 | * @param array $array |
30 | 29 | * @param bool $unsignedInt |
31 | 30 | */ |
32 | - public function __construct($array = array(0, 0, 0, 0), $unsignedInt = false) |
|
33 | - { |
|
31 | + public function __construct($array = array(0, 0, 0, 0), $unsignedInt = false) { |
|
34 | 32 | $this->limbs = array( |
35 | 33 | (int) $array[0], |
36 | 34 | (int) $array[1], |
@@ -47,8 +45,7 @@ discard block |
||
47 | 45 | * @param ParagonIE_Sodium_Core32_Int64 $addend |
48 | 46 | * @return ParagonIE_Sodium_Core32_Int64 |
49 | 47 | */ |
50 | - public function addInt64(ParagonIE_Sodium_Core32_Int64 $addend) |
|
51 | - { |
|
48 | + public function addInt64(ParagonIE_Sodium_Core32_Int64 $addend) { |
|
52 | 49 | $i0 = $this->limbs[0]; |
53 | 50 | $i1 = $this->limbs[1]; |
54 | 51 | $i2 = $this->limbs[2]; |
@@ -91,8 +88,7 @@ discard block |
||
91 | 88 | * @throws SodiumException |
92 | 89 | * @throws TypeError |
93 | 90 | */ |
94 | - public function addInt($int) |
|
95 | - { |
|
91 | + public function addInt($int) { |
|
96 | 92 | ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1); |
97 | 93 | /** @var int $int */ |
98 | 94 | $int = (int) $int; |
@@ -130,8 +126,7 @@ discard block |
||
130 | 126 | * @param int $b |
131 | 127 | * @return int |
132 | 128 | */ |
133 | - public function compareInt($b = 0) |
|
134 | - { |
|
129 | + public function compareInt($b = 0) { |
|
135 | 130 | $gt = 0; |
136 | 131 | $eq = 1; |
137 | 132 | |
@@ -155,8 +150,7 @@ discard block |
||
155 | 150 | * @param int $b |
156 | 151 | * @return bool |
157 | 152 | */ |
158 | - public function isGreaterThan($b = 0) |
|
159 | - { |
|
153 | + public function isGreaterThan($b = 0) { |
|
160 | 154 | return $this->compareInt($b) > 0; |
161 | 155 | } |
162 | 156 | |
@@ -164,8 +158,7 @@ discard block |
||
164 | 158 | * @param int $b |
165 | 159 | * @return bool |
166 | 160 | */ |
167 | - public function isLessThanInt($b = 0) |
|
168 | - { |
|
161 | + public function isLessThanInt($b = 0) { |
|
169 | 162 | return $this->compareInt($b) < 0; |
170 | 163 | } |
171 | 164 | |
@@ -174,8 +167,7 @@ discard block |
||
174 | 167 | * @param int $lo |
175 | 168 | * @return ParagonIE_Sodium_Core32_Int64 |
176 | 169 | */ |
177 | - public function mask64($hi = 0, $lo = 0) |
|
178 | - { |
|
170 | + public function mask64($hi = 0, $lo = 0) { |
|
179 | 171 | /** @var int $a */ |
180 | 172 | $a = ($hi >> 16) & 0xffff; |
181 | 173 | /** @var int $b */ |
@@ -203,8 +195,7 @@ discard block |
||
203 | 195 | * @throws TypeError |
204 | 196 | * @psalm-suppress MixedAssignment |
205 | 197 | */ |
206 | - public function mulInt($int = 0, $size = 0) |
|
207 | - { |
|
198 | + public function mulInt($int = 0, $size = 0) { |
|
208 | 199 | if (ParagonIE_Sodium_Compat::$fastMult) { |
209 | 200 | return $this->mulIntFast($int); |
210 | 201 | } |
@@ -326,8 +317,7 @@ discard block |
||
326 | 317 | * @param int $baseLog2 |
327 | 318 | * @return array<int, int> |
328 | 319 | */ |
329 | - public function multiplyLong(array $a, array $b, $baseLog2 = 16) |
|
330 | - { |
|
320 | + public function multiplyLong(array $a, array $b, $baseLog2 = 16) { |
|
331 | 321 | $a_l = count($a); |
332 | 322 | $b_l = count($b); |
333 | 323 | /** @var array<int, int> $r */ |
@@ -350,8 +340,7 @@ discard block |
||
350 | 340 | * @param int $int |
351 | 341 | * @return ParagonIE_Sodium_Core32_Int64 |
352 | 342 | */ |
353 | - public function mulIntFast($int) |
|
354 | - { |
|
343 | + public function mulIntFast($int) { |
|
355 | 344 | // Handle negative numbers |
356 | 345 | $aNeg = ($this->limbs[0] >> 15) & 1; |
357 | 346 | $bNeg = ($int >> 31) & 1; |
@@ -410,8 +399,7 @@ discard block |
||
410 | 399 | * @param ParagonIE_Sodium_Core32_Int64 $right |
411 | 400 | * @return ParagonIE_Sodium_Core32_Int64 |
412 | 401 | */ |
413 | - public function mulInt64Fast(ParagonIE_Sodium_Core32_Int64 $right) |
|
414 | - { |
|
402 | + public function mulInt64Fast(ParagonIE_Sodium_Core32_Int64 $right) { |
|
415 | 403 | $aNeg = ($this->limbs[0] >> 15) & 1; |
416 | 404 | $bNeg = ($right->limbs[0] >> 15) & 1; |
417 | 405 | |
@@ -464,8 +452,7 @@ discard block |
||
464 | 452 | * @throws TypeError |
465 | 453 | * @psalm-suppress MixedAssignment |
466 | 454 | */ |
467 | - public function mulInt64(ParagonIE_Sodium_Core32_Int64 $int, $size = 0) |
|
468 | - { |
|
455 | + public function mulInt64(ParagonIE_Sodium_Core32_Int64 $int, $size = 0) { |
|
469 | 456 | if (ParagonIE_Sodium_Compat::$fastMult) { |
470 | 457 | return $this->mulInt64Fast($int); |
471 | 458 | } |
@@ -558,8 +545,7 @@ discard block |
||
558 | 545 | * @param ParagonIE_Sodium_Core32_Int64 $b |
559 | 546 | * @return ParagonIE_Sodium_Core32_Int64 |
560 | 547 | */ |
561 | - public function orInt64(ParagonIE_Sodium_Core32_Int64 $b) |
|
562 | - { |
|
548 | + public function orInt64(ParagonIE_Sodium_Core32_Int64 $b) { |
|
563 | 549 | $return = new ParagonIE_Sodium_Core32_Int64(); |
564 | 550 | $return->unsignedInt = $this->unsignedInt; |
565 | 551 | $return->limbs = array( |
@@ -578,8 +564,7 @@ discard block |
||
578 | 564 | * @throws TypeError |
579 | 565 | * @psalm-suppress MixedArrayAccess |
580 | 566 | */ |
581 | - public function rotateLeft($c = 0) |
|
582 | - { |
|
567 | + public function rotateLeft($c = 0) { |
|
583 | 568 | ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1); |
584 | 569 | /** @var int $c */ |
585 | 570 | $c = (int) $c; |
@@ -628,8 +613,7 @@ discard block |
||
628 | 613 | * @throws TypeError |
629 | 614 | * @psalm-suppress MixedArrayAccess |
630 | 615 | */ |
631 | - public function rotateRight($c = 0) |
|
632 | - { |
|
616 | + public function rotateRight($c = 0) { |
|
633 | 617 | ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1); |
634 | 618 | /** @var int $c */ |
635 | 619 | $c = (int) $c; |
@@ -676,8 +660,7 @@ discard block |
||
676 | 660 | * @throws SodiumException |
677 | 661 | * @throws TypeError |
678 | 662 | */ |
679 | - public function shiftLeft($c = 0) |
|
680 | - { |
|
663 | + public function shiftLeft($c = 0) { |
|
681 | 664 | ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1); |
682 | 665 | /** @var int $c */ |
683 | 666 | $c = (int) $c; |
@@ -730,8 +713,7 @@ discard block |
||
730 | 713 | * @throws SodiumException |
731 | 714 | * @throws TypeError |
732 | 715 | */ |
733 | - public function shiftRight($c = 0) |
|
734 | - { |
|
716 | + public function shiftRight($c = 0) { |
|
735 | 717 | ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1); |
736 | 718 | $c = (int) $c; |
737 | 719 | /** @var int $c */ |
@@ -796,8 +778,7 @@ discard block |
||
796 | 778 | * @throws SodiumException |
797 | 779 | * @throws TypeError |
798 | 780 | */ |
799 | - public function subInt($int) |
|
800 | - { |
|
781 | + public function subInt($int) { |
|
801 | 782 | ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1); |
802 | 783 | $int = (int) $int; |
803 | 784 | |
@@ -822,8 +803,7 @@ discard block |
||
822 | 803 | * @param ParagonIE_Sodium_Core32_Int64 $b |
823 | 804 | * @return ParagonIE_Sodium_Core32_Int64 |
824 | 805 | */ |
825 | - public function subInt64(ParagonIE_Sodium_Core32_Int64 $b) |
|
826 | - { |
|
806 | + public function subInt64(ParagonIE_Sodium_Core32_Int64 $b) { |
|
827 | 807 | $return = new ParagonIE_Sodium_Core32_Int64(); |
828 | 808 | $return->unsignedInt = $this->unsignedInt; |
829 | 809 | /** @var int $carry */ |
@@ -844,8 +824,7 @@ discard block |
||
844 | 824 | * @param ParagonIE_Sodium_Core32_Int64 $b |
845 | 825 | * @return ParagonIE_Sodium_Core32_Int64 |
846 | 826 | */ |
847 | - public function xorInt64(ParagonIE_Sodium_Core32_Int64 $b) |
|
848 | - { |
|
827 | + public function xorInt64(ParagonIE_Sodium_Core32_Int64 $b) { |
|
849 | 828 | $return = new ParagonIE_Sodium_Core32_Int64(); |
850 | 829 | $return->unsignedInt = $this->unsignedInt; |
851 | 830 | $return->limbs = array( |
@@ -864,8 +843,7 @@ discard block |
||
864 | 843 | * @throws SodiumException |
865 | 844 | * @throws TypeError |
866 | 845 | */ |
867 | - public static function fromInts($low, $high) |
|
868 | - { |
|
846 | + public static function fromInts($low, $high) { |
|
869 | 847 | ParagonIE_Sodium_Core32_Util::declareScalarType($low, 'int', 1); |
870 | 848 | ParagonIE_Sodium_Core32_Util::declareScalarType($high, 'int', 2); |
871 | 849 | |
@@ -887,8 +865,7 @@ discard block |
||
887 | 865 | * @throws SodiumException |
888 | 866 | * @throws TypeError |
889 | 867 | */ |
890 | - public static function fromInt($low) |
|
891 | - { |
|
868 | + public static function fromInt($low) { |
|
892 | 869 | ParagonIE_Sodium_Core32_Util::declareScalarType($low, 'int', 1); |
893 | 870 | $low = (int) $low; |
894 | 871 | |
@@ -905,8 +882,7 @@ discard block |
||
905 | 882 | /** |
906 | 883 | * @return int |
907 | 884 | */ |
908 | - public function toInt() |
|
909 | - { |
|
885 | + public function toInt() { |
|
910 | 886 | return (int) ( |
911 | 887 | (($this->limbs[2] & 0xffff) << 16) |
912 | 888 | | |
@@ -920,8 +896,7 @@ discard block |
||
920 | 896 | * @throws SodiumException |
921 | 897 | * @throws TypeError |
922 | 898 | */ |
923 | - public static function fromString($string) |
|
924 | - { |
|
899 | + public static function fromString($string) { |
|
925 | 900 | ParagonIE_Sodium_Core32_Util::declareScalarType($string, 'string', 1); |
926 | 901 | $string = (string) $string; |
927 | 902 | if (ParagonIE_Sodium_Core32_Util::strlen($string) !== 8) { |
@@ -948,8 +923,7 @@ discard block |
||
948 | 923 | * @throws SodiumException |
949 | 924 | * @throws TypeError |
950 | 925 | */ |
951 | - public static function fromReverseString($string) |
|
952 | - { |
|
926 | + public static function fromReverseString($string) { |
|
953 | 927 | ParagonIE_Sodium_Core32_Util::declareScalarType($string, 'string', 1); |
954 | 928 | $string = (string) $string; |
955 | 929 | if (ParagonIE_Sodium_Core32_Util::strlen($string) !== 8) { |
@@ -973,8 +947,7 @@ discard block |
||
973 | 947 | /** |
974 | 948 | * @return array<int, int> |
975 | 949 | */ |
976 | - public function toArray() |
|
977 | - { |
|
950 | + public function toArray() { |
|
978 | 951 | return array( |
979 | 952 | (int) ((($this->limbs[0] & 0xffff) << 16) | ($this->limbs[1] & 0xffff)), |
980 | 953 | (int) ((($this->limbs[2] & 0xffff) << 16) | ($this->limbs[3] & 0xffff)) |
@@ -984,8 +957,7 @@ discard block |
||
984 | 957 | /** |
985 | 958 | * @return ParagonIE_Sodium_Core32_Int32 |
986 | 959 | */ |
987 | - public function toInt32() |
|
988 | - { |
|
960 | + public function toInt32() { |
|
989 | 961 | $return = new ParagonIE_Sodium_Core32_Int32(); |
990 | 962 | $return->limbs[0] = (int) ($this->limbs[2]); |
991 | 963 | $return->limbs[1] = (int) ($this->limbs[3]); |
@@ -997,8 +969,7 @@ discard block |
||
997 | 969 | /** |
998 | 970 | * @return ParagonIE_Sodium_Core32_Int64 |
999 | 971 | */ |
1000 | - public function toInt64() |
|
1001 | - { |
|
972 | + public function toInt64() { |
|
1002 | 973 | $return = new ParagonIE_Sodium_Core32_Int64(); |
1003 | 974 | $return->limbs[0] = (int) ($this->limbs[0]); |
1004 | 975 | $return->limbs[1] = (int) ($this->limbs[1]); |
@@ -1013,8 +984,7 @@ discard block |
||
1013 | 984 | * @param bool $bool |
1014 | 985 | * @return self |
1015 | 986 | */ |
1016 | - public function setUnsignedInt($bool = false) |
|
1017 | - { |
|
987 | + public function setUnsignedInt($bool = false) { |
|
1018 | 988 | $this->unsignedInt = !empty($bool); |
1019 | 989 | return $this; |
1020 | 990 | } |
@@ -1023,8 +993,7 @@ discard block |
||
1023 | 993 | * @return string |
1024 | 994 | * @throws TypeError |
1025 | 995 | */ |
1026 | - public function toString() |
|
1027 | - { |
|
996 | + public function toString() { |
|
1028 | 997 | return ParagonIE_Sodium_Core32_Util::intToChr(($this->limbs[0] >> 8) & 0xff) . |
1029 | 998 | ParagonIE_Sodium_Core32_Util::intToChr($this->limbs[0] & 0xff) . |
1030 | 999 | ParagonIE_Sodium_Core32_Util::intToChr(($this->limbs[1] >> 8) & 0xff) . |
@@ -1039,8 +1008,7 @@ discard block |
||
1039 | 1008 | * @return string |
1040 | 1009 | * @throws TypeError |
1041 | 1010 | */ |
1042 | - public function toReverseString() |
|
1043 | - { |
|
1011 | + public function toReverseString() { |
|
1044 | 1012 | return ParagonIE_Sodium_Core32_Util::intToChr($this->limbs[3] & 0xff) . |
1045 | 1013 | ParagonIE_Sodium_Core32_Util::intToChr(($this->limbs[3] >> 8) & 0xff) . |
1046 | 1014 | ParagonIE_Sodium_Core32_Util::intToChr($this->limbs[2] & 0xff) . |
@@ -1054,8 +1022,7 @@ discard block |
||
1054 | 1022 | /** |
1055 | 1023 | * @return string |
1056 | 1024 | */ |
1057 | - public function __toString() |
|
1058 | - { |
|
1025 | + public function __toString() { |
|
1059 | 1026 | try { |
1060 | 1027 | return $this->toString(); |
1061 | 1028 | } catch (TypeError $ex) { |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_Salsa20 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_Salsa20 extends ParagonIE_Sodium_Core32_Util |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_Salsa20 extends ParagonIE_Sodium_Core32_Util { |
|
12 | 11 | const ROUNDS = 20; |
13 | 12 | |
14 | 13 | /** |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | * @throws SodiumException |
24 | 23 | * @throws TypeError |
25 | 24 | */ |
26 | - public static function core_salsa20($in, $k, $c = null) |
|
27 | - { |
|
25 | + public static function core_salsa20($in, $k, $c = null) { |
|
28 | 26 | /** |
29 | 27 | * @var ParagonIE_Sodium_Core32_Int32 $x0 |
30 | 28 | * @var ParagonIE_Sodium_Core32_Int32 $x1 |
@@ -190,8 +188,7 @@ discard block |
||
190 | 188 | * @throws SodiumException |
191 | 189 | * @throws TypeError |
192 | 190 | */ |
193 | - public static function salsa20($len, $nonce, $key) |
|
194 | - { |
|
191 | + public static function salsa20($len, $nonce, $key) { |
|
195 | 192 | if (self::strlen($key) !== 32) { |
196 | 193 | throw new RangeException('Key must be 32 bytes long'); |
197 | 194 | } |
@@ -235,8 +232,7 @@ discard block |
||
235 | 232 | * @throws SodiumException |
236 | 233 | * @throws TypeError |
237 | 234 | */ |
238 | - public static function salsa20_xor_ic($m, $n, $ic, $k) |
|
239 | - { |
|
235 | + public static function salsa20_xor_ic($m, $n, $ic, $k) { |
|
240 | 236 | $mlen = self::strlen($m); |
241 | 237 | if ($mlen < 1) { |
242 | 238 | return ''; |
@@ -292,8 +288,7 @@ discard block |
||
292 | 288 | * @throws SodiumException |
293 | 289 | * @throws TypeError |
294 | 290 | */ |
295 | - public static function salsa20_xor($message, $nonce, $key) |
|
296 | - { |
|
291 | + public static function salsa20_xor($message, $nonce, $key) { |
|
297 | 292 | return self::xorStrings( |
298 | 293 | $message, |
299 | 294 | self::salsa20( |