aboutsummaryrefslogtreecommitdiff
path: root/vendor/paragonie
diff options
context:
space:
mode:
authorsupahgreg <supahgreg@users.noreply.github.com>2025-10-09 02:49:56 +0000
committersupahgreg <supahgreg@users.noreply.github.com>2025-10-09 03:08:30 +0000
commite41d6361221a30ca9d996cde7591111e626b7e1c (patch)
tree4572f61f37bbc76192ad60e0940c281483bc03af /vendor/paragonie
parentab0aabf8548c206f3f624de5451a9b6abbde90be (diff)
Remove dev dependencies and update the rest.
Diffstat (limited to 'vendor/paragonie')
-rw-r--r--vendor/paragonie/constant_time_encoding/composer.json15
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base32.php75
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base32Hex.php11
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base64.php98
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php4
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php4
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php4
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Binary.php22
-rw-r--r--vendor/paragonie/constant_time_encoding/src/EncoderInterface.php13
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Encoding.php45
-rw-r--r--vendor/paragonie/constant_time_encoding/src/Hex.php51
-rw-r--r--vendor/paragonie/constant_time_encoding/src/RFC4648.php22
12 files changed, 253 insertions, 111 deletions
diff --git a/vendor/paragonie/constant_time_encoding/composer.json b/vendor/paragonie/constant_time_encoding/composer.json
index 5023095b4..11fad5e63 100644
--- a/vendor/paragonie/constant_time_encoding/composer.json
+++ b/vendor/paragonie/constant_time_encoding/composer.json
@@ -40,8 +40,10 @@
"php": "^8"
},
"require-dev": {
- "phpunit/phpunit": "^9",
- "vimeo/psalm": "^4|^5"
+ "infection/infection": "^0",
+ "nikic/php-fuzzer": "^0",
+ "phpunit/phpunit": "^9|^10|^11",
+ "vimeo/psalm": "^4|^5|^6"
},
"autoload": {
"psr-4": {
@@ -52,5 +54,14 @@
"psr-4": {
"ParagonIE\\ConstantTime\\Tests\\": "tests/"
}
+ },
+ "scripts": {
+ "mutation-test": "infection"
+ },
+ "config": {
+ "process-timeout": 0,
+ "allow-plugins": {
+ "infection/extension-installer": true
+ }
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Base32.php b/vendor/paragonie/constant_time_encoding/src/Base32.php
index 48d00b991..379552af5 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base32.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base32.php
@@ -3,8 +3,15 @@ declare(strict_types=1);
namespace ParagonIE\ConstantTime;
use InvalidArgumentException;
+use Override;
use RangeException;
+use SensitiveParameter;
use TypeError;
+use function pack;
+use function rtrim;
+use function strlen;
+use function substr;
+use function unpack;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -44,8 +51,9 @@ abstract class Base32 implements EncoderInterface
* @param bool $strictPadding
* @return string
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
@@ -60,7 +68,7 @@ abstract class Base32 implements EncoderInterface
* @return string
*/
public static function decodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $strictPadding = false
): string {
@@ -74,8 +82,9 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
return static::doEncode($binString, false, true);
@@ -87,9 +96,10 @@ abstract class Base32 implements EncoderInterface
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, false, false);
@@ -101,9 +111,10 @@ abstract class Base32 implements EncoderInterface
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, true);
@@ -115,9 +126,10 @@ abstract class Base32 implements EncoderInterface
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUpperUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, false);
@@ -129,6 +141,7 @@ abstract class Base32 implements EncoderInterface
*
* @param int $src
* @return int
+ * @api
*/
protected static function decode5Bits(int $src): int
{
@@ -151,6 +164,7 @@ abstract class Base32 implements EncoderInterface
*
* @param int $src
* @return int
+ * @api
*/
protected static function decode5BitsUpper(int $src): int
{
@@ -171,6 +185,7 @@ abstract class Base32 implements EncoderInterface
*
* @param int $src
* @return string
+ * @api
*/
protected static function encode5Bits(int $src): string
{
@@ -179,7 +194,7 @@ abstract class Base32 implements EncoderInterface
// if ($src > 25) $ret -= 72;
$diff -= ((25 - $src) >> 8) & 73;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
/**
@@ -190,6 +205,7 @@ abstract class Base32 implements EncoderInterface
*
* @param int $src
* @return string
+ * @api
*/
protected static function encode5BitsUpper(int $src): string
{
@@ -198,20 +214,21 @@ abstract class Base32 implements EncoderInterface
// if ($src > 25) $ret -= 40;
$diff -= ((25 - $src) >> 8) & 41;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
/**
* @param string $encodedString
* @param bool $upper
* @return string
+ * @api
*/
public static function decodeNoPadding(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $upper = false
): string {
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -242,7 +259,7 @@ abstract class Base32 implements EncoderInterface
* @throws TypeError
*/
protected static function doDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $upper = false,
bool $strictPadding = false
@@ -253,7 +270,7 @@ abstract class Base32 implements EncoderInterface
: 'decode5Bits';
// Remove padding
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
if ($srcLen === 0) {
return '';
}
@@ -273,8 +290,8 @@ abstract class Base32 implements EncoderInterface
);
}
} else {
- $src = \rtrim($src, '=');
- $srcLen = Binary::safeStrlen($src);
+ $src = rtrim($src, '=');
+ $srcLen = strlen($src);
}
$err = 0;
@@ -282,7 +299,7 @@ abstract class Base32 implements EncoderInterface
// Main loop (no padding):
for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
+ $chunk = unpack('C*', substr($src, $i, 8));
/** @var int $c0 */
$c0 = static::$method($chunk[1]);
/** @var int $c1 */
@@ -300,7 +317,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c7 */
$c7 = static::$method($chunk[8]);
- $dest .= \pack(
+ $dest .= pack(
'CCCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -313,7 +330,7 @@ abstract class Base32 implements EncoderInterface
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
/** @var int $c0 */
$c0 = static::$method($chunk[1]);
@@ -331,7 +348,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c6 */
$c6 = static::$method($chunk[7]);
- $dest .= \pack(
+ $dest .= pack(
'CCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -354,7 +371,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c5 */
$c5 = static::$method($chunk[6]);
- $dest .= \pack(
+ $dest .= pack(
'CCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -372,7 +389,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c4 */
$c4 = static::$method($chunk[5]);
- $dest .= \pack(
+ $dest .= pack(
'CCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -390,7 +407,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c3 */
$c3 = static::$method($chunk[4]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
@@ -405,7 +422,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c2 */
$c2 = static::$method($chunk[3]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) ) & 0xff
@@ -418,7 +435,7 @@ abstract class Base32 implements EncoderInterface
/** @var int $c1 */
$c1 = static::$method($chunk[2]);
- $dest .= \pack(
+ $dest .= pack(
'C',
(($c0 << 3) | ($c1 >> 2) ) & 0xff
);
@@ -427,7 +444,7 @@ abstract class Base32 implements EncoderInterface
$err |= ($c1 << 6) & 0xff;
}
} else {
- $dest .= \pack(
+ $dest .= pack(
'C',
(($c0 << 3) ) & 0xff
);
@@ -453,10 +470,10 @@ abstract class Base32 implements EncoderInterface
* @throws TypeError
*/
protected static function doEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $upper = false,
- $pad = true
+ bool $pad = true
): string {
// We do this to reduce code duplication:
$method = $upper
@@ -464,12 +481,12 @@ abstract class Base32 implements EncoderInterface
: 'encode5Bits';
$dest = '';
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
// Main loop (no padding):
for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 5));
+ $chunk = unpack('C*', substr($src, $i, 5));
$b0 = $chunk[1];
$b1 = $chunk[2];
$b2 = $chunk[3];
@@ -488,7 +505,7 @@ abstract class Base32 implements EncoderInterface
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
if ($i + 3 < $srcLen) {
$b1 = $chunk[2];
diff --git a/vendor/paragonie/constant_time_encoding/src/Base32Hex.php b/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
index b868dd048..4323a573a 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
@@ -2,6 +2,9 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+use function pack;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -40,6 +43,7 @@ abstract class Base32Hex extends Base32
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode5Bits(int $src): int
{
$ret = -1;
@@ -60,6 +64,7 @@ abstract class Base32Hex extends Base32
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode5BitsUpper(int $src): int
{
$ret = -1;
@@ -80,6 +85,7 @@ abstract class Base32Hex extends Base32
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode5Bits(int $src): string
{
$src += 0x30;
@@ -87,7 +93,7 @@ abstract class Base32Hex extends Base32
// if ($src > 0x39) $src += 0x61 - 0x3a; // 39
$src += ((0x39 - $src) >> 8) & 39;
- return \pack('C', $src);
+ return pack('C', $src);
}
/**
@@ -99,6 +105,7 @@ abstract class Base32Hex extends Base32
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode5BitsUpper(int $src): string
{
$src += 0x30;
@@ -106,6 +113,6 @@ abstract class Base32Hex extends Base32
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
$src += ((0x39 - $src) >> 8) & 7;
- return \pack('C', $src);
+ return pack('C', $src);
}
} \ No newline at end of file
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64.php b/vendor/paragonie/constant_time_encoding/src/Base64.php
index 2e3ecc859..9679748dc 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64.php
@@ -3,8 +3,23 @@ declare(strict_types=1);
namespace ParagonIE\ConstantTime;
use InvalidArgumentException;
+use Override;
use RangeException;
+use SensitiveParameter;
+use SodiumException;
use TypeError;
+use function extension_loaded;
+use function pack;
+use function rtrim;
+use function sodium_base642bin;
+use function sodium_bin2base64;
+use function strlen;
+use function substr;
+use function unpack;
+use const SODIUM_BASE64_VARIANT_ORIGINAL;
+use const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING;
+use const SODIUM_BASE64_VARIANT_URLSAFE;
+use const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -47,10 +62,25 @@ abstract class Base64 implements EncoderInterface
*
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_bin2base64($binString, $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
return static::doEncode($binString, true);
}
@@ -63,11 +93,26 @@ abstract class Base64 implements EncoderInterface
* @return string
*
* @throws TypeError
+ * @api
*/
public static function encodeUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_bin2base64($src, $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
return static::doEncode($src, false);
}
@@ -79,16 +124,16 @@ abstract class Base64 implements EncoderInterface
* @throws TypeError
*/
protected static function doEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $pad = true
): string {
$dest = '';
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
// Main loop (no padding):
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 3));
+ $chunk = unpack('C*', substr($src, $i, 3));
$b0 = $chunk[1];
$b1 = $chunk[2];
$b2 = $chunk[3];
@@ -102,7 +147,7 @@ abstract class Base64 implements EncoderInterface
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
if ($i + 1 < $srcLen) {
$b1 = $chunk[2];
@@ -137,13 +182,14 @@ abstract class Base64 implements EncoderInterface
* @throws RangeException
* @throws TypeError
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
// Remove padding
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -167,9 +213,24 @@ abstract class Base64 implements EncoderInterface
'Incorrect padding'
);
}
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_base642bin(substr($encodedString, 0, $srcLen), $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
} else {
- $encodedString = \rtrim($encodedString, '=');
- $srcLen = Binary::safeStrlen($encodedString);
+ // Just remove all padding.
+ $encodedString = rtrim($encodedString, '=');
+ $srcLen = strlen($encodedString);
}
$err = 0;
@@ -177,13 +238,13 @@ abstract class Base64 implements EncoderInterface
// Main loop (no padding):
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, 4));
+ $chunk = unpack('C*', substr($encodedString, $i, 4));
$c0 = static::decode6Bits($chunk[1]);
$c1 = static::decode6Bits($chunk[2]);
$c2 = static::decode6Bits($chunk[3]);
$c3 = static::decode6Bits($chunk[4]);
- $dest .= \pack(
+ $dest .= pack(
'CCC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff),
@@ -194,13 +255,13 @@ abstract class Base64 implements EncoderInterface
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($encodedString, $i, $srcLen - $i));
$c0 = static::decode6Bits($chunk[1]);
if ($i + 2 < $srcLen) {
$c1 = static::decode6Bits($chunk[2]);
$c2 = static::decode6Bits($chunk[3]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff)
@@ -211,7 +272,7 @@ abstract class Base64 implements EncoderInterface
}
} elseif ($i + 1 < $srcLen) {
$c1 = static::decode6Bits($chunk[2]);
- $dest .= \pack(
+ $dest .= pack(
'C',
((($c0 << 2) | ($c1 >> 4)) & 0xff)
);
@@ -235,12 +296,13 @@ abstract class Base64 implements EncoderInterface
/**
* @param string $encodedString
* @return string
+ * @api
*/
public static function decodeNoPadding(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString
): string {
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -314,6 +376,6 @@ abstract class Base64 implements EncoderInterface
// if ($src > 62) $diff += 0x2f - 0x2b - 1; // 3
$diff += ((62 - $src) >> 8) & 3;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php b/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
index 5e98a8f79..847751767 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -44,6 +46,7 @@ abstract class Base64DotSlash extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -70,6 +73,7 @@ abstract class Base64DotSlash extends Base64
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$src += 0x2e;
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php b/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
index 9780b14bb..2c42db37f 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -44,6 +46,7 @@ abstract class Base64DotSlashOrdered extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -67,6 +70,7 @@ abstract class Base64DotSlashOrdered extends Base64
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$src += 0x2e;
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php b/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
index 8192c63d5..845aaf626 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -45,6 +47,7 @@ abstract class Base64UrlSafe extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -74,6 +77,7 @@ abstract class Base64UrlSafe extends Base64
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$diff = 0x41;
diff --git a/vendor/paragonie/constant_time_encoding/src/Binary.php b/vendor/paragonie/constant_time_encoding/src/Binary.php
index a958f2f7c..369584407 100644
--- a/vendor/paragonie/constant_time_encoding/src/Binary.php
+++ b/vendor/paragonie/constant_time_encoding/src/Binary.php
@@ -2,7 +2,10 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
use TypeError;
+use function strlen;
+use function substr;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -46,16 +49,10 @@ abstract class Binary
* @return int
*/
public static function safeStrlen(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): int {
- if (\function_exists('mb_strlen')) {
- // mb_strlen in PHP 7.x can return false.
- /** @psalm-suppress RedundantCast */
- return (int) \mb_strlen($str, '8bit');
- } else {
- return \strlen($str);
- }
+ return strlen($str);
}
/**
@@ -72,7 +69,7 @@ abstract class Binary
* @throws TypeError
*/
public static function safeSubstr(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str,
int $start = 0,
?int $length = null
@@ -80,14 +77,11 @@ abstract class Binary
if ($length === 0) {
return '';
}
- if (\function_exists('mb_substr')) {
- return \mb_substr($str, $start, $length, '8bit');
- }
// Unlike mb_substr(), substr() doesn't accept NULL for length
if ($length !== null) {
- return \substr($str, $start, $length);
+ return substr($str, $start, $length);
} else {
- return \substr($str, $start);
+ return substr($str, $start);
}
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php b/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
index 9cafbf96c..cb358ea0d 100644
--- a/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
+++ b/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -38,7 +40,10 @@ interface EncoderInterface
* @param string $binString (raw binary)
* @return string
*/
- public static function encode(string $binString): string;
+ public static function encode(
+ #[SensitiveParameter]
+ string $binString
+ ): string;
/**
* Convert a binary string into a hexadecimal string without cache-timing
@@ -48,5 +53,9 @@ interface EncoderInterface
* @param bool $strictPadding Error on invalid padding
* @return string (raw binary)
*/
- public static function decode(string $encodedString, bool $strictPadding = false): string;
+ public static function decode(
+ #[SensitiveParameter]
+ string $encodedString,
+ bool $strictPadding = false
+ ): string;
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Encoding.php b/vendor/paragonie/constant_time_encoding/src/Encoding.php
index 8b7e3878e..b28a5014e 100644
--- a/vendor/paragonie/constant_time_encoding/src/Encoding.php
+++ b/vendor/paragonie/constant_time_encoding/src/Encoding.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use RangeException;
+use SensitiveParameter;
use TypeError;
/**
@@ -30,6 +32,7 @@ use TypeError;
/**
* Class Encoding
* @package ParagonIE\ConstantTime
+ * @api
*/
abstract class Encoding
{
@@ -41,7 +44,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encode($str);
@@ -55,7 +58,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32EncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -69,7 +72,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decode($str);
@@ -83,7 +86,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32DecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str);
@@ -97,7 +100,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32HexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::encode($str);
@@ -111,7 +114,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32HexEncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::encodeUpper($str);
@@ -125,7 +128,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32HexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::decode($str);
@@ -139,7 +142,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32HexDecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::decodeUpper($str);
@@ -153,7 +156,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base64Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::encode($str);
@@ -167,7 +170,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base64Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::decode($str);
@@ -182,7 +185,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base64EncodeDotSlash(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlash::encode($str);
@@ -195,11 +198,11 @@ abstract class Encoding
*
* @param string $str
* @return string
- * @throws \RangeException
+ * @throws RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlash(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlash::decode($str);
@@ -214,7 +217,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base64EncodeDotSlashOrdered(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::encode($str);
@@ -227,11 +230,11 @@ abstract class Encoding
*
* @param string $str
* @return string
- * @throws \RangeException
+ * @throws RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlashOrdered(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::decode($str);
@@ -246,7 +249,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function hexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::encode($bin_string);
@@ -258,10 +261,10 @@ abstract class Encoding
*
* @param string $hex_string
* @return string (raw binary)
- * @throws \RangeException
+ * @throws RangeException
*/
public static function hexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $hex_string
): string {
return Hex::decode($hex_string);
@@ -276,7 +279,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function hexEncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::encodeUpper($bin_string);
@@ -290,7 +293,7 @@ abstract class Encoding
* @return string
*/
public static function hexDecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::decode($bin_string);
diff --git a/vendor/paragonie/constant_time_encoding/src/Hex.php b/vendor/paragonie/constant_time_encoding/src/Hex.php
index 97c2046f0..b515b9758 100644
--- a/vendor/paragonie/constant_time_encoding/src/Hex.php
+++ b/vendor/paragonie/constant_time_encoding/src/Hex.php
@@ -2,11 +2,20 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
use RangeException;
+use SensitiveParameter;
+use SodiumException;
use TypeError;
+use function extension_loaded;
+use function pack;
+use function sodium_bin2hex;
+use function sodium_hex2bin;
+use function strlen;
+use function unpack;
/**
- * Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
+ * Copyright (c) 2016 - 2025 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -42,19 +51,27 @@ abstract class Hex implements EncoderInterface
* @return string
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
+ if (extension_loaded('sodium')) {
+ try {
+ return sodium_bin2hex($binString);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
$hex = '';
- $len = Binary::safeStrlen($binString);
+ $len = strlen($binString);
for ($i = 0; $i < $len; ++$i) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C', $binString[$i]);
+ $chunk = unpack('C', $binString[$i]);
$c = $chunk[1] & 0xf;
$b = $chunk[1] >> 4;
- $hex .= \pack(
+ $hex .= pack(
'CC',
(87 + $b + ((($b - 10) >> 8) & ~38)),
(87 + $c + ((($c - 10) >> 8) & ~38))
@@ -72,19 +89,19 @@ abstract class Hex implements EncoderInterface
* @throws TypeError
*/
public static function encodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
$hex = '';
- $len = Binary::safeStrlen($binString);
+ $len = strlen($binString);
for ($i = 0; $i < $len; ++$i) {
/** @var array<int, int> $chunk */
- $chunk = \unpack('C', $binString[$i]);
+ $chunk = unpack('C', $binString[$i]);
$c = $chunk[1] & 0xf;
$b = $chunk[1] >> 4;
- $hex .= \pack(
+ $hex .= pack(
'CC',
(55 + $b + ((($b - 10) >> 8) & ~6)),
(55 + $c + ((($c - 10) >> 8) & ~6))
@@ -102,15 +119,23 @@ abstract class Hex implements EncoderInterface
* @return string (raw binary)
* @throws RangeException
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
+ if (extension_loaded('sodium') && $strictPadding) {
+ try {
+ return sodium_hex2bin($encodedString);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
$hex_pos = 0;
$bin = '';
$c_acc = 0;
- $hex_len = Binary::safeStrlen($encodedString);
+ $hex_len = strlen($encodedString);
$state = 0;
if (($hex_len & 1) !== 0) {
if ($strictPadding) {
@@ -124,7 +149,7 @@ abstract class Hex implements EncoderInterface
}
/** @var array<int, int> $chunk */
- $chunk = \unpack('C*', $encodedString);
+ $chunk = unpack('C*', $encodedString);
while ($hex_pos < $hex_len) {
++$hex_pos;
$c = $chunk[$hex_pos];
@@ -142,7 +167,7 @@ abstract class Hex implements EncoderInterface
if ($state === 0) {
$c_acc = $c_val * 16;
} else {
- $bin .= \pack('C', $c_acc | $c_val);
+ $bin .= pack('C', $c_acc | $c_val);
}
$state ^= 1;
}
diff --git a/vendor/paragonie/constant_time_encoding/src/RFC4648.php b/vendor/paragonie/constant_time_encoding/src/RFC4648.php
index 7cd2e9909..fb66f73d7 100644
--- a/vendor/paragonie/constant_time_encoding/src/RFC4648.php
+++ b/vendor/paragonie/constant_time_encoding/src/RFC4648.php
@@ -2,6 +2,7 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
use TypeError;
/**
@@ -33,6 +34,7 @@ use TypeError;
* This class conforms strictly to the RFC
*
* @package ParagonIE\ConstantTime
+ * @api
*/
abstract class RFC4648
{
@@ -47,7 +49,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base64Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::encode($str);
@@ -64,7 +66,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base64Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::decode($str, true);
@@ -81,7 +83,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base64UrlSafeEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64UrlSafe::encode($str);
@@ -98,7 +100,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base64UrlSafeDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64UrlSafe::decode($str, true);
@@ -115,7 +117,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base32Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -132,7 +134,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base32Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
@@ -149,7 +151,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base32HexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -166,7 +168,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base32HexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
@@ -183,7 +185,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base16Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Hex::encodeUpper($str);
@@ -198,7 +200,7 @@ abstract class RFC4648
* @return string
*/
public static function base16Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Hex::decode($str, true);