@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * Based on the work of Devi Mandiri in devi/salt. |
| 11 | 11 | */ |
| 12 | -abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util |
|
| 13 | -{ |
|
| 12 | +abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util { |
|
| 14 | 13 | /** |
| 15 | 14 | * @var SplFixedArray |
| 16 | 15 | */ |
@@ -48,8 +47,7 @@ discard block |
||
| 48 | 47 | * @return SplFixedArray |
| 49 | 48 | * @psalm-suppress MixedAssignment |
| 50 | 49 | */ |
| 51 | - public static function new64($high, $low) |
|
| 52 | - { |
|
| 50 | + public static function new64($high, $low) { |
|
| 53 | 51 | $i64 = new SplFixedArray(2); |
| 54 | 52 | $i64[0] = $high & 0xffffffff; |
| 55 | 53 | $i64[1] = $low & 0xffffffff; |
@@ -65,8 +63,7 @@ discard block |
||
| 65 | 63 | * @param int $num |
| 66 | 64 | * @return SplFixedArray |
| 67 | 65 | */ |
| 68 | - protected static function to64($num) |
|
| 69 | - { |
|
| 66 | + protected static function to64($num) { |
|
| 70 | 67 | list($hi, $lo) = self::numericTo64BitInteger($num); |
| 71 | 68 | return self::new64($hi, $lo); |
| 72 | 69 | } |
@@ -84,8 +81,7 @@ discard block |
||
| 84 | 81 | * @psalm-suppress MixedAssignment |
| 85 | 82 | * @psalm-suppress MixedOperand |
| 86 | 83 | */ |
| 87 | - protected static function add64($x, $y) |
|
| 88 | - { |
|
| 84 | + protected static function add64($x, $y) { |
|
| 89 | 85 | $l = ($x[1] + $y[1]) & 0xffffffff; |
| 90 | 86 | return self::new64( |
| 91 | 87 | (int) ($x[0] + $y[0] + ( |
@@ -103,8 +99,7 @@ discard block |
||
| 103 | 99 | * @param SplFixedArray $z |
| 104 | 100 | * @return SplFixedArray |
| 105 | 101 | */ |
| 106 | - protected static function add364($x, $y, $z) |
|
| 107 | - { |
|
| 102 | + protected static function add364($x, $y, $z) { |
|
| 108 | 103 | return self::add64($x, self::add64($y, $z)); |
| 109 | 104 | } |
| 110 | 105 | |
@@ -117,8 +112,7 @@ discard block |
||
| 117 | 112 | * @throws SodiumException |
| 118 | 113 | * @throws TypeError |
| 119 | 114 | */ |
| 120 | - protected static function xor64(SplFixedArray $x, SplFixedArray $y) |
|
| 121 | - { |
|
| 115 | + protected static function xor64(SplFixedArray $x, SplFixedArray $y) { |
|
| 122 | 116 | if (!is_numeric($x[0])) { |
| 123 | 117 | throw new SodiumException('x[0] is not an integer'); |
| 124 | 118 | } |
@@ -145,8 +139,7 @@ discard block |
||
| 145 | 139 | * @return SplFixedArray |
| 146 | 140 | * @psalm-suppress MixedAssignment |
| 147 | 141 | */ |
| 148 | - public static function rotr64($x, $c) |
|
| 149 | - { |
|
| 142 | + public static function rotr64($x, $c) { |
|
| 150 | 143 | if ($c >= 64) { |
| 151 | 144 | $c %= 64; |
| 152 | 145 | } |
@@ -203,8 +196,7 @@ discard block |
||
| 203 | 196 | * @return int |
| 204 | 197 | * @psalm-suppress MixedOperand |
| 205 | 198 | */ |
| 206 | - protected static function flatten64($x) |
|
| 207 | - { |
|
| 199 | + protected static function flatten64($x) { |
|
| 208 | 200 | return (int) ($x[0] * 4294967296 + $x[1]); |
| 209 | 201 | } |
| 210 | 202 | |
@@ -217,8 +209,7 @@ discard block |
||
| 217 | 209 | * @psalm-suppress MixedArgument |
| 218 | 210 | * @psalm-suppress MixedArrayOffset |
| 219 | 211 | */ |
| 220 | - protected static function load64(SplFixedArray $x, $i) |
|
| 221 | - { |
|
| 212 | + protected static function load64(SplFixedArray $x, $i) { |
|
| 222 | 213 | /** @var int $l */ |
| 223 | 214 | $l = (int) ($x[$i]) |
| 224 | 215 | | ((int) ($x[$i+1]) << 8) |
@@ -241,8 +232,7 @@ discard block |
||
| 241 | 232 | * @return void |
| 242 | 233 | * @psalm-suppress MixedAssignment |
| 243 | 234 | */ |
| 244 | - protected static function store64(SplFixedArray $x, $i, SplFixedArray $u) |
|
| 245 | - { |
|
| 235 | + protected static function store64(SplFixedArray $x, $i, SplFixedArray $u) { |
|
| 246 | 236 | $maxLength = $x->getSize() - 1; |
| 247 | 237 | for ($j = 0; $j < 8; ++$j) { |
| 248 | 238 | /* |
@@ -268,8 +258,7 @@ discard block |
||
| 268 | 258 | * |
| 269 | 259 | * @return void |
| 270 | 260 | */ |
| 271 | - public static function pseudoConstructor() |
|
| 272 | - { |
|
| 261 | + public static function pseudoConstructor() { |
|
| 273 | 262 | static $called = false; |
| 274 | 263 | if ($called) { |
| 275 | 264 | return; |
@@ -297,8 +286,7 @@ discard block |
||
| 297 | 286 | * @psalm-suppress MixedArrayAccess |
| 298 | 287 | * @psalm-suppress MixedArrayAssignment |
| 299 | 288 | */ |
| 300 | - protected static function context() |
|
| 301 | - { |
|
| 289 | + protected static function context() { |
|
| 302 | 290 | $ctx = new SplFixedArray(6); |
| 303 | 291 | $ctx[0] = new SplFixedArray(8); // h |
| 304 | 292 | $ctx[1] = new SplFixedArray(2); // t |
@@ -337,8 +325,7 @@ discard block |
||
| 337 | 325 | * @psalm-suppress MixedArrayAssignment |
| 338 | 326 | * @psalm-suppress MixedArrayOffset |
| 339 | 327 | */ |
| 340 | - protected static function compress(SplFixedArray $ctx, SplFixedArray $buf) |
|
| 341 | - { |
|
| 328 | + protected static function compress(SplFixedArray $ctx, SplFixedArray $buf) { |
|
| 342 | 329 | $m = new SplFixedArray(16); |
| 343 | 330 | $v = new SplFixedArray(16); |
| 344 | 331 | |
@@ -395,8 +382,7 @@ discard block |
||
| 395 | 382 | * @psalm-suppress MixedArgument |
| 396 | 383 | * @psalm-suppress MixedArrayOffset |
| 397 | 384 | */ |
| 398 | - public static function G($r, $i, $a, $b, $c, $d, SplFixedArray $v, SplFixedArray $m) |
|
| 399 | - { |
|
| 385 | + public static function G($r, $i, $a, $b, $c, $d, SplFixedArray $v, SplFixedArray $m) { |
|
| 400 | 386 | $v[$a] = self::add364($v[$a], $v[$b], $m[self::$sigma[$r][$i << 1]]); |
| 401 | 387 | $v[$d] = self::rotr64(self::xor64($v[$d], $v[$a]), 32); |
| 402 | 388 | $v[$c] = self::add64($v[$c], $v[$d]); |
@@ -419,8 +405,7 @@ discard block |
||
| 419 | 405 | * @psalm-suppress MixedArrayAccess |
| 420 | 406 | * @psalm-suppress MixedArrayAssignment |
| 421 | 407 | */ |
| 422 | - public static function increment_counter($ctx, $inc) |
|
| 423 | - { |
|
| 408 | + public static function increment_counter($ctx, $inc) { |
|
| 424 | 409 | if ($inc < 0) { |
| 425 | 410 | throw new SodiumException('Increasing by a negative number makes no sense.'); |
| 426 | 411 | } |
@@ -452,8 +437,7 @@ discard block |
||
| 452 | 437 | * @psalm-suppress MixedArrayOffset |
| 453 | 438 | * @psalm-suppress MixedOperand |
| 454 | 439 | */ |
| 455 | - public static function update(SplFixedArray $ctx, SplFixedArray $p, $plen) |
|
| 456 | - { |
|
| 440 | + public static function update(SplFixedArray $ctx, SplFixedArray $p, $plen) { |
|
| 457 | 441 | self::pseudoConstructor(); |
| 458 | 442 | |
| 459 | 443 | $offset = 0; |
@@ -515,8 +499,7 @@ discard block |
||
| 515 | 499 | * @psalm-suppress MixedArrayOffset |
| 516 | 500 | * @psalm-suppress MixedOperand |
| 517 | 501 | */ |
| 518 | - public static function finish(SplFixedArray $ctx, SplFixedArray $out) |
|
| 519 | - { |
|
| 502 | + public static function finish(SplFixedArray $ctx, SplFixedArray $out) { |
|
| 520 | 503 | self::pseudoConstructor(); |
| 521 | 504 | if ($ctx[4] > 128) { |
| 522 | 505 | self::increment_counter($ctx, 128); |
@@ -646,8 +629,7 @@ discard block |
||
| 646 | 629 | * @return SplFixedArray |
| 647 | 630 | * @psalm-suppress MixedArgumentTypeCoercion |
| 648 | 631 | */ |
| 649 | - public static function stringToSplFixedArray($str = '') |
|
| 650 | - { |
|
| 632 | + public static function stringToSplFixedArray($str = '') { |
|
| 651 | 633 | $values = unpack('C*', $str); |
| 652 | 634 | return SplFixedArray::fromArray(array_values($values)); |
| 653 | 635 | } |
@@ -661,8 +643,7 @@ discard block |
||
| 661 | 643 | * @return string |
| 662 | 644 | * @throws TypeError |
| 663 | 645 | */ |
| 664 | - public static function SplFixedArrayToString(SplFixedArray $a) |
|
| 665 | - { |
|
| 646 | + public static function SplFixedArrayToString(SplFixedArray $a) { |
|
| 666 | 647 | /** |
| 667 | 648 | * @var array<int, int|string> $arr |
| 668 | 649 | */ |
@@ -685,8 +666,7 @@ discard block |
||
| 685 | 666 | * @psalm-suppress MixedArrayOffset |
| 686 | 667 | * @psalm-suppress MixedMethodCall |
| 687 | 668 | */ |
| 688 | - public static function contextToString(SplFixedArray $ctx) |
|
| 689 | - { |
|
| 669 | + public static function contextToString(SplFixedArray $ctx) { |
|
| 690 | 670 | $str = ''; |
| 691 | 671 | /** @var array<int, array<int, int>> $ctxA */ |
| 692 | 672 | $ctxA = $ctx[0]->toArray(); |
@@ -740,8 +720,7 @@ discard block |
||
| 740 | 720 | * @throws TypeError |
| 741 | 721 | * @psalm-suppress MixedArrayAssignment |
| 742 | 722 | */ |
| 743 | - public static function stringToContext($string) |
|
| 744 | - { |
|
| 723 | + public static function stringToContext($string) { |
|
| 745 | 724 | $ctx = self::context(); |
| 746 | 725 | |
| 747 | 726 | # uint64_t h[8]; |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * Class ParagonIE_Sodium_Core_Ed25519 |
| 9 | 9 | */ |
| 10 | -abstract class ParagonIE_Sodium_Core_Ed25519 extends ParagonIE_Sodium_Core_Curve25519 |
|
| 11 | -{ |
|
| 10 | +abstract class ParagonIE_Sodium_Core_Ed25519 extends ParagonIE_Sodium_Core_Curve25519 { |
|
| 12 | 11 | const KEYPAIR_BYTES = 96; |
| 13 | 12 | const SEED_BYTES = 32; |
| 14 | 13 | const SCALAR_BYTES = 32; |
@@ -21,8 +20,7 @@ discard block |
||
| 21 | 20 | * @throws SodiumException |
| 22 | 21 | * @throws TypeError |
| 23 | 22 | */ |
| 24 | - public static function keypair() |
|
| 25 | - { |
|
| 23 | + public static function keypair() { |
|
| 26 | 24 | $seed = random_bytes(self::SEED_BYTES); |
| 27 | 25 | $pk = ''; |
| 28 | 26 | $sk = ''; |
@@ -40,8 +38,7 @@ discard block |
||
| 40 | 38 | * @throws SodiumException |
| 41 | 39 | * @throws TypeError |
| 42 | 40 | */ |
| 43 | - public static function seed_keypair(&$pk, &$sk, $seed) |
|
| 44 | - { |
|
| 41 | + public static function seed_keypair(&$pk, &$sk, $seed) { |
|
| 45 | 42 | if (self::strlen($seed) !== self::SEED_BYTES) { |
| 46 | 43 | throw new RangeException('crypto_sign keypair seed must be 32 bytes long'); |
| 47 | 44 | } |
@@ -59,8 +56,7 @@ discard block |
||
| 59 | 56 | * @return string |
| 60 | 57 | * @throws TypeError |
| 61 | 58 | */ |
| 62 | - public static function secretkey($keypair) |
|
| 63 | - { |
|
| 59 | + public static function secretkey($keypair) { |
|
| 64 | 60 | if (self::strlen($keypair) !== self::KEYPAIR_BYTES) { |
| 65 | 61 | throw new RangeException('crypto_sign keypair must be 96 bytes long'); |
| 66 | 62 | } |
@@ -74,8 +70,7 @@ discard block |
||
| 74 | 70 | * @return string |
| 75 | 71 | * @throws TypeError |
| 76 | 72 | */ |
| 77 | - public static function publickey($keypair) |
|
| 78 | - { |
|
| 73 | + public static function publickey($keypair) { |
|
| 79 | 74 | if (self::strlen($keypair) !== self::KEYPAIR_BYTES) { |
| 80 | 75 | throw new RangeException('crypto_sign keypair must be 96 bytes long'); |
| 81 | 76 | } |
@@ -90,8 +85,7 @@ discard block |
||
| 90 | 85 | * @throws SodiumException |
| 91 | 86 | * @throws TypeError |
| 92 | 87 | */ |
| 93 | - public static function publickey_from_secretkey($sk) |
|
| 94 | - { |
|
| 88 | + public static function publickey_from_secretkey($sk) { |
|
| 95 | 89 | /** @var string $sk */ |
| 96 | 90 | $sk = hash('sha512', self::substr($sk, 0, 32), true); |
| 97 | 91 | $sk[0] = self::intToChr( |
@@ -109,8 +103,7 @@ discard block |
||
| 109 | 103 | * @throws SodiumException |
| 110 | 104 | * @throws TypeError |
| 111 | 105 | */ |
| 112 | - public static function pk_to_curve25519($pk) |
|
| 113 | - { |
|
| 106 | + public static function pk_to_curve25519($pk) { |
|
| 114 | 107 | if (self::small_order($pk)) { |
| 115 | 108 | throw new SodiumException('Public key is on a small order'); |
| 116 | 109 | } |
@@ -150,8 +143,7 @@ discard block |
||
| 150 | 143 | * @throws SodiumException |
| 151 | 144 | * @throws TypeError |
| 152 | 145 | */ |
| 153 | - public static function sk_to_pk($sk) |
|
| 154 | - { |
|
| 146 | + public static function sk_to_pk($sk) { |
|
| 155 | 147 | return self::ge_p3_tobytes( |
| 156 | 148 | self::ge_scalarmult_base( |
| 157 | 149 | self::substr($sk, 0, 32) |
@@ -168,8 +160,7 @@ discard block |
||
| 168 | 160 | * @throws SodiumException |
| 169 | 161 | * @throws TypeError |
| 170 | 162 | */ |
| 171 | - public static function sign($message, $sk) |
|
| 172 | - { |
|
| 163 | + public static function sign($message, $sk) { |
|
| 173 | 164 | /** @var string $signature */ |
| 174 | 165 | $signature = self::sign_detached($message, $sk); |
| 175 | 166 | return $signature . $message; |
@@ -184,8 +175,7 @@ discard block |
||
| 184 | 175 | * @throws SodiumException |
| 185 | 176 | * @throws TypeError |
| 186 | 177 | */ |
| 187 | - public static function sign_open($message, $pk) |
|
| 188 | - { |
|
| 178 | + public static function sign_open($message, $pk) { |
|
| 189 | 179 | /** @var string $signature */ |
| 190 | 180 | $signature = self::substr($message, 0, 64); |
| 191 | 181 | |
@@ -207,8 +197,7 @@ discard block |
||
| 207 | 197 | * @throws SodiumException |
| 208 | 198 | * @throws TypeError |
| 209 | 199 | */ |
| 210 | - public static function sign_detached($message, $sk) |
|
| 211 | - { |
|
| 200 | + public static function sign_detached($message, $sk) { |
|
| 212 | 201 | # crypto_hash_sha512(az, sk, 32); |
| 213 | 202 | $az = hash('sha512', self::substr($sk, 0, 32), true); |
| 214 | 203 | |
@@ -272,8 +261,7 @@ discard block |
||
| 272 | 261 | * @throws SodiumException |
| 273 | 262 | * @throws TypeError |
| 274 | 263 | */ |
| 275 | - public static function verify_detached($sig, $message, $pk) |
|
| 276 | - { |
|
| 264 | + public static function verify_detached($sig, $message, $pk) { |
|
| 277 | 265 | if (self::strlen($sig) < 64) { |
| 278 | 266 | throw new SodiumException('Signature is too short'); |
| 279 | 267 | } |
@@ -339,8 +327,7 @@ discard block |
||
| 339 | 327 | * @throws SodiumException |
| 340 | 328 | * @throws TypeError |
| 341 | 329 | */ |
| 342 | - public static function check_S_lt_L($S) |
|
| 343 | - { |
|
| 330 | + public static function check_S_lt_L($S) { |
|
| 344 | 331 | if (self::strlen($S) < 32) { |
| 345 | 332 | throw new SodiumException('Signature must be 32 bytes'); |
| 346 | 333 | } |
@@ -375,8 +362,7 @@ discard block |
||
| 375 | 362 | * @throws SodiumException |
| 376 | 363 | * @throws TypeError |
| 377 | 364 | */ |
| 378 | - public static function small_order($R) |
|
| 379 | - { |
|
| 365 | + public static function small_order($R) { |
|
| 380 | 366 | /** @var array<int, array<int, int>> $blocklist */ |
| 381 | 367 | $blocklist = array( |
| 382 | 368 | /* 0 (order 4) */ |
@@ -484,8 +470,7 @@ discard block |
||
| 484 | 470 | * @return string |
| 485 | 471 | * @throws SodiumException |
| 486 | 472 | */ |
| 487 | - public static function scalar_complement($s) |
|
| 488 | - { |
|
| 473 | + public static function scalar_complement($s) { |
|
| 489 | 474 | $t_ = self::L . str_repeat("\x00", 32); |
| 490 | 475 | sodium_increment($t_); |
| 491 | 476 | $s_ = $s . str_repeat("\x00", 32); |
@@ -497,8 +482,7 @@ discard block |
||
| 497 | 482 | * @return string |
| 498 | 483 | * @throws SodiumException |
| 499 | 484 | */ |
| 500 | - public static function scalar_random() |
|
| 501 | - { |
|
| 485 | + public static function scalar_random() { |
|
| 502 | 486 | do { |
| 503 | 487 | $r = ParagonIE_Sodium_Compat::randombytes_buf(self::SCALAR_BYTES); |
| 504 | 488 | $r[self::SCALAR_BYTES - 1] = self::intToChr( |
@@ -515,8 +499,7 @@ discard block |
||
| 515 | 499 | * @return string |
| 516 | 500 | * @throws SodiumException |
| 517 | 501 | */ |
| 518 | - public static function scalar_negate($s) |
|
| 519 | - { |
|
| 502 | + public static function scalar_negate($s) { |
|
| 520 | 503 | $t_ = self::L . str_repeat("\x00", 32) ; |
| 521 | 504 | $s_ = $s . str_repeat("\x00", 32) ; |
| 522 | 505 | ParagonIE_Sodium_Compat::sub($t_, $s_); |
@@ -529,8 +512,7 @@ discard block |
||
| 529 | 512 | * @return string |
| 530 | 513 | * @throws SodiumException |
| 531 | 514 | */ |
| 532 | - public static function scalar_add($a, $b) |
|
| 533 | - { |
|
| 515 | + public static function scalar_add($a, $b) { |
|
| 534 | 516 | $a_ = $a . str_repeat("\x00", 32); |
| 535 | 517 | $b_ = $b . str_repeat("\x00", 32); |
| 536 | 518 | ParagonIE_Sodium_Compat::add($a_, $b_); |
@@ -543,8 +525,7 @@ discard block |
||
| 543 | 525 | * @return string |
| 544 | 526 | * @throws SodiumException |
| 545 | 527 | */ |
| 546 | - public static function scalar_sub($x, $y) |
|
| 547 | - { |
|
| 528 | + public static function scalar_sub($x, $y) { |
|
| 548 | 529 | $yn = self::scalar_negate($y); |
| 549 | 530 | return self::scalar_add($x, $yn); |
| 550 | 531 | } |
@@ -7,15 +7,13 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * Class ParagonIE_Sodium_Core_Util |
| 9 | 9 | */ |
| 10 | -abstract class ParagonIE_Sodium_Core_Util |
|
| 11 | -{ |
|
| 10 | +abstract class ParagonIE_Sodium_Core_Util { |
|
| 12 | 11 | /** |
| 13 | 12 | * @param int $integer |
| 14 | 13 | * @param int $size (16, 32, 64) |
| 15 | 14 | * @return int |
| 16 | 15 | */ |
| 17 | - public static function abs($integer, $size = 0) |
|
| 18 | - { |
|
| 16 | + public static function abs($integer, $size = 0) { |
|
| 19 | 17 | /** @var int $realSize */ |
| 20 | 18 | $realSize = (PHP_INT_SIZE << 3) - 1; |
| 21 | 19 | if ($size) { |
@@ -43,8 +41,7 @@ discard block |
||
| 43 | 41 | * @return string |
| 44 | 42 | * @throws TypeError |
| 45 | 43 | */ |
| 46 | - public static function bin2hex($binaryString) |
|
| 47 | - { |
|
| 44 | + public static function bin2hex($binaryString) { |
|
| 48 | 45 | /* Type checks: */ |
| 49 | 46 | if (!is_string($binaryString)) { |
| 50 | 47 | throw new TypeError('Argument 1 must be a string, ' . gettype($binaryString) . ' given.'); |
@@ -78,8 +75,7 @@ discard block |
||
| 78 | 75 | * @return string |
| 79 | 76 | * @throws TypeError |
| 80 | 77 | */ |
| 81 | - public static function bin2hexUpper($bin_string) |
|
| 82 | - { |
|
| 78 | + public static function bin2hexUpper($bin_string) { |
|
| 83 | 79 | $hex = ''; |
| 84 | 80 | $len = self::strlen($bin_string); |
| 85 | 81 | for ($i = 0; $i < $len; ++$i) { |
@@ -123,8 +119,7 @@ discard block |
||
| 123 | 119 | * @throws SodiumException |
| 124 | 120 | * @throws TypeError |
| 125 | 121 | */ |
| 126 | - public static function chrToInt($chr) |
|
| 127 | - { |
|
| 122 | + public static function chrToInt($chr) { |
|
| 128 | 123 | /* Type checks: */ |
| 129 | 124 | if (!is_string($chr)) { |
| 130 | 125 | throw new TypeError('Argument 1 must be a string, ' . gettype($chr) . ' given.'); |
@@ -149,8 +144,7 @@ discard block |
||
| 149 | 144 | * @throws SodiumException |
| 150 | 145 | * @throws TypeError |
| 151 | 146 | */ |
| 152 | - public static function compare($left, $right, $len = null) |
|
| 153 | - { |
|
| 147 | + public static function compare($left, $right, $len = null) { |
|
| 154 | 148 | $leftLen = self::strlen($left); |
| 155 | 149 | $rightLen = self::strlen($right); |
| 156 | 150 | if ($len === null) { |
@@ -180,8 +174,7 @@ discard block |
||
| 180 | 174 | * @throws SodiumException |
| 181 | 175 | * @return void |
| 182 | 176 | */ |
| 183 | - public static function declareScalarType(&$mixedVar = null, $type = 'void', $argumentIndex = 0) |
|
| 184 | - { |
|
| 177 | + public static function declareScalarType(&$mixedVar = null, $type = 'void', $argumentIndex = 0) { |
|
| 185 | 178 | if (func_num_args() === 0) { |
| 186 | 179 | /* Tautology, by default */ |
| 187 | 180 | return; |
@@ -257,8 +250,7 @@ discard block |
||
| 257 | 250 | * @throws SodiumException |
| 258 | 251 | * @throws TypeError |
| 259 | 252 | */ |
| 260 | - public static function hashEquals($left, $right) |
|
| 261 | - { |
|
| 253 | + public static function hashEquals($left, $right) { |
|
| 262 | 254 | /* Type checks: */ |
| 263 | 255 | if (!is_string($left)) { |
| 264 | 256 | throw new TypeError('Argument 1 must be a string, ' . gettype($left) . ' given.'); |
@@ -295,8 +287,7 @@ discard block |
||
| 295 | 287 | * @throws SodiumException |
| 296 | 288 | * @psalm-suppress PossiblyInvalidArgument |
| 297 | 289 | */ |
| 298 | - protected static function hash_update(&$hs, $data) |
|
| 299 | - { |
|
| 290 | + protected static function hash_update(&$hs, $data) { |
|
| 300 | 291 | if (!hash_update($hs, $data)) { |
| 301 | 292 | throw new SodiumException('hash_update() failed'); |
| 302 | 293 | } |
@@ -314,8 +305,7 @@ discard block |
||
| 314 | 305 | * @throws RangeException |
| 315 | 306 | * @throws TypeError |
| 316 | 307 | */ |
| 317 | - public static function hex2bin($hexString, $strictPadding = false) |
|
| 318 | - { |
|
| 308 | + public static function hex2bin($hexString, $strictPadding = false) { |
|
| 319 | 309 | /* Type checks: */ |
| 320 | 310 | if (!is_string($hexString)) { |
| 321 | 311 | throw new TypeError('Argument 1 must be a string, ' . gettype($hexString) . ' given.'); |
@@ -380,8 +370,7 @@ discard block |
||
| 380 | 370 | * @param array<int, int> $ints |
| 381 | 371 | * @return string |
| 382 | 372 | */ |
| 383 | - public static function intArrayToString(array $ints) |
|
| 384 | - { |
|
| 373 | + public static function intArrayToString(array $ints) { |
|
| 385 | 374 | /** @var array<int, int> $args */ |
| 386 | 375 | $args = $ints; |
| 387 | 376 | foreach ($args as $i => $v) { |
@@ -400,8 +389,7 @@ discard block |
||
| 400 | 389 | * @return string |
| 401 | 390 | * @throws TypeError |
| 402 | 391 | */ |
| 403 | - public static function intToChr($int) |
|
| 404 | - { |
|
| 392 | + public static function intToChr($int) { |
|
| 405 | 393 | return pack('C', $int); |
| 406 | 394 | } |
| 407 | 395 | |
@@ -415,8 +403,7 @@ discard block |
||
| 415 | 403 | * @throws RangeException |
| 416 | 404 | * @throws TypeError |
| 417 | 405 | */ |
| 418 | - public static function load_3($string) |
|
| 419 | - { |
|
| 406 | + public static function load_3($string) { |
|
| 420 | 407 | /* Type checks: */ |
| 421 | 408 | if (!is_string($string)) { |
| 422 | 409 | throw new TypeError('Argument 1 must be a string, ' . gettype($string) . ' given.'); |
@@ -443,8 +430,7 @@ discard block |
||
| 443 | 430 | * @throws RangeException |
| 444 | 431 | * @throws TypeError |
| 445 | 432 | */ |
| 446 | - public static function load_4($string) |
|
| 447 | - { |
|
| 433 | + public static function load_4($string) { |
|
| 448 | 434 | /* Type checks: */ |
| 449 | 435 | if (!is_string($string)) { |
| 450 | 436 | throw new TypeError('Argument 1 must be a string, ' . gettype($string) . ' given.'); |
@@ -472,8 +458,7 @@ discard block |
||
| 472 | 458 | * @throws SodiumException |
| 473 | 459 | * @throws TypeError |
| 474 | 460 | */ |
| 475 | - public static function load64_le($string) |
|
| 476 | - { |
|
| 461 | + public static function load64_le($string) { |
|
| 477 | 462 | /* Type checks: */ |
| 478 | 463 | if (!is_string($string)) { |
| 479 | 464 | throw new TypeError('Argument 1 must be a string, ' . gettype($string) . ' given.'); |
@@ -512,8 +497,7 @@ discard block |
||
| 512 | 497 | * @throws SodiumException |
| 513 | 498 | * @throws TypeError |
| 514 | 499 | */ |
| 515 | - public static function memcmp($left, $right) |
|
| 516 | - { |
|
| 500 | + public static function memcmp($left, $right) { |
|
| 517 | 501 | if (self::hashEquals($left, $right)) { |
| 518 | 502 | return 0; |
| 519 | 503 | } |
@@ -537,8 +521,7 @@ discard block |
||
| 537 | 521 | * constant operands) |
| 538 | 522 | * @return int |
| 539 | 523 | */ |
| 540 | - public static function mul($a, $b, $size = 0) |
|
| 541 | - { |
|
| 524 | + public static function mul($a, $b, $size = 0) { |
|
| 542 | 525 | if (ParagonIE_Sodium_Compat::$fastMult) { |
| 543 | 526 | return (int) ($a * $b); |
| 544 | 527 | } |
@@ -609,8 +592,7 @@ discard block |
||
| 609 | 592 | * @param int|float $num |
| 610 | 593 | * @return array<int, int> |
| 611 | 594 | */ |
| 612 | - public static function numericTo64BitInteger($num) |
|
| 613 | - { |
|
| 595 | + public static function numericTo64BitInteger($num) { |
|
| 614 | 596 | $high = 0; |
| 615 | 597 | /** @var int $low */ |
| 616 | 598 | $low = $num & 0xffffffff; |
@@ -636,8 +618,7 @@ discard block |
||
| 636 | 618 | * @return string |
| 637 | 619 | * @throws TypeError |
| 638 | 620 | */ |
| 639 | - public static function store_3($int) |
|
| 640 | - { |
|
| 621 | + public static function store_3($int) { |
|
| 641 | 622 | /* Type checks: */ |
| 642 | 623 | if (!is_int($int)) { |
| 643 | 624 | if (is_numeric($int)) { |
@@ -660,8 +641,7 @@ discard block |
||
| 660 | 641 | * @return string |
| 661 | 642 | * @throws TypeError |
| 662 | 643 | */ |
| 663 | - public static function store32_le($int) |
|
| 664 | - { |
|
| 644 | + public static function store32_le($int) { |
|
| 665 | 645 | /* Type checks: */ |
| 666 | 646 | if (!is_int($int)) { |
| 667 | 647 | if (is_numeric($int)) { |
@@ -685,8 +665,7 @@ discard block |
||
| 685 | 665 | * @return string |
| 686 | 666 | * @throws TypeError |
| 687 | 667 | */ |
| 688 | - public static function store_4($int) |
|
| 689 | - { |
|
| 668 | + public static function store_4($int) { |
|
| 690 | 669 | /* Type checks: */ |
| 691 | 670 | if (!is_int($int)) { |
| 692 | 671 | if (is_numeric($int)) { |
@@ -710,8 +689,7 @@ discard block |
||
| 710 | 689 | * @return string |
| 711 | 690 | * @throws TypeError |
| 712 | 691 | */ |
| 713 | - public static function store64_le($int) |
|
| 714 | - { |
|
| 692 | + public static function store64_le($int) { |
|
| 715 | 693 | /* Type checks: */ |
| 716 | 694 | if (!is_int($int)) { |
| 717 | 695 | if (is_numeric($int)) { |
@@ -763,8 +741,7 @@ discard block |
||
| 763 | 741 | * @return int |
| 764 | 742 | * @throws TypeError |
| 765 | 743 | */ |
| 766 | - public static function strlen($str) |
|
| 767 | - { |
|
| 744 | + public static function strlen($str) { |
|
| 768 | 745 | /* Type checks: */ |
| 769 | 746 | if (!is_string($str)) { |
| 770 | 747 | throw new TypeError('String expected'); |
@@ -786,8 +763,7 @@ discard block |
||
| 786 | 763 | * @return array<int, int> |
| 787 | 764 | * @throws TypeError |
| 788 | 765 | */ |
| 789 | - public static function stringToIntArray($string) |
|
| 790 | - { |
|
| 766 | + public static function stringToIntArray($string) { |
|
| 791 | 767 | if (!is_string($string)) { |
| 792 | 768 | throw new TypeError('String expected'); |
| 793 | 769 | } |
@@ -813,8 +789,7 @@ discard block |
||
| 813 | 789 | * @return string |
| 814 | 790 | * @throws TypeError |
| 815 | 791 | */ |
| 816 | - public static function substr($str, $start = 0, $length = null) |
|
| 817 | - { |
|
| 792 | + public static function substr($str, $start = 0, $length = null) { |
|
| 818 | 793 | /* Type checks: */ |
| 819 | 794 | if (!is_string($str)) { |
| 820 | 795 | throw new TypeError('String expected'); |
@@ -851,8 +826,7 @@ discard block |
||
| 851 | 826 | * @throws SodiumException |
| 852 | 827 | * @throws TypeError |
| 853 | 828 | */ |
| 854 | - public static function verify_16($a, $b) |
|
| 855 | - { |
|
| 829 | + public static function verify_16($a, $b) { |
|
| 856 | 830 | /* Type checks: */ |
| 857 | 831 | if (!is_string($a)) { |
| 858 | 832 | throw new TypeError('String expected'); |
@@ -877,8 +851,7 @@ discard block |
||
| 877 | 851 | * @throws SodiumException |
| 878 | 852 | * @throws TypeError |
| 879 | 853 | */ |
| 880 | - public static function verify_32($a, $b) |
|
| 881 | - { |
|
| 854 | + public static function verify_32($a, $b) { |
|
| 882 | 855 | /* Type checks: */ |
| 883 | 856 | if (!is_string($a)) { |
| 884 | 857 | throw new TypeError('String expected'); |
@@ -902,8 +875,7 @@ discard block |
||
| 902 | 875 | * @return string |
| 903 | 876 | * @throws TypeError |
| 904 | 877 | */ |
| 905 | - public static function xorStrings($a, $b) |
|
| 906 | - { |
|
| 878 | + public static function xorStrings($a, $b) { |
|
| 907 | 879 | /* Type checks: */ |
| 908 | 880 | if (!is_string($a)) { |
| 909 | 881 | throw new TypeError('Argument 1 must be a string'); |
@@ -925,8 +897,7 @@ discard block |
||
| 925 | 897 | * |
| 926 | 898 | * @return bool |
| 927 | 899 | */ |
| 928 | - protected static function isMbStringOverride() |
|
| 929 | - { |
|
| 900 | + protected static function isMbStringOverride() { |
|
| 930 | 901 | static $mbstring = null; |
| 931 | 902 | |
| 932 | 903 | if ($mbstring === null) { |
@@ -9,8 +9,7 @@ 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_Core_SipHash extends ParagonIE_Sodium_Core_Util |
|
| 13 | -{ |
|
| 12 | +class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util { |
|
| 14 | 13 | /** |
| 15 | 14 | * @internal You should not use this directly from another application |
| 16 | 15 | * |
@@ -18,8 +17,7 @@ discard block |
||
| 18 | 17 | * @return int[] |
| 19 | 18 | * |
| 20 | 19 | */ |
| 21 | - public static function sipRound(array $v) |
|
| 22 | - { |
|
| 20 | + public static function sipRound(array $v) { |
|
| 23 | 21 | # v0 += v1; |
| 24 | 22 | list($v[0], $v[1]) = self::add( |
| 25 | 23 | array($v[0], $v[1]), |
@@ -90,8 +88,7 @@ discard block |
||
| 90 | 88 | * @param int[] $b |
| 91 | 89 | * @return array<int, mixed> |
| 92 | 90 | */ |
| 93 | - public static function add(array $a, array $b) |
|
| 94 | - { |
|
| 91 | + public static function add(array $a, array $b) { |
|
| 95 | 92 | /** @var int $x1 */ |
| 96 | 93 | $x1 = $a[1] + $b[1]; |
| 97 | 94 | /** @var int $c */ |
@@ -112,8 +109,7 @@ discard block |
||
| 112 | 109 | * @param int $c |
| 113 | 110 | * @return array<int, mixed> |
| 114 | 111 | */ |
| 115 | - public static function rotl_64($int0, $int1, $c) |
|
| 116 | - { |
|
| 112 | + public static function rotl_64($int0, $int1, $c) { |
|
| 117 | 113 | $int0 &= 0xffffffff; |
| 118 | 114 | $int1 &= 0xffffffff; |
| 119 | 115 | $c &= 63; |
@@ -160,8 +156,7 @@ discard block |
||
| 160 | 156 | * @throws SodiumException |
| 161 | 157 | * @throws TypeError |
| 162 | 158 | */ |
| 163 | - public static function sipHash24($in, $key) |
|
| 164 | - { |
|
| 159 | + public static function sipHash24($in, $key) { |
|
| 165 | 160 | $inlen = self::strlen($in); |
| 166 | 161 | |
| 167 | 162 | # /* "somepseudorandomlygeneratedbytes" */ |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * Class ParagonIE_Sodium_Core_XChaCha20 |
| 9 | 9 | */ |
| 10 | -class ParagonIE_Sodium_Core_XChaCha20 extends ParagonIE_Sodium_Core_HChaCha20 |
|
| 11 | -{ |
|
| 10 | +class ParagonIE_Sodium_Core_XChaCha20 extends ParagonIE_Sodium_Core_HChaCha20 { |
|
| 12 | 11 | /** |
| 13 | 12 | * @internal You should not use this directly from another application |
| 14 | 13 | * |
@@ -19,8 +18,7 @@ discard block |
||
| 19 | 18 | * @throws SodiumException |
| 20 | 19 | * @throws TypeError |
| 21 | 20 | */ |
| 22 | - public static function stream($len = 64, $nonce = '', $key = '') |
|
| 23 | - { |
|
| 21 | + public static function stream($len = 64, $nonce = '', $key = '') { |
|
| 24 | 22 | if (self::strlen($nonce) !== 24) { |
| 25 | 23 | throw new SodiumException('Nonce must be 24 bytes long'); |
| 26 | 24 | } |
@@ -46,8 +44,7 @@ discard block |
||
| 46 | 44 | * @throws SodiumException |
| 47 | 45 | * @throws TypeError |
| 48 | 46 | */ |
| 49 | - public static function ietfStream($len = 64, $nonce = '', $key = '') |
|
| 50 | - { |
|
| 47 | + public static function ietfStream($len = 64, $nonce = '', $key = '') { |
|
| 51 | 48 | if (self::strlen($nonce) !== 24) { |
| 52 | 49 | throw new SodiumException('Nonce must be 24 bytes long'); |
| 53 | 50 | } |
@@ -74,8 +71,7 @@ discard block |
||
| 74 | 71 | * @throws SodiumException |
| 75 | 72 | * @throws TypeError |
| 76 | 73 | */ |
| 77 | - public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
| 78 | - { |
|
| 74 | + public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
| 79 | 75 | if (self::strlen($nonce) !== 24) { |
| 80 | 76 | throw new SodiumException('Nonce must be 24 bytes long'); |
| 81 | 77 | } |
@@ -100,8 +96,7 @@ discard block |
||
| 100 | 96 | * @throws SodiumException |
| 101 | 97 | * @throws TypeError |
| 102 | 98 | */ |
| 103 | - public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
| 104 | - { |
|
| 99 | + public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
| 105 | 100 | if (self::strlen($nonce) !== 24) { |
| 106 | 101 | throw new SodiumException('Nonce must be 24 bytes long'); |
| 107 | 102 | } |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * Class ParagonIE_Sodium_Core_X25519 |
| 9 | 9 | */ |
| 10 | -abstract class ParagonIE_Sodium_Core_X25519 extends ParagonIE_Sodium_Core_Curve25519 |
|
| 11 | -{ |
|
| 10 | +abstract class ParagonIE_Sodium_Core_X25519 extends ParagonIE_Sodium_Core_Curve25519 { |
|
| 12 | 11 | /** |
| 13 | 12 | * Alters the objects passed to this method in place. |
| 14 | 13 | * |
@@ -84,8 +83,7 @@ discard block |
||
| 84 | 83 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $f |
| 85 | 84 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
| 86 | 85 | */ |
| 87 | - public static function fe_mul121666(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
| 88 | - { |
|
| 86 | + public static function fe_mul121666(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
| 89 | 87 | $h = array( |
| 90 | 88 | self::mul((int) $f[0], 121666, 17), |
| 91 | 89 | self::mul((int) $f[1], 121666, 17), |
@@ -158,8 +156,7 @@ discard block |
||
| 158 | 156 | * @throws SodiumException |
| 159 | 157 | * @throws TypeError |
| 160 | 158 | */ |
| 161 | - public static function crypto_scalarmult_curve25519_ref10($n, $p) |
|
| 162 | - { |
|
| 159 | + public static function crypto_scalarmult_curve25519_ref10($n, $p) { |
|
| 163 | 160 | # for (i = 0;i < 32;++i) e[i] = n[i]; |
| 164 | 161 | $e = '' . $n; |
| 165 | 162 | # e[0] &= 248; |
@@ -297,8 +294,7 @@ discard block |
||
| 297 | 294 | * @throws SodiumException |
| 298 | 295 | * @throws TypeError |
| 299 | 296 | */ |
| 300 | - public static function crypto_scalarmult_curve25519_ref10_base($n) |
|
| 301 | - { |
|
| 297 | + public static function crypto_scalarmult_curve25519_ref10_base($n) { |
|
| 302 | 298 | # for (i = 0;i < 32;++i) e[i] = n[i]; |
| 303 | 299 | $e = '' . $n; |
| 304 | 300 | |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * Class ParagonIE_Sodium_Core_Poly1305 |
| 9 | 9 | */ |
| 10 | -abstract class ParagonIE_Sodium_Core_Poly1305 extends ParagonIE_Sodium_Core_Util |
|
| 11 | -{ |
|
| 10 | +abstract class ParagonIE_Sodium_Core_Poly1305 extends ParagonIE_Sodium_Core_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_Core_XSalsa20 |
| 9 | 9 | */ |
| 10 | -abstract class ParagonIE_Sodium_Core_XSalsa20 extends ParagonIE_Sodium_Core_HSalsa20 |
|
| 11 | -{ |
|
| 10 | +abstract class ParagonIE_Sodium_Core_XSalsa20 extends ParagonIE_Sodium_Core_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_Core_ChaCha20 |
| 9 | 9 | */ |
| 10 | -class ParagonIE_Sodium_Core_ChaCha20 extends ParagonIE_Sodium_Core_Util |
|
| 11 | -{ |
|
| 10 | +class ParagonIE_Sodium_Core_ChaCha20 extends ParagonIE_Sodium_Core_Util { |
|
| 12 | 11 | /** |
| 13 | 12 | * Bitwise left rotation |
| 14 | 13 | * |
@@ -18,8 +17,7 @@ discard block |
||
| 18 | 17 | * @param int $n |
| 19 | 18 | * @return int |
| 20 | 19 | */ |
| 21 | - public static function rotate($v, $n) |
|
| 22 | - { |
|
| 20 | + public static function rotate($v, $n) { |
|
| 23 | 21 | $v &= 0xffffffff; |
| 24 | 22 | $n &= 31; |
| 25 | 23 | return (int) ( |
@@ -42,8 +40,7 @@ discard block |
||
| 42 | 40 | * @param int $d |
| 43 | 41 | * @return array<int, int> |
| 44 | 42 | */ |
| 45 | - protected static function quarterRound($a, $b, $c, $d) |
|
| 46 | - { |
|
| 43 | + protected static function quarterRound($a, $b, $c, $d) { |
|
| 47 | 44 | # a = PLUS(a,b); d = ROTATE(XOR(d,a),16); |
| 48 | 45 | /** @var int $a */ |
| 49 | 46 | $a = ($a + $b) & 0xffffffff; |
@@ -329,8 +326,7 @@ discard block |
||
| 329 | 326 | * @throws SodiumException |
| 330 | 327 | * @throws TypeError |
| 331 | 328 | */ |
| 332 | - public static function stream($len = 64, $nonce = '', $key = '') |
|
| 333 | - { |
|
| 329 | + public static function stream($len = 64, $nonce = '', $key = '') { |
|
| 334 | 330 | return self::encryptBytes( |
| 335 | 331 | new ParagonIE_Sodium_Core_ChaCha20_Ctx($key, $nonce), |
| 336 | 332 | str_repeat("\x00", $len) |
@@ -347,8 +343,7 @@ discard block |
||
| 347 | 343 | * @throws SodiumException |
| 348 | 344 | * @throws TypeError |
| 349 | 345 | */ |
| 350 | - public static function ietfStream($len, $nonce = '', $key = '') |
|
| 351 | - { |
|
| 346 | + public static function ietfStream($len, $nonce = '', $key = '') { |
|
| 352 | 347 | return self::encryptBytes( |
| 353 | 348 | new ParagonIE_Sodium_Core_ChaCha20_IetfCtx($key, $nonce), |
| 354 | 349 | str_repeat("\x00", $len) |
@@ -366,8 +361,7 @@ discard block |
||
| 366 | 361 | * @throws SodiumException |
| 367 | 362 | * @throws TypeError |
| 368 | 363 | */ |
| 369 | - public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
| 370 | - { |
|
| 364 | + public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
| 371 | 365 | return self::encryptBytes( |
| 372 | 366 | new ParagonIE_Sodium_Core_ChaCha20_IetfCtx($key, $nonce, $ic), |
| 373 | 367 | $message |
@@ -385,8 +379,7 @@ discard block |
||
| 385 | 379 | * @throws SodiumException |
| 386 | 380 | * @throws TypeError |
| 387 | 381 | */ |
| 388 | - public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') |
|
| 389 | - { |
|
| 382 | + public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') { |
|
| 390 | 383 | return self::encryptBytes( |
| 391 | 384 | new ParagonIE_Sodium_Core_ChaCha20_Ctx($key, $nonce, $ic), |
| 392 | 385 | $message |