mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-11 08:39:43 +01:00
Merge remote-tracking branch 'jworman/Php_7.1'
This commit is contained in:
commit
a95abeb4c4
@ -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,
|
||||
]
|
||||
);
|
||||
|
@ -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
@ -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.",
|
||||
"ext-dom": "Install the DOM extension to load XML formatted public keys."
|
||||
},
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -94,8 +94,6 @@ abstract class AsymmetricKey
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
*/
|
||||
abstract public function toString(string $type, array $options = []): string;
|
||||
|
||||
/**
|
||||
@ -129,9 +127,8 @@ abstract class AsymmetricKey
|
||||
* Load the key
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public static function load($key, $password = false): AsymmetricKey
|
||||
public static function load($key, ?string $password = null): AsymmetricKey
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
@ -210,10 +207,9 @@ abstract class AsymmetricKey
|
||||
/**
|
||||
* Load the key, assuming a specific format
|
||||
*
|
||||
* @param string $password optional
|
||||
* @return static
|
||||
*/
|
||||
public static function loadFormat(string $type, string $key, $password = false): AsymmetricKey
|
||||
public static function loadFormat(string $type, string $key, ?string $password = null): AsymmetricKey
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
@ -239,10 +235,8 @@ abstract class AsymmetricKey
|
||||
|
||||
/**
|
||||
* Loads a private key
|
||||
*
|
||||
* @param string $password optional
|
||||
*/
|
||||
public static function loadPrivateKeyFormat(string $type, string $key, $password = false): PrivateKey
|
||||
public static function loadPrivateKeyFormat(string $type, string $key, ?string $password = null): PrivateKey
|
||||
{
|
||||
$key = self::loadFormat($type, $key, $password);
|
||||
if (!$key instanceof PrivateKey) {
|
||||
|
@ -57,9 +57,8 @@ abstract class OpenSSH
|
||||
* $type can be either ssh-dss or ssh-rsa
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -90,7 +89,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
|
||||
|
@ -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;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
@ -106,10 +106,9 @@ abstract class PKCS1 extends PKCS
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
* @return array|string
|
||||
*/
|
||||
protected static function load($key, $password = '')
|
||||
protected static function load($key, ?string $password = null)
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
|
@ -295,16 +295,15 @@ abstract class PKCS8 extends PKCS
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
protected static function load($key, $password = ''): array
|
||||
protected static function load($key, ?string $password = null): array
|
||||
{
|
||||
$decoded = self::preParse($key);
|
||||
|
||||
$meta = [];
|
||||
|
||||
$decrypted = ASN1::asn1map($decoded[0], Maps\EncryptedPrivateKeyInfo::MAP);
|
||||
if ($password !== false && strlen($password) && is_array($decrypted)) {
|
||||
if ($password !== null && strlen($password) && is_array($decrypted)) {
|
||||
$algorithm = $decrypted['encryptionAlgorithm']['algorithm'];
|
||||
switch ($algorithm) {
|
||||
// PBES1
|
||||
|
@ -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:
|
||||
|
@ -26,7 +26,7 @@ interface PrivateKey
|
||||
public function toString(string $type, array $options = []): string;
|
||||
|
||||
/**
|
||||
* @param string|false $password
|
||||
* @return static
|
||||
*/
|
||||
public function withPassword($password = false);
|
||||
public function withPassword(?string $password = null): PrivateKey;
|
||||
}
|
||||
|
@ -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.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,11 +23,9 @@ namespace phpseclib3\Crypt\Common\Traits;
|
||||
trait PasswordProtected
|
||||
{
|
||||
/**
|
||||
* Password
|
||||
*
|
||||
* @var string|bool
|
||||
* @var string|null
|
||||
*/
|
||||
private $password = false;
|
||||
private $password = null;
|
||||
|
||||
/**
|
||||
* Sets the password
|
||||
@ -37,9 +35,10 @@ trait PasswordProtected
|
||||
*
|
||||
* @see self::createKey()
|
||||
* @see self::load()
|
||||
* @param string|bool $password
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withPassword($password = false)
|
||||
public function withPassword(?string $password = null): self
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->password = $password;
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -46,7 +46,7 @@ abstract class DH extends AsymmetricKey
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ALGORITHM = 'DH';
|
||||
public const ALGORITHM = 'DH';
|
||||
|
||||
/**
|
||||
* DH prime
|
||||
@ -307,9 +307,8 @@ abstract class DH extends AsymmetricKey
|
||||
* Load the key
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public static function load($key, $password = false): AsymmetricKey
|
||||
public static function load($key, ?string $password = null): AsymmetricKey
|
||||
{
|
||||
try {
|
||||
return EC::load($key, $password);
|
||||
@ -322,7 +321,7 @@ abstract class DH extends AsymmetricKey
|
||||
/**
|
||||
* OnLoad Handler
|
||||
*
|
||||
* @return bool
|
||||
* @return Parameters|PrivateKey|PublicKey
|
||||
*/
|
||||
protected static function onLoad(array $components)
|
||||
{
|
||||
|
@ -39,9 +39,8 @@ abstract class PKCS1 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
|
@ -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
|
||||
@ -59,9 +59,8 @@ abstract class PKCS8 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -103,11 +102,8 @@ abstract class PKCS8 extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $prime, BigInteger $base, BigInteger $privateKey, BigInteger $publicKey, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $prime, BigInteger $base, BigInteger $privateKey, BigInteger $publicKey, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$params = [
|
||||
'prime' => $prime,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -39,9 +39,8 @@ abstract class OpenSSH extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
$parsed = parent::load($key, $password);
|
||||
|
||||
@ -94,11 +93,8 @@ abstract class OpenSSH extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$publicKey = self::savePublicKey($p, $q, $g, $y, ['binary' => true]);
|
||||
$privateKey = Strings::packSSH2('si5', 'ssh-dss', $p, $q, $g, $y, $x);
|
||||
|
@ -46,9 +46,8 @@ abstract class PKCS1 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
|
@ -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
|
||||
@ -63,9 +63,8 @@ abstract class PKCS8 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -113,11 +112,8 @@ abstract class PKCS8 extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$params = [
|
||||
'p' => $p,
|
||||
|
@ -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
|
||||
@ -69,11 +69,8 @@ abstract class PuTTY extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = false, array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, ?string $password = null, array $options = []): string
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
|
@ -30,9 +30,8 @@ abstract class Raw
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!is_array($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key));
|
||||
|
@ -35,10 +35,8 @@ abstract class XML
|
||||
{
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load(string $key, $password = ''): array
|
||||
public static function load(string $key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -39,14 +39,12 @@ 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
|
||||
*
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load(string $key, $password = ''): array
|
||||
public static function load(string $key, ?string $password = null): array
|
||||
{
|
||||
switch (strlen($key)) {
|
||||
case 32:
|
||||
@ -82,9 +80,8 @@ abstract class MontgomeryPrivate
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param Integer[] $publicKey
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $privateKey, MontgomeryCurve $curve, array $publicKey, $password = ''): string
|
||||
public static function savePrivateKey(BigInteger $privateKey, MontgomeryCurve $curve, array $publicKey, ?string $password = null): string
|
||||
{
|
||||
if (!empty($password) && is_string($password)) {
|
||||
throw new UnsupportedFormatException('MontgomeryPrivate private keys do not support encryption');
|
||||
|
@ -30,14 +30,12 @@ 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
|
||||
*
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load(string $key, $password = ''): array
|
||||
public static function load(string $key, ?string $password = null): array
|
||||
{
|
||||
switch (strlen($key)) {
|
||||
case 32:
|
||||
|
@ -49,9 +49,8 @@ abstract class OpenSSH extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
$parsed = parent::load($key, $password);
|
||||
|
||||
|
@ -52,9 +52,8 @@ abstract class PKCS1 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
@ -164,10 +163,8 @@ abstract class PKCS1 extends Progenitor
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param Integer[] $publicKey
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, ?string $password = null, array $options = []): string
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -52,22 +52,21 @@ 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
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
// initialize_static_variables() is defined in both the trait and the parent class
|
||||
// when it's defined in two places it's the traits one that's called
|
||||
@ -201,10 +200,8 @@ abstract class PKCS8 extends Progenitor
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param Integer[] $publicKey
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, ?string $password = null, array $options = []): string
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -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
|
||||
@ -86,10 +86,8 @@ abstract class PuTTY extends Progenitor
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
|
||||
* @param string $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, ?string $password = null, array $options = []): string
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -57,9 +57,8 @@ abstract class XML
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -35,14 +35,12 @@ 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
|
||||
*
|
||||
* @param string|false $password optional
|
||||
*/
|
||||
public static function load(string $key, $password = ''): array
|
||||
public static function load(string $key, ?string $password = null): array
|
||||
{
|
||||
switch (strlen($key)) {
|
||||
case 32:
|
||||
@ -89,9 +87,8 @@ abstract class libsodium
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $privateKey, Ed25519 $curve, array $publicKey, $password = ''): string
|
||||
public static function savePrivateKey(BigInteger $privateKey, Ed25519 $curve, array $publicKey, ?string $password = null): string
|
||||
{
|
||||
if (!isset($privateKey->secret)) {
|
||||
throw new \RuntimeException('Private Key does not have a secret set');
|
||||
|
@ -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
|
||||
|
@ -32,9 +32,8 @@ abstract class PublicKeyLoader
|
||||
* Loads a public or private key
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public static function load($key, $password = false): AsymmetricKey
|
||||
public static function load($key, ?string $password = null): AsymmetricKey
|
||||
{
|
||||
try {
|
||||
return EC::load($key, $password);
|
||||
@ -68,9 +67,8 @@ abstract class PublicKeyLoader
|
||||
* Loads a private key
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public static function loadPrivateKey($key, $password = false): PrivateKey
|
||||
public static function loadPrivateKey($key, ?string $password = null): PrivateKey
|
||||
{
|
||||
$key = self::load($key, $password);
|
||||
if (!$key instanceof PrivateKey) {
|
||||
|
@ -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
|
||||
*
|
||||
@ -79,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.
|
||||
*
|
||||
@ -335,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;
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
@ -414,7 +414,7 @@ abstract class RSA extends AsymmetricKey
|
||||
/**
|
||||
* OnLoad Handler
|
||||
*
|
||||
* @return bool
|
||||
* @return PrivateKey|PublicKey|RSA
|
||||
*/
|
||||
protected static function onLoad(array $components)
|
||||
{
|
||||
|
@ -34,39 +34,38 @@ 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
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -168,10 +167,8 @@ abstract class MSBLOB
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = ''): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null): string
|
||||
{
|
||||
if (count($primes) != 2) {
|
||||
throw new \InvalidArgumentException('MSBLOB does not support multi-prime RSA keys');
|
||||
|
@ -39,9 +39,8 @@ abstract class OpenSSH extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
static $one;
|
||||
if (!isset($one)) {
|
||||
@ -109,11 +108,8 @@ abstract class OpenSSH extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$publicKey = self::savePublicKey($n, $e, ['binary' => true]);
|
||||
$privateKey = Strings::packSSH2('si6', 'ssh-rsa', $n, $e, $d, $coefficients[2], $primes[1], $primes[2]);
|
||||
|
@ -43,7 +43,7 @@ abstract class PKCS1 extends Progenitor
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -106,7 +106,7 @@ abstract class PKCS1 extends Progenitor
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$num_primes = count($primes);
|
||||
$key = [
|
||||
|
@ -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
|
||||
@ -64,9 +64,8 @@ abstract class PKCS8 extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
@ -105,11 +104,8 @@ abstract class PKCS8 extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
$key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
|
||||
$key = ASN1::extractBER($key);
|
||||
|
@ -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
|
||||
@ -94,9 +94,8 @@ abstract class PSS extends Progenitor
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
@ -154,11 +153,8 @@ abstract class PSS extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -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
|
||||
@ -86,11 +86,8 @@ abstract class PuTTY extends Progenitor
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
if (count($primes) != 2) {
|
||||
throw new \InvalidArgumentException('PuTTY does not support multi-prime RSA keys');
|
||||
|
@ -39,9 +39,8 @@ abstract class Raw
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|false $password
|
||||
*/
|
||||
public static function load($key, $password = ''): array
|
||||
public static function load($key, ?string $password = null): array
|
||||
{
|
||||
if (!is_array($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key));
|
||||
@ -139,11 +138,8 @@ abstract class Raw
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @param string|false $password optional
|
||||
* @param array $options optional
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
|
||||
{
|
||||
if (!empty($password) && is_string($password)) {
|
||||
throw new UnsupportedFormatException('Raw private keys do not support encryption');
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
@ -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],
|
||||
|
@ -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
|
||||
|
@ -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],
|
||||
|
@ -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],
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class Attribute
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'type' => AttributeType::MAP,
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class AttributeTypeAndValue
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'type' => AttributeType::MAP,
|
||||
|
@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class AttributeValue
|
||||
{
|
||||
const MAP = ['type' => ASN1::TYPE_ANY];
|
||||
public const MAP = ['type' => ASN1::TYPE_ANY];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class Attributes
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SET,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class AuthorityInfoAccessSyntax
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class AuthorityKeyIdentifier
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'keyIdentifier' => [
|
||||
|
@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class BaseDistance
|
||||
{
|
||||
const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
public const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class BasicConstraints
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'cA' => [
|
||||
|
@ -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],
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CRLDistributionPoints
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
|
@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CRLNumber
|
||||
{
|
||||
const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
public const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CRLReason
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_ENUMERATED,
|
||||
'mapping' => [
|
||||
'unspecified',
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class Certificate
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'tbsCertificate' => TBSCertificate::MAP,
|
||||
|
@ -22,5 +22,5 @@ namespace phpseclib3\File\ASN1\Maps;
|
||||
*/
|
||||
abstract class CertificateIssuer
|
||||
{
|
||||
const MAP = GeneralNames::MAP;
|
||||
public const MAP = GeneralNames::MAP;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CertificateList
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'tbsCertList' => TBSCertList::MAP,
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CertificatePolicies
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
|
@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CertificateSerialNumber
|
||||
{
|
||||
const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
public const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CertificationRequest
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'certificationRequestInfo' => CertificationRequestInfo::MAP,
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class CertificationRequestInfo
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'version' => [
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class Curve
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'a' => FieldElement::MAP,
|
||||
|
@ -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],
|
||||
|
@ -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],
|
||||
|
@ -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],
|
||||
|
@ -24,5 +24,5 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class DSAPublicKey
|
||||
{
|
||||
const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
public const MAP = ['type' => ASN1::TYPE_INTEGER];
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class DigestInfo
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'digestAlgorithm' => AlgorithmIdentifier::MAP,
|
||||
|
@ -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],
|
||||
|
@ -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],
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class DistributionPoint
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => [
|
||||
'distributionPoint' => [
|
||||
|
@ -24,7 +24,7 @@ use phpseclib3\File\ASN1;
|
||||
*/
|
||||
abstract class DistributionPointName
|
||||
{
|
||||
const MAP = [
|
||||
public const MAP = [
|
||||
'type' => ASN1::TYPE_CHOICE,
|
||||
'children' => [
|
||||
'fullName' => [
|
||||
|
@ -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],
|
||||
|
@ -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],
|
||||
|
@ -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];
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user