Update composer dependencies
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Jun 2022 07:24:50 +0000 (09:24 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Jun 2022 07:24:50 +0000 (09:24 +0200)
16 files changed:
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/.gitattributes [deleted file]
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/composer.json
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base32.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base32Hex.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base64.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base64DotSlash.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Base64UrlSafe.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Binary.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/EncoderInterface.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Encoding.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/Hex.php
wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/src/RFC4648.php

index eff6026ce1f05efb07ca4372b1b9d0b030ecf66a..f7d0bf19a18ce92c2fe3de000d1811799e9f28f5 100644 (file)
         },
         {
             "name": "paragonie/constant_time_encoding",
-            "version": "v2.5.0",
+            "version": "v2.6.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/paragonie/constant_time_encoding.git",
-                "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8"
+                "reference": "58c3f47f650c94ec05a151692652a868995d2938"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8",
-                "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8",
+                "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
+                "reference": "58c3f47f650c94ec05a151692652a868995d2938",
                 "shasum": ""
             },
             "require": {
                 "issues": "https://github.com/paragonie/constant_time_encoding/issues",
                 "source": "https://github.com/paragonie/constant_time_encoding"
             },
-            "time": "2022-01-17T05:32:27+00:00"
+            "time": "2022-06-14T06:56:20+00:00"
         },
         {
             "name": "pear/net_idna2",
index 03c7fdbacfc25dfc9dc92ac07100ec377fd8be13..3aab4ecdff3ed1e0ec0e7b8b2a01cfa47a9653b0 100644 (file)
         },
         {
             "name": "paragonie/constant_time_encoding",
-            "version": "v2.5.0",
-            "version_normalized": "2.5.0.0",
+            "version": "v2.6.3",
+            "version_normalized": "2.6.3.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/paragonie/constant_time_encoding.git",
-                "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8"
+                "reference": "58c3f47f650c94ec05a151692652a868995d2938"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8",
-                "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8",
+                "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
+                "reference": "58c3f47f650c94ec05a151692652a868995d2938",
                 "shasum": ""
             },
             "require": {
                 "phpunit/phpunit": "^6|^7|^8|^9",
                 "vimeo/psalm": "^1|^2|^3|^4"
             },
-            "time": "2022-01-17T05:32:27+00:00",
+            "time": "2022-06-14T06:56:20+00:00",
             "type": "library",
             "installation-source": "dist",
             "autoload": {
index 372806b551e6c18ebfd0fd04d883fd628cc7d314..88455af1f0b581eee9c9abf1136c0964aed37799 100644 (file)
             'dev_requirement' => false,
         ),
         'paragonie/constant_time_encoding' => array(
-            'pretty_version' => 'v2.5.0',
-            'version' => '2.5.0.0',
+            'pretty_version' => 'v2.6.3',
+            'version' => '2.6.3.0',
             'type' => 'library',
             'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
             'aliases' => array(),
-            'reference' => '9229e15f2e6ba772f0c55dd6986c563b937170a8',
+            'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
             'dev_requirement' => false,
         ),
         'pear/net_idna2' => array(
diff --git a/wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/.gitattributes b/wcfsetup/install/files/lib/system/api/paragonie/constant_time_encoding/.gitattributes
deleted file mode 100644 (file)
index cb40fe2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# Path-based git attributes
-# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
-
-# This way, the files would be available in the repository but it would not be downloaded when the package is required by another project.
-/.github            export-ignore
-/.gitignore         export-ignore
-/tests              export-ignore
-/phpunit.xml.dist   export-ignore
-/psalm.xml          export-ignore
index 583fe366fb1c19cd931132ed30faec5c701a50b9..2fe9717adb7b8bdda10e6f2d0ee198139459b96c 100644 (file)
     "psr-4": {
       "ParagonIE\\ConstantTime\\": "src/"
     }
+  },
+  "autoload-dev": {
+    "psr-4": {
+      "ParagonIE\\ConstantTime\\Tests\\": "tests/"
+    }
   }
 }
index b4f2de1452acf79b4df5c2e4bf48c5d11c1ddbae..7508b3df6f59cc4fff77caca98047d746d6d02d7 100644 (file)
@@ -2,8 +2,12 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use InvalidArgumentException;
+use RangeException;
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -62,7 +66,7 @@ abstract class Base32 implements EncoderInterface
      *
      * @param string $binString
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encode(string $binString): string
     {
@@ -73,7 +77,7 @@ abstract class Base32 implements EncoderInterface
      *
      * @param string $src
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encodeUnpadded(string $src): string
     {
@@ -85,7 +89,7 @@ abstract class Base32 implements EncoderInterface
      *
      * @param string $src
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encodeUpper(string $src): string
     {
@@ -97,7 +101,7 @@ abstract class Base32 implements EncoderInterface
      *
      * @param string $src
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encodeUpperUnpadded(string $src): string
     {
@@ -182,6 +186,32 @@ abstract class Base32 implements EncoderInterface
         return \pack('C', $src + $diff);
     }
 
+    /**
+     * @param string $encodedString
+     * @param bool $upper
+     * @return string
+     */
+    public static function decodeNoPadding(string $encodedString, bool $upper = false): string
+    {
+        $srcLen = Binary::safeStrlen($encodedString);
+        if ($srcLen === 0) {
+            return '';
+        }
+        if (($srcLen & 7) === 0) {
+            for ($j = 0; $j < 7 && $j < $srcLen; ++$j) {
+                if ($encodedString[$srcLen - $j - 1] === '=') {
+                    throw new InvalidArgumentException(
+                        "decodeNoPadding() doesn't tolerate padding"
+                    );
+                }
+            }
+        }
+        return static::doDecode(
+            $encodedString,
+            $upper,
+            true
+        );
+    }
 
     /**
      * Base32 decoding
@@ -190,11 +220,15 @@ abstract class Base32 implements EncoderInterface
      * @param bool $upper
      * @param bool $strictPadding
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      * @psalm-suppress RedundantCondition
      */
-    protected static function doDecode(string $src, bool $upper = false, bool $strictPadding = false): string
-    {
+    protected static function doDecode(
+        string $src,
+        bool $upper = false,
+        bool $strictPadding = false
+    ): string {
         // We do this to reduce code duplication:
         $method = $upper
             ? 'decode5BitsUpper'
@@ -216,7 +250,7 @@ abstract class Base32 implements EncoderInterface
                 }
             }
             if (($srcLen & 7) === 1) {
-                throw new \RangeException(
+                throw new RangeException(
                     'Incorrect padding'
                 );
             }
@@ -287,6 +321,9 @@ abstract class Base32 implements EncoderInterface
                     (($c4 << 7) | ($c5 << 2) | ($c6 >> 3)) & 0xff
                 );
                 $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c6 << 5) & 0xff;
+                }
             } elseif ($i + 5 < $srcLen) {
                 /** @var int $c1 */
                 $c1 = static::$method($chunk[2]);
@@ -324,6 +361,9 @@ abstract class Base32 implements EncoderInterface
                     (($c3 << 4) | ($c4 >> 1)             ) & 0xff
                 );
                 $err |= ($c0 | $c1 | $c2 | $c3 | $c4) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c4 << 7) & 0xff;
+                }
             } elseif ($i + 3 < $srcLen) {
                 /** @var int $c1 */
                 $c1 = static::$method($chunk[2]);
@@ -338,6 +378,9 @@ abstract class Base32 implements EncoderInterface
                     (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
                 );
                 $err |= ($c0 | $c1 | $c2 | $c3) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c3 << 4) & 0xff;
+                }
             } elseif ($i + 2 < $srcLen) {
                 /** @var int $c1 */
                 $c1 = static::$method($chunk[2]);
@@ -350,6 +393,9 @@ abstract class Base32 implements EncoderInterface
                     (($c1 << 6) | ($c2 << 1)             ) & 0xff
                 );
                 $err |= ($c0 | $c1 | $c2) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c2 << 6) & 0xff;
+                }
             } elseif ($i + 1 < $srcLen) {
                 /** @var int $c1 */
                 $c1 = static::$method($chunk[2]);
@@ -359,6 +405,9 @@ abstract class Base32 implements EncoderInterface
                     (($c0 << 3) | ($c1 >> 2)             ) & 0xff
                 );
                 $err |= ($c0 | $c1) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c1 << 6) & 0xff;
+                }
             } else {
                 $dest .= \pack(
                     'C',
@@ -369,7 +418,7 @@ abstract class Base32 implements EncoderInterface
         }
         $check = ($err === 0);
         if (!$check) {
-            throw new \RangeException(
+            throw new RangeException(
                 'Base32::doDecode() only expects characters in the correct base32 alphabet'
             );
         }
@@ -383,7 +432,7 @@ abstract class Base32 implements EncoderInterface
      * @param bool $upper
      * @param bool $pad
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     protected static function doEncode(string $src, bool $upper = false, $pad = true): string
     {
index 68fdad52c8941e563ae489d4123bd4802151d325..b868dd0483122c33a4bc682c67010f189f34e7d4 100644 (file)
@@ -3,7 +3,7 @@ declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
index dd16938f22754fc217184da64ba384114ed7dc11..f5716179f17438770121f39773bc3df493f969d9 100644 (file)
@@ -2,8 +2,12 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use InvalidArgumentException;
+use RangeException;
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -40,7 +44,8 @@ abstract class Base64 implements EncoderInterface
      *
      * @param string $binString
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function encode(string $binString): string
     {
@@ -54,7 +59,8 @@ abstract class Base64 implements EncoderInterface
      *
      * @param string $src
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function encodeUnpadded(string $src): string
     {
@@ -65,7 +71,8 @@ abstract class Base64 implements EncoderInterface
      * @param string $src
      * @param bool $pad   Include = padding?
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     protected static function doEncode(string $src, bool $pad = true): string
     {
@@ -119,8 +126,9 @@ abstract class Base64 implements EncoderInterface
      * @param string $encodedString
      * @param bool $strictPadding
      * @return string
-     * @throws \RangeException
-     * @throws \TypeError
+     *
+     * @throws RangeException
+     * @throws TypeError
      * @psalm-suppress RedundantCondition
      */
     public static function decode(string $encodedString, bool $strictPadding = false): string
@@ -141,12 +149,12 @@ abstract class Base64 implements EncoderInterface
                 }
             }
             if (($srcLen & 3) === 1) {
-                throw new \RangeException(
+                throw new RangeException(
                     'Incorrect padding'
                 );
             }
             if ($encodedString[$srcLen - 1] === '=') {
-                throw new \RangeException(
+                throw new RangeException(
                     'Incorrect padding'
                 );
             }
@@ -189,6 +197,9 @@ abstract class Base64 implements EncoderInterface
                     ((($c1 << 4) | ($c2 >> 2)) & 0xff)
                 );
                 $err |= ($c0 | $c1 | $c2) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c2 << 6) & 0xff;
+                }
             } elseif ($i + 1 < $srcLen) {
                 $c1 = static::decode6Bits($chunk[2]);
                 $dest .= \pack(
@@ -196,19 +207,52 @@ abstract class Base64 implements EncoderInterface
                     ((($c0 << 2) | ($c1 >> 4)) & 0xff)
                 );
                 $err |= ($c0 | $c1) >> 8;
+                if ($strictPadding) {
+                    $err |= ($c1 << 4) & 0xff;
+                }
             } elseif ($strictPadding) {
                 $err |= 1;
             }
         }
         $check = ($err === 0);
         if (!$check) {
-            throw new \RangeException(
+            throw new RangeException(
                 'Base64::decode() only expects characters in the correct base64 alphabet'
             );
         }
         return $dest;
     }
 
+    /**
+     * @param string $encodedString
+     * @return string
+     */
+    public static function decodeNoPadding(string $encodedString): string
+    {
+        $srcLen = Binary::safeStrlen($encodedString);
+        if ($srcLen === 0) {
+            return '';
+        }
+        if (($srcLen & 3) === 0) {
+            if ($encodedString[$srcLen - 1] === '=') {
+                throw new InvalidArgumentException(
+                    "decodeNoPadding() doesn't tolerate padding"
+                );
+            }
+            if (($srcLen & 3) > 1) {
+                if ($encodedString[$srcLen - 2] === '=') {
+                    throw new InvalidArgumentException(
+                        "decodeNoPadding() doesn't tolerate padding"
+                    );
+                }
+            }
+        }
+        return static::decode(
+            $encodedString,
+            true
+        );
+    }
+
     /**
      * Uses bitwise operators instead of table-lookups to turn 6-bit integers
      * into 8-bit integers.
index 8ad2e2bf155c773207a818acf4c01892bdaac3e1..5e98a8f7930f0bf84f0b117a120f842d94846d1a 100644 (file)
@@ -3,7 +3,7 @@ declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
index dd1459e8508ff864cfa4191ccbc9ee2de6c42e11..9780b14bb0ce4451657079927ad15cf081310a05 100644 (file)
@@ -3,7 +3,7 @@ declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
index 1a4107527a794458655113dd7c0dd780071584a6..8192c63d585f45a28f88dee1ed2a77614ee4f1f9 100644 (file)
@@ -3,7 +3,7 @@ declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
index add0522896ce1b39f14fbdea8868f7e1f43f1c13..828f3e0f64a64be4b0d9e6245ea8d943066e8a7e 100644 (file)
@@ -2,8 +2,10 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -64,7 +66,8 @@ abstract class Binary
      * @param int $start
      * @param ?int $length
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function safeSubstr(
         string $str,
index 7aeee55a8604d5c9f1def288ce0ff6db3006ea61..9cafbf96c839a163e99c2bd86bc7ad925f4b5c15 100644 (file)
@@ -3,7 +3,7 @@ declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
index 896a6684179e61c9c846a67264ca94d0ba30ad30..8649f31fc1994aa1575a2d5b18dd240b6e426779 100644 (file)
@@ -2,8 +2,10 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -36,7 +38,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32Encode(string $str): string
     {
@@ -48,7 +50,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32EncodeUpper(string $str): string
     {
@@ -60,7 +62,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32Decode(string $str): string
     {
@@ -72,7 +74,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32DecodeUpper(string $str): string
     {
@@ -84,7 +86,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32HexEncode(string $str): string
     {
@@ -96,7 +98,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32HexEncodeUpper(string $str): string
     {
@@ -108,7 +110,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32HexDecode(string $str): string
     {
@@ -120,7 +122,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base32HexDecodeUpper(string $str): string
     {
@@ -132,7 +134,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64Encode(string $str): string
     {
@@ -144,7 +146,7 @@ abstract class Encoding
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64Decode(string $str): string
     {
@@ -157,7 +159,7 @@ abstract class Encoding
      * Base64 character set "./[A-Z][a-z][0-9]"
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64EncodeDotSlash(string $str): string
     {
@@ -172,7 +174,7 @@ abstract class Encoding
      * @param string $str
      * @return string
      * @throws \RangeException
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64DecodeDotSlash(string $str): string
     {
@@ -185,7 +187,7 @@ abstract class Encoding
      * Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
      * @param string $str
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64EncodeDotSlashOrdered(string $str): string
     {
@@ -200,7 +202,7 @@ abstract class Encoding
      * @param string $str
      * @return string
      * @throws \RangeException
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function base64DecodeDotSlashOrdered(string $str): string
     {
@@ -213,7 +215,7 @@ abstract class Encoding
      *
      * @param string $bin_string (raw binary)
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function hexEncode(string $bin_string): string
     {
@@ -239,7 +241,7 @@ abstract class Encoding
      *
      * @param string $bin_string (raw binary)
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function hexEncodeUpper(string $bin_string): string
     {
index 4c2732862dcbb607f756b41e8bd8e90142cdc07c..a9e058cd3601cd32565fcb0141ab4d945d0e3af1 100644 (file)
@@ -2,8 +2,11 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use RangeException;
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -37,7 +40,7 @@ abstract class Hex implements EncoderInterface
      *
      * @param string $binString (raw binary)
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encode(string $binString): string
     {
@@ -45,11 +48,11 @@ abstract class Hex implements EncoderInterface
         $len = Binary::safeStrlen($binString);
         for ($i = 0; $i < $len; ++$i) {
             /** @var array<int, int> $chunk */
-            $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1));
+            $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))
@@ -64,7 +67,7 @@ abstract class Hex implements EncoderInterface
      *
      * @param string $binString (raw binary)
      * @return string
-     * @throws \TypeError
+     * @throws TypeError
      */
     public static function encodeUpper(string $binString): string
     {
@@ -73,11 +76,11 @@ abstract class Hex implements EncoderInterface
 
         for ($i = 0; $i < $len; ++$i) {
             /** @var array<int, int> $chunk */
-            $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2));
+            $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))
@@ -93,10 +96,12 @@ abstract class Hex implements EncoderInterface
      * @param string $encodedString
      * @param bool $strictPadding
      * @return string (raw binary)
-     * @throws \RangeException
+     * @throws RangeException
      */
-    public static function decode(string $encodedString, bool $strictPadding = false): string
-    {
+    public static function decode(
+        string $encodedString,
+        bool $strictPadding = false
+    ): string {
         $hex_pos = 0;
         $bin = '';
         $c_acc = 0;
@@ -104,7 +109,7 @@ abstract class Hex implements EncoderInterface
         $state = 0;
         if (($hex_len & 1) !== 0) {
             if ($strictPadding) {
-                throw new \RangeException(
+                throw new RangeException(
                     'Expected an even number of hexadecimal characters'
                 );
             } else {
@@ -124,7 +129,7 @@ abstract class Hex implements EncoderInterface
             $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
 
             if (($c_num0 | $c_alpha0) === 0) {
-                throw new \RangeException(
+                throw new RangeException(
                     'Expected hexadecimal character'
                 );
             }
index 492cad00ef4776bfbcd097eb53c00c0697c945a6..f124d65bfd99dd30e4b34d90fb8d0965aa136982 100644 (file)
@@ -2,8 +2,10 @@
 declare(strict_types=1);
 namespace ParagonIE\ConstantTime;
 
+use TypeError;
+
 /**
- *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
+ *  Copyright (c) 2016 - 2022 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
@@ -41,7 +43,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base64Encode(string $str): string
     {
@@ -55,7 +58,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base64Decode(string $str): string
     {
@@ -69,7 +73,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base64UrlSafeEncode(string $str): string
     {
@@ -83,7 +88,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base64UrlSafeDecode(string $str): string
     {
@@ -97,7 +103,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base32Encode(string $str): string
     {
@@ -111,7 +118,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base32Decode(string $str): string
     {
@@ -125,7 +133,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base32HexEncode(string $str): string
     {
@@ -139,7 +148,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base32HexDecode(string $str): string
     {
@@ -153,7 +163,8 @@ abstract class RFC4648
      *
      * @param string $str
      * @return string
-     * @throws \TypeError
+     *
+     * @throws TypeError
      */
     public static function base16Encode(string $str): string
     {