Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 873 → Rev 874

/trunk/vendor/paragonie/constant_time_encoding/composer.json
Cannot display: file marked as a binary type.
svn:mime-type = application/json
/trunk/vendor/paragonie/constant_time_encoding/src/Base32.php
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
*
* @param string $binString
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encode(string $binString): string
{
73,7 → 77,7
*
* @param string $src
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encodeUnpadded(string $src): string
{
85,7 → 89,7
*
* @param string $src
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encodeUpper(string $src): string
{
97,7 → 101,7
*
* @param string $src
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encodeUpperUnpadded(string $src): string
{
182,6 → 186,32
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
* @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
}
}
if (($srcLen & 7) === 1) {
throw new \RangeException(
throw new RangeException(
'Incorrect padding'
);
}
287,6 → 321,9
(($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
(($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
(($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
(($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
(($c0 << 3) | ($c1 >> 2) ) & 0xff
);
$err |= ($c0 | $c1) >> 8;
if ($strictPadding) {
$err |= ($c1 << 6) & 0xff;
}
} else {
$dest .= \pack(
'C',
369,7 → 418,7
}
$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
* @param bool $upper
* @param bool $pad
* @return string
* @throws \TypeError
* @throws TypeError
*/
protected static function doEncode(string $src, bool $upper = false, $pad = true): string
{
/trunk/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
3,7 → 3,7
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
/trunk/vendor/paragonie/constant_time_encoding/src/Base64.php
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
*
* @param string $binString
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function encode(string $binString): string
{
54,7 → 59,8
*
* @param string $src
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function encodeUnpadded(string $src): string
{
65,7 → 71,8
* @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
* @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
}
}
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
((($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,6 → 207,9
((($c0 << 2) | ($c1 >> 4)) & 0xff)
);
$err |= ($c0 | $c1) >> 8;
if ($strictPadding) {
$err |= ($c1 << 4) & 0xff;
}
} elseif ($strictPadding) {
$err |= 1;
}
202,7 → 216,7
}
$check = ($err === 0);
if (!$check) {
throw new \RangeException(
throw new RangeException(
'Base64::decode() only expects characters in the correct base64 alphabet'
);
}
210,6 → 224,36
}
 
/**
* @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.
*
/trunk/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
3,7 → 3,7
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
/trunk/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
3,7 → 3,7
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
/trunk/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
3,7 → 3,7
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
/trunk/vendor/paragonie/constant_time_encoding/src/Binary.php
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
* @param int $start
* @param ?int $length
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function safeSubstr(
string $str,
/trunk/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
3,7 → 3,7
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
/trunk/vendor/paragonie/constant_time_encoding/src/Encoding.php
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
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32Encode(string $str): string
{
48,7 → 50,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32EncodeUpper(string $str): string
{
60,7 → 62,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32Decode(string $str): string
{
72,7 → 74,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32DecodeUpper(string $str): string
{
84,7 → 86,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32HexEncode(string $str): string
{
96,7 → 98,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32HexEncodeUpper(string $str): string
{
108,7 → 110,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32HexDecode(string $str): string
{
120,7 → 122,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base32HexDecodeUpper(string $str): string
{
132,7 → 134,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base64Encode(string $str): string
{
144,7 → 146,7
*
* @param string $str
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function base64Decode(string $str): string
{
157,7 → 159,7
* 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
* @param string $str
* @return string
* @throws \RangeException
* @throws \TypeError
* @throws TypeError
*/
public static function base64DecodeDotSlash(string $str): string
{
185,7 → 187,7
* 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
* @param string $str
* @return string
* @throws \RangeException
* @throws \TypeError
* @throws TypeError
*/
public static function base64DecodeDotSlashOrdered(string $str): string
{
213,7 → 215,7
*
* @param string $bin_string (raw binary)
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function hexEncode(string $bin_string): string
{
239,7 → 241,7
*
* @param string $bin_string (raw binary)
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function hexEncodeUpper(string $bin_string): string
{
/trunk/vendor/paragonie/constant_time_encoding/src/Hex.php
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
*
* @param string $binString (raw binary)
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encode(string $binString): string
{
45,11 → 48,11
$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
*
* @param string $binString (raw binary)
* @return string
* @throws \TypeError
* @throws TypeError
*/
public static function encodeUpper(string $binString): string
{
73,11 → 76,11
 
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
* @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
$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
$c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
 
if (($c_num0 | $c_alpha0) === 0) {
throw new \RangeException(
throw new RangeException(
'Expected hexadecimal character'
);
}
/trunk/vendor/paragonie/constant_time_encoding/src/RFC4648.php
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
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base64Encode(string $str): string
{
55,7 → 58,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base64Decode(string $str): string
{
69,7 → 73,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base64UrlSafeEncode(string $str): string
{
83,7 → 88,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base64UrlSafeDecode(string $str): string
{
97,7 → 103,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base32Encode(string $str): string
{
111,7 → 118,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base32Decode(string $str): string
{
125,7 → 133,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base32HexEncode(string $str): string
{
139,7 → 148,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base32HexDecode(string $str): string
{
153,7 → 163,8
*
* @param string $str
* @return string
* @throws \TypeError
*
* @throws TypeError
*/
public static function base16Encode(string $str): string
{