mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-06-06 18:40:49 +00:00
Fix mode mapping order and param type
This commit is contained in:
parent
b89c488f43
commit
488433e10f
|
@ -288,17 +288,17 @@ class Blowfish extends BlockCipher
|
|||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
throw new \InvalidArgumentException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
|
||||
parent::__construct($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -602,20 +602,22 @@ abstract class SymmetricKey
|
|||
*
|
||||
* - gcm
|
||||
*
|
||||
* @param string $mode
|
||||
* @param string|int $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
$mode = strtolower($mode);
|
||||
// necessary because of 5.6 compatibility; we can't do isset(self::MODE_MAP[$mode]) in 5.6
|
||||
$map = self::MODE_MAP;
|
||||
if (!isset($map[$mode])) {
|
||||
throw new BadModeException('No valid mode has been specified');
|
||||
}
|
||||
if (!is_int($mode) || !in_array($mode, self::MODE_MAP, true)) {
|
||||
$mode = strtolower($mode);
|
||||
// necessary because of 5.6 compatibility; we can't do isset(self::MODE_MAP[$mode]) in 5.6
|
||||
$map = self::MODE_MAP;
|
||||
if (!isset($map[$mode])) {
|
||||
throw new BadModeException('No valid mode has been specified');
|
||||
}
|
||||
|
||||
$mode = self::MODE_MAP[$mode];
|
||||
$mode = self::MODE_MAP[$mode];
|
||||
}
|
||||
|
||||
// $mode dependent settings
|
||||
switch ($mode) {
|
||||
|
|
|
@ -584,17 +584,17 @@ class DES extends BlockCipher
|
|||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
|
||||
parent::__construct($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -265,17 +265,17 @@ class RC2 extends BlockCipher
|
|||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
|
||||
parent::__construct($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -168,17 +168,17 @@ class Rijndael extends BlockCipher
|
|||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
|
||||
parent::__construct($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,7 +138,7 @@ class TripleDES extends DES
|
|||
*
|
||||
* @see \phpseclib\Crypt\DES::__construct()
|
||||
* @see \phpseclib\Crypt\Common\SymmetricKey::__construct()
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($mode)
|
||||
|
|
|
@ -374,17 +374,17 @@ class Twofish extends BlockCipher
|
|||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int $mode
|
||||
* @param int|string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
|
||||
parent::__construct($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user