@@ -23,8 +23,7 @@ discard block |
||
| 23 | 23 | * SplFixedArray constructor. |
| 24 | 24 | * @param int $size |
| 25 | 25 | */ |
| 26 | - public function __construct($size = 0) |
|
| 27 | - { |
|
| 26 | + public function __construct($size = 0) { |
|
| 28 | 27 | $this->size = $size; |
| 29 | 28 | $this->internalArray = array(); |
| 30 | 29 | } |
@@ -32,16 +31,14 @@ discard block |
||
| 32 | 31 | /** |
| 33 | 32 | * @return int |
| 34 | 33 | */ |
| 35 | - public function count() |
|
| 36 | - { |
|
| 34 | + public function count() { |
|
| 37 | 35 | return count($this->internalArray); |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | 38 | /** |
| 41 | 39 | * @return array |
| 42 | 40 | */ |
| 43 | - public function toArray() |
|
| 44 | - { |
|
| 41 | + public function toArray() { |
|
| 45 | 42 | ksort($this->internalArray); |
| 46 | 43 | return (array) $this->internalArray; |
| 47 | 44 | } |
@@ -52,8 +49,7 @@ discard block |
||
| 52 | 49 | * @return SplFixedArray |
| 53 | 50 | * @psalm-suppress MixedAssignment |
| 54 | 51 | */ |
| 55 | - public static function fromArray(array $array, $save_indexes = true) |
|
| 56 | - { |
|
| 52 | + public static function fromArray(array $array, $save_indexes = true) { |
|
| 57 | 53 | $self = new SplFixedArray(count($array)); |
| 58 | 54 | if($save_indexes) { |
| 59 | 55 | foreach($array as $key => $value) { |
@@ -72,8 +68,7 @@ discard block |
||
| 72 | 68 | /** |
| 73 | 69 | * @return int |
| 74 | 70 | */ |
| 75 | - public function getSize() |
|
| 76 | - { |
|
| 71 | + public function getSize() { |
|
| 77 | 72 | return $this->size; |
| 78 | 73 | } |
| 79 | 74 | |
@@ -81,8 +76,7 @@ discard block |
||
| 81 | 76 | * @param int $size |
| 82 | 77 | * @return bool |
| 83 | 78 | */ |
| 84 | - public function setSize($size) |
|
| 85 | - { |
|
| 79 | + public function setSize($size) { |
|
| 86 | 80 | $this->size = $size; |
| 87 | 81 | return true; |
| 88 | 82 | } |
@@ -91,8 +85,7 @@ discard block |
||
| 91 | 85 | * @param string|int $index |
| 92 | 86 | * @return bool |
| 93 | 87 | */ |
| 94 | - public function offsetExists($index) |
|
| 95 | - { |
|
| 88 | + public function offsetExists($index) { |
|
| 96 | 89 | return array_key_exists((int) $index, $this->internalArray); |
| 97 | 90 | } |
| 98 | 91 | |
@@ -100,8 +93,7 @@ discard block |
||
| 100 | 93 | * @param string|int $index |
| 101 | 94 | * @return mixed |
| 102 | 95 | */ |
| 103 | - public function offsetGet($index) |
|
| 104 | - { |
|
| 96 | + public function offsetGet($index) { |
|
| 105 | 97 | /** @psalm-suppress MixedReturnStatement */ |
| 106 | 98 | return $this->internalArray[(int) $index]; |
| 107 | 99 | } |
@@ -111,16 +103,14 @@ discard block |
||
| 111 | 103 | * @param mixed $newval |
| 112 | 104 | * @psalm-suppress MixedAssignment |
| 113 | 105 | */ |
| 114 | - public function offsetSet($index, $newval) |
|
| 115 | - { |
|
| 106 | + public function offsetSet($index, $newval) { |
|
| 116 | 107 | $this->internalArray[(int) $index] = $newval; |
| 117 | 108 | } |
| 118 | 109 | |
| 119 | 110 | /** |
| 120 | 111 | * @param string|int $index |
| 121 | 112 | */ |
| 122 | - public function offsetUnset($index) |
|
| 123 | - { |
|
| 113 | + public function offsetUnset($index) { |
|
| 124 | 114 | unset($this->internalArray[(int) $index]); |
| 125 | 115 | } |
| 126 | 116 | |
@@ -130,8 +120,7 @@ discard block |
||
| 130 | 120 | * @return void |
| 131 | 121 | * @since 5.3.0 |
| 132 | 122 | */ |
| 133 | - public function rewind() |
|
| 134 | - { |
|
| 123 | + public function rewind() { |
|
| 135 | 124 | reset($this->internalArray); |
| 136 | 125 | } |
| 137 | 126 | |
@@ -141,8 +130,7 @@ discard block |
||
| 141 | 130 | * @return mixed The current element value. |
| 142 | 131 | * @since 5.3.0 |
| 143 | 132 | */ |
| 144 | - public function current() |
|
| 145 | - { |
|
| 133 | + public function current() { |
|
| 146 | 134 | /** @psalm-suppress MixedReturnStatement */ |
| 147 | 135 | return current($this->internalArray); |
| 148 | 136 | } |
@@ -151,16 +139,14 @@ discard block |
||
| 151 | 139 | * Return current array index |
| 152 | 140 | * @return int The current array index. |
| 153 | 141 | */ |
| 154 | - public function key() |
|
| 155 | - { |
|
| 142 | + public function key() { |
|
| 156 | 143 | return key($this->internalArray); |
| 157 | 144 | } |
| 158 | 145 | |
| 159 | 146 | /** |
| 160 | 147 | * @return void |
| 161 | 148 | */ |
| 162 | - public function next() |
|
| 163 | - { |
|
| 149 | + public function next() { |
|
| 164 | 150 | next($this->internalArray); |
| 165 | 151 | } |
| 166 | 152 | |
@@ -169,8 +155,7 @@ discard block |
||
| 169 | 155 | * @link https://php.net/manual/en/splfixedarray.valid.php |
| 170 | 156 | * @return bool true if the array contains any more elements, false otherwise. |
| 171 | 157 | */ |
| 172 | - public function valid() |
|
| 173 | - { |
|
| 158 | + public function valid() { |
|
| 174 | 159 | if (empty($this->internalArray)) { |
| 175 | 160 | return false; |
| 176 | 161 | } |
@@ -182,8 +167,7 @@ discard block |
||
| 182 | 167 | /** |
| 183 | 168 | * Do nothing. |
| 184 | 169 | */ |
| 185 | - public function __wakeup() |
|
| 186 | - { |
|
| 170 | + public function __wakeup() { |
|
| 187 | 171 | // NOP |
| 188 | 172 | } |
| 189 | 173 | } |
| 190 | 174 | \ No newline at end of file |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -class ParagonIE_Sodium_Compat |
|
| 29 | -{ |
|
| 28 | +class ParagonIE_Sodium_Compat { |
|
| 30 | 29 | /** |
| 31 | 30 | * This parameter prevents the use of the PECL extension. |
| 32 | 31 | * It should only be used for unit testing. |
@@ -155,8 +154,7 @@ discard block |
||
| 155 | 154 | * @return void |
| 156 | 155 | * @throws SodiumException |
| 157 | 156 | */ |
| 158 | - public static function add(&$val, $addv) |
|
| 159 | - { |
|
| 157 | + public static function add(&$val, $addv) { |
|
| 160 | 158 | $val_len = ParagonIE_Sodium_Core_Util::strlen($val); |
| 161 | 159 | $addv_len = ParagonIE_Sodium_Core_Util::strlen($addv); |
| 162 | 160 | if ($val_len !== $addv_len) { |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | * @return string |
| 182 | 180 | * @throws SodiumException |
| 183 | 181 | */ |
| 184 | - public static function base642bin($encoded, $variant, $ignore = '') |
|
| 185 | - { |
|
| 182 | + public static function base642bin($encoded, $variant, $ignore = '') { |
|
| 186 | 183 | /* Type checks: */ |
| 187 | 184 | ParagonIE_Sodium_Core_Util::declareScalarType($encoded, 'string', 1); |
| 188 | 185 | |
@@ -224,8 +221,7 @@ discard block |
||
| 224 | 221 | * @return string |
| 225 | 222 | * @throws SodiumException |
| 226 | 223 | */ |
| 227 | - public static function bin2base64($decoded, $variant) |
|
| 228 | - { |
|
| 224 | + public static function bin2base64($decoded, $variant) { |
|
| 229 | 225 | /* Type checks: */ |
| 230 | 226 | ParagonIE_Sodium_Core_Util::declareScalarType($decoded, 'string', 1); |
| 231 | 227 | /** @var string $decoded */ |
@@ -257,8 +253,7 @@ discard block |
||
| 257 | 253 | * @throws TypeError |
| 258 | 254 | * @psalm-suppress MixedArgument |
| 259 | 255 | */ |
| 260 | - public static function bin2hex($string) |
|
| 261 | - { |
|
| 256 | + public static function bin2hex($string) { |
|
| 262 | 257 | /* Type checks: */ |
| 263 | 258 | ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1); |
| 264 | 259 | |
@@ -284,8 +279,7 @@ discard block |
||
| 284 | 279 | * @throws TypeError |
| 285 | 280 | * @psalm-suppress MixedArgument |
| 286 | 281 | */ |
| 287 | - public static function compare($left, $right) |
|
| 288 | - { |
|
| 282 | + public static function compare($left, $right) { |
|
| 289 | 283 | /* Type checks: */ |
| 290 | 284 | ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1); |
| 291 | 285 | ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2); |
@@ -307,8 +301,7 @@ discard block |
||
| 307 | 301 | * @psalm-suppress MixedInferredReturnType |
| 308 | 302 | * @psalm-suppress MixedReturnStatement |
| 309 | 303 | */ |
| 310 | - public static function crypto_aead_aes256gcm_is_available() |
|
| 311 | - { |
|
| 304 | + public static function crypto_aead_aes256gcm_is_available() { |
|
| 312 | 305 | if (self::useNewSodiumAPI()) { |
| 313 | 306 | return sodium_crypto_aead_aes256gcm_is_available(); |
| 314 | 307 | } |
@@ -454,8 +447,7 @@ discard block |
||
| 454 | 447 | * @throws Exception |
| 455 | 448 | * @throws Error |
| 456 | 449 | */ |
| 457 | - public static function crypto_aead_aes256gcm_keygen() |
|
| 458 | - { |
|
| 450 | + public static function crypto_aead_aes256gcm_keygen() { |
|
| 459 | 451 | return random_bytes(self::CRYPTO_AEAD_AES256GCM_KEYBYTES); |
| 460 | 452 | } |
| 461 | 453 | |
@@ -702,8 +694,7 @@ discard block |
||
| 702 | 694 | * @throws Exception |
| 703 | 695 | * @throws Error |
| 704 | 696 | */ |
| 705 | - public static function crypto_aead_chacha20poly1305_keygen() |
|
| 706 | - { |
|
| 697 | + public static function crypto_aead_chacha20poly1305_keygen() { |
|
| 707 | 698 | return random_bytes(self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES); |
| 708 | 699 | } |
| 709 | 700 | |
@@ -790,8 +781,7 @@ discard block |
||
| 790 | 781 | * @throws Exception |
| 791 | 782 | * @throws Error |
| 792 | 783 | */ |
| 793 | - public static function crypto_aead_chacha20poly1305_ietf_keygen() |
|
| 794 | - { |
|
| 784 | + public static function crypto_aead_chacha20poly1305_ietf_keygen() { |
|
| 795 | 785 | return random_bytes(self::CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES); |
| 796 | 786 | } |
| 797 | 787 | |
@@ -949,8 +939,7 @@ discard block |
||
| 949 | 939 | * @throws Exception |
| 950 | 940 | * @throws Error |
| 951 | 941 | */ |
| 952 | - public static function crypto_aead_xchacha20poly1305_ietf_keygen() |
|
| 953 | - { |
|
| 942 | + public static function crypto_aead_xchacha20poly1305_ietf_keygen() { |
|
| 954 | 943 | return random_bytes(self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES); |
| 955 | 944 | } |
| 956 | 945 | |
@@ -971,8 +960,7 @@ discard block |
||
| 971 | 960 | * @throws TypeError |
| 972 | 961 | * @psalm-suppress MixedArgument |
| 973 | 962 | */ |
| 974 | - public static function crypto_auth($message, $key) |
|
| 975 | - { |
|
| 963 | + public static function crypto_auth($message, $key) { |
|
| 976 | 964 | /* Type checks: */ |
| 977 | 965 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 978 | 966 | ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 2); |
@@ -999,8 +987,7 @@ discard block |
||
| 999 | 987 | * @throws Exception |
| 1000 | 988 | * @throws Error |
| 1001 | 989 | */ |
| 1002 | - public static function crypto_auth_keygen() |
|
| 1003 | - { |
|
| 990 | + public static function crypto_auth_keygen() { |
|
| 1004 | 991 | return random_bytes(self::CRYPTO_AUTH_KEYBYTES); |
| 1005 | 992 | } |
| 1006 | 993 | |
@@ -1016,8 +1003,7 @@ discard block |
||
| 1016 | 1003 | * @throws TypeError |
| 1017 | 1004 | * @psalm-suppress MixedArgument |
| 1018 | 1005 | */ |
| 1019 | - public static function crypto_auth_verify($mac, $message, $key) |
|
| 1020 | - { |
|
| 1006 | + public static function crypto_auth_verify($mac, $message, $key) { |
|
| 1021 | 1007 | /* Type checks: */ |
| 1022 | 1008 | ParagonIE_Sodium_Core_Util::declareScalarType($mac, 'string', 1); |
| 1023 | 1009 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2); |
@@ -1060,8 +1046,7 @@ discard block |
||
| 1060 | 1046 | * @throws TypeError |
| 1061 | 1047 | * @psalm-suppress MixedArgument |
| 1062 | 1048 | */ |
| 1063 | - public static function crypto_box($plaintext, $nonce, $keypair) |
|
| 1064 | - { |
|
| 1049 | + public static function crypto_box($plaintext, $nonce, $keypair) { |
|
| 1065 | 1050 | /* Type checks: */ |
| 1066 | 1051 | ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); |
| 1067 | 1052 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -1104,8 +1089,7 @@ discard block |
||
| 1104 | 1089 | * @throws TypeError |
| 1105 | 1090 | * @psalm-suppress MixedArgument |
| 1106 | 1091 | */ |
| 1107 | - public static function crypto_box_seal($plaintext, $publicKey) |
|
| 1108 | - { |
|
| 1092 | + public static function crypto_box_seal($plaintext, $publicKey) { |
|
| 1109 | 1093 | /* Type checks: */ |
| 1110 | 1094 | ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); |
| 1111 | 1095 | ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2); |
@@ -1142,8 +1126,7 @@ discard block |
||
| 1142 | 1126 | * @psalm-suppress MixedInferredReturnType |
| 1143 | 1127 | * @psalm-suppress MixedReturnStatement |
| 1144 | 1128 | */ |
| 1145 | - public static function crypto_box_seal_open($ciphertext, $keypair) |
|
| 1146 | - { |
|
| 1129 | + public static function crypto_box_seal_open($ciphertext, $keypair) { |
|
| 1147 | 1130 | /* Type checks: */ |
| 1148 | 1131 | ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1); |
| 1149 | 1132 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 2); |
@@ -1180,8 +1163,7 @@ discard block |
||
| 1180 | 1163 | * @throws TypeError |
| 1181 | 1164 | * @psalm-suppress MixedArgument |
| 1182 | 1165 | */ |
| 1183 | - public static function crypto_box_keypair() |
|
| 1184 | - { |
|
| 1166 | + public static function crypto_box_keypair() { |
|
| 1185 | 1167 | if (self::useNewSodiumAPI()) { |
| 1186 | 1168 | return (string) sodium_crypto_box_keypair(); |
| 1187 | 1169 | } |
@@ -1205,8 +1187,7 @@ discard block |
||
| 1205 | 1187 | * @throws TypeError |
| 1206 | 1188 | * @psalm-suppress MixedArgument |
| 1207 | 1189 | */ |
| 1208 | - public static function crypto_box_keypair_from_secretkey_and_publickey($secretKey, $publicKey) |
|
| 1209 | - { |
|
| 1190 | + public static function crypto_box_keypair_from_secretkey_and_publickey($secretKey, $publicKey) { |
|
| 1210 | 1191 | /* Type checks: */ |
| 1211 | 1192 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1); |
| 1212 | 1193 | ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2); |
@@ -1244,8 +1225,7 @@ discard block |
||
| 1244 | 1225 | * @psalm-suppress MixedInferredReturnType |
| 1245 | 1226 | * @psalm-suppress MixedReturnStatement |
| 1246 | 1227 | */ |
| 1247 | - public static function crypto_box_open($ciphertext, $nonce, $keypair) |
|
| 1248 | - { |
|
| 1228 | + public static function crypto_box_open($ciphertext, $nonce, $keypair) { |
|
| 1249 | 1229 | /* Type checks: */ |
| 1250 | 1230 | ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1); |
| 1251 | 1231 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -1287,8 +1267,7 @@ discard block |
||
| 1287 | 1267 | * @throws TypeError |
| 1288 | 1268 | * @psalm-suppress MixedArgument |
| 1289 | 1269 | */ |
| 1290 | - public static function crypto_box_publickey($keypair) |
|
| 1291 | - { |
|
| 1270 | + public static function crypto_box_publickey($keypair) { |
|
| 1292 | 1271 | /* Type checks: */ |
| 1293 | 1272 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 1294 | 1273 | |
@@ -1318,8 +1297,7 @@ discard block |
||
| 1318 | 1297 | * @throws TypeError |
| 1319 | 1298 | * @psalm-suppress MixedArgument |
| 1320 | 1299 | */ |
| 1321 | - public static function crypto_box_publickey_from_secretkey($secretKey) |
|
| 1322 | - { |
|
| 1300 | + public static function crypto_box_publickey_from_secretkey($secretKey) { |
|
| 1323 | 1301 | /* Type checks: */ |
| 1324 | 1302 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1); |
| 1325 | 1303 | |
@@ -1349,8 +1327,7 @@ discard block |
||
| 1349 | 1327 | * @throws TypeError |
| 1350 | 1328 | * @psalm-suppress MixedArgument |
| 1351 | 1329 | */ |
| 1352 | - public static function crypto_box_secretkey($keypair) |
|
| 1353 | - { |
|
| 1330 | + public static function crypto_box_secretkey($keypair) { |
|
| 1354 | 1331 | /* Type checks: */ |
| 1355 | 1332 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 1356 | 1333 | |
@@ -1381,8 +1358,7 @@ discard block |
||
| 1381 | 1358 | * @psalm-suppress MixedArgument |
| 1382 | 1359 | * @psalm-suppress UndefinedFunction |
| 1383 | 1360 | */ |
| 1384 | - public static function crypto_box_seed_keypair($seed) |
|
| 1385 | - { |
|
| 1361 | + public static function crypto_box_seed_keypair($seed) { |
|
| 1386 | 1362 | /* Type checks: */ |
| 1387 | 1363 | ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1); |
| 1388 | 1364 | |
@@ -1411,8 +1387,7 @@ discard block |
||
| 1411 | 1387 | * @throws TypeError |
| 1412 | 1388 | * @psalm-suppress MixedArgument |
| 1413 | 1389 | */ |
| 1414 | - public static function crypto_generichash($message, $key = '', $length = self::CRYPTO_GENERICHASH_BYTES) |
|
| 1415 | - { |
|
| 1390 | + public static function crypto_generichash($message, $key = '', $length = self::CRYPTO_GENERICHASH_BYTES) { |
|
| 1416 | 1391 | /* Type checks: */ |
| 1417 | 1392 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 1418 | 1393 | if (is_null($key)) { |
@@ -1455,8 +1430,7 @@ discard block |
||
| 1455 | 1430 | * @psalm-suppress ReferenceConstraintViolation |
| 1456 | 1431 | * @psalm-suppress ConflictingReferenceConstraint |
| 1457 | 1432 | */ |
| 1458 | - public static function crypto_generichash_final(&$ctx, $length = self::CRYPTO_GENERICHASH_BYTES) |
|
| 1459 | - { |
|
| 1433 | + public static function crypto_generichash_final(&$ctx, $length = self::CRYPTO_GENERICHASH_BYTES) { |
|
| 1460 | 1434 | /* Type checks: */ |
| 1461 | 1435 | ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1); |
| 1462 | 1436 | ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2); |
@@ -1500,8 +1474,7 @@ discard block |
||
| 1500 | 1474 | * @throws TypeError |
| 1501 | 1475 | * @psalm-suppress MixedArgument |
| 1502 | 1476 | */ |
| 1503 | - public static function crypto_generichash_init($key = '', $length = self::CRYPTO_GENERICHASH_BYTES) |
|
| 1504 | - { |
|
| 1477 | + public static function crypto_generichash_init($key = '', $length = self::CRYPTO_GENERICHASH_BYTES) { |
|
| 1505 | 1478 | /* Type checks: */ |
| 1506 | 1479 | if (is_null($key)) { |
| 1507 | 1480 | $key = ''; |
@@ -1591,8 +1564,7 @@ discard block |
||
| 1591 | 1564 | * @psalm-suppress MixedArgument |
| 1592 | 1565 | * @psalm-suppress ReferenceConstraintViolation |
| 1593 | 1566 | */ |
| 1594 | - public static function crypto_generichash_update(&$ctx, $message) |
|
| 1595 | - { |
|
| 1567 | + public static function crypto_generichash_update(&$ctx, $message) { |
|
| 1596 | 1568 | /* Type checks: */ |
| 1597 | 1569 | ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1); |
| 1598 | 1570 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2); |
@@ -1618,8 +1590,7 @@ discard block |
||
| 1618 | 1590 | * @throws Exception |
| 1619 | 1591 | * @throws Error |
| 1620 | 1592 | */ |
| 1621 | - public static function crypto_generichash_keygen() |
|
| 1622 | - { |
|
| 1593 | + public static function crypto_generichash_keygen() { |
|
| 1623 | 1594 | return random_bytes(self::CRYPTO_GENERICHASH_KEYBYTES); |
| 1624 | 1595 | } |
| 1625 | 1596 | |
@@ -1677,8 +1648,7 @@ discard block |
||
| 1677 | 1648 | * @throws Exception |
| 1678 | 1649 | * @throws Error |
| 1679 | 1650 | */ |
| 1680 | - public static function crypto_kdf_keygen() |
|
| 1681 | - { |
|
| 1651 | + public static function crypto_kdf_keygen() { |
|
| 1682 | 1652 | return random_bytes(self::CRYPTO_KDF_KEYBYTES); |
| 1683 | 1653 | } |
| 1684 | 1654 | |
@@ -1712,8 +1682,7 @@ discard block |
||
| 1712 | 1682 | * @throws TypeError |
| 1713 | 1683 | * @psalm-suppress MixedArgument |
| 1714 | 1684 | */ |
| 1715 | - public static function crypto_kx($my_secret, $their_public, $client_public, $server_public, $dontFallback = false) |
|
| 1716 | - { |
|
| 1685 | + public static function crypto_kx($my_secret, $their_public, $client_public, $server_public, $dontFallback = false) { |
|
| 1717 | 1686 | /* Type checks: */ |
| 1718 | 1687 | ParagonIE_Sodium_Core_Util::declareScalarType($my_secret, 'string', 1); |
| 1719 | 1688 | ParagonIE_Sodium_Core_Util::declareScalarType($their_public, 'string', 2); |
@@ -1774,8 +1743,7 @@ discard block |
||
| 1774 | 1743 | * @return string |
| 1775 | 1744 | * @throws SodiumException |
| 1776 | 1745 | */ |
| 1777 | - public static function crypto_kx_seed_keypair($seed) |
|
| 1778 | - { |
|
| 1746 | + public static function crypto_kx_seed_keypair($seed) { |
|
| 1779 | 1747 | ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1); |
| 1780 | 1748 | |
| 1781 | 1749 | $seed = (string) $seed; |
@@ -1793,8 +1761,7 @@ discard block |
||
| 1793 | 1761 | * @return string |
| 1794 | 1762 | * @throws Exception |
| 1795 | 1763 | */ |
| 1796 | - public static function crypto_kx_keypair() |
|
| 1797 | - { |
|
| 1764 | + public static function crypto_kx_keypair() { |
|
| 1798 | 1765 | $sk = self::randombytes_buf(self::CRYPTO_KX_SECRETKEYBYTES); |
| 1799 | 1766 | $pk = self::crypto_scalarmult_base($sk); |
| 1800 | 1767 | return $sk . $pk; |
@@ -1806,8 +1773,7 @@ discard block |
||
| 1806 | 1773 | * @return array{0: string, 1: string} |
| 1807 | 1774 | * @throws SodiumException |
| 1808 | 1775 | */ |
| 1809 | - public static function crypto_kx_client_session_keys($keypair, $serverPublicKey) |
|
| 1810 | - { |
|
| 1776 | + public static function crypto_kx_client_session_keys($keypair, $serverPublicKey) { |
|
| 1811 | 1777 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 1812 | 1778 | ParagonIE_Sodium_Core_Util::declareScalarType($serverPublicKey, 'string', 2); |
| 1813 | 1779 | |
@@ -1848,8 +1814,7 @@ discard block |
||
| 1848 | 1814 | * @return array{0: string, 1: string} |
| 1849 | 1815 | * @throws SodiumException |
| 1850 | 1816 | */ |
| 1851 | - public static function crypto_kx_server_session_keys($keypair, $clientPublicKey) |
|
| 1852 | - { |
|
| 1817 | + public static function crypto_kx_server_session_keys($keypair, $clientPublicKey) { |
|
| 1853 | 1818 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 1854 | 1819 | ParagonIE_Sodium_Core_Util::declareScalarType($clientPublicKey, 'string', 2); |
| 1855 | 1820 | |
@@ -1889,8 +1854,7 @@ discard block |
||
| 1889 | 1854 | * @return string |
| 1890 | 1855 | * @throws SodiumException |
| 1891 | 1856 | */ |
| 1892 | - public static function crypto_kx_secretkey($kp) |
|
| 1893 | - { |
|
| 1857 | + public static function crypto_kx_secretkey($kp) { |
|
| 1894 | 1858 | return ParagonIE_Sodium_Core_Util::substr( |
| 1895 | 1859 | $kp, |
| 1896 | 1860 | 0, |
@@ -1903,8 +1867,7 @@ discard block |
||
| 1903 | 1867 | * @return string |
| 1904 | 1868 | * @throws SodiumException |
| 1905 | 1869 | */ |
| 1906 | - public static function crypto_kx_publickey($kp) |
|
| 1907 | - { |
|
| 1870 | + public static function crypto_kx_publickey($kp) { |
|
| 1908 | 1871 | return ParagonIE_Sodium_Core_Util::substr( |
| 1909 | 1872 | $kp, |
| 1910 | 1873 | self::CRYPTO_KX_SECRETKEYBYTES, |
@@ -1924,8 +1887,7 @@ discard block |
||
| 1924 | 1887 | * @throws TypeError |
| 1925 | 1888 | * @psalm-suppress MixedArgument |
| 1926 | 1889 | */ |
| 1927 | - public static function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg = null) |
|
| 1928 | - { |
|
| 1890 | + public static function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg = null) { |
|
| 1929 | 1891 | ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1); |
| 1930 | 1892 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2); |
| 1931 | 1893 | ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3); |
@@ -1956,8 +1918,7 @@ discard block |
||
| 1956 | 1918 | * |
| 1957 | 1919 | * @return bool |
| 1958 | 1920 | */ |
| 1959 | - public static function crypto_pwhash_is_available() |
|
| 1960 | - { |
|
| 1921 | + public static function crypto_pwhash_is_available() { |
|
| 1961 | 1922 | if (self::useNewSodiumAPI()) { |
| 1962 | 1923 | return true; |
| 1963 | 1924 | } |
@@ -1976,8 +1937,7 @@ discard block |
||
| 1976 | 1937 | * @throws TypeError |
| 1977 | 1938 | * @psalm-suppress MixedArgument |
| 1978 | 1939 | */ |
| 1979 | - public static function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
| 1980 | - { |
|
| 1940 | + public static function crypto_pwhash_str($passwd, $opslimit, $memlimit) { |
|
| 1981 | 1941 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 1982 | 1942 | ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2); |
| 1983 | 1943 | ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3); |
@@ -2003,8 +1963,7 @@ discard block |
||
| 2003 | 1963 | * @return bool |
| 2004 | 1964 | * @throws SodiumException |
| 2005 | 1965 | */ |
| 2006 | - public static function crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit) |
|
| 2007 | - { |
|
| 1966 | + public static function crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit) { |
|
| 2008 | 1967 | ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 1); |
| 2009 | 1968 | ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2); |
| 2010 | 1969 | ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3); |
@@ -2032,8 +1991,7 @@ discard block |
||
| 2032 | 1991 | * @throws TypeError |
| 2033 | 1992 | * @psalm-suppress MixedArgument |
| 2034 | 1993 | */ |
| 2035 | - public static function crypto_pwhash_str_verify($passwd, $hash) |
|
| 2036 | - { |
|
| 1994 | + public static function crypto_pwhash_str_verify($passwd, $hash) { |
|
| 2037 | 1995 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 2038 | 1996 | ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2); |
| 2039 | 1997 | |
@@ -2059,8 +2017,7 @@ discard block |
||
| 2059 | 2017 | * @throws SodiumException |
| 2060 | 2018 | * @throws TypeError |
| 2061 | 2019 | */ |
| 2062 | - public static function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
| 2063 | - { |
|
| 2020 | + public static function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) { |
|
| 2064 | 2021 | ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1); |
| 2065 | 2022 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2); |
| 2066 | 2023 | ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3); |
@@ -2100,8 +2057,7 @@ discard block |
||
| 2100 | 2057 | * |
| 2101 | 2058 | * @return bool |
| 2102 | 2059 | */ |
| 2103 | - public static function crypto_pwhash_scryptsalsa208sha256_is_available() |
|
| 2104 | - { |
|
| 2060 | + public static function crypto_pwhash_scryptsalsa208sha256_is_available() { |
|
| 2105 | 2061 | if (self::useNewSodiumAPI()) { |
| 2106 | 2062 | return true; |
| 2107 | 2063 | } |
@@ -2119,8 +2075,7 @@ discard block |
||
| 2119 | 2075 | * @throws SodiumException |
| 2120 | 2076 | * @throws TypeError |
| 2121 | 2077 | */ |
| 2122 | - public static function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
| 2123 | - { |
|
| 2078 | + public static function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) { |
|
| 2124 | 2079 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 2125 | 2080 | ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2); |
| 2126 | 2081 | ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3); |
@@ -2153,8 +2108,7 @@ discard block |
||
| 2153 | 2108 | * @throws SodiumException |
| 2154 | 2109 | * @throws TypeError |
| 2155 | 2110 | */ |
| 2156 | - public static function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
| 2157 | - { |
|
| 2111 | + public static function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) { |
|
| 2158 | 2112 | ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 2159 | 2113 | ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2); |
| 2160 | 2114 | |
@@ -2190,8 +2144,7 @@ discard block |
||
| 2190 | 2144 | * @throws TypeError |
| 2191 | 2145 | * @psalm-suppress MixedArgument |
| 2192 | 2146 | */ |
| 2193 | - public static function crypto_scalarmult($secretKey, $publicKey) |
|
| 2194 | - { |
|
| 2147 | + public static function crypto_scalarmult($secretKey, $publicKey) { |
|
| 2195 | 2148 | /* Type checks: */ |
| 2196 | 2149 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1); |
| 2197 | 2150 | ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2); |
@@ -2234,8 +2187,7 @@ discard block |
||
| 2234 | 2187 | * @psalm-suppress TooFewArguments |
| 2235 | 2188 | * @psalm-suppress MixedArgument |
| 2236 | 2189 | */ |
| 2237 | - public static function crypto_scalarmult_base($secretKey) |
|
| 2238 | - { |
|
| 2190 | + public static function crypto_scalarmult_base($secretKey) { |
|
| 2239 | 2191 | /* Type checks: */ |
| 2240 | 2192 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1); |
| 2241 | 2193 | |
@@ -2272,8 +2224,7 @@ discard block |
||
| 2272 | 2224 | * @throws TypeError |
| 2273 | 2225 | * @psalm-suppress MixedArgument |
| 2274 | 2226 | */ |
| 2275 | - public static function crypto_secretbox($plaintext, $nonce, $key) |
|
| 2276 | - { |
|
| 2227 | + public static function crypto_secretbox($plaintext, $nonce, $key) { |
|
| 2277 | 2228 | /* Type checks: */ |
| 2278 | 2229 | ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); |
| 2279 | 2230 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -2312,8 +2263,7 @@ discard block |
||
| 2312 | 2263 | * @psalm-suppress MixedInferredReturnType |
| 2313 | 2264 | * @psalm-suppress MixedReturnStatement |
| 2314 | 2265 | */ |
| 2315 | - public static function crypto_secretbox_open($ciphertext, $nonce, $key) |
|
| 2316 | - { |
|
| 2266 | + public static function crypto_secretbox_open($ciphertext, $nonce, $key) { |
|
| 2317 | 2267 | /* Type checks: */ |
| 2318 | 2268 | ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1); |
| 2319 | 2269 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -2350,8 +2300,7 @@ discard block |
||
| 2350 | 2300 | * @throws Exception |
| 2351 | 2301 | * @throws Error |
| 2352 | 2302 | */ |
| 2353 | - public static function crypto_secretbox_keygen() |
|
| 2354 | - { |
|
| 2303 | + public static function crypto_secretbox_keygen() { |
|
| 2355 | 2304 | return random_bytes(self::CRYPTO_SECRETBOX_KEYBYTES); |
| 2356 | 2305 | } |
| 2357 | 2306 | |
@@ -2368,8 +2317,7 @@ discard block |
||
| 2368 | 2317 | * @throws TypeError |
| 2369 | 2318 | * @psalm-suppress MixedArgument |
| 2370 | 2319 | */ |
| 2371 | - public static function crypto_secretbox_xchacha20poly1305($plaintext, $nonce, $key) |
|
| 2372 | - { |
|
| 2320 | + public static function crypto_secretbox_xchacha20poly1305($plaintext, $nonce, $key) { |
|
| 2373 | 2321 | /* Type checks: */ |
| 2374 | 2322 | ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); |
| 2375 | 2323 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -2398,8 +2346,7 @@ discard block |
||
| 2398 | 2346 | * @throws TypeError |
| 2399 | 2347 | * @psalm-suppress MixedArgument |
| 2400 | 2348 | */ |
| 2401 | - public static function crypto_secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key) |
|
| 2402 | - { |
|
| 2349 | + public static function crypto_secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key) { |
|
| 2403 | 2350 | /* Type checks: */ |
| 2404 | 2351 | ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1); |
| 2405 | 2352 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -2425,8 +2372,7 @@ discard block |
||
| 2425 | 2372 | * @throws Exception |
| 2426 | 2373 | * @throws SodiumException |
| 2427 | 2374 | */ |
| 2428 | - public static function crypto_secretstream_xchacha20poly1305_init_push($key) |
|
| 2429 | - { |
|
| 2375 | + public static function crypto_secretstream_xchacha20poly1305_init_push($key) { |
|
| 2430 | 2376 | if (PHP_INT_SIZE === 4) { |
| 2431 | 2377 | return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_init_push($key); |
| 2432 | 2378 | } |
@@ -2439,8 +2385,7 @@ discard block |
||
| 2439 | 2385 | * @return string Returns a state. |
| 2440 | 2386 | * @throws Exception |
| 2441 | 2387 | */ |
| 2442 | - public static function crypto_secretstream_xchacha20poly1305_init_pull($header, $key) |
|
| 2443 | - { |
|
| 2388 | + public static function crypto_secretstream_xchacha20poly1305_init_pull($header, $key) { |
|
| 2444 | 2389 | if (ParagonIE_Sodium_Core_Util::strlen($header) < self::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES) { |
| 2445 | 2390 | throw new SodiumException( |
| 2446 | 2391 | 'header size should be SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES bytes' |
@@ -2460,8 +2405,7 @@ discard block |
||
| 2460 | 2405 | * @return string |
| 2461 | 2406 | * @throws SodiumException |
| 2462 | 2407 | */ |
| 2463 | - public static function crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0) |
|
| 2464 | - { |
|
| 2408 | + public static function crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0) { |
|
| 2465 | 2409 | if (PHP_INT_SIZE === 4) { |
| 2466 | 2410 | return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_push( |
| 2467 | 2411 | $state, |
@@ -2485,8 +2429,7 @@ discard block |
||
| 2485 | 2429 | * @return bool|array{0: string, 1: int} |
| 2486 | 2430 | * @throws SodiumException |
| 2487 | 2431 | */ |
| 2488 | - public static function crypto_secretstream_xchacha20poly1305_pull(&$state, $msg, $aad = '') |
|
| 2489 | - { |
|
| 2432 | + public static function crypto_secretstream_xchacha20poly1305_pull(&$state, $msg, $aad = '') { |
|
| 2490 | 2433 | if (PHP_INT_SIZE === 4) { |
| 2491 | 2434 | return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_pull( |
| 2492 | 2435 | $state, |
@@ -2505,8 +2448,7 @@ discard block |
||
| 2505 | 2448 | * @return string |
| 2506 | 2449 | * @throws Exception |
| 2507 | 2450 | */ |
| 2508 | - public static function crypto_secretstream_xchacha20poly1305_keygen() |
|
| 2509 | - { |
|
| 2451 | + public static function crypto_secretstream_xchacha20poly1305_keygen() { |
|
| 2510 | 2452 | return random_bytes(self::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES); |
| 2511 | 2453 | } |
| 2512 | 2454 | |
@@ -2515,8 +2457,7 @@ discard block |
||
| 2515 | 2457 | * @return void |
| 2516 | 2458 | * @throws SodiumException |
| 2517 | 2459 | */ |
| 2518 | - public static function crypto_secretstream_xchacha20poly1305_rekey(&$state) |
|
| 2519 | - { |
|
| 2460 | + public static function crypto_secretstream_xchacha20poly1305_rekey(&$state) { |
|
| 2520 | 2461 | if (PHP_INT_SIZE === 4) { |
| 2521 | 2462 | ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_rekey($state); |
| 2522 | 2463 | } else { |
@@ -2536,8 +2477,7 @@ discard block |
||
| 2536 | 2477 | * @psalm-suppress MixedInferredReturnType |
| 2537 | 2478 | * @psalm-suppress MixedReturnStatement |
| 2538 | 2479 | */ |
| 2539 | - public static function crypto_shorthash($message, $key) |
|
| 2540 | - { |
|
| 2480 | + public static function crypto_shorthash($message, $key) { |
|
| 2541 | 2481 | /* Type checks: */ |
| 2542 | 2482 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 2543 | 2483 | ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 2); |
@@ -2566,8 +2506,7 @@ discard block |
||
| 2566 | 2506 | * @throws Exception |
| 2567 | 2507 | * @throws Error |
| 2568 | 2508 | */ |
| 2569 | - public static function crypto_shorthash_keygen() |
|
| 2570 | - { |
|
| 2509 | + public static function crypto_shorthash_keygen() { |
|
| 2571 | 2510 | return random_bytes(self::CRYPTO_SHORTHASH_KEYBYTES); |
| 2572 | 2511 | } |
| 2573 | 2512 | |
@@ -2586,8 +2525,7 @@ discard block |
||
| 2586 | 2525 | * @psalm-suppress MixedInferredReturnType |
| 2587 | 2526 | * @psalm-suppress MixedReturnStatement |
| 2588 | 2527 | */ |
| 2589 | - public static function crypto_sign($message, $secretKey) |
|
| 2590 | - { |
|
| 2528 | + public static function crypto_sign($message, $secretKey) { |
|
| 2591 | 2529 | /* Type checks: */ |
| 2592 | 2530 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 2593 | 2531 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 2); |
@@ -2622,8 +2560,7 @@ discard block |
||
| 2622 | 2560 | * @psalm-suppress MixedInferredReturnType |
| 2623 | 2561 | * @psalm-suppress MixedReturnStatement |
| 2624 | 2562 | */ |
| 2625 | - public static function crypto_sign_open($signedMessage, $publicKey) |
|
| 2626 | - { |
|
| 2563 | + public static function crypto_sign_open($signedMessage, $publicKey) { |
|
| 2627 | 2564 | /* Type checks: */ |
| 2628 | 2565 | ParagonIE_Sodium_Core_Util::declareScalarType($signedMessage, 'string', 1); |
| 2629 | 2566 | ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2); |
@@ -2659,8 +2596,7 @@ discard block |
||
| 2659 | 2596 | * @throws SodiumException |
| 2660 | 2597 | * @throws TypeError |
| 2661 | 2598 | */ |
| 2662 | - public static function crypto_sign_keypair() |
|
| 2663 | - { |
|
| 2599 | + public static function crypto_sign_keypair() { |
|
| 2664 | 2600 | if (self::useNewSodiumAPI()) { |
| 2665 | 2601 | return sodium_crypto_sign_keypair(); |
| 2666 | 2602 | } |
@@ -2679,8 +2615,7 @@ discard block |
||
| 2679 | 2615 | * @return string |
| 2680 | 2616 | * @throws SodiumException |
| 2681 | 2617 | */ |
| 2682 | - public static function crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk) |
|
| 2683 | - { |
|
| 2618 | + public static function crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk) { |
|
| 2684 | 2619 | ParagonIE_Sodium_Core_Util::declareScalarType($sk, 'string', 1); |
| 2685 | 2620 | ParagonIE_Sodium_Core_Util::declareScalarType($pk, 'string', 1); |
| 2686 | 2621 | $sk = (string) $sk; |
@@ -2708,8 +2643,7 @@ discard block |
||
| 2708 | 2643 | * @throws TypeError |
| 2709 | 2644 | * @psalm-suppress MixedArgument |
| 2710 | 2645 | */ |
| 2711 | - public static function crypto_sign_seed_keypair($seed) |
|
| 2712 | - { |
|
| 2646 | + public static function crypto_sign_seed_keypair($seed) { |
|
| 2713 | 2647 | ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1); |
| 2714 | 2648 | |
| 2715 | 2649 | if (self::useNewSodiumAPI()) { |
@@ -2737,8 +2671,7 @@ discard block |
||
| 2737 | 2671 | * @throws TypeError |
| 2738 | 2672 | * @psalm-suppress MixedArgument |
| 2739 | 2673 | */ |
| 2740 | - public static function crypto_sign_publickey($keypair) |
|
| 2741 | - { |
|
| 2674 | + public static function crypto_sign_publickey($keypair) { |
|
| 2742 | 2675 | /* Type checks: */ |
| 2743 | 2676 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 2744 | 2677 | |
@@ -2768,8 +2701,7 @@ discard block |
||
| 2768 | 2701 | * @throws TypeError |
| 2769 | 2702 | * @psalm-suppress MixedArgument |
| 2770 | 2703 | */ |
| 2771 | - public static function crypto_sign_publickey_from_secretkey($secretKey) |
|
| 2772 | - { |
|
| 2704 | + public static function crypto_sign_publickey_from_secretkey($secretKey) { |
|
| 2773 | 2705 | /* Type checks: */ |
| 2774 | 2706 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1); |
| 2775 | 2707 | |
@@ -2799,8 +2731,7 @@ discard block |
||
| 2799 | 2731 | * @throws TypeError |
| 2800 | 2732 | * @psalm-suppress MixedArgument |
| 2801 | 2733 | */ |
| 2802 | - public static function crypto_sign_secretkey($keypair) |
|
| 2803 | - { |
|
| 2734 | + public static function crypto_sign_secretkey($keypair) { |
|
| 2804 | 2735 | /* Type checks: */ |
| 2805 | 2736 | ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1); |
| 2806 | 2737 | |
@@ -2833,8 +2764,7 @@ discard block |
||
| 2833 | 2764 | * @throws TypeError |
| 2834 | 2765 | * @psalm-suppress MixedArgument |
| 2835 | 2766 | */ |
| 2836 | - public static function crypto_sign_detached($message, $secretKey) |
|
| 2837 | - { |
|
| 2767 | + public static function crypto_sign_detached($message, $secretKey) { |
|
| 2838 | 2768 | /* Type checks: */ |
| 2839 | 2769 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 2840 | 2770 | ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 2); |
@@ -2868,8 +2798,7 @@ discard block |
||
| 2868 | 2798 | * @throws TypeError |
| 2869 | 2799 | * @psalm-suppress MixedArgument |
| 2870 | 2800 | */ |
| 2871 | - public static function crypto_sign_verify_detached($signature, $message, $publicKey) |
|
| 2872 | - { |
|
| 2801 | + public static function crypto_sign_verify_detached($signature, $message, $publicKey) { |
|
| 2873 | 2802 | /* Type checks: */ |
| 2874 | 2803 | ParagonIE_Sodium_Core_Util::declareScalarType($signature, 'string', 1); |
| 2875 | 2804 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2); |
@@ -2909,8 +2838,7 @@ discard block |
||
| 2909 | 2838 | * @throws TypeError |
| 2910 | 2839 | * @psalm-suppress MixedArgument |
| 2911 | 2840 | */ |
| 2912 | - public static function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
| 2913 | - { |
|
| 2841 | + public static function crypto_sign_ed25519_pk_to_curve25519($pk) { |
|
| 2914 | 2842 | /* Type checks: */ |
| 2915 | 2843 | ParagonIE_Sodium_Core_Util::declareScalarType($pk, 'string', 1); |
| 2916 | 2844 | |
@@ -2941,8 +2869,7 @@ discard block |
||
| 2941 | 2869 | * @throws TypeError |
| 2942 | 2870 | * @psalm-suppress MixedArgument |
| 2943 | 2871 | */ |
| 2944 | - public static function crypto_sign_ed25519_sk_to_curve25519($sk) |
|
| 2945 | - { |
|
| 2872 | + public static function crypto_sign_ed25519_sk_to_curve25519($sk) { |
|
| 2946 | 2873 | /* Type checks: */ |
| 2947 | 2874 | ParagonIE_Sodium_Core_Util::declareScalarType($sk, 'string', 1); |
| 2948 | 2875 | |
@@ -2983,8 +2910,7 @@ discard block |
||
| 2983 | 2910 | * @throws TypeError |
| 2984 | 2911 | * @psalm-suppress MixedArgument |
| 2985 | 2912 | */ |
| 2986 | - public static function crypto_stream($len, $nonce, $key) |
|
| 2987 | - { |
|
| 2913 | + public static function crypto_stream($len, $nonce, $key) { |
|
| 2988 | 2914 | /* Type checks: */ |
| 2989 | 2915 | ParagonIE_Sodium_Core_Util::declareScalarType($len, 'int', 1); |
| 2990 | 2916 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -3030,8 +2956,7 @@ discard block |
||
| 3030 | 2956 | * @throws TypeError |
| 3031 | 2957 | * @psalm-suppress MixedArgument |
| 3032 | 2958 | */ |
| 3033 | - public static function crypto_stream_xor($message, $nonce, $key) |
|
| 3034 | - { |
|
| 2959 | + public static function crypto_stream_xor($message, $nonce, $key) { |
|
| 3035 | 2960 | /* Type checks: */ |
| 3036 | 2961 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 3037 | 2962 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -3064,8 +2989,7 @@ discard block |
||
| 3064 | 2989 | * @throws Exception |
| 3065 | 2990 | * @throws Error |
| 3066 | 2991 | */ |
| 3067 | - public static function crypto_stream_keygen() |
|
| 3068 | - { |
|
| 2992 | + public static function crypto_stream_keygen() { |
|
| 3069 | 2993 | return random_bytes(self::CRYPTO_STREAM_KEYBYTES); |
| 3070 | 2994 | } |
| 3071 | 2995 | |
@@ -3085,8 +3009,7 @@ discard block |
||
| 3085 | 3009 | * @throws TypeError |
| 3086 | 3010 | * @psalm-suppress MixedArgument |
| 3087 | 3011 | */ |
| 3088 | - public static function crypto_stream_xchacha20($len, $nonce, $key, $dontFallback = false) |
|
| 3089 | - { |
|
| 3012 | + public static function crypto_stream_xchacha20($len, $nonce, $key, $dontFallback = false) { |
|
| 3090 | 3013 | /* Type checks: */ |
| 3091 | 3014 | ParagonIE_Sodium_Core_Util::declareScalarType($len, 'int', 1); |
| 3092 | 3015 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -3130,8 +3053,7 @@ discard block |
||
| 3130 | 3053 | * @throws TypeError |
| 3131 | 3054 | * @psalm-suppress MixedArgument |
| 3132 | 3055 | */ |
| 3133 | - public static function crypto_stream_xchacha20_xor($message, $nonce, $key, $dontFallback = false) |
|
| 3134 | - { |
|
| 3056 | + public static function crypto_stream_xchacha20_xor($message, $nonce, $key, $dontFallback = false) { |
|
| 3135 | 3057 | /* Type checks: */ |
| 3136 | 3058 | ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); |
| 3137 | 3059 | ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); |
@@ -3161,8 +3083,7 @@ discard block |
||
| 3161 | 3083 | * @throws Exception |
| 3162 | 3084 | * @throws Error |
| 3163 | 3085 | */ |
| 3164 | - public static function crypto_stream_xchacha20_keygen() |
|
| 3165 | - { |
|
| 3086 | + public static function crypto_stream_xchacha20_keygen() { |
|
| 3166 | 3087 | return random_bytes(self::CRYPTO_STREAM_XCHACHA20_KEYBYTES); |
| 3167 | 3088 | } |
| 3168 | 3089 | |
@@ -3176,8 +3097,7 @@ discard block |
||
| 3176 | 3097 | * @psalm-suppress TooFewArguments |
| 3177 | 3098 | * @psalm-suppress MixedArgument |
| 3178 | 3099 | */ |
| 3179 | - public static function hex2bin($string) |
|
| 3180 | - { |
|
| 3100 | + public static function hex2bin($string) { |
|
| 3181 | 3101 | /* Type checks: */ |
| 3182 | 3102 | ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1); |
| 3183 | 3103 | |
@@ -3202,8 +3122,7 @@ discard block |
||
| 3202 | 3122 | * @throws TypeError |
| 3203 | 3123 | * @psalm-suppress MixedArgument |
| 3204 | 3124 | */ |
| 3205 | - public static function increment(&$var) |
|
| 3206 | - { |
|
| 3125 | + public static function increment(&$var) { |
|
| 3207 | 3126 | /* Type checks: */ |
| 3208 | 3127 | ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1); |
| 3209 | 3128 | |
@@ -3236,8 +3155,7 @@ discard block |
||
| 3236 | 3155 | * |
| 3237 | 3156 | * @throws SodiumException |
| 3238 | 3157 | */ |
| 3239 | - public static function is_zero($str) |
|
| 3240 | - { |
|
| 3158 | + public static function is_zero($str) { |
|
| 3241 | 3159 | $d = 0; |
| 3242 | 3160 | for ($i = 0; $i < 32; ++$i) { |
| 3243 | 3161 | $d |= ParagonIE_Sodium_Core_Util::chrToInt($str[$i]); |
@@ -3251,8 +3169,7 @@ discard block |
||
| 3251 | 3169 | * |
| 3252 | 3170 | * @return int |
| 3253 | 3171 | */ |
| 3254 | - public static function library_version_major() |
|
| 3255 | - { |
|
| 3172 | + public static function library_version_major() { |
|
| 3256 | 3173 | if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MAJOR_VERSION')) { |
| 3257 | 3174 | return SODIUM_LIBRARY_MAJOR_VERSION; |
| 3258 | 3175 | } |
@@ -3269,8 +3186,7 @@ discard block |
||
| 3269 | 3186 | * |
| 3270 | 3187 | * @return int |
| 3271 | 3188 | */ |
| 3272 | - public static function library_version_minor() |
|
| 3273 | - { |
|
| 3189 | + public static function library_version_minor() { |
|
| 3274 | 3190 | if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MINOR_VERSION')) { |
| 3275 | 3191 | return SODIUM_LIBRARY_MINOR_VERSION; |
| 3276 | 3192 | } |
@@ -3291,8 +3207,7 @@ discard block |
||
| 3291 | 3207 | * @throws TypeError |
| 3292 | 3208 | * @psalm-suppress MixedArgument |
| 3293 | 3209 | */ |
| 3294 | - public static function memcmp($left, $right) |
|
| 3295 | - { |
|
| 3210 | + public static function memcmp($left, $right) { |
|
| 3296 | 3211 | /* Type checks: */ |
| 3297 | 3212 | ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1); |
| 3298 | 3213 | ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2); |
@@ -3320,8 +3235,7 @@ discard block |
||
| 3320 | 3235 | * @throws TypeError |
| 3321 | 3236 | * @psalm-suppress TooFewArguments |
| 3322 | 3237 | */ |
| 3323 | - public static function memzero(&$var) |
|
| 3324 | - { |
|
| 3238 | + public static function memzero(&$var) { |
|
| 3325 | 3239 | /* Type checks: */ |
| 3326 | 3240 | ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1); |
| 3327 | 3241 | |
@@ -3351,8 +3265,7 @@ discard block |
||
| 3351 | 3265 | * @return string |
| 3352 | 3266 | * @throws SodiumException |
| 3353 | 3267 | */ |
| 3354 | - public static function pad($unpadded, $blockSize, $dontFallback = false) |
|
| 3355 | - { |
|
| 3268 | + public static function pad($unpadded, $blockSize, $dontFallback = false) { |
|
| 3356 | 3269 | /* Type checks: */ |
| 3357 | 3270 | ParagonIE_Sodium_Core_Util::declareScalarType($unpadded, 'string', 1); |
| 3358 | 3271 | ParagonIE_Sodium_Core_Util::declareScalarType($blockSize, 'int', 2); |
@@ -3437,8 +3350,7 @@ discard block |
||
| 3437 | 3350 | * @return string |
| 3438 | 3351 | * @throws SodiumException |
| 3439 | 3352 | */ |
| 3440 | - public static function unpad($padded, $blockSize, $dontFallback = false) |
|
| 3441 | - { |
|
| 3353 | + public static function unpad($padded, $blockSize, $dontFallback = false) { |
|
| 3442 | 3354 | /* Type checks: */ |
| 3443 | 3355 | ParagonIE_Sodium_Core_Util::declareScalarType($padded, 'string', 1); |
| 3444 | 3356 | ParagonIE_Sodium_Core_Util::declareScalarType($blockSize, 'int', 2); |
@@ -3501,8 +3413,7 @@ discard block |
||
| 3501 | 3413 | * |
| 3502 | 3414 | * @return bool |
| 3503 | 3415 | */ |
| 3504 | - public static function polyfill_is_fast() |
|
| 3505 | - { |
|
| 3416 | + public static function polyfill_is_fast() { |
|
| 3506 | 3417 | if (extension_loaded('sodium')) { |
| 3507 | 3418 | return true; |
| 3508 | 3419 | } |
@@ -3521,8 +3432,7 @@ discard block |
||
| 3521 | 3432 | * @throws Exception |
| 3522 | 3433 | * @throws TypeError |
| 3523 | 3434 | */ |
| 3524 | - public static function randombytes_buf($numBytes) |
|
| 3525 | - { |
|
| 3435 | + public static function randombytes_buf($numBytes) { |
|
| 3526 | 3436 | /* Type checks: */ |
| 3527 | 3437 | if (!is_int($numBytes)) { |
| 3528 | 3438 | if (is_numeric($numBytes)) { |
@@ -3548,8 +3458,7 @@ discard block |
||
| 3548 | 3458 | * @throws Error |
| 3549 | 3459 | * @throws TypeError |
| 3550 | 3460 | */ |
| 3551 | - public static function randombytes_uniform($range) |
|
| 3552 | - { |
|
| 3461 | + public static function randombytes_uniform($range) { |
|
| 3553 | 3462 | /* Type checks: */ |
| 3554 | 3463 | if (!is_int($range)) { |
| 3555 | 3464 | if (is_numeric($range)) { |
@@ -3574,8 +3483,7 @@ discard block |
||
| 3574 | 3483 | * @throws Error |
| 3575 | 3484 | * @throws TypeError |
| 3576 | 3485 | */ |
| 3577 | - public static function randombytes_random16() |
|
| 3578 | - { |
|
| 3486 | + public static function randombytes_random16() { |
|
| 3579 | 3487 | if (self::use_fallback('randombytes_random16')) { |
| 3580 | 3488 | return (int) call_user_func('\\Sodium\\randombytes_random16'); |
| 3581 | 3489 | } |
@@ -3588,8 +3496,7 @@ discard block |
||
| 3588 | 3496 | * @return bool |
| 3589 | 3497 | * @throws SodiumException |
| 3590 | 3498 | */ |
| 3591 | - public static function ristretto255_is_valid_point($p, $dontFallback = false) |
|
| 3592 | - { |
|
| 3499 | + public static function ristretto255_is_valid_point($p, $dontFallback = false) { |
|
| 3593 | 3500 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3594 | 3501 | return sodium_crypto_core_ristretto255_is_valid_point($p); |
| 3595 | 3502 | } |
@@ -3612,8 +3519,7 @@ discard block |
||
| 3612 | 3519 | * @return string |
| 3613 | 3520 | * @throws SodiumException |
| 3614 | 3521 | */ |
| 3615 | - public static function ristretto255_add($p, $q, $dontFallback = false) |
|
| 3616 | - { |
|
| 3522 | + public static function ristretto255_add($p, $q, $dontFallback = false) { |
|
| 3617 | 3523 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3618 | 3524 | return sodium_crypto_core_ristretto255_add($p, $q); |
| 3619 | 3525 | } |
@@ -3627,8 +3533,7 @@ discard block |
||
| 3627 | 3533 | * @return string |
| 3628 | 3534 | * @throws SodiumException |
| 3629 | 3535 | */ |
| 3630 | - public static function ristretto255_sub($p, $q, $dontFallback = false) |
|
| 3631 | - { |
|
| 3536 | + public static function ristretto255_sub($p, $q, $dontFallback = false) { |
|
| 3632 | 3537 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3633 | 3538 | return sodium_crypto_core_ristretto255_sub($p, $q); |
| 3634 | 3539 | } |
@@ -3642,8 +3547,7 @@ discard block |
||
| 3642 | 3547 | * |
| 3643 | 3548 | * @throws SodiumException |
| 3644 | 3549 | */ |
| 3645 | - public static function ristretto255_from_hash($r, $dontFallback = false) |
|
| 3646 | - { |
|
| 3550 | + public static function ristretto255_from_hash($r, $dontFallback = false) { |
|
| 3647 | 3551 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3648 | 3552 | return sodium_crypto_core_ristretto255_from_hash($r); |
| 3649 | 3553 | } |
@@ -3656,8 +3560,7 @@ discard block |
||
| 3656 | 3560 | * |
| 3657 | 3561 | * @throws SodiumException |
| 3658 | 3562 | */ |
| 3659 | - public static function ristretto255_random($dontFallback = false) |
|
| 3660 | - { |
|
| 3563 | + public static function ristretto255_random($dontFallback = false) { |
|
| 3661 | 3564 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3662 | 3565 | return sodium_crypto_core_ristretto255_random(); |
| 3663 | 3566 | } |
@@ -3670,8 +3573,7 @@ discard block |
||
| 3670 | 3573 | * |
| 3671 | 3574 | * @throws SodiumException |
| 3672 | 3575 | */ |
| 3673 | - public static function ristretto255_scalar_random($dontFallback = false) |
|
| 3674 | - { |
|
| 3576 | + public static function ristretto255_scalar_random($dontFallback = false) { |
|
| 3675 | 3577 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3676 | 3578 | return sodium_crypto_core_ristretto255_scalar_random(); |
| 3677 | 3579 | } |
@@ -3684,8 +3586,7 @@ discard block |
||
| 3684 | 3586 | * @return string |
| 3685 | 3587 | * @throws SodiumException |
| 3686 | 3588 | */ |
| 3687 | - public static function ristretto255_scalar_invert($s, $dontFallback = false) |
|
| 3688 | - { |
|
| 3589 | + public static function ristretto255_scalar_invert($s, $dontFallback = false) { |
|
| 3689 | 3590 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3690 | 3591 | return sodium_crypto_core_ristretto255_scalar_invert($s); |
| 3691 | 3592 | } |
@@ -3697,8 +3598,7 @@ discard block |
||
| 3697 | 3598 | * @return string |
| 3698 | 3599 | * @throws SodiumException |
| 3699 | 3600 | */ |
| 3700 | - public static function ristretto255_scalar_negate($s, $dontFallback = false) |
|
| 3701 | - { |
|
| 3601 | + public static function ristretto255_scalar_negate($s, $dontFallback = false) { |
|
| 3702 | 3602 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3703 | 3603 | return sodium_crypto_core_ristretto255_scalar_negate($s); |
| 3704 | 3604 | } |
@@ -3711,8 +3611,7 @@ discard block |
||
| 3711 | 3611 | * @return string |
| 3712 | 3612 | * @throws SodiumException |
| 3713 | 3613 | */ |
| 3714 | - public static function ristretto255_scalar_complement($s, $dontFallback = false) |
|
| 3715 | - { |
|
| 3614 | + public static function ristretto255_scalar_complement($s, $dontFallback = false) { |
|
| 3716 | 3615 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3717 | 3616 | return sodium_crypto_core_ristretto255_scalar_complement($s); |
| 3718 | 3617 | } |
@@ -3726,8 +3625,7 @@ discard block |
||
| 3726 | 3625 | * @return string |
| 3727 | 3626 | * @throws SodiumException |
| 3728 | 3627 | */ |
| 3729 | - public static function ristretto255_scalar_add($x, $y, $dontFallback = false) |
|
| 3730 | - { |
|
| 3628 | + public static function ristretto255_scalar_add($x, $y, $dontFallback = false) { |
|
| 3731 | 3629 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3732 | 3630 | return sodium_crypto_core_ristretto255_scalar_add($x, $y); |
| 3733 | 3631 | } |
@@ -3741,8 +3639,7 @@ discard block |
||
| 3741 | 3639 | * @return string |
| 3742 | 3640 | * @throws SodiumException |
| 3743 | 3641 | */ |
| 3744 | - public static function ristretto255_scalar_sub($x, $y, $dontFallback = false) |
|
| 3745 | - { |
|
| 3642 | + public static function ristretto255_scalar_sub($x, $y, $dontFallback = false) { |
|
| 3746 | 3643 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3747 | 3644 | return sodium_crypto_core_ristretto255_scalar_sub($x, $y); |
| 3748 | 3645 | } |
@@ -3756,8 +3653,7 @@ discard block |
||
| 3756 | 3653 | * @return string |
| 3757 | 3654 | * @throws SodiumException |
| 3758 | 3655 | */ |
| 3759 | - public static function ristretto255_scalar_mul($x, $y, $dontFallback = false) |
|
| 3760 | - { |
|
| 3656 | + public static function ristretto255_scalar_mul($x, $y, $dontFallback = false) { |
|
| 3761 | 3657 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3762 | 3658 | return sodium_crypto_core_ristretto255_scalar_mul($x, $y); |
| 3763 | 3659 | } |
@@ -3771,8 +3667,7 @@ discard block |
||
| 3771 | 3667 | * @return string |
| 3772 | 3668 | * @throws SodiumException |
| 3773 | 3669 | */ |
| 3774 | - public static function scalarmult_ristretto255($n, $p, $dontFallback = false) |
|
| 3775 | - { |
|
| 3670 | + public static function scalarmult_ristretto255($n, $p, $dontFallback = false) { |
|
| 3776 | 3671 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3777 | 3672 | return sodium_crypto_scalarmult_ristretto255($n, $p); |
| 3778 | 3673 | } |
@@ -3786,8 +3681,7 @@ discard block |
||
| 3786 | 3681 | * @return string |
| 3787 | 3682 | * @throws SodiumException |
| 3788 | 3683 | */ |
| 3789 | - public static function scalarmult_ristretto255_base($n, $dontFallback = false) |
|
| 3790 | - { |
|
| 3684 | + public static function scalarmult_ristretto255_base($n, $dontFallback = false) { |
|
| 3791 | 3685 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3792 | 3686 | return sodium_crypto_scalarmult_ristretto255_base($n); |
| 3793 | 3687 | } |
@@ -3800,8 +3694,7 @@ discard block |
||
| 3800 | 3694 | * @return string |
| 3801 | 3695 | * @throws SodiumException |
| 3802 | 3696 | */ |
| 3803 | - public static function ristretto255_scalar_reduce($s, $dontFallback = false) |
|
| 3804 | - { |
|
| 3697 | + public static function ristretto255_scalar_reduce($s, $dontFallback = false) { |
|
| 3805 | 3698 | if (self::useNewSodiumAPI() && !$dontFallback) { |
| 3806 | 3699 | return sodium_crypto_core_ristretto255_scalar_reduce($s); |
| 3807 | 3700 | } |
@@ -3821,8 +3714,7 @@ discard block |
||
| 3821 | 3714 | * @return bool TRUE if we're fast enough, FALSE is not |
| 3822 | 3715 | * @throws SodiumException |
| 3823 | 3716 | */ |
| 3824 | - public static function runtime_speed_test($iterations, $maxTimeout) |
|
| 3825 | - { |
|
| 3717 | + public static function runtime_speed_test($iterations, $maxTimeout) { |
|
| 3826 | 3718 | if (self::polyfill_is_fast()) { |
| 3827 | 3719 | return true; |
| 3828 | 3720 | } |
@@ -3855,8 +3747,7 @@ discard block |
||
| 3855 | 3747 | * @return void |
| 3856 | 3748 | * @throws SodiumException |
| 3857 | 3749 | */ |
| 3858 | - public static function sub(&$val, $addv) |
|
| 3859 | - { |
|
| 3750 | + public static function sub(&$val, $addv) { |
|
| 3860 | 3751 | $val_len = ParagonIE_Sodium_Core_Util::strlen($val); |
| 3861 | 3752 | $addv_len = ParagonIE_Sodium_Core_Util::strlen($addv); |
| 3862 | 3753 | if ($val_len !== $addv_len) { |
@@ -3882,8 +3773,7 @@ discard block |
||
| 3882 | 3773 | * @psalm-suppress MixedInferredReturnType |
| 3883 | 3774 | * @psalm-suppress UndefinedFunction |
| 3884 | 3775 | */ |
| 3885 | - public static function version_string() |
|
| 3886 | - { |
|
| 3776 | + public static function version_string() { |
|
| 3887 | 3777 | if (self::useNewSodiumAPI()) { |
| 3888 | 3778 | return (string) sodium_version_string(); |
| 3889 | 3779 | } |
@@ -3905,8 +3795,7 @@ discard block |
||
| 3905 | 3795 | * |
| 3906 | 3796 | * @return bool |
| 3907 | 3797 | */ |
| 3908 | - protected static function use_fallback($sodium_func_name = '') |
|
| 3909 | - { |
|
| 3798 | + protected static function use_fallback($sodium_func_name = '') { |
|
| 3910 | 3799 | static $res = null; |
| 3911 | 3800 | if ($res === null) { |
| 3912 | 3801 | $res = extension_loaded('libsodium') && PHP_VERSION_ID >= 50300; |
@@ -3932,8 +3821,7 @@ discard block |
||
| 3932 | 3821 | * @ref https://wiki.php.net/rfc/libsodium |
| 3933 | 3822 | * @return bool |
| 3934 | 3823 | */ |
| 3935 | - protected static function useNewSodiumAPI() |
|
| 3936 | - { |
|
| 3824 | + protected static function useNewSodiumAPI() { |
|
| 3937 | 3825 | static $res = null; |
| 3938 | 3826 | if ($res === null) { |
| 3939 | 3827 | $res = PHP_VERSION_ID >= 70000 && extension_loaded('sodium'); |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | * If you are using this library, you should be using |
| 13 | 13 | * ParagonIE_Sodium_Compat in your code, not this class. |
| 14 | 14 | */ |
| 15 | -abstract class ParagonIE_Sodium_Crypto32 |
|
| 16 | -{ |
|
| 15 | +abstract class ParagonIE_Sodium_Crypto32 { |
|
| 17 | 16 | const aead_chacha20poly1305_KEYBYTES = 32; |
| 18 | 17 | const aead_chacha20poly1305_NSECBYTES = 0; |
| 19 | 18 | const aead_chacha20poly1305_NPUBBYTES = 8; |
@@ -381,8 +380,7 @@ discard block |
||
| 381 | 380 | * @return string |
| 382 | 381 | * @throws TypeError |
| 383 | 382 | */ |
| 384 | - public static function auth($message, $key) |
|
| 385 | - { |
|
| 383 | + public static function auth($message, $key) { |
|
| 386 | 384 | return ParagonIE_Sodium_Core32_Util::substr( |
| 387 | 385 | hash_hmac('sha512', $message, $key, true), |
| 388 | 386 | 0, |
@@ -402,8 +400,7 @@ discard block |
||
| 402 | 400 | * @throws SodiumException |
| 403 | 401 | * @throws TypeError |
| 404 | 402 | */ |
| 405 | - public static function auth_verify($mac, $message, $key) |
|
| 406 | - { |
|
| 403 | + public static function auth_verify($mac, $message, $key) { |
|
| 407 | 404 | return ParagonIE_Sodium_Core32_Util::hashEquals( |
| 408 | 405 | $mac, |
| 409 | 406 | self::auth($message, $key) |
@@ -422,8 +419,7 @@ discard block |
||
| 422 | 419 | * @throws SodiumException |
| 423 | 420 | * @throws TypeError |
| 424 | 421 | */ |
| 425 | - public static function box($plaintext, $nonce, $keypair) |
|
| 426 | - { |
|
| 422 | + public static function box($plaintext, $nonce, $keypair) { |
|
| 427 | 423 | return self::secretbox( |
| 428 | 424 | $plaintext, |
| 429 | 425 | $nonce, |
@@ -445,8 +441,7 @@ discard block |
||
| 445 | 441 | * @throws SodiumException |
| 446 | 442 | * @throws TypeError |
| 447 | 443 | */ |
| 448 | - public static function box_seal($message, $publicKey) |
|
| 449 | - { |
|
| 444 | + public static function box_seal($message, $publicKey) { |
|
| 450 | 445 | /** @var string $ephemeralKeypair */ |
| 451 | 446 | $ephemeralKeypair = self::box_keypair(); |
| 452 | 447 | |
@@ -491,8 +486,7 @@ discard block |
||
| 491 | 486 | * @throws SodiumException |
| 492 | 487 | * @throws TypeError |
| 493 | 488 | */ |
| 494 | - public static function box_seal_open($message, $keypair) |
|
| 495 | - { |
|
| 489 | + public static function box_seal_open($message, $keypair) { |
|
| 496 | 490 | /** @var string $ephemeralPK */ |
| 497 | 491 | $ephemeralPK = ParagonIE_Sodium_Core32_Util::substr($message, 0, 32); |
| 498 | 492 | |
@@ -540,8 +534,7 @@ discard block |
||
| 540 | 534 | * @throws SodiumException |
| 541 | 535 | * @throws TypeError |
| 542 | 536 | */ |
| 543 | - public static function box_beforenm($sk, $pk) |
|
| 544 | - { |
|
| 537 | + public static function box_beforenm($sk, $pk) { |
|
| 545 | 538 | return ParagonIE_Sodium_Core32_HSalsa20::hsalsa20( |
| 546 | 539 | str_repeat("\x00", 16), |
| 547 | 540 | self::scalarmult($sk, $pk) |
@@ -556,8 +549,7 @@ discard block |
||
| 556 | 549 | * @throws SodiumException |
| 557 | 550 | * @throws TypeError |
| 558 | 551 | */ |
| 559 | - public static function box_keypair() |
|
| 560 | - { |
|
| 552 | + public static function box_keypair() { |
|
| 561 | 553 | $sKey = random_bytes(32); |
| 562 | 554 | $pKey = self::scalarmult_base($sKey); |
| 563 | 555 | return $sKey . $pKey; |
@@ -569,8 +561,7 @@ discard block |
||
| 569 | 561 | * @throws SodiumException |
| 570 | 562 | * @throws TypeError |
| 571 | 563 | */ |
| 572 | - public static function box_seed_keypair($seed) |
|
| 573 | - { |
|
| 564 | + public static function box_seed_keypair($seed) { |
|
| 574 | 565 | $sKey = ParagonIE_Sodium_Core32_Util::substr( |
| 575 | 566 | hash('sha512', $seed, true), |
| 576 | 567 | 0, |
@@ -588,8 +579,7 @@ discard block |
||
| 588 | 579 | * @return string |
| 589 | 580 | * @throws TypeError |
| 590 | 581 | */ |
| 591 | - public static function box_keypair_from_secretkey_and_publickey($sKey, $pKey) |
|
| 592 | - { |
|
| 582 | + public static function box_keypair_from_secretkey_and_publickey($sKey, $pKey) { |
|
| 593 | 583 | return ParagonIE_Sodium_Core32_Util::substr($sKey, 0, 32) . |
| 594 | 584 | ParagonIE_Sodium_Core32_Util::substr($pKey, 0, 32); |
| 595 | 585 | } |
@@ -602,8 +592,7 @@ discard block |
||
| 602 | 592 | * @throws RangeException |
| 603 | 593 | * @throws TypeError |
| 604 | 594 | */ |
| 605 | - public static function box_secretkey($keypair) |
|
| 606 | - { |
|
| 595 | + public static function box_secretkey($keypair) { |
|
| 607 | 596 | if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== 64) { |
| 608 | 597 | throw new RangeException( |
| 609 | 598 | 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.' |
@@ -620,8 +609,7 @@ discard block |
||
| 620 | 609 | * @throws RangeException |
| 621 | 610 | * @throws TypeError |
| 622 | 611 | */ |
| 623 | - public static function box_publickey($keypair) |
|
| 624 | - { |
|
| 612 | + public static function box_publickey($keypair) { |
|
| 625 | 613 | if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) { |
| 626 | 614 | throw new RangeException( |
| 627 | 615 | 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.' |
@@ -639,8 +627,7 @@ discard block |
||
| 639 | 627 | * @throws SodiumException |
| 640 | 628 | * @throws TypeError |
| 641 | 629 | */ |
| 642 | - public static function box_publickey_from_secretkey($sKey) |
|
| 643 | - { |
|
| 630 | + public static function box_publickey_from_secretkey($sKey) { |
|
| 644 | 631 | if (ParagonIE_Sodium_Core32_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) { |
| 645 | 632 | throw new RangeException( |
| 646 | 633 | 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.' |
@@ -661,8 +648,7 @@ discard block |
||
| 661 | 648 | * @throws SodiumException |
| 662 | 649 | * @throws TypeError |
| 663 | 650 | */ |
| 664 | - public static function box_open($ciphertext, $nonce, $keypair) |
|
| 665 | - { |
|
| 651 | + public static function box_open($ciphertext, $nonce, $keypair) { |
|
| 666 | 652 | return self::secretbox_open( |
| 667 | 653 | $ciphertext, |
| 668 | 654 | $nonce, |
@@ -686,8 +672,7 @@ discard block |
||
| 686 | 672 | * @throws SodiumException |
| 687 | 673 | * @throws TypeError |
| 688 | 674 | */ |
| 689 | - public static function generichash($message, $key = '', $outlen = 32) |
|
| 690 | - { |
|
| 675 | + public static function generichash($message, $key = '', $outlen = 32) { |
|
| 691 | 676 | // This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized |
| 692 | 677 | ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor(); |
| 693 | 678 | |
@@ -727,8 +712,7 @@ discard block |
||
| 727 | 712 | * @throws SodiumException |
| 728 | 713 | * @throws TypeError |
| 729 | 714 | */ |
| 730 | - public static function generichash_final($ctx, $outlen = 32) |
|
| 731 | - { |
|
| 715 | + public static function generichash_final($ctx, $outlen = 32) { |
|
| 732 | 716 | if (!is_string($ctx)) { |
| 733 | 717 | throw new TypeError('Context must be a string'); |
| 734 | 718 | } |
@@ -757,8 +741,7 @@ discard block |
||
| 757 | 741 | * @throws SodiumException |
| 758 | 742 | * @throws TypeError |
| 759 | 743 | */ |
| 760 | - public static function generichash_init($key = '', $outputLength = 32) |
|
| 761 | - { |
|
| 744 | + public static function generichash_init($key = '', $outputLength = 32) { |
|
| 762 | 745 | // This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized |
| 763 | 746 | ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor(); |
| 764 | 747 | |
@@ -834,8 +817,7 @@ discard block |
||
| 834 | 817 | * @throws SodiumException |
| 835 | 818 | * @throws TypeError |
| 836 | 819 | */ |
| 837 | - public static function generichash_update($ctx, $message) |
|
| 838 | - { |
|
| 820 | + public static function generichash_update($ctx, $message) { |
|
| 839 | 821 | // This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized |
| 840 | 822 | ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor(); |
| 841 | 823 | |
@@ -863,8 +845,7 @@ discard block |
||
| 863 | 845 | * @throws SodiumException |
| 864 | 846 | * @throws TypeError |
| 865 | 847 | */ |
| 866 | - public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk) |
|
| 867 | - { |
|
| 848 | + public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk) { |
|
| 868 | 849 | return self::generichash( |
| 869 | 850 | self::scalarmult($my_sk, $their_pk) . |
| 870 | 851 | $client_pk . |
@@ -884,8 +865,7 @@ discard block |
||
| 884 | 865 | * @throws SodiumException |
| 885 | 866 | * @throws TypeError |
| 886 | 867 | */ |
| 887 | - public static function scalarmult($sKey, $pKey) |
|
| 888 | - { |
|
| 868 | + public static function scalarmult($sKey, $pKey) { |
|
| 889 | 869 | $q = ParagonIE_Sodium_Core32_X25519::crypto_scalarmult_curve25519_ref10($sKey, $pKey); |
| 890 | 870 | self::scalarmult_throw_if_zero($q); |
| 891 | 871 | return $q; |
@@ -901,8 +881,7 @@ discard block |
||
| 901 | 881 | * @throws SodiumException |
| 902 | 882 | * @throws TypeError |
| 903 | 883 | */ |
| 904 | - public static function scalarmult_base($secret) |
|
| 905 | - { |
|
| 884 | + public static function scalarmult_base($secret) { |
|
| 906 | 885 | $q = ParagonIE_Sodium_Core32_X25519::crypto_scalarmult_curve25519_ref10_base($secret); |
| 907 | 886 | self::scalarmult_throw_if_zero($q); |
| 908 | 887 | return $q; |
@@ -916,8 +895,7 @@ discard block |
||
| 916 | 895 | * @throws SodiumException |
| 917 | 896 | * @throws TypeError |
| 918 | 897 | */ |
| 919 | - protected static function scalarmult_throw_if_zero($q) |
|
| 920 | - { |
|
| 898 | + protected static function scalarmult_throw_if_zero($q) { |
|
| 921 | 899 | $d = 0; |
| 922 | 900 | for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) { |
| 923 | 901 | $d |= ParagonIE_Sodium_Core32_Util::chrToInt($q[$i]); |
@@ -941,8 +919,7 @@ discard block |
||
| 941 | 919 | * @throws SodiumException |
| 942 | 920 | * @throws TypeError |
| 943 | 921 | */ |
| 944 | - public static function secretbox($plaintext, $nonce, $key) |
|
| 945 | - { |
|
| 922 | + public static function secretbox($plaintext, $nonce, $key) { |
|
| 946 | 923 | /** @var string $subkey */ |
| 947 | 924 | $subkey = ParagonIE_Sodium_Core32_HSalsa20::hsalsa20($nonce, $key); |
| 948 | 925 | |
@@ -1016,8 +993,7 @@ discard block |
||
| 1016 | 993 | * @throws SodiumException |
| 1017 | 994 | * @throws TypeError |
| 1018 | 995 | */ |
| 1019 | - public static function secretbox_open($ciphertext, $nonce, $key) |
|
| 1020 | - { |
|
| 996 | + public static function secretbox_open($ciphertext, $nonce, $key) { |
|
| 1021 | 997 | /** @var string $mac */ |
| 1022 | 998 | $mac = ParagonIE_Sodium_Core32_Util::substr( |
| 1023 | 999 | $ciphertext, |
@@ -1089,8 +1065,7 @@ discard block |
||
| 1089 | 1065 | * @throws SodiumException |
| 1090 | 1066 | * @throws TypeError |
| 1091 | 1067 | */ |
| 1092 | - public static function secretbox_xchacha20poly1305($plaintext, $nonce, $key) |
|
| 1093 | - { |
|
| 1068 | + public static function secretbox_xchacha20poly1305($plaintext, $nonce, $key) { |
|
| 1094 | 1069 | /** @var string $subkey */ |
| 1095 | 1070 | $subkey = ParagonIE_Sodium_Core32_HChaCha20::hChaCha20( |
| 1096 | 1071 | ParagonIE_Sodium_Core32_Util::substr($nonce, 0, 16), |
@@ -1168,8 +1143,7 @@ discard block |
||
| 1168 | 1143 | * @throws SodiumException |
| 1169 | 1144 | * @throws TypeError |
| 1170 | 1145 | */ |
| 1171 | - public static function secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key) |
|
| 1172 | - { |
|
| 1146 | + public static function secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key) { |
|
| 1173 | 1147 | /** @var string $mac */ |
| 1174 | 1148 | $mac = ParagonIE_Sodium_Core32_Util::substr( |
| 1175 | 1149 | $ciphertext, |
@@ -1237,8 +1211,7 @@ discard block |
||
| 1237 | 1211 | * @throws Exception |
| 1238 | 1212 | * @throws SodiumException |
| 1239 | 1213 | */ |
| 1240 | - public static function secretstream_xchacha20poly1305_init_push($key) |
|
| 1241 | - { |
|
| 1214 | + public static function secretstream_xchacha20poly1305_init_push($key) { |
|
| 1242 | 1215 | # randombytes_buf(out, crypto_secretstream_xchacha20poly1305_HEADERBYTES); |
| 1243 | 1216 | $out = random_bytes(24); |
| 1244 | 1217 | |
@@ -1267,8 +1240,7 @@ discard block |
||
| 1267 | 1240 | * @return string Returns a state. |
| 1268 | 1241 | * @throws Exception |
| 1269 | 1242 | */ |
| 1270 | - public static function secretstream_xchacha20poly1305_init_pull($key, $header) |
|
| 1271 | - { |
|
| 1243 | + public static function secretstream_xchacha20poly1305_init_pull($key, $header) { |
|
| 1272 | 1244 | # crypto_core_hchacha20(state->k, in, k, NULL); |
| 1273 | 1245 | $subkey = ParagonIE_Sodium_Core32_HChaCha20::hChaCha20( |
| 1274 | 1246 | ParagonIE_Sodium_Core32_Util::substr($header, 0, 16), |
@@ -1294,8 +1266,7 @@ discard block |
||
| 1294 | 1266 | * @return string |
| 1295 | 1267 | * @throws SodiumException |
| 1296 | 1268 | */ |
| 1297 | - public static function secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0) |
|
| 1298 | - { |
|
| 1269 | + public static function secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0) { |
|
| 1299 | 1270 | $st = ParagonIE_Sodium_Core32_SecretStream_State::fromString($state); |
| 1300 | 1271 | # crypto_onetimeauth_poly1305_state poly1305_state; |
| 1301 | 1272 | # unsigned char block[64U]; |
@@ -1423,8 +1394,7 @@ discard block |
||
| 1423 | 1394 | * @return bool|array{0: string, 1: int} |
| 1424 | 1395 | * @throws SodiumException |
| 1425 | 1396 | */ |
| 1426 | - public static function secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '') |
|
| 1427 | - { |
|
| 1397 | + public static function secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '') { |
|
| 1428 | 1398 | $st = ParagonIE_Sodium_Core32_SecretStream_State::fromString($state); |
| 1429 | 1399 | |
| 1430 | 1400 | $cipherlen = ParagonIE_Sodium_Core32_Util::strlen($cipher); |
@@ -1546,8 +1516,7 @@ discard block |
||
| 1546 | 1516 | * @return void |
| 1547 | 1517 | * @throws SodiumException |
| 1548 | 1518 | */ |
| 1549 | - public static function secretstream_xchacha20poly1305_rekey(&$state) |
|
| 1550 | - { |
|
| 1519 | + public static function secretstream_xchacha20poly1305_rekey(&$state) { |
|
| 1551 | 1520 | $st = ParagonIE_Sodium_Core32_SecretStream_State::fromString($state); |
| 1552 | 1521 | # unsigned char new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + |
| 1553 | 1522 | # crypto_secretstream_xchacha20poly1305_INONCEBYTES]; |
@@ -1598,8 +1567,7 @@ discard block |
||
| 1598 | 1567 | * @throws SodiumException |
| 1599 | 1568 | * @throws TypeError |
| 1600 | 1569 | */ |
| 1601 | - public static function sign_detached($message, $sk) |
|
| 1602 | - { |
|
| 1570 | + public static function sign_detached($message, $sk) { |
|
| 1603 | 1571 | return ParagonIE_Sodium_Core32_Ed25519::sign_detached($message, $sk); |
| 1604 | 1572 | } |
| 1605 | 1573 | |
@@ -1614,8 +1582,7 @@ discard block |
||
| 1614 | 1582 | * @throws SodiumException |
| 1615 | 1583 | * @throws TypeError |
| 1616 | 1584 | */ |
| 1617 | - public static function sign($message, $sk) |
|
| 1618 | - { |
|
| 1585 | + public static function sign($message, $sk) { |
|
| 1619 | 1586 | return ParagonIE_Sodium_Core32_Ed25519::sign($message, $sk); |
| 1620 | 1587 | } |
| 1621 | 1588 | |
@@ -1630,8 +1597,7 @@ discard block |
||
| 1630 | 1597 | * @throws SodiumException |
| 1631 | 1598 | * @throws TypeError |
| 1632 | 1599 | */ |
| 1633 | - public static function sign_open($signedMessage, $pk) |
|
| 1634 | - { |
|
| 1600 | + public static function sign_open($signedMessage, $pk) { |
|
| 1635 | 1601 | return ParagonIE_Sodium_Core32_Ed25519::sign_open($signedMessage, $pk); |
| 1636 | 1602 | } |
| 1637 | 1603 | |
@@ -1647,8 +1613,7 @@ discard block |
||
| 1647 | 1613 | * @throws SodiumException |
| 1648 | 1614 | * @throws TypeError |
| 1649 | 1615 | */ |
| 1650 | - public static function sign_verify_detached($signature, $message, $pk) |
|
| 1651 | - { |
|
| 1616 | + public static function sign_verify_detached($signature, $message, $pk) { |
|
| 1652 | 1617 | return ParagonIE_Sodium_Core32_Ed25519::verify_detached($signature, $message, $pk); |
| 1653 | 1618 | } |
| 1654 | 1619 | } |
@@ -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 | |