Php 7.1 Upgrade

This commit is contained in:
Jack Worman 2022-07-06 20:43:09 -05:00
parent 0b5bca65c7
commit e210166f43
208 changed files with 746 additions and 1442 deletions

View File

@ -26,11 +26,9 @@ return (new PhpCsFixer\Config())
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_trim' => true,
// PHP 7.0
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'declare_strict_types' => false,
// PHP 7.1
'void_return' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
]
);

View File

@ -15,5 +15,6 @@
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR12.Files.FileHeader.IncorrectOrder"/>
</rule>
</ruleset>

File diff suppressed because it is too large Load Diff

View File

@ -55,12 +55,12 @@
"paragonie/constant_time_encoding": "^2"
},
"require-dev": {
"ext-xml": "*",
"phpunit/phpunit": "*"
},
"suggest": {
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations."
},
"autoload": {

View File

@ -220,7 +220,7 @@ abstract class Strings
$parts = preg_split('#(\d+)#', $format, -1, PREG_SPLIT_DELIM_CAPTURE);
$format = '';
for ($i = 1; $i < count($parts); $i += 2) {
$format .= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), (int) $parts[$i]);
$format .= substr($parts[$i - 1], 0, -1) . str_repeat($parts[$i - 1][-1], (int) $parts[$i]);
}
$format .= $parts[$i - 1];

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of AES.
*
* Uses mcrypt, if available/possible, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of Blowfish.
*
* Uses mcrypt, if available, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -55,22 +55,6 @@ class Blowfish extends BlockCipher
*/
protected $block_size = 8;
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'blowfish';
/**
* Optimizing value while CFB-encrypting
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
/**
* The fixed subkeys boxes ($sbox0 - $sbox3) with 256 entries each
*

View File

@ -80,22 +80,6 @@ abstract class AsymmetricKey
*/
private static $invisiblePlugins = [];
/**
* Supported signature formats (lower case)
*
* @see self::initialize_static_variables()
* @var array
*/
private static $signatureFormats = [];
/**
* Supported signature formats (original case)
*
* @see self::initialize_static_variables()
* @var array
*/
private static $signatureFileFormats = [];
/**
* Available Engines
*
@ -110,8 +94,6 @@ abstract class AsymmetricKey
*/
private $comment;
/**
*/
abstract public function toString(string $type, array $options = []): string;
/**

View File

@ -90,7 +90,7 @@ abstract class OpenSSH
bcrypt is basically Blowfish with an altered key expansion. whereas Blowfish just runs the
key through the key expansion bcrypt interleaves the key expansion with the salt and
password. this renders openssl / mcrypt unusuable. this forces us to use a pure-PHP implementation
password. this renders openssl unusable. this forces us to use a pure-PHP implementation
of bcrypt. the problem with that is that pure-PHP is too slow to be practically useful.
in addition to encrypting a different string 64 times the OpenSSH implementation also performs bcrypt
@ -129,7 +129,7 @@ abstract class OpenSSH
if (!isset($parts[1])) {
$key = base64_decode($parts[0]);
$comment = $parts[1] ?? false;
$comment = false;
} else {
$asciiType = $parts[0];
self::checkType($parts[0]);

View File

@ -25,15 +25,15 @@ abstract class PKCS
/**
* Auto-detect the format
*/
const MODE_ANY = 0;
public const MODE_ANY = 0;
/**
* Require base64-encoded PEM's be supplied
*/
const MODE_PEM = 1;
public const MODE_PEM = 1;
/**
* Require raw DER's be supplied
*/
const MODE_DER = 2;
public const MODE_DER = 2;
/**#@-*/
/**

View File

@ -140,12 +140,12 @@ abstract class PuTTY
foreach ($lines as $line) {
switch (true) {
case preg_match('#^(.*?): (.*)#', $line, $match):
$in_value = $line[strlen($line) - 1] == '\\';
$in_value = $line[-1] == '\\';
$current = strtolower($match[1]);
$values[$current] = $in_value ? substr($match[2], 0, -1) : $match[2];
break;
case $in_value:
$in_value = $line[strlen($line) - 1] == '\\';
$in_value = $line[-1] == '\\';
$values[$current] .= $in_value ? substr($line, 0, -1) : $line;
break;
default:

View File

@ -64,7 +64,7 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_CTR = -1;
public const MODE_CTR = -1;
/**
* Encrypt / decrypt using the Electronic Code Book mode.
*
@ -72,7 +72,7 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_ECB = 1;
public const MODE_ECB = 1;
/**
* Encrypt / decrypt using the Code Book Chaining mode.
*
@ -80,7 +80,7 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_CBC = 2;
public const MODE_CBC = 2;
/**
* Encrypt / decrypt using the Cipher Feedback mode.
*
@ -88,21 +88,21 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_CFB = 3;
public const MODE_CFB = 3;
/**
* Encrypt / decrypt using the Cipher Feedback mode (8bit)
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_CFB8 = 7;
public const MODE_CFB8 = 7;
/**
* Encrypt / decrypt using the Output Feedback mode (8bit)
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_OFB8 = 8;
public const MODE_OFB8 = 8;
/**
* Encrypt / decrypt using the Output Feedback mode.
*
@ -110,7 +110,7 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_OFB = 4;
public const MODE_OFB = 4;
/**
* Encrypt / decrypt using Galois/Counter mode.
*
@ -118,21 +118,21 @@ abstract class SymmetricKey
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_GCM = 5;
public const MODE_GCM = 5;
/**
* Encrypt / decrypt using streaming mode.
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
*/
const MODE_STREAM = 6;
public const MODE_STREAM = 6;
/**
* Mode Map
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const MODE_MAP = [
public const MODE_MAP = [
'ctr' => self::MODE_CTR,
'ecb' => self::MODE_ECB,
'cbc' => self::MODE_CBC,
@ -149,47 +149,40 @@ abstract class SymmetricKey
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_INTERNAL = 1;
public const ENGINE_INTERNAL = 1;
/**
* Base value for the eval() implementation $engine switch
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_EVAL = 2;
/**
* Base value for the mcrypt implementation $engine switch
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_MCRYPT = 3;
public const ENGINE_EVAL = 2;
/**
* Base value for the openssl implementation $engine switch
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_OPENSSL = 4;
public const ENGINE_OPENSSL = 4;
/**
* Base value for the libsodium implementation $engine switch
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_LIBSODIUM = 5;
public const ENGINE_LIBSODIUM = 5;
/**
* Base value for the openssl / gcm implementation $engine switch
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
*/
const ENGINE_OPENSSL_GCM = 6;
public const ENGINE_OPENSSL_GCM = 6;
/**
* Engine Reverse Map
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::getEngine()
*/
const ENGINE_MAP = [
public const ENGINE_MAP = [
self::ENGINE_INTERNAL => 'PHP',
self::ENGINE_EVAL => 'Eval',
self::ENGINE_MCRYPT => 'mcrypt',
self::ENGINE_OPENSSL => 'OpenSSL',
self::ENGINE_LIBSODIUM => 'libsodium',
self::ENGINE_OPENSSL_GCM => 'OpenSSL (GCM)'
@ -270,85 +263,6 @@ abstract class SymmetricKey
*/
protected $debuffer;
/**
* mcrypt resource for encryption
*
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
*
* @see self::encrypt()
* @var resource
*/
private $enmcrypt;
/**
* mcrypt resource for decryption
*
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
*
* @see self::decrypt()
* @var resource
*/
private $demcrypt;
/**
* Does the enmcrypt resource need to be (re)initialized?
*
* @see \phpseclib3\Crypt\Twofish::setKey()
* @see \phpseclib3\Crypt\Twofish::setIV()
* @var bool
*/
private $enchanged = true;
/**
* Does the demcrypt resource need to be (re)initialized?
*
* @see \phpseclib3\Crypt\Twofish::setKey()
* @see \phpseclib3\Crypt\Twofish::setIV()
* @var bool
*/
private $dechanged = true;
/**
* mcrypt resource for CFB mode
*
* mcrypt's CFB mode, in (and only in) buffered context,
* is broken, so phpseclib implements the CFB mode by it self,
* even when the mcrypt php extension is available.
*
* In order to do the CFB-mode work (fast) phpseclib
* use a separate ECB-mode mcrypt resource.
*
* @link http://phpseclib.sourceforge.net/cfb-demo.phps
* @see self::encrypt()
* @see self::decrypt()
* @see self::setupMcrypt()
* @var resource
*/
private $ecb;
/**
* Optimizing value while CFB-encrypting
*
* Only relevant if $continuousBuffer enabled
* and $engine == self::ENGINE_MCRYPT
*
* It's faster to re-init $enmcrypt if
* $buffer bytes > $cfb_init_len than
* using the $ecb resource furthermore.
*
* This value depends of the chosen cipher
* and the time it would be needed for it's
* initialization [by mcrypt_generic_init()]
* which, typically, depends on the complexity
* on its internaly Key-expanding algorithm.
*
* @see self::encrypt()
* @var int
*/
protected $cfb_init_len = 600;
/**
* Does internal cipher state need to be (re)initialized?
*
@ -391,7 +305,6 @@ abstract class SymmetricKey
* - self::ENGINE_LIBSODIUM (very fast, php-extension: libsodium, extension_loaded('libsodium') required)
* - self::ENGINE_OPENSSL_GCM (very fast, php-extension: openssl, extension_loaded('openssl') required)
* - self::ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required)
* - self::ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
* - self::ENGINE_EVAL (medium, pure php-engine, no php-extension required)
* - self::ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
*
@ -411,18 +324,6 @@ abstract class SymmetricKey
*/
private $preferredEngine;
/**
* The mcrypt specific name of the cipher
*
* Only used if $engine == self::ENGINE_MCRYPT
*
* @link http://www.php.net/mcrypt_module_open
* @link http://www.php.net/mcrypt_list_algorithms
* @see self::setupMcrypt()
* @var string
*/
protected $cipher_name_mcrypt;
/**
* The openssl specific name of the cipher
*
@ -473,14 +374,6 @@ abstract class SymmetricKey
*/
private $openssl_emulate_ctr = false;
/**
* Don't truncate / null pad key
*
* @see self::clearBuffers()
* @var bool
*/
private $skip_key_adjustment = false;
/**
* Has the key length explicitly been set or should it be derived from the key, itself?
*
@ -1169,83 +1062,6 @@ abstract class SymmetricKey
}
}
if ($this->engine === self::ENGINE_MCRYPT) {
set_error_handler(function (): void {
});
if ($this->enchanged) {
mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV));
$this->enchanged = false;
}
// re: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
// using mcrypt's default handing of CFB the above would output two different things. using phpseclib's
// rewritten CFB implementation the above outputs the same thing twice.
if ($this->mode == self::MODE_CFB && $this->continuousBuffer) {
$block_size = $this->block_size;
$iv = &$this->encryptIV;
$pos = &$this->enbuffer['pos'];
$len = strlen($plaintext);
$ciphertext = '';
$i = 0;
if ($pos) {
$orig_pos = $pos;
$max = $block_size - $pos;
if ($len >= $max) {
$i = $max;
$len -= $max;
$pos = 0;
} else {
$i = $len;
$pos += $len;
$len = 0;
}
$ciphertext = substr($iv, $orig_pos) ^ $plaintext;
$iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
$this->enbuffer['enmcrypt_init'] = true;
}
if ($len >= $block_size) {
if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) {
if ($this->enbuffer['enmcrypt_init'] === true) {
mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
$this->enbuffer['enmcrypt_init'] = false;
}
$ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
$iv = substr($ciphertext, -$block_size);
$len %= $block_size;
} else {
while ($len >= $block_size) {
$iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
$ciphertext .= $iv;
$len -= $block_size;
$i += $block_size;
}
}
}
if ($len) {
$iv = mcrypt_generic($this->ecb, $iv);
$block = $iv ^ substr($plaintext, -$len);
$iv = substr_replace($iv, $block, 0, $len);
$ciphertext .= $block;
$pos = $len;
}
restore_error_handler();
return $ciphertext;
}
$ciphertext = mcrypt_generic($this->enmcrypt, $plaintext);
if (!$this->continuousBuffer) {
mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV));
}
restore_error_handler();
return $ciphertext;
}
if ($this->engine === self::ENGINE_EVAL) {
$inline = $this->inline_crypt;
return $inline('encrypt', $plaintext);
@ -1558,66 +1374,6 @@ abstract class SymmetricKey
return $this->paddable ? $this->unpad($plaintext) : $plaintext;
}
if ($this->engine === self::ENGINE_MCRYPT) {
set_error_handler(function (): void {
});
$block_size = $this->block_size;
if ($this->dechanged) {
mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV));
$this->dechanged = false;
}
if ($this->mode == self::MODE_CFB && $this->continuousBuffer) {
$iv = &$this->decryptIV;
$pos = &$this->debuffer['pos'];
$len = strlen($ciphertext);
$plaintext = '';
$i = 0;
if ($pos) {
$orig_pos = $pos;
$max = $block_size - $pos;
if ($len >= $max) {
$i = $max;
$len -= $max;
$pos = 0;
} else {
$i = $len;
$pos += $len;
$len = 0;
}
// ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
$plaintext = substr($iv, $orig_pos) ^ $ciphertext;
$iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
}
if ($len >= $block_size) {
$cb = substr($ciphertext, $i, $len - $len % $block_size);
$plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
$iv = substr($cb, -$block_size);
$len %= $block_size;
}
if ($len) {
$iv = mcrypt_generic($this->ecb, $iv);
$plaintext .= $iv ^ substr($ciphertext, -$len);
$iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
$pos = $len;
}
restore_error_handler();
return $plaintext;
}
$plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
if (!$this->continuousBuffer) {
mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV));
}
restore_error_handler();
return $this->paddable ? $this->unpad($plaintext) : $plaintext;
}
if ($this->engine === self::ENGINE_EVAL) {
$inline = $this->inline_crypt;
return $inline('decrypt', $ciphertext);
@ -1839,19 +1595,6 @@ abstract class SymmetricKey
$this->oldtag = $tag;
}
/**
* Get the IV
*
* mcrypt requires an IV even if ECB is used
*
* @see self::encrypt()
* @see self::decrypt()
*/
protected function getIV(string $iv): string
{
return $this->mode == self::MODE_ECB ? str_repeat("\0", $this->block_size) : $iv;
}
/**
* OpenSSL CTR Processor
*
@ -2144,14 +1887,6 @@ abstract class SymmetricKey
}
}
return false;
case self::ENGINE_MCRYPT:
set_error_handler(function (): void {
});
$result = $this->cipher_name_mcrypt &&
extension_loaded('mcrypt') &&
in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms());
restore_error_handler();
return $result;
case self::ENGINE_EVAL:
return method_exists($this, 'setupInlineCrypt');
case self::ENGINE_INTERNAL:
@ -2190,8 +1925,6 @@ abstract class SymmetricKey
*
* - OpenSSL [very fast]
*
* - mcrypt [fast]
*
* - Eval [slow]
*
* - PHP [slowest]
@ -2236,7 +1969,6 @@ abstract class SymmetricKey
self::ENGINE_LIBSODIUM,
self::ENGINE_OPENSSL_GCM,
self::ENGINE_OPENSSL,
self::ENGINE_MCRYPT,
self::ENGINE_EVAL
];
if (isset($this->preferredEngine)) {
@ -2256,23 +1988,6 @@ abstract class SymmetricKey
$this->engine = self::ENGINE_INTERNAL;
}
if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) {
set_error_handler(function (): void {
});
// Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
// (re)open them with the module named in $this->cipher_name_mcrypt
mcrypt_module_close($this->enmcrypt);
mcrypt_module_close($this->demcrypt);
$this->enmcrypt = null;
$this->demcrypt = null;
if ($this->ecb) {
mcrypt_module_close($this->ecb);
$this->ecb = null;
}
restore_error_handler();
}
$this->changed = $this->nonIVChanged = true;
}
@ -2365,42 +2080,6 @@ abstract class SymmetricKey
$this->encryptIV = $this->decryptIV = $this->iv;
switch ($this->engine) {
case self::ENGINE_MCRYPT:
$this->enchanged = $this->dechanged = true;
set_error_handler(function (): void {
});
if (!isset($this->enmcrypt)) {
static $mcrypt_modes = [
self::MODE_CTR => 'ctr',
self::MODE_ECB => MCRYPT_MODE_ECB,
self::MODE_CBC => MCRYPT_MODE_CBC,
self::MODE_CFB => 'ncfb',
self::MODE_CFB8 => MCRYPT_MODE_CFB,
self::MODE_OFB => MCRYPT_MODE_NOFB,
self::MODE_OFB8 => MCRYPT_MODE_OFB,
self::MODE_STREAM => MCRYPT_MODE_STREAM,
];
$this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
$this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
// we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer()
// to workaround mcrypt's broken ncfb implementation in buffered mode
// see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
if ($this->mode == self::MODE_CFB) {
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
}
} // else should mcrypt_generic_deinit be called?
if ($this->mode == self::MODE_CFB) {
mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size));
}
restore_error_handler();
break;
case self::ENGINE_INTERNAL:
$this->setupKey();
break;
@ -2459,7 +2138,7 @@ abstract class SymmetricKey
return $text;
}
$length = ord($text[strlen($text) - 1]);
$length = ord($text[-1]);
if (!$length || $length > $this->block_size) {
throw new BadDecryptionException("The ciphertext has an invalid padding length ($length) compared to the block size ({$this->block_size})");
@ -2631,7 +2310,6 @@ abstract class SymmetricKey
* ];
* </code>
*
* @return string (the name of the created callback function)
* @see self::decrypt()
* @see self::setupInlineCrypt()
* @see self::encrypt()
@ -3071,9 +2749,25 @@ abstract class SymmetricKey
// Before discrediting this, please read the following:
// @see https://github.com/phpseclib/phpseclib/issues/1293
// @see https://github.com/phpseclib/phpseclib/pull/1143
eval('$func = function ($_action, $_text) { ' . $init_crypt . 'if ($_action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }};');
/** @var \Closure $func */
$func = eval(<<<PHP
return function (string \$_action, string \$_text): string
{
{$init_crypt}
if (\$_action === 'encrypt') {
{$encrypt}
} else {
{$decrypt}
}
};
PHP
);
return \Closure::bind($func, $this, static::class);
$bindedClosure = \Closure::bind($func, $this, static::class);
if ($bindedClosure instanceof \Closure) {
return $bindedClosure;
}
throw new \LogicException('\Closure::bind() failed.');
}
/**

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of DES.
*
* Uses mcrypt, if available, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -58,14 +58,14 @@ class DES extends BlockCipher
* @see \phpseclib3\Crypt\DES::setupKey()
* @see \phpseclib3\Crypt\DES::processBlock()
*/
const ENCRYPT = 0;
public const ENCRYPT = 0;
/**
* Contains $keys[self::DECRYPT]
*
* @see \phpseclib3\Crypt\DES::setupKey()
* @see \phpseclib3\Crypt\DES::processBlock()
*/
const DECRYPT = 1;
public const DECRYPT = 1;
/**
* Block Length of the cipher
@ -83,14 +83,6 @@ class DES extends BlockCipher
*/
protected $key_length = 8;
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'des';
/**
* The OpenSSL names of the cipher / modes
*
@ -105,14 +97,6 @@ class DES extends BlockCipher
// self::MODE_CTR is undefined for DES
];
/**
* Optimizing value while CFB-encrypting
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
/**
* Switch for DES/3DES encryption
*

View File

@ -46,7 +46,7 @@ abstract class DH extends AsymmetricKey
*
* @var string
*/
const ALGORITHM = 'DH';
public const ALGORITHM = 'DH';
/**
* DH prime
@ -322,7 +322,7 @@ abstract class DH extends AsymmetricKey
/**
* OnLoad Handler
*
* @return bool
* @return Parameters|PrivateKey|PublicKey
*/
protected static function onLoad(array $components)
{

View File

@ -39,14 +39,14 @@ abstract class PKCS8 extends Progenitor
*
* @var string
*/
const OID_NAME = 'dhKeyAgreement';
public const OID_NAME = 'dhKeyAgreement';
/**
* OID Value
*
* @var string
*/
const OID_VALUE = '1.2.840.113549.1.3.1';
public const OID_VALUE = '1.2.840.113549.1.3.1';
/**
* Child OIDs loaded

View File

@ -50,7 +50,7 @@ abstract class DSA extends AsymmetricKey
*
* @var string
*/
const ALGORITHM = 'DSA';
public const ALGORITHM = 'DSA';
/**
* DSA Prime P
@ -213,7 +213,7 @@ abstract class DSA extends AsymmetricKey
/**
* OnLoad Handler
*
* @return bool
* @return Parameters|PrivateKey|PublicKey
*/
protected static function onLoad(array $components)
{

View File

@ -43,14 +43,14 @@ abstract class PKCS8 extends Progenitor
*
* @var string
*/
const OID_NAME = 'id-dsa';
public const OID_NAME = 'id-dsa';
/**
* OID Value
*
* @var string
*/
const OID_VALUE = '1.2.840.10040.4.1';
public const OID_VALUE = '1.2.840.10040.4.1';
/**
* Child OIDs loaded

View File

@ -36,7 +36,7 @@ abstract class PuTTY extends Progenitor
*
* @var string
*/
const PUBLIC_HANDLER = 'phpseclib3\Crypt\DSA\Formats\Keys\OpenSSH';
public const PUBLIC_HANDLER = 'phpseclib3\Crypt\DSA\Formats\Keys\OpenSSH';
/**
* Algorithm Identifier

View File

@ -60,7 +60,7 @@ abstract class EC extends AsymmetricKey
*
* @var string
*/
const ALGORITHM = 'EC';
public const ALGORITHM = 'EC';
/**
* Public Key QA
@ -197,7 +197,7 @@ abstract class EC extends AsymmetricKey
/**
* OnLoad Handler
*
* @return bool
* @return AsymmetricKey|Parameters|PrivateKey|PublicKey
*/
protected static function onLoad(array $components)
{

View File

@ -24,20 +24,6 @@ use phpseclib3\Math\BigInteger;
*/
abstract class Base
{
/**
* Doubles
*
* @var object[]
*/
protected $doubles;
/**
* NAF Points
*
* @var int[]
*/
private $naf;
/**
* The Order
*

View File

@ -22,7 +22,7 @@ use phpseclib3\Math\PrimeField\Integer;
class Ed25519 extends TwistedEdwards
{
const HASH = 'sha512';
public const HASH = 'sha512';
/*
Per https://tools.ietf.org/html/rfc8032#page-6 EdDSA has several parameters, one of which is b:
@ -33,7 +33,7 @@ class Ed25519 extends TwistedEdwards
SIZE corresponds to b
*/
const SIZE = 32;
public const SIZE = 32;
public function __construct()
{

View File

@ -21,8 +21,8 @@ use phpseclib3\Math\BigInteger;
class Ed448 extends TwistedEdwards
{
const HASH = 'shake256-912';
const SIZE = 57;
public const HASH = 'shake256-912';
public const SIZE = 57;
public function __construct()
{

View File

@ -39,7 +39,7 @@ abstract class MontgomeryPrivate
/**
* Is invisible flag
*/
const IS_INVISIBLE = true;
public const IS_INVISIBLE = true;
/**
* Break a public or private key down into its constituent components

View File

@ -30,7 +30,7 @@ abstract class MontgomeryPublic
/**
* Is invisible flag
*/
const IS_INVISIBLE = true;
public const IS_INVISIBLE = true;
/**
* Break a public or private key down into its constituent components

View File

@ -52,14 +52,14 @@ abstract class PKCS8 extends Progenitor
*
* @var array
*/
const OID_NAME = ['id-ecPublicKey', 'id-Ed25519', 'id-Ed448'];
public const OID_NAME = ['id-ecPublicKey', 'id-Ed25519', 'id-Ed448'];
/**
* OID Value
*
* @var string
*/
const OID_VALUE = ['1.2.840.10045.2.1', '1.3.101.112', '1.3.101.113'];
public const OID_VALUE = ['1.2.840.10045.2.1', '1.3.101.112', '1.3.101.113'];
/**
* Break a public or private key down into its constituent components

View File

@ -36,7 +36,7 @@ abstract class PuTTY extends Progenitor
*
* @var string
*/
const PUBLIC_HANDLER = 'phpseclib3\Crypt\EC\Formats\Keys\OpenSSH';
public const PUBLIC_HANDLER = 'phpseclib3\Crypt\EC\Formats\Keys\OpenSSH';
/**
* Supported Key Types

View File

@ -35,7 +35,7 @@ abstract class libsodium
/**
* Is invisible flag
*/
const IS_INVISIBLE = true;
public const IS_INVISIBLE = true;
/**
* Break a public or private key down into its constituent components

View File

@ -48,17 +48,17 @@ class Hash
/**
* Padding Types
*/
const PADDING_KECCAK = 1;
public const PADDING_KECCAK = 1;
/**
* Padding Types
*/
const PADDING_SHA3 = 2;
public const PADDING_SHA3 = 2;
/**
* Padding Types
*/
const PADDING_SHAKE = 3;
public const PADDING_SHAKE = 3;
/**
* Padding Type

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of RC2.
*
* Uses mcrypt, if available, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -71,14 +71,6 @@ class RC2 extends BlockCipher
*/
private $orig_key;
/**
* Don't truncate / null pad key
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::clearBuffers()
* @var bool
*/
private $skip_key_adjustment = true;
/**
* Key Length (in bytes)
*
@ -87,22 +79,6 @@ class RC2 extends BlockCipher
*/
protected $key_length = 16; // = 128 bits
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'rc2';
/**
* Optimizing value while CFB-encrypting
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
/**
* The key length in bits.
*
@ -343,12 +319,6 @@ class RC2 extends BlockCipher
$t = strlen($key);
// The mcrypt RC2 implementation only supports effective key length
// of 1024 bits. It is however possible to handle effective key
// lengths in range 1..1024 by expanding the key and applying
// inverse pitable mapping to the first byte before submitting it
// to mcrypt.
// Key expansion.
$l = array_values(unpack('C*', $key));
$t8 = ($t1 + 7) >> 3;

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of RC4.
*
* Uses mcrypt, if available, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -56,12 +56,12 @@ class RC4 extends StreamCipher
/**
* @see \phpseclib3\Crypt\RC4::_crypt()
*/
const ENCRYPT = 0;
public const ENCRYPT = 0;
/**
* @see \phpseclib3\Crypt\RC4::_crypt()
*/
const DECRYPT = 1;
public const DECRYPT = 1;
/**
* Key Length (in bytes)
@ -71,14 +71,6 @@ class RC4 extends StreamCipher
*/
protected $key_length = 128; // = 1024 bits
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'arcfour';
/**
* The Key
*

View File

@ -75,7 +75,7 @@ abstract class RSA extends AsymmetricKey
*
* @var string
*/
const ALGORITHM = 'RSA';
public const ALGORITHM = 'RSA';
/**
* Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding}
@ -88,7 +88,7 @@ abstract class RSA extends AsymmetricKey
* @see self::encrypt()
* @see self::decrypt()
*/
const ENCRYPTION_OAEP = 1;
public const ENCRYPTION_OAEP = 1;
/**
* Use PKCS#1 padding.
@ -99,7 +99,7 @@ abstract class RSA extends AsymmetricKey
* @see self::encrypt()
* @see self::decrypt()
*/
const ENCRYPTION_PKCS1 = 2;
public const ENCRYPTION_PKCS1 = 2;
/**
* Do not use any padding
@ -110,7 +110,7 @@ abstract class RSA extends AsymmetricKey
* @see self::encrypt()
* @see self::decrypt()
*/
const ENCRYPTION_NONE = 4;
public const ENCRYPTION_NONE = 4;
/**
* Use the Probabilistic Signature Scheme for signing
@ -124,7 +124,7 @@ abstract class RSA extends AsymmetricKey
* @see self::verify()
* @see self::setHash()
*/
const SIGNATURE_PSS = 16;
public const SIGNATURE_PSS = 16;
/**
* Use a relaxed version of PKCS#1 padding for signature verification
@ -133,7 +133,7 @@ abstract class RSA extends AsymmetricKey
* @see self::verify()
* @see self::setHash()
*/
const SIGNATURE_RELAXED_PKCS1 = 32;
public const SIGNATURE_RELAXED_PKCS1 = 32;
/**
* Use PKCS#1 padding for signature verification
@ -142,7 +142,7 @@ abstract class RSA extends AsymmetricKey
* @see self::verify()
* @see self::setHash()
*/
const SIGNATURE_PKCS1 = 64;
public const SIGNATURE_PKCS1 = 64;
/**
* Encryption padding mode
@ -416,7 +416,7 @@ abstract class RSA extends AsymmetricKey
/**
* OnLoad Handler
*
* @return bool
* @return PrivateKey|PublicKey|RSA
*/
protected static function onLoad(array $components)
{

View File

@ -34,31 +34,31 @@ abstract class MSBLOB
/**
* Public/Private Key Pair
*/
const PRIVATEKEYBLOB = 0x7;
public const PRIVATEKEYBLOB = 0x7;
/**
* Public Key
*/
const PUBLICKEYBLOB = 0x6;
public const PUBLICKEYBLOB = 0x6;
/**
* Public Key
*/
const PUBLICKEYBLOBEX = 0xA;
public const PUBLICKEYBLOBEX = 0xA;
/**
* RSA public key exchange algorithm
*/
const CALG_RSA_KEYX = 0x0000A400;
public const CALG_RSA_KEYX = 0x0000A400;
/**
* RSA public key exchange algorithm
*/
const CALG_RSA_SIGN = 0x00002400;
public const CALG_RSA_SIGN = 0x00002400;
/**
* Public Key
*/
const RSA1 = 0x31415352;
public const RSA1 = 0x31415352;
/**
* Private Key
*/
const RSA2 = 0x32415352;
public const RSA2 = 0x32415352;
/**
* Break a public or private key down into its constituent components

View File

@ -44,14 +44,14 @@ abstract class PKCS8 extends Progenitor
*
* @var string
*/
const OID_NAME = 'rsaEncryption';
public const OID_NAME = 'rsaEncryption';
/**
* OID Value
*
* @var string
*/
const OID_VALUE = '1.2.840.113549.1.1.1';
public const OID_VALUE = '1.2.840.113549.1.1.1';
/**
* Child OIDs loaded

View File

@ -43,14 +43,14 @@ abstract class PSS extends Progenitor
*
* @var string
*/
const OID_NAME = 'id-RSASSA-PSS';
public const OID_NAME = 'id-RSASSA-PSS';
/**
* OID Value
*
* @var string
*/
const OID_VALUE = '1.2.840.113549.1.1.10';
public const OID_VALUE = '1.2.840.113549.1.1.10';
/**
* OIDs loaded

View File

@ -31,7 +31,7 @@ abstract class PuTTY extends Progenitor
*
* @var string
*/
const PUBLIC_HANDLER = 'phpseclib3\Crypt\RSA\Formats\Keys\OpenSSH';
public const PUBLIC_HANDLER = 'phpseclib3\Crypt\RSA\Formats\Keys\OpenSSH';
/**
* Algorithm Identifier

View File

@ -223,7 +223,7 @@ class PublicKey extends RSA implements Common\PublicKey
return false;
}
if ($em[strlen($em) - 1] != chr(0xBC)) {
if ($em[-1] != chr(0xBC)) {
return false;
}

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of Rijndael.
*
* Uses mcrypt, if available/possible, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -13,8 +13,8 @@
* 136-bits it'll be null-padded to 192-bits and 192 bits will be the key length until
* {@link self::setKey() setKey()} is called, again, at which point, it'll be recalculated.
*
* Not all Rijndael implementations may support 160-bits or 224-bits as the block length / key length. mcrypt, for example,
* does not. AES, itself, only supports block lengths of 128 and key lengths of 128, 192, and 256.
* Not all Rijndael implementations may support 160-bits or 224-bits as the block length / key length. AES, itself, only
* supports block lengths of 128 and key lengths of 128, 192, and 256.
* {@link http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=10 Rijndael-ammended.pdf#page=10} defines the
* algorithm for block lengths of 192 and 256 but not for block lengths / key lengths of 160 and 224. Indeed, 160 and 224
* are first defined as valid key / block lengths in
@ -68,21 +68,6 @@ use phpseclib3\Exception\InsufficientSetupException;
*/
class Rijndael extends BlockCipher
{
/**
* The mcrypt specific name of the cipher
*
* Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not.
* \phpseclib3\Crypt\Rijndael determines automatically whether mcrypt is useable
* or not for the current $block_size/$key_length.
* In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @see \phpseclib3\Crypt\Common\SymmetricKey::engine
* @see self::isValidEngine()
* @var string
*/
protected $cipher_name_mcrypt = 'rijndael-128';
/**
* The Key Schedule
*
@ -178,15 +163,11 @@ class Rijndael extends BlockCipher
*
* Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined
* and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to
* 192/256 bits as, for example, mcrypt will do.
* 192/256 bits as.
*
* That said, if you want be compatible with other Rijndael and AES implementations,
* you should not setKeyLength(160) or setKeyLength(224).
*
* Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use
* the mcrypt php extension, even if available.
* This results then in slower encryption.
*
* @throws \LengthException if the key length is invalid
*/
public function setKeyLength(int $length): void
@ -287,12 +268,6 @@ class Rijndael extends BlockCipher
$this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb';
$this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->openssl_translate_mode();
break;
case self::ENGINE_MCRYPT:
$this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3);
if ($this->key_length % 8) { // is it a 160/224-bit key?
// mcrypt is not usable for them, only for 128/192/256-bit keys
return false;
}
}
return parent::isValidEngineHelper($engine);

View File

@ -51,12 +51,12 @@ class Salsa20 extends StreamCipher
/**
* @see \phpseclib3\Crypt\Salsa20::crypt()
*/
const ENCRYPT = 0;
public const ENCRYPT = 0;
/**
* @see \phpseclib3\Crypt\Salsa20::crypt()
*/
const DECRYPT = 1;
public const DECRYPT = 1;
/**
* Encryption buffer for continuous mode

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of Triple DES.
*
* Uses mcrypt, if available, and an internal implementation, otherwise. Operates in the EDE3 mode (encrypt-decrypt-encrypt).
* Uses an internal implementation. Operates in the EDE3 mode (encrypt-decrypt-encrypt).
*
* PHP version 5
*
@ -36,6 +36,8 @@ declare(strict_types=1);
namespace phpseclib3\Crypt;
use phpseclib3\Exception\BadModeException;
/**
* Pure-PHP implementation of Triple DES.
*
@ -48,14 +50,14 @@ class TripleDES extends DES
*
* Inner chaining is used by SSH-1 and is generally considered to be less secure then outer chaining (self::MODE_CBC3).
*/
const MODE_3CBC = -2;
public const MODE_3CBC = -2;
/**
* Encrypt / decrypt using outer chaining
*
* Outer chaining is used by SSH-2 and when the mode is set to \phpseclib3\Crypt\Common\BlockCipher::MODE_CBC.
*/
const MODE_CBC3 = self::MODE_CBC;
public const MODE_CBC3 = self::MODE_CBC;
/**
* Key Length (in bytes)
@ -65,23 +67,6 @@ class TripleDES extends DES
*/
protected $key_length = 24;
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\DES::cipher_name_mcrypt
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'tripledes';
/**
* Optimizing value while CFB-encrypting
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 750;
/**
* max possible size of $key
*
@ -110,8 +95,6 @@ class TripleDES extends DES
/**
* Default Constructor.
*
* Determines whether or not the mcrypt or OpenSSL extensions should be used.
*
* $mode could be:
*
* - ecb
@ -386,7 +369,7 @@ class TripleDES extends DES
{
switch (true) {
// if $key <= 64bits we configure our internal pure-php cipher engine
// to act as regular [1]DES, not as 3DES. mcrypt.so::tripledes does the same.
// to act as regular [1]DES, not as 3DES.
case strlen($this->key) <= 8:
$this->des_rounds = 1;
break;

View File

@ -3,7 +3,7 @@
/**
* Pure-PHP implementation of Twofish.
*
* Uses mcrypt, if available, and an internal implementation, otherwise.
* Uses an internal implementation.
*
* PHP version 5
*
@ -48,22 +48,6 @@ use phpseclib3\Exception\BadModeException;
*/
class Twofish extends BlockCipher
{
/**
* The mcrypt specific name of the cipher
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'twofish';
/**
* Optimizing value while CFB-encrypting
*
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 800;
/**
* Q-Table
*

View File

@ -76,13 +76,6 @@ class ANSI
*/
private $y;
/**
* Old Column
*
* @var int
*/
private $old_x;
/**
* Old Row
*
@ -221,7 +214,6 @@ class ANSI
// http://ascii-table.com/ansi-escape-sequences-vt-100.php
switch ($this->ansi) {
case "\x1B[H": // Move cursor to upper left corner
$this->old_x = $this->x;
$this->old_y = $this->y;
$this->x = $this->y = 0;
break;
@ -261,17 +253,14 @@ class ANSI
$this->y += (int) $match[1];
break;
case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h
$this->old_x = $this->x;
$this->old_y = $this->y;
$this->x = $match[2] - 1;
$this->y = (int) $match[1] - 1;
break;
case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines
$this->old_x = $this->x;
$this->x += $match[1];
break;
case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines
$this->old_x = $this->x;
$this->x -= $match[1];
if ($this->x < 0) {
$this->x = 0;

View File

@ -38,49 +38,49 @@ abstract class ASN1
{
// Tag Classes
// http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12
const CLASS_UNIVERSAL = 0;
const CLASS_APPLICATION = 1;
const CLASS_CONTEXT_SPECIFIC = 2;
const CLASS_PRIVATE = 3;
public const CLASS_UNIVERSAL = 0;
public const CLASS_APPLICATION = 1;
public const CLASS_CONTEXT_SPECIFIC = 2;
public const CLASS_PRIVATE = 3;
// Tag Classes
// http://www.obj-sys.com/asn1tutorial/node124.html
const TYPE_BOOLEAN = 1;
const TYPE_INTEGER = 2;
const TYPE_BIT_STRING = 3;
const TYPE_OCTET_STRING = 4;
const TYPE_NULL = 5;
const TYPE_OBJECT_IDENTIFIER = 6;
public const TYPE_BOOLEAN = 1;
public const TYPE_INTEGER = 2;
public const TYPE_BIT_STRING = 3;
public const TYPE_OCTET_STRING = 4;
public const TYPE_NULL = 5;
public const TYPE_OBJECT_IDENTIFIER = 6;
//const TYPE_OBJECT_DESCRIPTOR = 7;
//const TYPE_INSTANCE_OF = 8; // EXTERNAL
const TYPE_REAL = 9;
const TYPE_ENUMERATED = 10;
public const TYPE_REAL = 9;
public const TYPE_ENUMERATED = 10;
//const TYPE_EMBEDDED = 11;
const TYPE_UTF8_STRING = 12;
public const TYPE_UTF8_STRING = 12;
//const TYPE_RELATIVE_OID = 13;
const TYPE_SEQUENCE = 16; // SEQUENCE OF
const TYPE_SET = 17; // SET OF
public const TYPE_SEQUENCE = 16; // SEQUENCE OF
public const TYPE_SET = 17; // SET OF
// More Tag Classes
// http://www.obj-sys.com/asn1tutorial/node10.html
const TYPE_NUMERIC_STRING = 18;
const TYPE_PRINTABLE_STRING = 19;
const TYPE_TELETEX_STRING = 20; // T61String
const TYPE_VIDEOTEX_STRING = 21;
const TYPE_IA5_STRING = 22;
const TYPE_UTC_TIME = 23;
const TYPE_GENERALIZED_TIME = 24;
const TYPE_GRAPHIC_STRING = 25;
const TYPE_VISIBLE_STRING = 26; // ISO646String
const TYPE_GENERAL_STRING = 27;
const TYPE_UNIVERSAL_STRING = 28;
public const TYPE_NUMERIC_STRING = 18;
public const TYPE_PRINTABLE_STRING = 19;
public const TYPE_TELETEX_STRING = 20; // T61String
public const TYPE_VIDEOTEX_STRING = 21;
public const TYPE_IA5_STRING = 22;
public const TYPE_UTC_TIME = 23;
public const TYPE_GENERALIZED_TIME = 24;
public const TYPE_GRAPHIC_STRING = 25;
public const TYPE_VISIBLE_STRING = 26; // ISO646String
public const TYPE_GENERAL_STRING = 27;
public const TYPE_UNIVERSAL_STRING = 28;
//const TYPE_CHARACTER_STRING = 29;
const TYPE_BMP_STRING = 30;
public const TYPE_BMP_STRING = 30;
// Tag Aliases
// These tags are kinda place holders for other tags.
const TYPE_CHOICE = -1;
const TYPE_ANY = -2;
public const TYPE_CHOICE = -1;
public const TYPE_ANY = -2;
/**
* ASN.1 object identifiers
@ -144,7 +144,7 @@ abstract class ASN1
*
* @var array
*/
const ANY_MAP = [
public const ANY_MAP = [
self::TYPE_BOOLEAN => true,
self::TYPE_INTEGER => true,
self::TYPE_BIT_STRING => 'bitString',
@ -177,7 +177,7 @@ abstract class ASN1
*
* @var array
*/
const STRING_TYPE_SIZE = [
public const STRING_TYPE_SIZE = [
self::TYPE_UTF8_STRING => 0,
self::TYPE_BMP_STRING => 2,
self::TYPE_UNIVERSAL_STRING => 4,
@ -1217,7 +1217,7 @@ abstract class ASN1
$temp = (chr(0x80) | $submask->toBytes()) . $temp;
$part = $part->bitwise_rightShift(7);
}
$temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F);
$temp[-1] = $temp[-1] & chr(0x7F);
}
$value .= $temp;
}
@ -1257,7 +1257,7 @@ abstract class ASN1
$format .= '.u';
}
if ($content[strlen($content) - 1] == 'Z') {
if ($content[-1] == 'Z') {
$content = substr($content, 0, -1) . '+0000';
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AccessDescription
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'accessMethod' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AdministrationDomainName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
// if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
// (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AlgorithmIdentifier
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'algorithm' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AnotherName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'type-id' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Attribute
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'type' => AttributeType::MAP,

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class AttributeType
{
const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
public const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AttributeTypeAndValue
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'type' => AttributeType::MAP,

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class AttributeValue
{
const MAP = ['type' => ASN1::TYPE_ANY];
public const MAP = ['type' => ASN1::TYPE_ANY];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Attributes
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SET,
'min' => 1,
'max' => -1,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AuthorityInfoAccessSyntax
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class AuthorityKeyIdentifier
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'keyIdentifier' => [

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class BaseDistance
{
const MAP = ['type' => ASN1::TYPE_INTEGER];
public const MAP = ['type' => ASN1::TYPE_INTEGER];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class BasicConstraints
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'cA' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class BuiltInDomainDefinedAttribute
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'type' => ['type' => ASN1::TYPE_PRINTABLE_STRING],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class BuiltInDomainDefinedAttributes
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => 4, // ub-domain-defined-attributes

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class BuiltInStandardAttributes
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'country-name' => ['optional' => true] + CountryName::MAP,

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class CPSuri
{
const MAP = ['type' => ASN1::TYPE_IA5_STRING];
public const MAP = ['type' => ASN1::TYPE_IA5_STRING];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CRLDistributionPoints
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class CRLNumber
{
const MAP = ['type' => ASN1::TYPE_INTEGER];
public const MAP = ['type' => ASN1::TYPE_INTEGER];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CRLReason
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_ENUMERATED,
'mapping' => [
'unspecified',

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class CertPolicyId
{
const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
public const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Certificate
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'tbsCertificate' => TBSCertificate::MAP,

View File

@ -22,5 +22,5 @@ namespace phpseclib3\File\ASN1\Maps;
*/
abstract class CertificateIssuer
{
const MAP = GeneralNames::MAP;
public const MAP = GeneralNames::MAP;
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CertificateList
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'tbsCertList' => TBSCertList::MAP,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CertificatePolicies
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class CertificateSerialNumber
{
const MAP = ['type' => ASN1::TYPE_INTEGER];
public const MAP = ['type' => ASN1::TYPE_INTEGER];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CertificationRequest
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'certificationRequestInfo' => CertificationRequestInfo::MAP,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CertificationRequestInfo
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'version' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Characteristic_two
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'm' => ['type' => ASN1::TYPE_INTEGER], // field size 2**m

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class CountryName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
// if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
// (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Curve
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'a' => FieldElement::MAP,

View File

@ -26,7 +26,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DHParameter
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'prime' => ['type' => ASN1::TYPE_INTEGER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DSAParams
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'p' => ['type' => ASN1::TYPE_INTEGER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DSAPrivateKey
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'version' => ['type' => ASN1::TYPE_INTEGER],

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class DSAPublicKey
{
const MAP = ['type' => ASN1::TYPE_INTEGER];
public const MAP = ['type' => ASN1::TYPE_INTEGER];
}

View File

@ -26,7 +26,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DigestInfo
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'digestAlgorithm' => AlgorithmIdentifier::MAP,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DirectoryString
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
'children' => [
'teletexString' => ['type' => ASN1::TYPE_TELETEX_STRING],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DisplayText
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
'children' => [
'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DistributionPoint
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'distributionPoint' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DistributionPointName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
'children' => [
'fullName' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class DssSigValue
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'r' => ['type' => ASN1::TYPE_INTEGER],

View File

@ -36,7 +36,7 @@ use phpseclib3\File\ASN1;
*/
abstract class ECParameters
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
'children' => [
'namedCurve' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class ECPoint
{
const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
public const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
}

View File

@ -26,7 +26,7 @@ use phpseclib3\File\ASN1;
*/
abstract class ECPrivateKey
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'version' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class EDIPartyName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'nameAssigner' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class EcdsaSigValue
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'r' => ['type' => ASN1::TYPE_INTEGER],

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class EncryptedData
{
const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
public const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class EncryptedPrivateKeyInfo
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'encryptionAlgorithm' => AlgorithmIdentifier::MAP,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class ExtKeyUsageSyntax
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,

View File

@ -30,7 +30,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Extension
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'extnId' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class ExtensionAttribute
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'extension-attribute-type' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class ExtensionAttributes
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SET,
'min' => 1,
'max' => 256, // ub-extension-attributes

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class Extensions
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
// technically, it's MAX, but we'll assume anything < 0 is MAX

View File

@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
*/
abstract class FieldElement
{
const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
public const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
}

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class FieldID
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'fieldType' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class GeneralName
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_CHOICE,
'children' => [
'otherName' => [

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class GeneralNames
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,

View File

@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
*/
abstract class GeneralSubtree
{
const MAP = [
public const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'base' => GeneralName::MAP,

Some files were not shown because too many files have changed in this diff Show More