@@ -7,7 +7,6 @@ |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Util |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_Util extends ParagonIE_Sodium_Core_Util |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_Util extends ParagonIE_Sodium_Core_Util { |
|
12 | 11 | |
13 | 12 | } |
@@ -9,16 +9,14 @@ discard block |
||
9 | 9 | * |
10 | 10 | * Only uses 32-bit arithmetic, while the original SipHash used 64-bit integers |
11 | 11 | */ |
12 | -class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util |
|
13 | -{ |
|
12 | +class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util { |
|
14 | 13 | /** |
15 | 14 | * @internal You should not use this directly from another application |
16 | 15 | * |
17 | 16 | * @param array<int, ParagonIE_Sodium_Core32_Int64> $v |
18 | 17 | * @return array<int, ParagonIE_Sodium_Core32_Int64> |
19 | 18 | */ |
20 | - public static function sipRound(array $v) |
|
21 | - { |
|
19 | + public static function sipRound(array $v) { |
|
22 | 20 | # v0 += v1; |
23 | 21 | $v[0] = $v[0]->addInt64($v[1]); |
24 | 22 | |
@@ -73,8 +71,7 @@ discard block |
||
73 | 71 | * @throws SodiumException |
74 | 72 | * @throws TypeError |
75 | 73 | */ |
76 | - public static function sipHash24($in, $key) |
|
77 | - { |
|
74 | + public static function sipHash24($in, $key) { |
|
78 | 75 | $inlen = self::strlen($in); |
79 | 76 | |
80 | 77 | # /* "somepseudorandomlygeneratedbytes" */ |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core32_X25519 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Curve25519 |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Curve25519 { |
|
12 | 11 | /** |
13 | 12 | * Alters the objects passed to this method in place. |
14 | 13 | * |
@@ -100,8 +99,7 @@ discard block |
||
100 | 99 | * @psalm-suppress MixedAssignment |
101 | 100 | * @psalm-suppress MixedMethodCall |
102 | 101 | */ |
103 | - public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f) |
|
104 | - { |
|
102 | + public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f) { |
|
105 | 103 | /** @var array<int, ParagonIE_Sodium_Core32_Int64> $h */ |
106 | 104 | $h = array(); |
107 | 105 | for ($i = 0; $i < 10; ++$i) { |
@@ -167,8 +165,7 @@ discard block |
||
167 | 165 | * @throws SodiumException |
168 | 166 | * @throws TypeError |
169 | 167 | */ |
170 | - public static function crypto_scalarmult_curve25519_ref10($n, $p) |
|
171 | - { |
|
168 | + public static function crypto_scalarmult_curve25519_ref10($n, $p) { |
|
172 | 169 | # for (i = 0;i < 32;++i) e[i] = n[i]; |
173 | 170 | $e = '' . $n; |
174 | 171 | # e[0] &= 248; |
@@ -315,8 +312,7 @@ discard block |
||
315 | 312 | * @throws SodiumException |
316 | 313 | * @throws TypeError |
317 | 314 | */ |
318 | - public static function crypto_scalarmult_curve25519_ref10_base($n) |
|
319 | - { |
|
315 | + public static function crypto_scalarmult_curve25519_ref10_base($n) { |
|
320 | 316 | # for (i = 0;i < 32;++i) e[i] = n[i]; |
321 | 317 | $e = '' . $n; |
322 | 318 |
@@ -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; |