Changeset 60905 for trunk/src/wp-includes/sodium_compat/src/Core/Util.php
- Timestamp:
- 10/06/2025 03:46:40 PM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/src/Core/Util.php
r58752 r60905 182 182 $left = str_pad($left, $len, "\x00", STR_PAD_RIGHT); 183 183 $right = str_pad($right, $len, "\x00", STR_PAD_RIGHT); 184 } elseif ($leftLen !== $rightLen) { 185 throw new SodiumException("Argument #1 and argument #2 must have the same length"); 184 186 } 185 187 … … 337 339 * @param bool $strictPadding 338 340 * @return string (raw binary) 339 * @throws RangeException 341 * 342 * @throws SodiumException 340 343 * @throws TypeError 341 344 */ … … 355 358 $hex_len = self::strlen($hexString); 356 359 $state = 0; 357 if (($hex_len & 1) !== 0) {358 if ($strictPadding) {359 throw new RangeException(360 'Expected an even number of hexadecimal characters'361 );362 } else {363 $hexString = '0' . $hexString;364 ++$hex_len;365 }366 }367 360 368 361 $chunk = unpack('C*', $hexString); … … 391 384 $state ^= 1; 392 385 } 386 if ($strictPadding && $state !== 0) { 387 throw new SodiumException( 388 'Expected an even number of hexadecimal characters' 389 ); 390 } 393 391 return $bin; 394 392 } … … 535 533 public static function memcmp($left, $right) 536 534 { 537 if (self::hashEquals($left, $right)) { 538 return 0; 539 } 540 return -1; 535 $e = (int) !self::hashEquals($left, $right); 536 return 0 - $e; 541 537 } 542 538
Note: See TracChangeset
for help on using the changeset viewer.