1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-02 09:38:06 +01:00

Fix bad merge

This commit is contained in:
Daniil Gentili 2019-06-14 12:56:49 +02:00
parent 3097d2940b
commit 0aff25ea25
5 changed files with 241 additions and 238 deletions

View File

@ -15,12 +15,13 @@
namespace phpseclib\Crypt\Common;
use phpseclib\Crypt\DSA;
use phpseclib\Exception\UnsupportedFormatException;
use phpseclib\Exception\NoKeyLoadedException;
use phpseclib\Math\BigInteger;
use phpseclib\Crypt\Hash;
use phpseclib\Crypt\RSA;
use phpseclib\Exception\NoKeyLoadedException;
use phpseclib\Exception\UnsupportedFormatException;
use phpseclib\Math\BigInteger;
use phpseclib\Crypt\DSA;
use phpseclib\Crypt\ECDSA;
/**
* Base Class for all stream cipher classes
@ -199,7 +200,7 @@ abstract class AsymmetricKey
* @param string $method optional
* @return mixed
*/
protected static function validatePlugin($format, $type, $method = null)
protected static function validatePlugin($format, $type, $method = NULL)
{
$type = strtolower($type);
if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) {
@ -309,7 +310,7 @@ abstract class AsymmetricKey
// this test can be satisfied by either of the following:
// http://php.net/manual/en/book.sodium.php
// https://github.com/paragonie/sodium_compat
'libsodium' => function_exists('sodium_crypto_sign_keypair'),
'libsodium' => function_exists('sodium_crypto_sign_keypair')
];
return static::$engines;
@ -325,7 +326,7 @@ abstract class AsymmetricKey
static::$engines = [
'PHP' => true,
'OpenSSL' => false,
'libsodium' => false,
'libsodium' => false
];
}

View File

@ -54,11 +54,12 @@
namespace phpseclib\Crypt;
use phpseclib\Common\Functions\Strings;
use phpseclib\Crypt\Common\BlockCipher;
use phpseclib\Exception\BadDecryptionException;
use phpseclib\Common\Functions\Strings;
use phpseclib\Exception\BadModeException;
use phpseclib\Exception\InsufficientSetupException;
use phpseclib\Exception\BadDecryptionException;
/**
* Pure-PHP implementation of Rijndael.
@ -502,7 +503,7 @@ class Rijndael extends BlockCipher
0x6C000000, 0xD8000000, 0xAB000000, 0x4D000000, 0x9A000000,
0x2F000000, 0x5E000000, 0xBC000000, 0x63000000, 0xC6000000,
0x97000000, 0x35000000, 0x6A000000, 0xD4000000, 0xB3000000,
0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000,
0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000
];
if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_length === $this->kl['key_length'] && $this->block_size === $this->kl['block_size']) {
@ -669,7 +670,7 @@ class Rijndael extends BlockCipher
0xE1E138D9, 0xF8F813EB, 0x9898B32B, 0x11113322, 0x6969BBD2, 0xD9D970A9, 0x8E8E8907, 0x9494A733,
0x9B9BB62D, 0x1E1E223C, 0x87879215, 0xE9E920C9, 0xCECE4987, 0x5555FFAA, 0x28287850, 0xDFDF7AA5,
0x8C8C8F03, 0xA1A1F859, 0x89898009, 0x0D0D171A, 0xBFBFDA65, 0xE6E631D7, 0x4242C684, 0x6868B8D0,
0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C,
0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C
]);
foreach ($t3 as $t3i) {
@ -701,8 +702,8 @@ class Rijndael extends BlockCipher
0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16,
],
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
]
];
}
return $tables;
@ -753,7 +754,7 @@ class Rijndael extends BlockCipher
0xD7618C9A, 0xA10C7A37, 0xF8148E59, 0x133C89EB, 0xA927EECE, 0x61C935B7, 0x1CE5EDE1, 0x47B13C7A,
0xD2DF599C, 0xF2733F55, 0x14CE7918, 0xC737BF73, 0xF7CDEA53, 0xFDAA5B5F, 0x3D6F14DF, 0x44DB8678,
0xAFF381CA, 0x68C43EB9, 0x24342C38, 0xA3405FC2, 0x1DC37216, 0xE2250CBC, 0x3C498B28, 0x0D9541FF,
0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0,
0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0
]);
foreach ($dt3 as $dt3i) {
@ -785,8 +786,8 @@ class Rijndael extends BlockCipher
0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D,
],
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
]
];
}
return $tables;
@ -929,7 +930,7 @@ class Rijndael extends BlockCipher
'init_encrypt' => $init_encrypt,
'init_decrypt' => $init_decrypt,
'encrypt_block' => $encrypt_block,
'decrypt_block' => $decrypt_block,
'decrypt_block' => $decrypt_block
]
);
}

View File

@ -135,7 +135,7 @@ class BigInteger implements \Serializable
['GMP'],
['PHP64', ['OpenSSL']],
['BCMath', ['OpenSSL']],
['PHP32', ['OpenSSL']],
['PHP32', ['OpenSSL']]
];
foreach ($engines as $engine) {
try {
@ -230,7 +230,7 @@ class BigInteger implements \Serializable
* @param bool $twos_compliment
* @return string
*/
public function toBits($twos_compliment = false)
function toBits($twos_compliment = false)
{
return $this->value->toBits($twos_compliment);
}
@ -252,7 +252,7 @@ class BigInteger implements \Serializable
* @param BigInteger $y
* @return BigInteger
*/
public function subtract(BigInteger $y)
function subtract(BigInteger $y)
{
return new static($this->value->subtract($y->value));
}
@ -298,7 +298,7 @@ class BigInteger implements \Serializable
list($q, $r) = $this->value->divide($y->value);
return [
new static($q),
new static($r),
new static($r)
];
}
@ -332,7 +332,7 @@ class BigInteger implements \Serializable
return [
'gcd' => new static($gcd),
'x' => new static($x),
'y' => new static($y),
'y' => new static($y)
];
}
@ -598,7 +598,7 @@ class BigInteger implements \Serializable
*/
return [
'min' => new static($min),
'max' => new static($max),
'max' => new static($max)
];
}

View File

@ -16,10 +16,10 @@
namespace phpseclib\Math\BigInteger\Engines;
use ParagonIE\ConstantTime\Hex;
use phpseclib\Common\Functions\Strings;
use phpseclib\Crypt\Random;
use phpseclib\Exception\BadConfigurationException;
use phpseclib\Crypt\Random;
use phpseclib\Math\BigInteger;
use phpseclib\Common\Functions\Strings;
/**
* Base Engine.
@ -85,7 +85,7 @@ abstract class Engine implements \Serializable
619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727,
733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829,
839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947,
953, 967, 971, 977, 983, 991, 997,
953, 967, 971, 977, 983, 991, 997
];
static::$zero = new static(0);
static::$one = new static(1);
@ -341,7 +341,7 @@ abstract class Engine implements \Serializable
{
return [
'value' => '0x' . $this->toHex(true),
'engine' => basename(static::class),
'engine' => basename(static::class)
];
}
@ -534,7 +534,7 @@ abstract class Engine implements \Serializable
}
return [
'min' => new static($min, 256),
'max' => new static($max, 256),
'max' => new static($max, 256)
];
}
@ -1126,7 +1126,7 @@ abstract class Engine implements \Serializable
return [
'gcd'=> $u,
'x' => $a,
'y' => $b,
'y' => $b
];
}
@ -1208,6 +1208,7 @@ abstract class Engine implements \Serializable
$length = max(strlen($left), strlen($right));
$left = str_pad($left, $length, chr(0), STR_PAD_LEFT);
$right = str_pad($right, $length, chr(0), STR_PAD_LEFT);
return $this->normalize(new static($left ^ $right, -256));

View File

@ -219,12 +219,12 @@ abstract class PHP extends Engine
if ($x_size == 0) {
return [
self::VALUE => $y_value,
self::SIGN => $y_negative,
self::SIGN => $y_negative
];
} elseif ($y_size == 0) {
return [
self::VALUE => $x_value,
self::SIGN => $x_negative,
self::SIGN => $x_negative
];
}
@ -233,7 +233,7 @@ abstract class PHP extends Engine
if ($x_value == $y_value) {
return [
self::VALUE => [],
self::SIGN => false,
self::SIGN => false
];
}
@ -283,7 +283,7 @@ abstract class PHP extends Engine
return [
self::VALUE => self::trim($value),
self::SIGN => $x_negative,
self::SIGN => $x_negative
];
}
@ -296,7 +296,7 @@ abstract class PHP extends Engine
* @param bool $y_negative
* @return array
*/
public static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative)
static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative)
{
$x_size = count($x_value);
$y_size = count($y_value);
@ -304,12 +304,12 @@ abstract class PHP extends Engine
if ($x_size == 0) {
return [
self::VALUE => $y_value,
self::SIGN => !$y_negative,
self::SIGN => !$y_negative
];
} elseif ($y_size == 0) {
return [
self::VALUE => $x_value,
self::SIGN => $x_negative,
self::SIGN => $x_negative
];
}
@ -326,7 +326,7 @@ abstract class PHP extends Engine
if (!$diff) {
return [
self::VALUE => [],
self::SIGN => false,
self::SIGN => false
];
}
@ -373,7 +373,7 @@ abstract class PHP extends Engine
return [
self::VALUE => self::trim($x_value),
self::SIGN => $x_negative,
self::SIGN => $x_negative
];
}
@ -401,7 +401,7 @@ abstract class PHP extends Engine
if (!$x_length || !$y_length) { // a 0 is being multiplied
return [
self::VALUE => [],
self::SIGN => false,
self::SIGN => false
];
}
@ -409,7 +409,7 @@ abstract class PHP extends Engine
self::VALUE => min($x_length, $y_length) < 2 * self::KARATSUBA_CUTOFF ?
self::trim(self::regularMultiply($x_value, $y_value)) :
self::trim(self::karatsuba($x_value, $y_value)),
self::SIGN => $x_negative != $y_negative,
self::SIGN => $x_negative != $y_negative
];
}
@ -595,11 +595,11 @@ abstract class PHP extends Engine
$x_window = [
isset($x_value[$i]) ? $x_value[$i] : 0,
isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0,
isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0,
isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0
];
$y_window = [
$y_value[$y_max],
($y_max > 0) ? $y_value[$y_max - 1] : 0,
($y_max > 0) ? $y_value[$y_max - 1] : 0
];
$q_index = $i - $y_max - 1;