mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-05 05:18:28 +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.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
@ -296,7 +296,7 @@ class Blowfish extends BlockCipher
|
|||||||
{
|
{
|
||||||
parent::__construct($mode);
|
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');
|
throw new \InvalidArgumentException('Block ciphers cannot be ran in stream mode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,23 +602,21 @@ abstract class SymmetricKey
|
|||||||
*
|
*
|
||||||
* - gcm
|
* - gcm
|
||||||
*
|
*
|
||||||
* @param string|int $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
public function __construct($mode)
|
public function __construct($mode)
|
||||||
{
|
{
|
||||||
if (!is_int($mode) || !in_array($mode, self::MODE_MAP, true)) {
|
$mode = strtolower($mode);
|
||||||
$mode = strtolower($mode);
|
// necessary because of 5.6 compatibility; we can't do isset(self::MODE_MAP[$mode]) in 5.6
|
||||||
// necessary because of 5.6 compatibility; we can't do isset(self::MODE_MAP[$mode]) in 5.6
|
$map = self::MODE_MAP;
|
||||||
$map = self::MODE_MAP;
|
if (!isset($map[$mode])) {
|
||||||
if (!isset($map[$mode])) {
|
throw new BadModeException('No valid mode has been specified');
|
||||||
throw new BadModeException('No valid mode has been specified');
|
|
||||||
}
|
|
||||||
|
|
||||||
$mode = self::MODE_MAP[$mode];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mode = self::MODE_MAP[$mode];
|
||||||
|
|
||||||
// $mode dependent settings
|
// $mode dependent settings
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case self::MODE_ECB:
|
case self::MODE_ECB:
|
||||||
|
@ -584,7 +584,7 @@ class DES extends BlockCipher
|
|||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
@ -592,7 +592,7 @@ class DES extends BlockCipher
|
|||||||
{
|
{
|
||||||
parent::__construct($mode);
|
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');
|
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class RC2 extends BlockCipher
|
|||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
@ -273,7 +273,7 @@ class RC2 extends BlockCipher
|
|||||||
{
|
{
|
||||||
parent::__construct($mode);
|
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');
|
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ class Rijndael extends BlockCipher
|
|||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
@ -176,7 +176,7 @@ class Rijndael extends BlockCipher
|
|||||||
{
|
{
|
||||||
parent::__construct($mode);
|
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');
|
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\DES::__construct()
|
||||||
* @see \phpseclib\Crypt\Common\SymmetricKey::__construct()
|
* @see \phpseclib\Crypt\Common\SymmetricKey::__construct()
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function __construct($mode)
|
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
|
// In case of self::MODE_3CBC, we init as CRYPT_DES_MODE_CBC
|
||||||
// and additional flag us internally as 3CBC
|
// and additional flag us internally as 3CBC
|
||||||
case '3cbc':
|
case '3cbc':
|
||||||
$mode = self::MODE_3CBC;
|
|
||||||
parent::__construct('cbc');
|
parent::__construct('cbc');
|
||||||
$this->mode_3cbc = true;
|
$this->mode_3cbc = true;
|
||||||
|
|
||||||
@ -168,6 +167,10 @@ class TripleDES extends DES
|
|||||||
// If not 3CBC, we init as usual
|
// If not 3CBC, we init as usual
|
||||||
default:
|
default:
|
||||||
parent::__construct($mode);
|
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.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param int|string $mode
|
* @param string $mode
|
||||||
* @access public
|
* @access public
|
||||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||||
*/
|
*/
|
||||||
@ -382,7 +382,7 @@ class Twofish extends BlockCipher
|
|||||||
{
|
{
|
||||||
parent::__construct($mode);
|
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');
|
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user