mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
SymmetricKey: don't define self::$gcmField unless we're in GCM mode
This commit is contained in:
parent
f98e0afc76
commit
c6f9807633
@ -584,10 +584,6 @@ abstract class SymmetricKey
|
|||||||
*/
|
*/
|
||||||
public function __construct($mode)
|
public function __construct($mode)
|
||||||
{
|
{
|
||||||
if (!isset(self::$gcmField)) {
|
|
||||||
self::initialize_static_variables();
|
|
||||||
}
|
|
||||||
|
|
||||||
$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;
|
||||||
@ -614,6 +610,9 @@ abstract class SymmetricKey
|
|||||||
if ($this->block_size != 16) {
|
if ($this->block_size != 16) {
|
||||||
throw new \InvalidArgumentException('GCM is only valid for block ciphers with a block size of 128 bits');
|
throw new \InvalidArgumentException('GCM is only valid for block ciphers with a block size of 128 bits');
|
||||||
}
|
}
|
||||||
|
if (!isset(self::$gcmField)) {
|
||||||
|
self::$gcmField = new BinaryField(128, 7, 2, 1, 0);
|
||||||
|
}
|
||||||
$this->paddable = false;
|
$this->paddable = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -623,16 +622,6 @@ abstract class SymmetricKey
|
|||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize static variables
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
private static function initialize_static_variables()
|
|
||||||
{
|
|
||||||
self::$gcmField = new BinaryField(128, 7, 2, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the initialization vector.
|
* Sets the initialization vector.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user