summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott <scott@paragonie.com>2016-04-08 12:54:25 -0400
committerScott <scott@paragonie.com>2016-04-08 12:54:25 -0400
commitce8e74b83fd4a5f2484b98b9c70214499df6aad2 (patch)
tree3be2037a5bcfde879de72cfad68f957b8e90693b /src
parent15c9076968907910390125e48e0eceeefadf8abe (diff)
downloadconstant_time_encoding-ce8e74b83fd4a5f2484b98b9c70214499df6aad2.zip
constant_time_encoding-ce8e74b83fd4a5f2484b98b9c70214499df6aad2.tar.gz
constant_time_encoding-ce8e74b83fd4a5f2484b98b9c70214499df6aad2.tar.bz2
Improved docblocks and test coverage
Diffstat (limited to 'src')
-rw-r--r--src/Base32.php55
-rw-r--r--src/Base32Hex.php41
-rw-r--r--src/Base64.php32
-rw-r--r--src/Base64DotSlash.php28
-rw-r--r--src/Base64DotSlashOrdered.php29
-rw-r--r--src/Base64UrlSafe.php28
-rw-r--r--src/Binary.php31
-rw-r--r--src/EncoderInterface.php30
-rw-r--r--src/Encoding.php6
-rw-r--r--src/Hex.php27
-rw-r--r--src/RFC4648.php23
11 files changed, 318 insertions, 12 deletions
diff --git a/src/Base32.php b/src/Base32.php
index a1d7d79..28b8ca2 100644
--- a/src/Base32.php
+++ b/src/Base32.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base32
* [A-Z][2-7]
*
@@ -21,7 +44,7 @@ abstract class Base32 implements EncoderInterface
}
/**
- * Decode a Base32-encoded string into raw binary
+ * Decode an uppercase Base32-encoded string into raw binary
*
* @param string $src
* @return string
@@ -43,7 +66,7 @@ abstract class Base32 implements EncoderInterface
}
/**
- * Encode into Base32 (RFC 4648)
+ * Encode into uppercase Base32 (RFC 4648)
*
* @param string $src
* @return string
@@ -54,6 +77,8 @@ abstract class Base32 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 5-bit integers
+ * into 8-bit integers.
*
* @param int $src
* @return int
@@ -72,6 +97,10 @@ abstract class Base32 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 5-bit integers
+ * into 8-bit integers.
+ *
+ * Uppercase variant.
*
* @param int $src
* @return int
@@ -90,6 +119,9 @@ abstract class Base32 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 5-bit integers.
+ *
* @param $src
* @return string
*/
@@ -104,6 +136,11 @@ abstract class Base32 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 5-bit integers.
+ *
+ * Uppercase variant.
+ *
* @param $src
* @return string
*/
@@ -119,12 +156,15 @@ abstract class Base32 implements EncoderInterface
/**
+ * Base32 decoding
+ *
* @param $src
* @param bool $upper
* @return string
*/
protected static function doDecode($src, $upper = false)
{
+ // We do this to reduce code duplication:
$method = $upper
? 'decode5BitsUpper'
: 'decode5Bits';
@@ -151,6 +191,7 @@ abstract class Base32 implements EncoderInterface
$err = 0;
$dest = '';
+ // Main loop (no padding):
for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
$c0 = static::$method($chunk[1]);
@@ -172,6 +213,7 @@ abstract class Base32 implements EncoderInterface
);
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6 | $c7) >> 8;
}
+ // The last chunk, which may have padding:
if ($i < $srcLen) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
$c0 = static::$method($chunk[1]);
@@ -259,26 +301,30 @@ abstract class Base32 implements EncoderInterface
}
if ($err !== 0) {
throw new \RangeException(
- 'base32Decode() only expects characters in the correct base32 alphabet'
+ 'Base32::doDecode() only expects characters in the correct base32 alphabet'
);
}
return $dest;
}
/**
- * Encode into Base32 (RFC 4648)
+ * Base32 Decoding
*
* @param string $src
+ * @param bool $upper
* @return string
*/
protected static function doEncode($src, $upper = false)
{
+ // We do this to reduce code duplication:
$method = $upper
? 'encode5BitsUpper'
: 'encode5Bits';
$dest = '';
$srcLen = Binary::safeStrlen($src);
+
+ // Main loop (no padding):
for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 5));
$b0 = $chunk[1];
@@ -296,6 +342,7 @@ abstract class Base32 implements EncoderInterface
static::$method((($b3 << 3) | ($b4 >> 5)) & 31) .
static::$method( $b4 & 31);
}
+ // The last chunk, which may have padding:
if ($i < $srcLen) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
diff --git a/src/Base32Hex.php b/src/Base32Hex.php
index 2d1c5d7..f37cf1d 100644
--- a/src/Base32Hex.php
+++ b/src/Base32Hex.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base32Hex
* [0-9][A-V]
*
@@ -10,9 +33,8 @@ namespace ParagonIE\ConstantTime;
abstract class Base32Hex extends Base32
{
/**
- * Base64 character set:
- * [0-9] [A-V]
- * 0x30-0x39, 0x41-0x56
+ * Uses bitwise operators instead of table-lookups to turn 5-bit integers
+ * into 8-bit integers.
*
* @param int $src
* @return int
@@ -31,9 +53,8 @@ abstract class Base32Hex extends Base32
}
/**
- * Base64 character set:
- * [0-9] [A-V]
- * 0x30-0x39, 0x41-0x56
+ * Uses bitwise operators instead of table-lookups to turn 5-bit integers
+ * into 8-bit integers.
*
* @param int $src
* @return int
@@ -52,6 +73,9 @@ abstract class Base32Hex extends Base32
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 5-bit integers.
+ *
* @param int $src
* @return string
*/
@@ -66,6 +90,11 @@ abstract class Base32Hex extends Base32
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 5-bit integers.
+ *
+ * Uppercase variant.
+ *
* @param int $src
* @return string
*/
diff --git a/src/Base64.php b/src/Base64.php
index ede66ed..46fc78d 100644
--- a/src/Base64.php
+++ b/src/Base64.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base64
* [A-Z][a-z][0-9]+/
*
@@ -21,6 +44,7 @@ abstract class Base64 implements EncoderInterface
{
$dest = '';
$srcLen = Binary::safeStrlen($src);
+ // Main loop (no padding):
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 3));
$b0 = $chunk[1];
@@ -33,6 +57,7 @@ abstract class Base64 implements EncoderInterface
static::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) .
static::encode6Bits( $b2 & 63);
}
+ // The last chunk, which may have padding:
if ($i < $srcLen) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
@@ -83,6 +108,7 @@ abstract class Base64 implements EncoderInterface
$err = 0;
$dest = '';
+ // Main loop (no padding):
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 4));
$c0 = static::decode6Bits($chunk[1]);
@@ -98,6 +124,7 @@ abstract class Base64 implements EncoderInterface
);
$err |= ($c0 | $c1 | $c2 | $c3) >> 8;
}
+ // The last chunk, which may have padding:
if ($i < $srcLen) {
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
$c0 = static::decode6Bits($chunk[1]);
@@ -126,6 +153,8 @@ abstract class Base64 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 6-bit integers
+ * into 8-bit integers.
*
* Base64 character set:
* [A-Z] [a-z] [0-9] + /
@@ -157,6 +186,9 @@ abstract class Base64 implements EncoderInterface
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 6-bit integers.
+ *
* @param int $src
* @return string
*/
diff --git a/src/Base64DotSlash.php b/src/Base64DotSlash.php
index f316a26..1604597 100644
--- a/src/Base64DotSlash.php
+++ b/src/Base64DotSlash.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base64DotSlash
* ./[A-Z][a-z][0-9]
*
@@ -10,6 +33,8 @@ namespace ParagonIE\ConstantTime;
abstract class Base64DotSlash extends Base64
{
/**
+ * Uses bitwise operators instead of table-lookups to turn 6-bit integers
+ * into 8-bit integers.
*
* Base64 character set:
* ./ [A-Z] [a-z] [0-9]
@@ -38,6 +63,9 @@ abstract class Base64DotSlash extends Base64
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 6-bit integers.
+ *
* @param int $src
* @return string
*/
diff --git a/src/Base64DotSlashOrdered.php b/src/Base64DotSlashOrdered.php
index 3057738..3f5e6b4 100644
--- a/src/Base64DotSlashOrdered.php
+++ b/src/Base64DotSlashOrdered.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base64DotSlashOrdered
* ./[0-9][A-Z][a-z]
*
@@ -10,6 +33,9 @@ namespace ParagonIE\ConstantTime;
abstract class Base64DotSlashOrdered extends Base64
{
/**
+ * Uses bitwise operators instead of table-lookups to turn 6-bit integers
+ * into 8-bit integers.
+ *
* Base64 character set:
* [.-9] [A-Z] [a-z]
* 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
@@ -34,6 +60,9 @@ abstract class Base64DotSlashOrdered extends Base64
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 6-bit integers.
+ *
* @param int $src
* @return string
*/
diff --git a/src/Base64UrlSafe.php b/src/Base64UrlSafe.php
index f7839ad..3e4edf8 100644
--- a/src/Base64UrlSafe.php
+++ b/src/Base64UrlSafe.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class Base64DotSlash
* ./[A-Z][a-z][0-9]
*
@@ -11,6 +34,8 @@ abstract class Base64UrlSafe extends Base64
{
/**
+ * Uses bitwise operators instead of table-lookups to turn 6-bit integers
+ * into 8-bit integers.
*
* Base64 character set:
* [A-Z] [a-z] [0-9] - _
@@ -42,6 +67,9 @@ abstract class Base64UrlSafe extends Base64
}
/**
+ * Uses bitwise operators instead of table-lookups to turn 8-bit integers
+ * into 6-bit integers.
+ *
* @param int $src
* @return string
*/
diff --git a/src/Binary.php b/src/Binary.php
index 2c3adae..4447b19 100644
--- a/src/Binary.php
+++ b/src/Binary.php
@@ -1,6 +1,37 @@
<?php
namespace ParagonIE\ConstantTime;
+/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * Class Binary
+ *
+ * Binary string operators that don't choke on
+ * mbstring.func_overload
+ *
+ * @package ParagonIE\ConstantTime
+ */
abstract class Binary
{
/**
diff --git a/src/EncoderInterface.php b/src/EncoderInterface.php
index 0c46ee4..8ecb45e 100644
--- a/src/EncoderInterface.php
+++ b/src/EncoderInterface.php
@@ -1,6 +1,33 @@
<?php
namespace ParagonIE\ConstantTime;
+/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * Interface EncoderInterface
+ * @package ParagonIE\ConstantTime
+ */
interface EncoderInterface
{
/**
@@ -20,5 +47,4 @@ interface EncoderInterface
* @return string (raw binary)
*/
public static function decode($encoded_string);
-
-} \ No newline at end of file
+}
diff --git a/src/Encoding.php b/src/Encoding.php
index d8d0004..55a3c78 100644
--- a/src/Encoding.php
+++ b/src/Encoding.php
@@ -2,6 +2,7 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
@@ -22,6 +23,11 @@ namespace ParagonIE\ConstantTime;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
+/**
+ * Class Encoding
+ * @package ParagonIE\ConstantTime
+ */
abstract class Encoding
{
/**
diff --git a/src/Hex.php b/src/Hex.php
index 7912d9a..32962c0 100644
--- a/src/Hex.php
+++ b/src/Hex.php
@@ -1,6 +1,33 @@
<?php
namespace ParagonIE\ConstantTime;
+/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * Class Hex
+ * @package ParagonIE\ConstantTime
+ */
abstract class Hex implements EncoderInterface
{
/**
diff --git a/src/RFC4648.php b/src/RFC4648.php
index e2c0207..58efdcc 100644
--- a/src/RFC4648.php
+++ b/src/RFC4648.php
@@ -2,6 +2,29 @@
namespace ParagonIE\ConstantTime;
/**
+ * Copyright (c) 2016 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
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
* Class RFC4648
*
* This class conforms strictly to the RFC