Ticket #47186: 47186-combined.patch
| File 47186-combined.patch, 30.9 KB (added by , 7 years ago) |
|---|
-
wp-includes/sodium_compat/lib/php72compat.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
250 250 function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) 251 251 { 252 252 try { 253 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key );253 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key, true); 254 254 } catch (Error $ex) { 255 255 return false; 256 256 } catch (Exception $ex) { … … 271 271 */ 272 272 function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) 273 273 { 274 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key );274 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key, true); 275 275 } 276 276 } 277 277 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) { -
wp-includes/sodium_compat/src/Core/Curve25519/Fe.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
12 12 class ParagonIE_Sodium_Core_Curve25519_Fe implements ArrayAccess 13 13 { 14 14 /** 15 * @var array 15 * @var array<int, int> 16 16 */ 17 17 protected $container = array(); 18 18 … … 24 24 /** 25 25 * @internal You should not use this directly from another application 26 26 * 27 * @param array $array27 * @param array<int, int> $array 28 28 * @param bool $save_indexes 29 29 * @return self 30 30 */ … … 37 37 $keys = range(0, $count - 1); 38 38 } 39 39 $array = array_values($array); 40 /** @var array<int, int> $keys */ 40 41 41 42 $obj = new ParagonIE_Sodium_Core_Curve25519_Fe(); 42 43 if ($save_indexes) { … … 54 55 /** 55 56 * @internal You should not use this directly from another application 56 57 * 57 * @param mixed$offset58 * @param mixed$value58 * @param int $offset 59 * @param int $value 59 60 * @return void 60 61 * @psalm-suppress MixedArrayOffset 61 62 */ … … 74 75 /** 75 76 * @internal You should not use this directly from another application 76 77 * 77 * @param mixed$offset78 * @param int $offset 78 79 * @return bool 79 80 * @psalm-suppress MixedArrayOffset 80 81 */ … … 86 87 /** 87 88 * @internal You should not use this directly from another application 88 89 * 89 * @param mixed$offset90 * @param int $offset 90 91 * @return void 91 92 * @psalm-suppress MixedArrayOffset 92 93 */ … … 98 99 /** 99 100 * @internal You should not use this directly from another application 100 101 * 101 * @param mixed$offset102 * @return mixed|null102 * @param int $offset 103 * @return int 103 104 * @psalm-suppress MixedArrayOffset 104 105 */ 105 106 public function offsetGet($offset) 106 107 { 107 return isset($this->container[$offset]) 108 ? $this->container[$offset] 109 : null; 108 if (!isset($this->container[$offset])) { 109 $this->container[$offset] = 0; 110 } 111 return (int) ($this->container[$offset]); 110 112 } 111 113 112 114 /** -
wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
89 89 /** 90 90 * @internal You should not use this directly from another application 91 91 * 92 * @param mixed$offset92 * @param int $offset 93 93 * @return bool 94 94 * @psalm-suppress MixedArrayOffset 95 95 */ … … 101 101 /** 102 102 * @internal You should not use this directly from another application 103 103 * 104 * @param mixed$offset104 * @param int $offset 105 105 * @return void 106 106 * @psalm-suppress MixedArrayOffset 107 107 */ … … 113 113 /** 114 114 * @internal You should not use this directly from another application 115 115 * 116 * @param mixed$offset116 * @param int $offset 117 117 * @return mixed|null 118 118 * @psalm-suppress MixedArrayOffset 119 119 */ -
wp-includes/sodium_compat/src/Core32/Int32.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
150 150 ); 151 151 } 152 152 153 /** 154 * @param array<int, int> $a 155 * @param array<int, int> $b 156 * @param int $baseLog2 157 * @return array<int, int> 158 */ 159 public function multiplyLong(array $a, array $b, $baseLog2 = 16) 160 { 161 $a_l = count($a); 162 $b_l = count($b); 163 /** @var array<int, int> $r */ 164 $r = array_fill(0, $a_l + $b_l + 1, 0); 165 $base = 1 << $baseLog2; 166 for ($i = 0; $i < $a_l; ++$i) { 167 $a_i = $a[$i]; 168 for ($j = 0; $j < $a_l; ++$j) { 169 $b_j = $b[$j]; 170 $product = ($a_i * $b_j) + $r[$i + $j]; 171 $carry = ($product >> $baseLog2 & 0xffff); 172 $r[$i + $j] = ($product - (int) ($carry * $base)) & 0xffff; 173 $r[$i + $j + 1] += $carry; 174 } 175 } 176 return array_slice($r, 0, 5); 177 } 178 179 /** 180 * @param int $int 181 * @return ParagonIE_Sodium_Core32_Int32 182 */ 183 public function mulIntFast($int) 184 { 185 // Handle negative numbers 186 $aNeg = ($this->limbs[0] >> 15) & 1; 187 $bNeg = ($int >> 31) & 1; 188 $a = array_reverse($this->limbs); 189 $b = array( 190 $int & 0xffff, 191 ($int >> 16) & 0xffff 192 ); 193 if ($aNeg) { 194 for ($i = 0; $i < 2; ++$i) { 195 $a[$i] = ($a[$i] ^ 0xffff) & 0xffff; 196 } 197 ++$a[0]; 198 } 199 if ($bNeg) { 200 for ($i = 0; $i < 2; ++$i) { 201 $b[$i] = ($b[$i] ^ 0xffff) & 0xffff; 202 } 203 ++$b[0]; 204 } 205 // Multiply 206 $res = $this->multiplyLong($a, $b); 207 208 // Re-apply negation to results 209 if ($aNeg !== $bNeg) { 210 for ($i = 0; $i < 2; ++$i) { 211 $res[$i] = (0xffff ^ $res[$i]) & 0xffff; 212 } 213 // Handle integer overflow 214 $c = 1; 215 for ($i = 0; $i < 2; ++$i) { 216 $res[$i] += $c; 217 $c = $res[$i] >> 16; 218 $res[$i] &= 0xffff; 219 } 220 } 221 222 // Return our values 223 $return = new ParagonIE_Sodium_Core32_Int32(); 224 $return->limbs = array( 225 $res[1] & 0xffff, 226 $res[0] & 0xffff 227 ); 228 if (count($res) > 2) { 229 $return->overflow = $res[2] & 0xffff; 230 } 231 $return->unsignedInt = $this->unsignedInt; 232 return $return; 233 } 234 235 /** 236 * @param ParagonIE_Sodium_Core32_Int32 $right 237 * @return ParagonIE_Sodium_Core32_Int32 238 */ 239 public function mulInt32Fast(ParagonIE_Sodium_Core32_Int32 $right) 240 { 241 $aNeg = ($this->limbs[0] >> 15) & 1; 242 $bNeg = ($right->limbs[0] >> 15) & 1; 243 244 $a = array_reverse($this->limbs); 245 $b = array_reverse($right->limbs); 246 if ($aNeg) { 247 for ($i = 0; $i < 2; ++$i) { 248 $a[$i] = ($a[$i] ^ 0xffff) & 0xffff; 249 } 250 ++$a[0]; 251 } 252 if ($bNeg) { 253 for ($i = 0; $i < 2; ++$i) { 254 $b[$i] = ($b[$i] ^ 0xffff) & 0xffff; 255 } 256 ++$b[0]; 257 } 258 $res = $this->multiplyLong($a, $b); 259 if ($aNeg !== $bNeg) { 260 if ($aNeg !== $bNeg) { 261 for ($i = 0; $i < 2; ++$i) { 262 $res[$i] = ($res[$i] ^ 0xffff) & 0xffff; 263 } 264 $c = 1; 265 for ($i = 0; $i < 2; ++$i) { 266 $res[$i] += $c; 267 $c = $res[$i] >> 16; 268 $res[$i] &= 0xffff; 269 } 270 } 271 } 272 $return = new ParagonIE_Sodium_Core32_Int32(); 273 $return->limbs = array( 274 $res[1] & 0xffff, 275 $res[0] & 0xffff 276 ); 277 if (count($res) > 2) { 278 $return->overflow = $res[2]; 279 } 280 return $return; 281 } 282 153 283 /** 154 284 * @param int $int 155 285 * @param int $size … … 161 291 { 162 292 ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1); 163 293 ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2); 294 if (ParagonIE_Sodium_Compat::$fastMult) { 295 return $this->mulIntFast((int) $int); 296 } 164 297 /** @var int $int */ 165 298 $int = (int) $int; 166 299 /** @var int $size */ … … 218 351 public function mulInt32(ParagonIE_Sodium_Core32_Int32 $int, $size = 0) 219 352 { 220 353 ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2); 354 if (ParagonIE_Sodium_Compat::$fastMult) { 355 return $this->mulInt32Fast($int); 356 } 221 357 if (!$size) { 222 358 $size = 31; 223 359 } … … 491 627 /** @var int $c */ 492 628 return $this->shiftLeft(-$c); 493 629 } else { 494 if ( is_null($c)) {630 if (!is_int($c)) { 495 631 throw new TypeError(); 496 632 } 497 633 /** @var int $c */ -
wp-includes/sodium_compat/src/Crypto.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
819 819 */ 820 820 public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk) 821 821 { 822 return self::generichash(823 self::scalarmult($my_sk, $their_pk) .822 return ParagonIE_Sodium_Compat::crypto_generichash( 823 ParagonIE_Sodium_Compat::crypto_scalarmult($my_sk, $their_pk) . 824 824 $client_pk . 825 825 $server_pk 826 826 ); -
wp-admin/includes/file.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1199 1199 1200 1200 } 1201 1201 1202 if ( 1203 ! extension_loaded( 'sodium' ) && 1204 ! ParagonIE_Sodium_Compat::polyfill_is_fast() 1205 ) { 1206 $max = ini_get('max_execution_time'); 1207 if ($max > 0 && $max < 60) { 1208 // This cannot be performed in a reasonable amount of time 1209 // https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast 1210 1211 return new WP_Error( 1212 'signature_verification_unsupported', 1213 sprintf( 1214 /* translators: 1: The filename of the package. */ 1215 __('The authenticity of %1$s could not be verified as signature verification is unavailable on this system.'), 1216 '<span class="code">' . esc_html($filename_for_errors) . '</span>' 1217 ), 1218 array( 1219 'php' => phpversion(), 1220 'sodium' => defined('SODIUM_LIBRARY_VERSION') ? SODIUM_LIBRARY_VERSION : (defined('ParagonIE_Sodium_Compat::VERSION_STRING') ? ParagonIE_Sodium_Compat::VERSION_STRING : false), 1221 'polyfill-is-fast' => false, 1222 'max-execution-time' => $max 1223 ) 1224 ); 1225 } 1226 } 1227 1202 1228 if ( ! $signatures ) { 1203 1229 return new WP_Error( 1204 1230 'signature_verification_no_signature', -
wp-includes/sodium_compat/src/Core32/X25519.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
102 102 */ 103 103 public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f) 104 104 { 105 /** @var array<int, ParagonIE_Sodium_Core32_Int 32> $h */105 /** @var array<int, ParagonIE_Sodium_Core32_Int64> $h */ 106 106 $h = array(); 107 107 for ($i = 0; $i < 10; ++$i) { 108 108 $h[$i] = $f[$i]->toInt64()->mulInt(121666, 17); 109 109 } 110 110 111 /** @var ParagonIE_Sodium_Core32_Int32 $carry9 */112 111 $carry9 = $h[9]->addInt(1 << 24)->shiftRight(25); 113 112 $h[0] = $h[0]->addInt64($carry9->mulInt(19, 5)); 114 113 $h[9] = $h[9]->subInt64($carry9->shiftLeft(25)); 115 114 116 /** @var ParagonIE_Sodium_Core32_Int32 $carry1 */117 115 $carry1 = $h[1]->addInt(1 << 24)->shiftRight(25); 118 116 $h[2] = $h[2]->addInt64($carry1); 119 117 $h[1] = $h[1]->subInt64($carry1->shiftLeft(25)); 120 118 121 /** @var ParagonIE_Sodium_Core32_Int32 $carry3 */122 119 $carry3 = $h[3]->addInt(1 << 24)->shiftRight(25); 123 120 $h[4] = $h[4]->addInt64($carry3); 124 121 $h[3] = $h[3]->subInt64($carry3->shiftLeft(25)); 125 122 126 /** @var ParagonIE_Sodium_Core32_Int32 $carry5 */127 123 $carry5 = $h[5]->addInt(1 << 24)->shiftRight(25); 128 124 $h[6] = $h[6]->addInt64($carry5); 129 125 $h[5] = $h[5]->subInt64($carry5->shiftLeft(25)); 130 126 131 /** @var ParagonIE_Sodium_Core32_Int32 $carry7 */132 127 $carry7 = $h[7]->addInt(1 << 24)->shiftRight(25); 133 128 $h[8] = $h[8]->addInt64($carry7); 134 129 $h[7] = $h[7]->subInt64($carry7->shiftLeft(25)); 135 130 136 /** @var ParagonIE_Sodium_Core32_Int32 $carry0 */137 131 $carry0 = $h[0]->addInt(1 << 25)->shiftRight(26); 138 132 $h[1] = $h[1]->addInt64($carry0); 139 133 $h[0] = $h[0]->subInt64($carry0->shiftLeft(26)); 140 134 141 /** @var ParagonIE_Sodium_Core32_Int32 $carry2 */142 135 $carry2 = $h[2]->addInt(1 << 25)->shiftRight(26); 143 136 $h[3] = $h[3]->addInt64($carry2); 144 137 $h[2] = $h[2]->subInt64($carry2->shiftLeft(26)); 145 138 146 /** @var ParagonIE_Sodium_Core32_Int32 $carry4 */147 139 $carry4 = $h[4]->addInt(1 << 25)->shiftRight(26); 148 140 $h[5] = $h[5]->addInt64($carry4); 149 141 $h[4] = $h[4]->subInt64($carry4->shiftLeft(26)); 150 142 151 /** @var ParagonIE_Sodium_Core32_Int32 $carry6 */152 143 $carry6 = $h[6]->addInt(1 << 25)->shiftRight(26); 153 144 $h[7] = $h[7]->addInt64($carry6); 154 145 $h[6] = $h[6]->subInt64($carry6->shiftLeft(26)); 155 146 156 /** @var ParagonIE_Sodium_Core32_Int32 $carry8 */157 147 $carry8 = $h[8]->addInt(1 << 25)->shiftRight(26); 158 148 $h[9] = $h[9]->addInt64($carry8); 159 149 $h[8] = $h[8]->subInt64($carry8->shiftLeft(26)); -
wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
83 83 /** 84 84 * @internal You should not use this directly from another application 85 85 * 86 * @param mixed$offset86 * @param int $offset 87 87 * @return bool 88 * @psalm-suppress MixedArrayOffset89 88 */ 90 89 public function offsetExists($offset) 91 90 { … … 95 94 /** 96 95 * @internal You should not use this directly from another application 97 96 * 98 * @param mixed$offset97 * @param int $offset 99 98 * @return void 100 99 * @psalm-suppress MixedArrayOffset 101 100 */ … … 107 106 /** 108 107 * @internal You should not use this directly from another application 109 108 * 110 * @param mixed$offset109 * @param int $offset 111 110 * @return mixed|null 112 111 * @psalm-suppress MixedArrayOffset 113 112 */ -
wp-includes/sodium_compat/src/Core32/Int64.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
205 205 */ 206 206 public function mulInt($int = 0, $size = 0) 207 207 { 208 if (ParagonIE_Sodium_Compat::$fastMult) { 209 return $this->mulIntFast($int); 210 } 208 211 ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1); 209 212 ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2); 210 213 /** @var int $int */ … … 268 271 $a3 &= 0xffff; 269 272 270 273 $int >>= 1; 271 $return->limbs[0] = $ret0;272 $return->limbs[1] = $ret1;273 $return->limbs[2] = $ret2;274 $return->limbs[3] = $ret3;275 }274 } 275 $return->limbs[0] = $ret0; 276 $return->limbs[1] = $ret1; 277 $return->limbs[2] = $ret2; 278 $return->limbs[3] = $ret3; 276 279 return $return; 277 280 } 278 281 … … 317 320 ); 318 321 } 319 322 323 /** 324 * @param array<int, int> $a 325 * @param array<int, int> $b 326 * @param int $baseLog2 327 * @return array<int, int> 328 */ 329 public function multiplyLong(array $a, array $b, $baseLog2 = 16) 330 { 331 $a_l = count($a); 332 $b_l = count($b); 333 /** @var array<int, int> $r */ 334 $r = array_fill(0, $a_l + $b_l + 1, 0); 335 $base = 1 << $baseLog2; 336 for ($i = 0; $i < $a_l; ++$i) { 337 $a_i = $a[$i]; 338 for ($j = 0; $j < $a_l; ++$j) { 339 $b_j = $b[$j]; 340 $product = ($a_i * $b_j) + $r[$i + $j]; 341 $carry = ($product >> $baseLog2 & 0xffff); 342 $r[$i + $j] = ($product - (int) ($carry * $base)) & 0xffff; 343 $r[$i + $j + 1] += $carry; 344 } 345 } 346 return array_slice($r, 0, 5); 347 } 348 349 /** 350 * @param int $int 351 * @return ParagonIE_Sodium_Core32_Int64 352 */ 353 public function mulIntFast($int) 354 { 355 // Handle negative numbers 356 $aNeg = ($this->limbs[0] >> 15) & 1; 357 $bNeg = ($int >> 31) & 1; 358 $a = array_reverse($this->limbs); 359 $b = array( 360 $int & 0xffff, 361 ($int >> 16) & 0xffff, 362 -$bNeg & 0xffff, 363 -$bNeg & 0xffff 364 ); 365 if ($aNeg) { 366 for ($i = 0; $i < 4; ++$i) { 367 $a[$i] = ($a[$i] ^ 0xffff) & 0xffff; 368 } 369 ++$a[0]; 370 } 371 if ($bNeg) { 372 for ($i = 0; $i < 4; ++$i) { 373 $b[$i] = ($b[$i] ^ 0xffff) & 0xffff; 374 } 375 ++$b[0]; 376 } 377 // Multiply 378 $res = $this->multiplyLong($a, $b); 379 380 // Re-apply negation to results 381 if ($aNeg !== $bNeg) { 382 for ($i = 0; $i < 4; ++$i) { 383 $res[$i] = (0xffff ^ $res[$i]) & 0xffff; 384 } 385 // Handle integer overflow 386 $c = 1; 387 for ($i = 0; $i < 4; ++$i) { 388 $res[$i] += $c; 389 $c = $res[$i] >> 16; 390 $res[$i] &= 0xffff; 391 } 392 } 393 394 // Return our values 395 $return = new ParagonIE_Sodium_Core32_Int64(); 396 $return->limbs = array( 397 $res[3] & 0xffff, 398 $res[2] & 0xffff, 399 $res[1] & 0xffff, 400 $res[0] & 0xffff 401 ); 402 if (count($res) > 4) { 403 $return->overflow = $res[4] & 0xffff; 404 } 405 $return->unsignedInt = $this->unsignedInt; 406 return $return; 407 } 408 409 /** 410 * @param ParagonIE_Sodium_Core32_Int64 $right 411 * @return ParagonIE_Sodium_Core32_Int64 412 */ 413 public function mulInt64Fast(ParagonIE_Sodium_Core32_Int64 $right) 414 { 415 $aNeg = ($this->limbs[0] >> 15) & 1; 416 $bNeg = ($right->limbs[0] >> 15) & 1; 417 418 $a = array_reverse($this->limbs); 419 $b = array_reverse($right->limbs); 420 if ($aNeg) { 421 for ($i = 0; $i < 4; ++$i) { 422 $a[$i] = ($a[$i] ^ 0xffff) & 0xffff; 423 } 424 ++$a[0]; 425 } 426 if ($bNeg) { 427 for ($i = 0; $i < 4; ++$i) { 428 $b[$i] = ($b[$i] ^ 0xffff) & 0xffff; 429 } 430 ++$b[0]; 431 } 432 $res = $this->multiplyLong($a, $b); 433 if ($aNeg !== $bNeg) { 434 if ($aNeg !== $bNeg) { 435 for ($i = 0; $i < 4; ++$i) { 436 $res[$i] = ($res[$i] ^ 0xffff) & 0xffff; 437 } 438 $c = 1; 439 for ($i = 0; $i < 4; ++$i) { 440 $res[$i] += $c; 441 $c = $res[$i] >> 16; 442 $res[$i] &= 0xffff; 443 } 444 } 445 } 446 $return = new ParagonIE_Sodium_Core32_Int64(); 447 $return->limbs = array( 448 $res[3] & 0xffff, 449 $res[2] & 0xffff, 450 $res[1] & 0xffff, 451 $res[0] & 0xffff 452 ); 453 if (count($res) > 4) { 454 $return->overflow = $res[4]; 455 } 456 return $return; 457 } 458 320 459 /** 321 460 * @param ParagonIE_Sodium_Core32_Int64 $int 322 461 * @param int $size … … 327 466 */ 328 467 public function mulInt64(ParagonIE_Sodium_Core32_Int64 $int, $size = 0) 329 468 { 469 if (ParagonIE_Sodium_Compat::$fastMult) { 470 return $this->mulInt64Fast($int); 471 } 330 472 ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2); 331 473 if (!$size) { 332 474 $size = 63; … … 566 708 /** @var int $c */ 567 709 return $this->shiftRight(-$c); 568 710 } else { 569 if ( is_null($c)) {711 if (!is_int($c)) { 570 712 throw new TypeError(); 571 713 } 572 714 /** @var int $carry */ … … 591 733 public function shiftRight($c = 0) 592 734 { 593 735 ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1); 736 $c = (int) $c; 737 /** @var int $c */ 594 738 $return = new ParagonIE_Sodium_Core32_Int64(); 595 739 $return->unsignedInt = $this->unsignedInt; 596 740 $c &= 63; 597 /** @var int $c */598 741 599 742 $negative = -(($this->limbs[0] >> 15) & 1); 600 743 if ($c >= 16) { -
wp-includes/sodium_compat/src/Core/BLAKE2b.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
256 256 if (++$i > $maxLength) { 257 257 return; 258 258 } 259 /** @psalm-suppress MixedOperand */ 259 260 $u[$uIdx] >>= 8; 260 261 } 261 262 } -
wp-includes/sodium_compat/src/Compat.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
669 669 * This mode uses a 64-bit random nonce with a 64-bit counter. 670 670 * IETF mode uses a 96-bit random nonce with a 32-bit counter. 671 671 * 672 * @param string $ciphertext Encrypted message (with Poly1305 MAC appended) 673 * @param string $assocData Authenticated Associated Data (unencrypted) 674 * @param string $nonce Number to be used only Once; must be 8 bytes 675 * @param string $key Encryption key 672 * @param string $ciphertext Encrypted message (with Poly1305 MAC appended) 673 * @param string $assocData Authenticated Associated Data (unencrypted) 674 * @param string $nonce Number to be used only Once; must be 8 bytes 675 * @param string $key Encryption key 676 * @param bool $dontFallback Don't fallback to ext/sodium 676 677 * 677 678 * @return string The original plaintext message 678 679 * @throws SodiumException … … 683 684 $ciphertext = '', 684 685 $assocData = '', 685 686 $nonce = '', 686 $key = '' 687 $key = '', 688 $dontFallback = false 687 689 ) { 688 690 /* Type checks: */ 689 691 ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1); … … 701 703 if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES) { 702 704 throw new SodiumException('Message must be at least CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES long'); 703 705 } 706 if (self::useNewSodiumAPI() && !$dontFallback) { 707 if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) { 708 return sodium_crypto_aead_xchacha20poly1305_ietf_decrypt( 709 $ciphertext, 710 $assocData, 711 $nonce, 712 $key 713 ); 714 } 715 } 704 716 705 717 if (PHP_INT_SIZE === 4) { 706 718 return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_decrypt( … … 727 739 * This mode uses a 64-bit random nonce with a 64-bit counter. 728 740 * IETF mode uses a 96-bit random nonce with a 32-bit counter. 729 741 * 730 * @param string $plaintext Message to be encrypted 731 * @param string $assocData Authenticated Associated Data (unencrypted) 732 * @param string $nonce Number to be used only Once; must be 8 bytes 733 * @param string $key Encryption key 742 * @param string $plaintext Message to be encrypted 743 * @param string $assocData Authenticated Associated Data (unencrypted) 744 * @param string $nonce Number to be used only Once; must be 8 bytes 745 * @param string $key Encryption key 746 * @param bool $dontFallback Don't fallback to ext/sodium 734 747 * 735 748 * @return string Ciphertext with a 16-byte Poly1305 message 736 749 * authentication code appended … … 742 755 $plaintext = '', 743 756 $assocData = '', 744 757 $nonce = '', 745 $key = '' 758 $key = '', 759 $dontFallback = false 746 760 ) { 747 761 /* Type checks: */ 748 762 ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); … … 757 771 if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) { 758 772 throw new SodiumException('Key must be CRYPTO_AEAD_XCHACHA20POLY1305_KEYBYTES long'); 759 773 } 774 if (self::useNewSodiumAPI() && !$dontFallback) { 775 if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) { 776 return sodium_crypto_aead_xchacha20poly1305_ietf_encrypt( 777 $plaintext, 778 $assocData, 779 $nonce, 780 $key 781 ); 782 } 783 } 760 784 761 785 if (PHP_INT_SIZE === 4) { 762 786 return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt( … … 1285 1309 * @throws SodiumException 1286 1310 * @throws TypeError 1287 1311 * @psalm-suppress MixedArgument 1312 * @psalm-suppress ReferenceConstraintViolation 1288 1313 */ 1289 1314 public static function crypto_generichash_final(&$ctx, $length = self::CRYPTO_GENERICHASH_BYTES) 1290 1315 { … … 1359 1384 * 1360 1385 * @param string &$ctx BLAKE2 hashing context. Generated by crypto_generichash_init(). 1361 1386 * $ctx is passed by reference and gets updated in-place. 1387 * @param-out string $ctx 1362 1388 * @param string $message The message to append to the existing hash state. 1363 1389 * @return void 1364 1390 * @throws SodiumException 1365 1391 * @throws TypeError 1366 1392 * @psalm-suppress MixedArgument 1393 * @psalm-suppress ReferenceConstraintViolation 1367 1394 */ 1368 1395 public static function crypto_generichash_update(&$ctx, $message) 1369 1396 { … … 2610 2637 * native library for that. 2611 2638 * 2612 2639 * @param string|null $var 2640 * @param-out string|null $var 2613 2641 * 2614 2642 * @return void 2615 2643 * @throws SodiumException (Unless libsodium is installed) … … 2622 2650 ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1); 2623 2651 2624 2652 if (self::useNewSodiumAPI()) { 2653 /** @psalm-suppress MixedArgument */ 2625 2654 sodium_memzero($var); 2626 2655 return; 2627 2656 } -
wp-includes/sodium_compat/src/File.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
590 590 $az[0] = self::intToChr(self::chrToInt($az[0]) & 248); 591 591 $az[31] = self::intToChr((self::chrToInt($az[31]) & 63) | 64); 592 592 593 /** @var resource $hs */594 593 $hs = hash_init('sha512'); 595 594 hash_update($hs, self::substr($az, 32, 32)); 596 595 /** @var resource $hs */ … … 610 609 ParagonIE_Sodium_Core_Ed25519::ge_scalarmult_base($nonce) 611 610 ); 612 611 613 /** @var resource $hs */614 612 $hs = hash_init('sha512'); 615 613 hash_update($hs, self::substr($sig, 0, 32)); 616 614 hash_update($hs, self::substr($pk, 0, 32)); … … 719 717 /** @var ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A */ 720 718 $A = ParagonIE_Sodium_Core_Ed25519::ge_frombytes_negate_vartime($publicKey); 721 719 722 /** @var resource $hs */723 720 $hs = hash_init('sha512'); 724 721 hash_update($hs, self::substr($sig, 0, 32)); 725 722 hash_update($hs, self::substr($publicKey, 0, 32)); … … 1167 1164 $az[0] = self::intToChr(self::chrToInt($az[0]) & 248); 1168 1165 $az[31] = self::intToChr((self::chrToInt($az[31]) & 63) | 64); 1169 1166 1170 /** @var resource $hs */1171 1167 $hs = hash_init('sha512'); 1172 1168 hash_update($hs, self::substr($az, 32, 32)); 1173 1169 /** @var resource $hs */ … … 1187 1183 ParagonIE_Sodium_Core32_Ed25519::ge_scalarmult_base($nonce) 1188 1184 ); 1189 1185 1190 /** @var resource $hs */1191 1186 $hs = hash_init('sha512'); 1192 1187 hash_update($hs, self::substr($sig, 0, 32)); 1193 1188 hash_update($hs, self::substr($pk, 0, 32)); … … 1272 1267 /** @var ParagonIE_Sodium_Core32_Curve25519_Ge_P3 $A */ 1273 1268 $A = ParagonIE_Sodium_Core32_Ed25519::ge_frombytes_negate_vartime($publicKey); 1274 1269 1275 /** @var resource $hs */1276 1270 $hs = hash_init('sha512'); 1277 1271 hash_update($hs, self::substr($sig, 0, 32)); 1278 1272 hash_update($hs, self::substr($publicKey, 0, 32));