mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-27 00:58:25 +00:00
revisions to gocom's code changes
This commit is contained in:
parent
488433e10f
commit
23ffa6452e
@ -288,7 +288,7 @@ class Blowfish extends BlockCipher
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
@ -296,7 +296,7 @@ class Blowfish extends BlockCipher
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new \InvalidArgumentException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
|
@ -602,23 +602,21 @@ abstract class SymmetricKey
|
||||
*
|
||||
* - gcm
|
||||
*
|
||||
* @param string|int $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
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 = 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 dependent settings
|
||||
switch ($mode) {
|
||||
case self::MODE_ECB:
|
||||
|
@ -584,7 +584,7 @@ class DES extends BlockCipher
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
@ -592,7 +592,7 @@ class DES extends BlockCipher
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ class RC2 extends BlockCipher
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
@ -273,7 +273,7 @@ class RC2 extends BlockCipher
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class Rijndael extends BlockCipher
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
@ -176,7 +176,7 @@ class Rijndael extends BlockCipher
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class TripleDES extends DES
|
||||
*
|
||||
* @see \phpseclib\Crypt\DES::__construct()
|
||||
* @see \phpseclib\Crypt\Common\SymmetricKey::__construct()
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($mode)
|
||||
@ -147,7 +147,6 @@ class TripleDES extends DES
|
||||
// In case of self::MODE_3CBC, we init as CRYPT_DES_MODE_CBC
|
||||
// and additional flag us internally as 3CBC
|
||||
case '3cbc':
|
||||
$mode = self::MODE_3CBC;
|
||||
parent::__construct('cbc');
|
||||
$this->mode_3cbc = true;
|
||||
|
||||
@ -168,6 +167,10 @@ class TripleDES extends DES
|
||||
// If not 3CBC, we init as usual
|
||||
default:
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ class Twofish extends BlockCipher
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param int|string $mode
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
@ -382,7 +382,7 @@ class Twofish extends BlockCipher
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($mode == self::MODE_STREAM) {
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user