phpseclib 1.0.1
This commit is contained in:
parent
27d1ea33c9
commit
3715bb4377
|
@ -11,13 +11,13 @@
|
||||||
* just a wrapper to Rijndael.php you may consider using Rijndael.php instead of
|
* just a wrapper to Rijndael.php you may consider using Rijndael.php instead of
|
||||||
* to save one include_once().
|
* to save one include_once().
|
||||||
*
|
*
|
||||||
* If {@link Crypt_AES::setKeyLength() setKeyLength()} isn't called, it'll be calculated from
|
* If {@link self::setKeyLength() setKeyLength()} isn't called, it'll be calculated from
|
||||||
* {@link Crypt_AES::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's 136-bits
|
* {@link self::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's 136-bits
|
||||||
* it'll be null-padded to 192-bits and 192 bits will be the key length until {@link Crypt_AES::setKey() setKey()}
|
* 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.
|
* is called, again, at which point, it'll be recalculated.
|
||||||
*
|
*
|
||||||
* Since Crypt_AES extends Crypt_Rijndael, some functions are available to be called that, in the context of AES, don't
|
* Since Crypt_AES extends Crypt_Rijndael, some functions are available to be called that, in the context of AES, don't
|
||||||
* make a whole lot of sense. {@link Crypt_AES::setBlockLength() setBlockLength()}, for instance. Calling that function,
|
* make a whole lot of sense. {@link self::setBlockLength() setBlockLength()}, for instance. Calling that function,
|
||||||
* however possible, won't do anything (AES has a fixed block length whereas Rijndael has a variable one).
|
* however possible, won't do anything (AES has a fixed block length whereas Rijndael has a variable one).
|
||||||
*
|
*
|
||||||
* Here's a short example of how to use this library:
|
* Here's a short example of how to use this library:
|
||||||
|
@ -74,8 +74,8 @@ if (!class_exists('Crypt_Rijndael')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_AES::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_AES::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -124,7 +124,7 @@ class Crypt_AES extends Crypt_Rijndael
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'AES';
|
var $const_namespace = 'AES';
|
||||||
|
@ -136,7 +136,7 @@ class Crypt_AES extends Crypt_Rijndael
|
||||||
*
|
*
|
||||||
* @see Crypt_Rijndael::setBlockLength()
|
* @see Crypt_Rijndael::setBlockLength()
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
*/
|
*/
|
||||||
function setBlockLength($length)
|
function setBlockLength($length)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ class Crypt_AES extends Crypt_Rijndael
|
||||||
*
|
*
|
||||||
* @see Crypt_Rijndael:setKeyLength()
|
* @see Crypt_Rijndael:setKeyLength()
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
*/
|
*/
|
||||||
function setKeyLength($length)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ class Crypt_AES extends Crypt_Rijndael
|
||||||
* @see Crypt_Rijndael:setKey()
|
* @see Crypt_Rijndael:setKey()
|
||||||
* @see setKeyLength()
|
* @see setKeyLength()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKey($key)
|
||||||
{
|
{
|
||||||
|
@ -183,13 +183,13 @@ class Crypt_AES extends Crypt_Rijndael
|
||||||
$length = strlen($key);
|
$length = strlen($key);
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $length <= 16:
|
case $length <= 16:
|
||||||
$this->key_size = 16;
|
$this->key_length = 16;
|
||||||
break;
|
break;
|
||||||
case $length <= 24:
|
case $length <= 24:
|
||||||
$this->key_size = 24;
|
$this->key_length = 24;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->key_size = 32;
|
$this->key_length = 32;
|
||||||
}
|
}
|
||||||
$this->_setEngine();
|
$this->_setEngine();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -97,7 +97,7 @@ define('CRYPT_MODE_STREAM', 5);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @internal These constants are for internal use only
|
* @internal These constants are for internal use only
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
@ -127,8 +127,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Encryption Mode
|
* The Encryption Mode
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $mode;
|
var $mode;
|
||||||
|
@ -136,7 +136,7 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Block Length of the block cipher
|
* The Block Length of the block cipher
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $block_size = 16;
|
var $block_size = 16;
|
||||||
|
@ -144,8 +144,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key
|
* The Key
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
var $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||||
|
@ -153,8 +153,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Initialization Vector
|
* The Initialization Vector
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setIV()
|
* @see self::setIV()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $iv;
|
var $iv;
|
||||||
|
@ -162,9 +162,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* A "sliding" Initialization Vector
|
* A "sliding" Initialization Vector
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enableContinuousBuffer()
|
* @see self::enableContinuousBuffer()
|
||||||
* @see Crypt_Base::_clearBuffers()
|
* @see self::_clearBuffers()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $encryptIV;
|
var $encryptIV;
|
||||||
|
@ -172,9 +172,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* A "sliding" Initialization Vector
|
* A "sliding" Initialization Vector
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enableContinuousBuffer()
|
* @see self::enableContinuousBuffer()
|
||||||
* @see Crypt_Base::_clearBuffers()
|
* @see self::_clearBuffers()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $decryptIV;
|
var $decryptIV;
|
||||||
|
@ -182,8 +182,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Continuous Buffer status
|
* Continuous Buffer status
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enableContinuousBuffer()
|
* @see self::enableContinuousBuffer()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $continuousBuffer = false;
|
var $continuousBuffer = false;
|
||||||
|
@ -191,9 +191,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Encryption buffer for CTR, OFB and CFB modes
|
* Encryption buffer for CTR, OFB and CFB modes
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::_clearBuffers()
|
* @see self::_clearBuffers()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $enbuffer;
|
var $enbuffer;
|
||||||
|
@ -201,9 +201,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Decryption buffer for CTR, OFB and CFB modes
|
* Decryption buffer for CTR, OFB and CFB modes
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @see Crypt_Base::_clearBuffers()
|
* @see self::_clearBuffers()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $debuffer;
|
var $debuffer;
|
||||||
|
@ -214,8 +214,8 @@ class Crypt_Base
|
||||||
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
|
* 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.
|
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $enmcrypt;
|
var $enmcrypt;
|
||||||
|
@ -226,8 +226,8 @@ class Crypt_Base
|
||||||
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
|
* 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.
|
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $demcrypt;
|
var $demcrypt;
|
||||||
|
@ -237,7 +237,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Twofish::setKey()
|
* @see Crypt_Twofish::setKey()
|
||||||
* @see Crypt_Twofish::setIV()
|
* @see Crypt_Twofish::setIV()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $enchanged = true;
|
var $enchanged = true;
|
||||||
|
@ -247,7 +247,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Twofish::setKey()
|
* @see Crypt_Twofish::setKey()
|
||||||
* @see Crypt_Twofish::setIV()
|
* @see Crypt_Twofish::setIV()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $dechanged = true;
|
var $dechanged = true;
|
||||||
|
@ -263,10 +263,10 @@ class Crypt_Base
|
||||||
* use a separate ECB-mode mcrypt resource.
|
* use a separate ECB-mode mcrypt resource.
|
||||||
*
|
*
|
||||||
* @link http://phpseclib.sourceforge.net/cfb-demo.phps
|
* @link http://phpseclib.sourceforge.net/cfb-demo.phps
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @see Crypt_Base::_setupMcrypt()
|
* @see self::_setupMcrypt()
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $ecb;
|
var $ecb;
|
||||||
|
@ -287,8 +287,8 @@ class Crypt_Base
|
||||||
* which, typically, depends on the complexity
|
* which, typically, depends on the complexity
|
||||||
* on its internaly Key-expanding algorithm.
|
* on its internaly Key-expanding algorithm.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 600;
|
var $cfb_init_len = 600;
|
||||||
|
@ -296,10 +296,10 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Does internal cipher state need to be (re)initialized?
|
* Does internal cipher state need to be (re)initialized?
|
||||||
*
|
*
|
||||||
* @see setKey()
|
* @see self::setKey()
|
||||||
* @see setIV()
|
* @see self::setIV()
|
||||||
* @see disableContinuousBuffer()
|
* @see self::disableContinuousBuffer()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $changed = true;
|
var $changed = true;
|
||||||
|
@ -307,8 +307,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Padding status
|
* Padding status
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enablePadding()
|
* @see self::enablePadding()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $padding = true;
|
var $padding = true;
|
||||||
|
@ -316,8 +316,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Is the mode one that is paddable?
|
* Is the mode one that is paddable?
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $paddable = false;
|
var $paddable = false;
|
||||||
|
@ -331,10 +331,10 @@ class Crypt_Base
|
||||||
* - CRYPT_ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
|
* - CRYPT_ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
|
||||||
* - CRYPT_ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
|
* - CRYPT_ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setEngine()
|
* @see self::_setEngine()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $engine;
|
var $engine;
|
||||||
|
@ -342,9 +342,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Holds the preferred crypt engine
|
* Holds the preferred crypt engine
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setEngine()
|
* @see self::_setEngine()
|
||||||
* @see Crypt_Base::setPreferredEngine()
|
* @see self::setPreferredEngine()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $preferredEngine;
|
var $preferredEngine;
|
||||||
|
@ -356,8 +356,8 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* @link http://www.php.net/mcrypt_module_open
|
* @link http://www.php.net/mcrypt_module_open
|
||||||
* @link http://www.php.net/mcrypt_list_algorithms
|
* @link http://www.php.net/mcrypt_list_algorithms
|
||||||
* @see Crypt_Base::_setupMcrypt()
|
* @see self::_setupMcrypt()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt;
|
var $cipher_name_mcrypt;
|
||||||
|
@ -368,7 +368,7 @@ class Crypt_Base
|
||||||
* Only used if $engine == CRYPT_ENGINE_OPENSSL
|
* Only used if $engine == CRYPT_ENGINE_OPENSSL
|
||||||
*
|
*
|
||||||
* @link http://www.php.net/openssl-get-cipher-methods
|
* @link http://www.php.net/openssl-get-cipher-methods
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_openssl;
|
var $cipher_name_openssl;
|
||||||
|
@ -380,25 +380,16 @@ class Crypt_Base
|
||||||
* it can still be emulated with ECB mode.
|
* it can still be emulated with ECB mode.
|
||||||
*
|
*
|
||||||
* @link http://www.php.net/openssl-get-cipher-methods
|
* @link http://www.php.net/openssl-get-cipher-methods
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_openssl_ecb;
|
var $cipher_name_openssl_ecb;
|
||||||
|
|
||||||
/**
|
|
||||||
* The default password key_size used by setPassword()
|
|
||||||
*
|
|
||||||
* @see Crypt_Base::setPassword()
|
|
||||||
* @var Integer
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $password_key_size = 32;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default salt used by setPassword()
|
* The default salt used by setPassword()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setPassword()
|
* @see self::setPassword()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_default_salt = 'phpseclib/salt';
|
var $password_default_salt = 'phpseclib/salt';
|
||||||
|
@ -420,8 +411,8 @@ class Crypt_Base
|
||||||
* $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode
|
* $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode
|
||||||
* $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical
|
* $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace;
|
var $const_namespace;
|
||||||
|
@ -432,10 +423,10 @@ class Crypt_Base
|
||||||
* Used by encrypt() / decrypt()
|
* Used by encrypt() / decrypt()
|
||||||
* only if $engine == CRYPT_ENGINE_INTERNAL
|
* only if $engine == CRYPT_ENGINE_INTERNAL
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @see Crypt_Base::_setupInlineCrypt()
|
* @see self::_setupInlineCrypt()
|
||||||
* @see Crypt_Base::$use_inline_crypt
|
* @see self::$use_inline_crypt
|
||||||
* @var Callback
|
* @var Callback
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -444,9 +435,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Holds whether performance-optimized $inline_crypt() can/should be used.
|
* Holds whether performance-optimized $inline_crypt() can/should be used.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @see Crypt_Base::inline_crypt
|
* @see self::inline_crypt
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -455,8 +446,8 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* If OpenSSL can be used in ECB but not in CTR we can emulate CTR
|
* If OpenSSL can be used in ECB but not in CTR we can emulate CTR
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_openssl_ctr_process()
|
* @see self::_openssl_ctr_process()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $openssl_emulate_ctr = false;
|
var $openssl_emulate_ctr = false;
|
||||||
|
@ -464,12 +455,30 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Determines what options are passed to openssl_encrypt/decrypt
|
* Determines what options are passed to openssl_encrypt/decrypt
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::isValidEngine()
|
* @see self::isValidEngine()
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $openssl_options;
|
var $openssl_options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has the key length explicitly been set or should it be derived from the key, itself?
|
||||||
|
*
|
||||||
|
* @see self::setKeyLength()
|
||||||
|
* @var bool
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $explicit_key_length = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't truncate / null pad key
|
||||||
|
*
|
||||||
|
* @see self::_clearBuffers()
|
||||||
|
* @var bool
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $skip_key_adjustment = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
|
@ -491,7 +500,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* If not explicitly set, CRYPT_MODE_CBC will be used.
|
* If not explicitly set, CRYPT_MODE_CBC will be used.
|
||||||
*
|
*
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Crypt_Base($mode = CRYPT_MODE_CBC)
|
function Crypt_Base($mode = CRYPT_MODE_CBC)
|
||||||
|
@ -529,7 +538,7 @@ class Crypt_Base
|
||||||
* to be all zero's.
|
* to be all zero's.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $iv
|
* @param string $iv
|
||||||
* @internal Can be overwritten by a sub class, but does not have to be
|
* @internal Can be overwritten by a sub class, but does not have to be
|
||||||
*/
|
*/
|
||||||
function setIV($iv)
|
function setIV($iv)
|
||||||
|
@ -542,6 +551,43 @@ class Crypt_Base
|
||||||
$this->changed = true;
|
$this->changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the key length.
|
||||||
|
*
|
||||||
|
* Keys with explicitly set lengths need to be treated accordingly
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param int $length
|
||||||
|
*/
|
||||||
|
function setKeyLength($length)
|
||||||
|
{
|
||||||
|
$this->explicit_key_length = true;
|
||||||
|
$this->changed = true;
|
||||||
|
$this->_setEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current key length in bits
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getKeyLength()
|
||||||
|
{
|
||||||
|
return $this->key_length << 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current block length in bits
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getBlockLength()
|
||||||
|
{
|
||||||
|
return $this->block_size << 3;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* Sets the key.
|
||||||
*
|
*
|
||||||
|
@ -553,11 +599,16 @@ class Crypt_Base
|
||||||
* If the key is not explicitly set, it'll be assumed to be all null bytes.
|
* If the key is not explicitly set, it'll be assumed to be all null bytes.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKey($key)
|
||||||
{
|
{
|
||||||
|
if (!$this->explicit_key_length) {
|
||||||
|
$this->setKeyLength(strlen($key) << 3);
|
||||||
|
$this->explicit_key_length = false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
$this->changed = true;
|
$this->changed = true;
|
||||||
$this->_setEngine();
|
$this->_setEngine();
|
||||||
|
@ -573,9 +624,9 @@ class Crypt_Base
|
||||||
* Where $hash (default = sha1) currently supports the following hashes: see: Crypt/Hash.php
|
* Where $hash (default = sha1) currently supports the following hashes: see: Crypt/Hash.php
|
||||||
*
|
*
|
||||||
* @see Crypt/Hash.php
|
* @see Crypt/Hash.php
|
||||||
* @param String $password
|
* @param string $password
|
||||||
* @param optional String $method
|
* @param string $method
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
|
@ -601,7 +652,7 @@ class Crypt_Base
|
||||||
if (isset($func_args[5])) {
|
if (isset($func_args[5])) {
|
||||||
$dkLen = $func_args[5];
|
$dkLen = $func_args[5];
|
||||||
} else {
|
} else {
|
||||||
$dkLen = $method == 'pbkdf1' ? 2 * $this->password_key_size : $this->password_key_size;
|
$dkLen = $method == 'pbkdf1' ? 2 * $this->key_length : $this->key_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
@ -670,10 +721,10 @@ class Crypt_Base
|
||||||
* strlen($plaintext) will still need to be a multiple of the block size, however, arbitrary values can be added to make it that
|
* strlen($plaintext) will still need to be a multiple of the block size, however, arbitrary values can be added to make it that
|
||||||
* length.
|
* length.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String $ciphertext
|
* @return string $ciphertext
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
function encrypt($plaintext)
|
function encrypt($plaintext)
|
||||||
|
@ -968,10 +1019,10 @@ class Crypt_Base
|
||||||
* If strlen($ciphertext) is not a multiple of the block size, null bytes will be added to the end of the string until
|
* If strlen($ciphertext) is not a multiple of the block size, null bytes will be added to the end of the string until
|
||||||
* it is.
|
* it is.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $ciphertext
|
* @param string $ciphertext
|
||||||
* @return String $plaintext
|
* @return string $plaintext
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
function decrypt($ciphertext)
|
function decrypt($ciphertext)
|
||||||
|
@ -993,7 +1044,7 @@ class Crypt_Base
|
||||||
break;
|
break;
|
||||||
case CRYPT_MODE_ECB:
|
case CRYPT_MODE_ECB:
|
||||||
if (!defined('OPENSSL_RAW_DATA')) {
|
if (!defined('OPENSSL_RAW_DATA')) {
|
||||||
$ciphetext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true);
|
$ciphertext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true);
|
||||||
}
|
}
|
||||||
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
|
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
|
||||||
break;
|
break;
|
||||||
|
@ -1259,12 +1310,12 @@ class Crypt_Base
|
||||||
* and Crypt_Base::decrypt(). Also, OpenSSL doesn't implement CTR for all of it's symmetric ciphers so this
|
* and Crypt_Base::decrypt(). Also, OpenSSL doesn't implement CTR for all of it's symmetric ciphers so this
|
||||||
* function will emulate CTR with ECB when necesary.
|
* function will emulate CTR with ECB when necesary.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @param String $encryptIV
|
* @param string $encryptIV
|
||||||
* @param Array $buffer
|
* @param array $buffer
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _openssl_ctr_process($plaintext, &$encryptIV, &$buffer)
|
function _openssl_ctr_process($plaintext, &$encryptIV, &$buffer)
|
||||||
|
@ -1353,12 +1404,12 @@ class Crypt_Base
|
||||||
* for OFB is the same for both encrypting and decrypting this function is re-used by both Crypt_Base::encrypt()
|
* for OFB is the same for both encrypting and decrypting this function is re-used by both Crypt_Base::encrypt()
|
||||||
* and Crypt_Base::decrypt().
|
* and Crypt_Base::decrypt().
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @param String $encryptIV
|
* @param string $encryptIV
|
||||||
* @param Array $buffer
|
* @param array $buffer
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _openssl_ofb_process($plaintext, &$encryptIV, &$buffer)
|
function _openssl_ofb_process($plaintext, &$encryptIV, &$buffer)
|
||||||
|
@ -1404,7 +1455,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* May need to be overwritten by classes extending this one in some cases
|
* May need to be overwritten by classes extending this one in some cases
|
||||||
*
|
*
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _openssl_translate_mode()
|
function _openssl_translate_mode()
|
||||||
|
@ -1435,7 +1486,7 @@ class Crypt_Base
|
||||||
* away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is
|
* away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is
|
||||||
* transmitted separately)
|
* transmitted separately)
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::disablePadding()
|
* @see self::disablePadding()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function enablePadding()
|
function enablePadding()
|
||||||
|
@ -1446,7 +1497,7 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Do not pad packets.
|
* Do not pad packets.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enablePadding()
|
* @see self::enablePadding()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function disablePadding()
|
function disablePadding()
|
||||||
|
@ -1488,7 +1539,7 @@ class Crypt_Base
|
||||||
* continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them),
|
* continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them),
|
||||||
* however, they are also less intuitive and more likely to cause you problems.
|
* however, they are also less intuitive and more likely to cause you problems.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::disableContinuousBuffer()
|
* @see self::disableContinuousBuffer()
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
|
@ -1508,7 +1559,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* The default behavior.
|
* The default behavior.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enableContinuousBuffer()
|
* @see self::enableContinuousBuffer()
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
|
@ -1530,10 +1581,10 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Test for engine validity
|
* Test for engine validity
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
|
@ -1597,8 +1648,8 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* If the preferred crypt engine is not available the fastest available one will be used
|
* If the preferred crypt engine is not available the fastest available one will be used
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setPreferredEngine($engine)
|
function setPreferredEngine($engine)
|
||||||
|
@ -1619,7 +1670,7 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Returns the engine currently being utilized
|
* Returns the engine currently being utilized
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setEngine()
|
* @see self::_setEngine()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getEngine()
|
function getEngine()
|
||||||
|
@ -1630,7 +1681,7 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Sets the engine as appropriate
|
* Sets the engine as appropriate
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see self::Crypt_Base()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _setEngine()
|
function _setEngine()
|
||||||
|
@ -1673,8 +1724,8 @@ class Crypt_Base
|
||||||
* Encrypts a block
|
* Encrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
* @internal Must be extended by the child Crypt_* class
|
* @internal Must be extended by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
|
@ -1686,8 +1737,8 @@ class Crypt_Base
|
||||||
* Decrypts a block
|
* Decrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
* @internal Must be extended by the child Crypt_* class
|
* @internal Must be extended by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
|
@ -1700,7 +1751,7 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* Only used if $engine == CRYPT_ENGINE_INTERNAL
|
* Only used if $engine == CRYPT_ENGINE_INTERNAL
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setup()
|
* @see self::_setup()
|
||||||
* @access private
|
* @access private
|
||||||
* @internal Must be extended by the child Crypt_* class
|
* @internal Must be extended by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
|
@ -1726,9 +1777,9 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* - First run of encrypt() / decrypt() with no init-settings
|
* - First run of encrypt() / decrypt() with no init-settings
|
||||||
*
|
*
|
||||||
* @see setKey()
|
* @see self::setKey()
|
||||||
* @see setIV()
|
* @see self::setIV()
|
||||||
* @see disableContinuousBuffer()
|
* @see self::disableContinuousBuffer()
|
||||||
* @access private
|
* @access private
|
||||||
* @internal _setup() is always called before en/decryption.
|
* @internal _setup() is always called before en/decryption.
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
|
@ -1760,9 +1811,9 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* - First run of encrypt() / decrypt()
|
* - First run of encrypt() / decrypt()
|
||||||
*
|
*
|
||||||
* @see setKey()
|
* @see self::setKey()
|
||||||
* @see setIV()
|
* @see self::setIV()
|
||||||
* @see disableContinuousBuffer()
|
* @see self::disableContinuousBuffer()
|
||||||
* @access private
|
* @access private
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
|
@ -1790,7 +1841,6 @@ class Crypt_Base
|
||||||
if ($this->mode == CRYPT_MODE_CFB) {
|
if ($this->mode == CRYPT_MODE_CFB) {
|
||||||
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
|
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
} // else should mcrypt_generic_deinit be called?
|
} // else should mcrypt_generic_deinit be called?
|
||||||
|
|
||||||
if ($this->mode == CRYPT_MODE_CFB) {
|
if ($this->mode == CRYPT_MODE_CFB) {
|
||||||
|
@ -1808,10 +1858,10 @@ class Crypt_Base
|
||||||
* If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
|
* If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
|
||||||
* and padding will, hence forth, be enabled.
|
* and padding will, hence forth, be enabled.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_unpad()
|
* @see self::_unpad()
|
||||||
* @param String $text
|
* @param string $text
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _pad($text)
|
function _pad($text)
|
||||||
{
|
{
|
||||||
|
@ -1837,10 +1887,10 @@ class Crypt_Base
|
||||||
* If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong
|
* If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong
|
||||||
* and false will be returned.
|
* and false will be returned.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_pad()
|
* @see self::_pad()
|
||||||
* @param String $text
|
* @param string $text
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _unpad($text)
|
function _unpad($text)
|
||||||
{
|
{
|
||||||
|
@ -1874,6 +1924,10 @@ class Crypt_Base
|
||||||
// mcrypt's handling of invalid's $iv:
|
// mcrypt's handling of invalid's $iv:
|
||||||
// $this->encryptIV = $this->decryptIV = strlen($this->iv) == $this->block_size ? $this->iv : str_repeat("\0", $this->block_size);
|
// $this->encryptIV = $this->decryptIV = strlen($this->iv) == $this->block_size ? $this->iv : str_repeat("\0", $this->block_size);
|
||||||
$this->encryptIV = $this->decryptIV = str_pad(substr($this->iv, 0, $this->block_size), $this->block_size, "\0");
|
$this->encryptIV = $this->decryptIV = str_pad(substr($this->iv, 0, $this->block_size), $this->block_size, "\0");
|
||||||
|
|
||||||
|
if (!$this->skip_key_adjustment) {
|
||||||
|
$this->key = str_pad(substr($this->key, 0, $this->key_length), $this->key_length, "\0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1881,10 +1935,10 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* Inspired by array_shift
|
* Inspired by array_shift
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _string_shift(&$string, $index = 1)
|
function _string_shift(&$string, $index = 1)
|
||||||
{
|
{
|
||||||
|
@ -1898,10 +1952,10 @@ class Crypt_Base
|
||||||
*
|
*
|
||||||
* Inspired by array_pop
|
* Inspired by array_pop
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _string_pop(&$string, $index = 1)
|
function _string_pop(&$string, $index = 1)
|
||||||
{
|
{
|
||||||
|
@ -1913,9 +1967,9 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Increment the current string
|
* Increment the current string
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @param String $var
|
* @param string $var
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _increment_str(&$var)
|
function _increment_str(&$var)
|
||||||
|
@ -2000,10 +2054,10 @@ class Crypt_Base
|
||||||
* - The callback function should not use the 'return' statement, but en/decrypt'ing the content of $in only
|
* - The callback function should not use the 'return' statement, but en/decrypt'ing the content of $in only
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setup()
|
* @see self::_setup()
|
||||||
* @see Crypt_Base::_createInlineCryptFunction()
|
* @see self::_createInlineCryptFunction()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @internal If a Crypt_* class providing inline crypting it must extend _setupInlineCrypt()
|
* @internal If a Crypt_* class providing inline crypting it must extend _setupInlineCrypt()
|
||||||
*/
|
*/
|
||||||
|
@ -2122,12 +2176,12 @@ class Crypt_Base
|
||||||
* );
|
* );
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_setupInlineCrypt()
|
* @see self::_setupInlineCrypt()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see self::decrypt()
|
||||||
* @param Array $cipher_code
|
* @param array $cipher_code
|
||||||
* @access private
|
* @access private
|
||||||
* @return String (the name of the created callback function)
|
* @return string (the name of the created callback function)
|
||||||
*/
|
*/
|
||||||
function _createInlineCryptFunction($cipher_code)
|
function _createInlineCryptFunction($cipher_code)
|
||||||
{
|
{
|
||||||
|
@ -2494,7 +2548,7 @@ class Crypt_Base
|
||||||
* for which $mode the lambda function was created.
|
* for which $mode the lambda function was created.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return Array &$functions
|
* @return array &$functions
|
||||||
*/
|
*/
|
||||||
function &_getLambdaFunctions()
|
function &_getLambdaFunctions()
|
||||||
{
|
{
|
||||||
|
@ -2505,10 +2559,10 @@ class Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Generates a digest from $bytes
|
* Generates a digest from $bytes
|
||||||
*
|
*
|
||||||
* @see _setupInlineCrypt()
|
* @see self::_setupInlineCrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param $bytes
|
* @param $bytes
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _hashInlineCryptFunction($bytes)
|
function _hashInlineCryptFunction($bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,8 +64,8 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Blowfish::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Blowfish::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -115,26 +115,16 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* Block Length of the cipher
|
* Block Length of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::block_size
|
* @see Crypt_Base::block_size
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $block_size = 8;
|
var $block_size = 8;
|
||||||
|
|
||||||
/**
|
|
||||||
* The default password key_size used by setPassword()
|
|
||||||
*
|
|
||||||
* @see Crypt_Base::password_key_size
|
|
||||||
* @see Crypt_Base::setPassword()
|
|
||||||
* @var Integer
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $password_key_size = 56;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'BLOWFISH';
|
var $const_namespace = 'BLOWFISH';
|
||||||
|
@ -143,7 +133,7 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'blowfish';
|
var $cipher_name_mcrypt = 'blowfish';
|
||||||
|
@ -152,7 +142,7 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* Optimizing value while CFB-encrypting
|
* Optimizing value while CFB-encrypting
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cfb_init_len
|
* @see Crypt_Base::cfb_init_len
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 500;
|
var $cfb_init_len = 500;
|
||||||
|
@ -165,7 +155,7 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* @access private
|
* @access private
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $sbox0 = array (
|
var $sbox0 = array(
|
||||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||||
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||||
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||||
|
@ -348,37 +338,43 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Holds the last used key
|
* Holds the last used key
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $kl;
|
var $kl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* The Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* Keys can be of any length. Blowfish, itself, requires the use of a key between 32 and max. 448-bits long.
|
* @see Crypt_Base::setKeyLength()
|
||||||
* If the key is less than 32-bits we NOT fill the key to 32bit but let the key as it is to be compatible
|
* @var int
|
||||||
* with mcrypt because mcrypt act this way with blowfish key's < 32 bits.
|
* @access private
|
||||||
|
* @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
|
||||||
|
* because the encryption / decryption / key schedule creation requires this number and not $key_length. We could
|
||||||
|
* derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
|
||||||
|
* of that, we'll just precompute it once.
|
||||||
|
*/
|
||||||
|
var $key_length = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the key length.
|
||||||
*
|
*
|
||||||
* If the key is more than 448-bits, we trim the excess bits.
|
* Key lengths can be between 32 and 448 bits.
|
||||||
*
|
|
||||||
* If the key is not explicitly set, or empty, it'll be assumed a 128 bits key to be all null bytes.
|
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Base::setKey()
|
* @param int $length
|
||||||
* @param String $key
|
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
$keylength = strlen($key);
|
if ($length < 32) {
|
||||||
|
$this->key_length = 7;
|
||||||
if (!$keylength) {
|
} elseif ($length > 448) {
|
||||||
$key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
$this->key_length = 56;
|
||||||
} elseif ($keylength > 56) {
|
} else {
|
||||||
$key = substr($key, 0, 56);
|
$this->key_length = $length >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::setKey($key);
|
parent::setKeyLength($length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,14 +383,14 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::isValidEngine()
|
* @see Crypt_Base::isValidEngine()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
if ($engine == CRYPT_ENGINE_OPENSSL) {
|
if ($engine == CRYPT_ENGINE_OPENSSL) {
|
||||||
if (strlen($this->key) != 16) {
|
if ($this->key_length != 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->cipher_name_openssl_ecb = 'bf-ecb';
|
$this->cipher_name_openssl_ecb = 'bf-ecb';
|
||||||
|
@ -464,8 +460,8 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* Encrypts a block
|
* Encrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -500,8 +496,8 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
* Decrypts a block
|
* Decrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -544,7 +540,7 @@ class Crypt_Blowfish extends Crypt_Base
|
||||||
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
||||||
// (Currently, for Crypt_Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit)
|
// (Currently, for Crypt_Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit)
|
||||||
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
|
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
|
||||||
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
|
$gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
|
||||||
|
|
||||||
// Generation of a unique hash for our generated code
|
// Generation of a unique hash for our generated code
|
||||||
$code_hash = "Crypt_Blowfish, {$this->mode}";
|
$code_hash = "Crypt_Blowfish, {$this->mode}";
|
||||||
|
|
|
@ -69,8 +69,8 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_DES::_setupKey()
|
* @see self::_setupKey()
|
||||||
* @see Crypt_DES::_processBlock()
|
* @see self::_processBlock()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Contains $keys[CRYPT_DES_ENCRYPT]
|
* Contains $keys[CRYPT_DES_ENCRYPT]
|
||||||
|
@ -84,8 +84,8 @@ define('CRYPT_DES_DECRYPT', 1);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_DES::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_DES::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -134,36 +134,25 @@ class Crypt_DES extends Crypt_Base
|
||||||
* Block Length of the cipher
|
* Block Length of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::block_size
|
* @see Crypt_Base::block_size
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $block_size = 8;
|
var $block_size = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Key
|
* Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::key
|
* @see Crypt_Base::setKeyLength()
|
||||||
* @see setKey()
|
* @var int
|
||||||
* @var String
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key = "\0\0\0\0\0\0\0\0";
|
var $key_length = 8;
|
||||||
|
|
||||||
/**
|
|
||||||
* The default password key_size used by setPassword()
|
|
||||||
*
|
|
||||||
* @see Crypt_Base::password_key_size
|
|
||||||
* @see Crypt_Base::setPassword()
|
|
||||||
* @var Integer
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $password_key_size = 8;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'DES';
|
var $const_namespace = 'DES';
|
||||||
|
@ -172,7 +161,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'des';
|
var $cipher_name_mcrypt = 'des';
|
||||||
|
@ -181,7 +170,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
* The OpenSSL names of the cipher / modes
|
* The OpenSSL names of the cipher / modes
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::openssl_mode_names
|
* @see Crypt_Base::openssl_mode_names
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $openssl_mode_names = array(
|
var $openssl_mode_names = array(
|
||||||
|
@ -196,7 +185,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
* Optimizing value while CFB-encrypting
|
* Optimizing value while CFB-encrypting
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cfb_init_len
|
* @see Crypt_Base::cfb_init_len
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 500;
|
var $cfb_init_len = 500;
|
||||||
|
@ -206,9 +195,9 @@ class Crypt_DES extends Crypt_Base
|
||||||
*
|
*
|
||||||
* Used only if $engine == CRYPT_DES_MODE_INTERNAL
|
* Used only if $engine == CRYPT_DES_MODE_INTERNAL
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::_setupKey()
|
* @see self::_setupKey()
|
||||||
* @see Crypt_DES::_processBlock()
|
* @see self::_processBlock()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $des_rounds = 1;
|
var $des_rounds = 1;
|
||||||
|
@ -216,17 +205,17 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* max possible size of $key
|
* max possible size of $key
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key_size_max = 8;
|
var $key_length_max = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Key Schedule
|
* The Key Schedule
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::_setupKey()
|
* @see self::_setupKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $keys;
|
var $keys;
|
||||||
|
@ -238,9 +227,9 @@ class Crypt_DES extends Crypt_Base
|
||||||
* with each byte containing all bits in the same state as the
|
* with each byte containing all bits in the same state as the
|
||||||
* corresponding bit in the index value.
|
* corresponding bit in the index value.
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::_processBlock()
|
* @see self::_processBlock()
|
||||||
* @see Crypt_DES::_setupKey()
|
* @see self::_setupKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $shuffle = array(
|
var $shuffle = array(
|
||||||
|
@ -379,7 +368,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
*
|
*
|
||||||
* Indexing this table with each source byte performs the initial bit permutation.
|
* Indexing this table with each source byte performs the initial bit permutation.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $ipmap = array(
|
var $ipmap = array(
|
||||||
|
@ -421,7 +410,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
* Inverse IP mapping helper table.
|
* Inverse IP mapping helper table.
|
||||||
* Indexing this table with a byte value reverses the bit order.
|
* Indexing this table with a byte value reverses the bit order.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $invipmap = array(
|
var $invipmap = array(
|
||||||
|
@ -465,7 +454,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
* Each box ($sbox1-$sbox8) has been vectorized, then each value pre-permuted using the
|
* Each box ($sbox1-$sbox8) has been vectorized, then each value pre-permuted using the
|
||||||
* P table: concatenation can then be replaced by exclusive ORs.
|
* P table: concatenation can then be replaced by exclusive ORs.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox1 = array(
|
var $sbox1 = array(
|
||||||
|
@ -490,7 +479,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box2
|
* Pre-permuted S-box2
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox2 = array(
|
var $sbox2 = array(
|
||||||
|
@ -515,7 +504,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box3
|
* Pre-permuted S-box3
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox3 = array(
|
var $sbox3 = array(
|
||||||
|
@ -540,7 +529,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box4
|
* Pre-permuted S-box4
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox4 = array(
|
var $sbox4 = array(
|
||||||
|
@ -565,7 +554,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box5
|
* Pre-permuted S-box5
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox5 = array(
|
var $sbox5 = array(
|
||||||
|
@ -590,7 +579,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box6
|
* Pre-permuted S-box6
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox6 = array(
|
var $sbox6 = array(
|
||||||
|
@ -615,7 +604,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box7
|
* Pre-permuted S-box7
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox7 = array(
|
var $sbox7 = array(
|
||||||
|
@ -640,7 +629,7 @@ class Crypt_DES extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Pre-permuted S-box8
|
* Pre-permuted S-box8
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sbox8 = array(
|
var $sbox8 = array(
|
||||||
|
@ -668,13 +657,13 @@ class Crypt_DES extends Crypt_Base
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::isValidEngine()
|
* @see Crypt_Base::isValidEngine()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
if ($this->key_size_max == 8) {
|
if ($this->key_length_max == 8) {
|
||||||
if ($engine == CRYPT_ENGINE_OPENSSL) {
|
if ($engine == CRYPT_ENGINE_OPENSSL) {
|
||||||
$this->cipher_name_openssl_ecb = 'des-ecb';
|
$this->cipher_name_openssl_ecb = 'des-ecb';
|
||||||
$this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode();
|
$this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode();
|
||||||
|
@ -697,14 +686,14 @@ class Crypt_DES extends Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setKey()
|
* @see Crypt_Base::setKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKey($key)
|
||||||
{
|
{
|
||||||
// We check/cut here only up to max length of the key.
|
// We check/cut here only up to max length of the key.
|
||||||
// Key padding to the proper length will be done in _setupKey()
|
// Key padding to the proper length will be done in _setupKey()
|
||||||
if (strlen($key) > $this->key_size_max) {
|
if (strlen($key) > $this->key_length_max) {
|
||||||
$key = substr($key, 0, $this->key_size_max);
|
$key = substr($key, 0, $this->key_length_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the key
|
// Sets the key
|
||||||
|
@ -716,10 +705,10 @@ class Crypt_DES extends Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_encryptBlock()
|
* @see Crypt_Base::_encryptBlock()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see Crypt_Base::encrypt()
|
||||||
* @see Crypt_DES::encrypt()
|
* @see self::encrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -731,10 +720,10 @@ class Crypt_DES extends Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::_decryptBlock()
|
* @see Crypt_Base::_decryptBlock()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see Crypt_Base::decrypt()
|
||||||
* @see Crypt_DES::decrypt()
|
* @see self::decrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -748,12 +737,12 @@ class Crypt_DES extends Crypt_Base
|
||||||
* {@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general
|
* {@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general
|
||||||
* idea of what this function does.
|
* idea of what this function does.
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::_encryptBlock()
|
* @see self::_encryptBlock()
|
||||||
* @see Crypt_DES::_decryptBlock()
|
* @see self::_decryptBlock()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $block
|
* @param string $block
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _processBlock($block, $mode)
|
function _processBlock($block, $mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* md2, md5, md5-96, sha1, sha1-96, sha256, sha256-96, sha384, and sha512, sha512-96
|
* md2, md5, md5-96, sha1, sha1-96, sha256, sha256-96, sha384, and sha512, sha512-96
|
||||||
*
|
*
|
||||||
* If {@link Crypt_Hash::setKey() setKey()} is called, {@link Crypt_Hash::hash() hash()} will return the HMAC as opposed to
|
* If {@link self::setKey() setKey()} is called, {@link self::hash() hash()} will return the HMAC as opposed to
|
||||||
* the hash. If no valid algorithm is provided, sha1 will be used.
|
* the hash. If no valid algorithm is provided, sha1 will be used.
|
||||||
*
|
*
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_Hash::Crypt_Hash()
|
* @see self::Crypt_Hash()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Toggles the internal implementation
|
* Toggles the internal implementation
|
||||||
|
@ -84,8 +84,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Hash Parameter
|
* Hash Parameter
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setHash()
|
* @see self::setHash()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $hashParam;
|
var $hashParam;
|
||||||
|
@ -93,8 +93,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Byte-length of compression blocks / key (Internal HMAC)
|
* Byte-length of compression blocks / key (Internal HMAC)
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setAlgorithm()
|
* @see self::setAlgorithm()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $b;
|
var $b;
|
||||||
|
@ -102,8 +102,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Byte-length of hash output (Internal HMAC)
|
* Byte-length of hash output (Internal HMAC)
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setHash()
|
* @see self::setHash()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $l = false;
|
var $l = false;
|
||||||
|
@ -111,8 +111,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Hash Algorithm
|
* Hash Algorithm
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setHash()
|
* @see self::setHash()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $hash;
|
var $hash;
|
||||||
|
@ -120,8 +120,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Key
|
* Key
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key = false;
|
var $key = false;
|
||||||
|
@ -129,8 +129,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Outer XOR (Internal HMAC)
|
* Outer XOR (Internal HMAC)
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $opad;
|
var $opad;
|
||||||
|
@ -138,8 +138,8 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Inner XOR (Internal HMAC)
|
* Inner XOR (Internal HMAC)
|
||||||
*
|
*
|
||||||
* @see Crypt_Hash::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $ipad;
|
var $ipad;
|
||||||
|
@ -147,7 +147,7 @@ class Crypt_Hash
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param optional String $hash
|
* @param string $hash
|
||||||
* @return Crypt_Hash
|
* @return Crypt_Hash
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -175,7 +175,7 @@ class Crypt_Hash
|
||||||
* Keys can be of any length.
|
* Keys can be of any length.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param optional String $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
function setKey($key = false)
|
function setKey($key = false)
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ class Crypt_Hash
|
||||||
* As set by the constructor or by the setHash() method.
|
* As set by the constructor or by the setHash() method.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getHash()
|
function getHash()
|
||||||
{
|
{
|
||||||
|
@ -199,7 +199,7 @@ class Crypt_Hash
|
||||||
* Sets the hash function.
|
* Sets the hash function.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $hash
|
* @param string $hash
|
||||||
*/
|
*/
|
||||||
function setHash($hash)
|
function setHash($hash)
|
||||||
{
|
{
|
||||||
|
@ -306,8 +306,8 @@ class Crypt_Hash
|
||||||
* Compute the HMAC.
|
* Compute the HMAC.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $text
|
* @param string $text
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function hash($text)
|
function hash($text)
|
||||||
{
|
{
|
||||||
|
@ -356,7 +356,7 @@ class Crypt_Hash
|
||||||
* Returns the hash length (in bytes)
|
* Returns the hash length (in bytes)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getLength()
|
function getLength()
|
||||||
{
|
{
|
||||||
|
@ -367,7 +367,7 @@ class Crypt_Hash
|
||||||
* Wrapper for MD5
|
* Wrapper for MD5
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
*/
|
*/
|
||||||
function _md5($m)
|
function _md5($m)
|
||||||
{
|
{
|
||||||
|
@ -378,7 +378,7 @@ class Crypt_Hash
|
||||||
* Wrapper for SHA1
|
* Wrapper for SHA1
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
*/
|
*/
|
||||||
function _sha1($m)
|
function _sha1($m)
|
||||||
{
|
{
|
||||||
|
@ -391,7 +391,7 @@ class Crypt_Hash
|
||||||
* See {@link http://tools.ietf.org/html/rfc1319 RFC1319}.
|
* See {@link http://tools.ietf.org/html/rfc1319 RFC1319}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
*/
|
*/
|
||||||
function _md2($m)
|
function _md2($m)
|
||||||
{
|
{
|
||||||
|
@ -467,7 +467,7 @@ class Crypt_Hash
|
||||||
* See {@link http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-256_.28a_SHA-2_variant.29_pseudocode SHA-256 (a SHA-2 variant) pseudocode - Wikipedia}.
|
* See {@link http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-256_.28a_SHA-2_variant.29_pseudocode SHA-256 (a SHA-2 variant) pseudocode - Wikipedia}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
*/
|
*/
|
||||||
function _sha256($m)
|
function _sha256($m)
|
||||||
{
|
{
|
||||||
|
@ -574,7 +574,7 @@ class Crypt_Hash
|
||||||
* Pure-PHP implementation of SHA384 and SHA512
|
* Pure-PHP implementation of SHA384 and SHA512
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
*/
|
*/
|
||||||
function _sha512($m)
|
function _sha512($m)
|
||||||
{
|
{
|
||||||
|
@ -757,10 +757,10 @@ class Crypt_Hash
|
||||||
* Right Rotate
|
* Right Rotate
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $int
|
* @param int $int
|
||||||
* @param Integer $amt
|
* @param int $amt
|
||||||
* @see _sha256()
|
* @see self::_sha256()
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _rightRotate($int, $amt)
|
function _rightRotate($int, $amt)
|
||||||
{
|
{
|
||||||
|
@ -773,10 +773,10 @@ class Crypt_Hash
|
||||||
* Right Shift
|
* Right Shift
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $int
|
* @param int $int
|
||||||
* @param Integer $amt
|
* @param int $amt
|
||||||
* @see _sha256()
|
* @see self::_sha256()
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _rightShift($int, $amt)
|
function _rightShift($int, $amt)
|
||||||
{
|
{
|
||||||
|
@ -788,9 +788,9 @@ class Crypt_Hash
|
||||||
* Not
|
* Not
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $int
|
* @param int $int
|
||||||
* @see _sha256()
|
* @see self::_sha256()
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _not($int)
|
function _not($int)
|
||||||
{
|
{
|
||||||
|
@ -803,9 +803,9 @@ class Crypt_Hash
|
||||||
* _sha256() adds multiple unsigned 32-bit integers. Since PHP doesn't support unsigned integers and since the
|
* _sha256() adds multiple unsigned 32-bit integers. Since PHP doesn't support unsigned integers and since the
|
||||||
* possibility of overflow exists, care has to be taken. Math_BigInteger() could be used but this should be faster.
|
* possibility of overflow exists, care has to be taken. Math_BigInteger() could be used but this should be faster.
|
||||||
*
|
*
|
||||||
* @param Integer $...
|
* @param int $...
|
||||||
* @return Integer
|
* @return int
|
||||||
* @see _sha256()
|
* @see self::_sha256()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _add()
|
function _add()
|
||||||
|
@ -829,9 +829,9 @@ class Crypt_Hash
|
||||||
*
|
*
|
||||||
* Inspired by array_shift
|
* Inspired by array_shift
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _string_shift(&$string, $index = 1)
|
function _string_shift(&$string, $index = 1)
|
||||||
|
|
|
@ -62,8 +62,8 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_RC2::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_RC2::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -111,7 +111,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* Block Length of the cipher
|
* Block Length of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::block_size
|
* @see Crypt_Base::block_size
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $block_size = 8;
|
var $block_size = 8;
|
||||||
|
@ -120,8 +120,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* The Key
|
* The Key
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::key
|
* @see Crypt_Base::key
|
||||||
* @see setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key;
|
var $key;
|
||||||
|
@ -130,29 +130,37 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* The Original (unpadded) Key
|
* The Original (unpadded) Key
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::key
|
* @see Crypt_Base::key
|
||||||
* @see setKey()
|
* @see self::setKey()
|
||||||
* @see encrypt()
|
* @see self::encrypt()
|
||||||
* @see decrypt()
|
* @see self::decrypt()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $orig_key;
|
var $orig_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default password key_size used by setPassword()
|
* Don't truncate / null pad key
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::password_key_size
|
* @see Crypt_Base::_clearBuffers()
|
||||||
* @see Crypt_Base::setPassword()
|
* @var bool
|
||||||
* @var Integer
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_key_size = 16; // = 128 bits
|
var $skip_key_adjustment = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key Length (in bytes)
|
||||||
|
*
|
||||||
|
* @see Crypt_RC2::setKeyLength()
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $key_length = 16; // = 128 bits
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'RC2';
|
var $const_namespace = 'RC2';
|
||||||
|
@ -161,7 +169,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'rc2';
|
var $cipher_name_mcrypt = 'rc2';
|
||||||
|
@ -170,7 +178,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* Optimizing value while CFB-encrypting
|
* Optimizing value while CFB-encrypting
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cfb_init_len
|
* @see Crypt_Base::cfb_init_len
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 500;
|
var $cfb_init_len = 500;
|
||||||
|
@ -178,9 +186,9 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The key length in bits.
|
* The key length in bits.
|
||||||
*
|
*
|
||||||
* @see Crypt_RC2::setKeyLength()
|
* @see self::setKeyLength()
|
||||||
* @see Crypt_RC2::setKey()
|
* @see self::setKey()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal Should be in range [1..1024].
|
* @internal Should be in range [1..1024].
|
||||||
* @internal Changing this value after setting the key has no effect.
|
* @internal Changing this value after setting the key has no effect.
|
||||||
|
@ -190,9 +198,9 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The key length in bits.
|
* The key length in bits.
|
||||||
*
|
*
|
||||||
* @see Crypt_RC2::isValidEnine()
|
* @see self::isValidEnine()
|
||||||
* @see Crypt_RC2::setKey()
|
* @see self::setKey()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal Should be in range [1..1024].
|
* @internal Should be in range [1..1024].
|
||||||
*/
|
*/
|
||||||
|
@ -201,8 +209,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key Schedule
|
* The Key Schedule
|
||||||
*
|
*
|
||||||
* @see Crypt_RC2::_setupKey()
|
* @see self::_setupKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $keys;
|
var $keys;
|
||||||
|
@ -211,8 +219,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* Key expansion randomization table.
|
* Key expansion randomization table.
|
||||||
* Twice the same 256-value sequence to save a modulus in key expansion.
|
* Twice the same 256-value sequence to save a modulus in key expansion.
|
||||||
*
|
*
|
||||||
* @see Crypt_RC2::setKey()
|
* @see self::setKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $pitable = array(
|
var $pitable = array(
|
||||||
|
@ -285,8 +293,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Inverse key expansion randomization table.
|
* Inverse key expansion randomization table.
|
||||||
*
|
*
|
||||||
* @see Crypt_RC2::setKey()
|
* @see self::setKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $invpitable = array(
|
var $invpitable = array(
|
||||||
|
@ -344,7 +352,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* If not explicitly set, CRYPT_RC2_MODE_CBC will be used.
|
* If not explicitly set, CRYPT_RC2_MODE_CBC will be used.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Crypt_RC2($mode = CRYPT_RC2_MODE_CBC)
|
function Crypt_RC2($mode = CRYPT_RC2_MODE_CBC)
|
||||||
|
@ -358,15 +366,15 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
switch ($engine) {
|
switch ($engine) {
|
||||||
case CRYPT_ENGINE_OPENSSL:
|
case CRYPT_ENGINE_OPENSSL:
|
||||||
if ($this->current_key_length != 128 || strlen($this->orig_key) != 16) {
|
if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->cipher_name_openssl_ecb = 'rc2-ecb';
|
$this->cipher_name_openssl_ecb = 'rc2-ecb';
|
||||||
|
@ -377,14 +385,14 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key length
|
* Sets the key length.
|
||||||
*
|
*
|
||||||
* Valid key lengths are 1 to 1024.
|
* Valid key lengths are 1 to 1024.
|
||||||
* Calling this function after setting the key has no effect until the next
|
* Calling this function after setting the key has no effect until the next
|
||||||
* Crypt_RC2::setKey() call.
|
* Crypt_RC2::setKey() call.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $length in bits
|
* @param int $length in bits
|
||||||
*/
|
*/
|
||||||
function setKeyLength($length)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
|
@ -393,6 +401,17 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current key length
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getKeyLength()
|
||||||
|
{
|
||||||
|
return $this->current_key_length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* Sets the key.
|
||||||
*
|
*
|
||||||
|
@ -406,8 +425,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setKey()
|
* @see Crypt_Base::setKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $t1 optional Effective key length in bits.
|
* @param int $t1 optional Effective key length in bits.
|
||||||
*/
|
*/
|
||||||
function setKey($key, $t1 = 0)
|
function setKey($key, $t1 = 0)
|
||||||
{
|
{
|
||||||
|
@ -448,6 +467,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
// Prepare the key for mcrypt.
|
// Prepare the key for mcrypt.
|
||||||
$l[0] = $this->invpitable[$l[0]];
|
$l[0] = $this->invpitable[$l[0]];
|
||||||
array_unshift($l, 'C*');
|
array_unshift($l, 'C*');
|
||||||
|
|
||||||
parent::setKey(call_user_func_array('pack', $l));
|
parent::setKey(call_user_func_array('pack', $l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,10 +476,10 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
*
|
*
|
||||||
* Mostly a wrapper for Crypt_Base::encrypt, with some additional OpenSSL handling code
|
* Mostly a wrapper for Crypt_Base::encrypt, with some additional OpenSSL handling code
|
||||||
*
|
*
|
||||||
* @see decrypt()
|
* @see self::decrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String $ciphertext
|
* @return string $ciphertext
|
||||||
*/
|
*/
|
||||||
function encrypt($plaintext)
|
function encrypt($plaintext)
|
||||||
{
|
{
|
||||||
|
@ -479,10 +499,10 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
*
|
*
|
||||||
* Mostly a wrapper for Crypt_Base::decrypt, with some additional OpenSSL handling code
|
* Mostly a wrapper for Crypt_Base::decrypt, with some additional OpenSSL handling code
|
||||||
*
|
*
|
||||||
* @see encrypt()
|
* @see self::encrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $ciphertext
|
* @param string $ciphertext
|
||||||
* @return String $plaintext
|
* @return string $plaintext
|
||||||
*/
|
*/
|
||||||
function decrypt($ciphertext)
|
function decrypt($ciphertext)
|
||||||
{
|
{
|
||||||
|
@ -503,8 +523,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* @see Crypt_Base::_encryptBlock()
|
* @see Crypt_Base::_encryptBlock()
|
||||||
* @see Crypt_Base::encrypt()
|
* @see Crypt_Base::encrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -548,8 +568,8 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
* @see Crypt_Base::_decryptBlock()
|
* @see Crypt_Base::_decryptBlock()
|
||||||
* @see Crypt_Base::decrypt()
|
* @see Crypt_Base::decrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -637,7 +657,7 @@ class Crypt_RC2 extends Crypt_Base
|
||||||
// for the mixing rounds, for better inline crypt performance [~20% faster].
|
// for the mixing rounds, for better inline crypt performance [~20% faster].
|
||||||
// But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10.
|
// But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10.
|
||||||
// (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit)
|
// (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit)
|
||||||
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
|
$gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
|
||||||
|
|
||||||
// Generation of a uniqe hash for our generated code
|
// Generation of a uniqe hash for our generated code
|
||||||
$code_hash = "Crypt_RC2, {$this->mode}";
|
$code_hash = "Crypt_RC2, {$this->mode}";
|
||||||
|
|
|
@ -71,7 +71,7 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_RC4::_crypt()
|
* @see self::_crypt()
|
||||||
*/
|
*/
|
||||||
define('CRYPT_RC4_ENCRYPT', 0);
|
define('CRYPT_RC4_ENCRYPT', 0);
|
||||||
define('CRYPT_RC4_DECRYPT', 1);
|
define('CRYPT_RC4_DECRYPT', 1);
|
||||||
|
@ -93,26 +93,25 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
* so we the block_size to 0
|
* so we the block_size to 0
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::block_size
|
* @see Crypt_Base::block_size
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $block_size = 0;
|
var $block_size = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default password key_size used by setPassword()
|
* Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::password_key_size
|
* @see Crypt_RC4::setKeyLength()
|
||||||
* @see Crypt_Base::setPassword()
|
* @var int
|
||||||
* @var Integer
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_key_size = 128; // = 1024 bits
|
var $key_length = 128; // = 1024 bits
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'RC4';
|
var $const_namespace = 'RC4';
|
||||||
|
@ -121,7 +120,7 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'arcfour';
|
var $cipher_name_mcrypt = 'arcfour';
|
||||||
|
@ -138,8 +137,8 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key
|
* The Key
|
||||||
*
|
*
|
||||||
* @see Crypt_RC4::setKey()
|
* @see self::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key = "\0";
|
var $key = "\0";
|
||||||
|
@ -147,8 +146,8 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key Stream for decryption and encryption
|
* The Key Stream for decryption and encryption
|
||||||
*
|
*
|
||||||
* @see Crypt_RC4::setKey()
|
* @see self::setKey()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $stream;
|
var $stream;
|
||||||
|
@ -173,9 +172,9 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
|
@ -214,8 +213,8 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
* {@link http://www.rsa.com/rsalabs/node.asp?id=2009 http://www.rsa.com/rsalabs/node.asp?id=2009}
|
* {@link http://www.rsa.com/rsalabs/node.asp?id=2009 http://www.rsa.com/rsalabs/node.asp?id=2009}
|
||||||
* {@link http://en.wikipedia.org/wiki/Related_key_attack http://en.wikipedia.org/wiki/Related_key_attack}
|
* {@link http://en.wikipedia.org/wiki/Related_key_attack http://en.wikipedia.org/wiki/Related_key_attack}
|
||||||
*
|
*
|
||||||
* @param String $iv
|
* @param string $iv
|
||||||
* @see Crypt_RC4::setKey()
|
* @see self::setKey()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setIV($iv)
|
function setIV($iv)
|
||||||
|
@ -223,28 +222,34 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* Sets the key length
|
||||||
*
|
*
|
||||||
* Keys can be between 1 and 256 bytes long. If they are longer then 256 bytes, the first 256 bytes will
|
* Keys can be between 1 and 256 bytes long.
|
||||||
* be used. If no key is explicitly set, it'll be assumed to be a single null byte.
|
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Base::setKey()
|
* @param int $length
|
||||||
* @param String $key
|
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
parent::setKey(substr($key, 0, 256));
|
if ($length < 8) {
|
||||||
|
$this->key_length = 1;
|
||||||
|
} elseif ($length > 2048) {
|
||||||
|
$this->key_length = 248;
|
||||||
|
} else {
|
||||||
|
$this->key_length = $length >> 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setKeyLength($length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a message.
|
* Encrypts a message.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see Crypt_Base::decrypt()
|
||||||
* @see Crypt_RC4::_crypt()
|
* @see self::_crypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String $ciphertext
|
* @return string $ciphertext
|
||||||
*/
|
*/
|
||||||
function encrypt($plaintext)
|
function encrypt($plaintext)
|
||||||
{
|
{
|
||||||
|
@ -261,10 +266,10 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
* At least if the continuous buffer is disabled.
|
* At least if the continuous buffer is disabled.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see Crypt_Base::encrypt()
|
||||||
* @see Crypt_RC4::_crypt()
|
* @see self::_crypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $ciphertext
|
* @param string $ciphertext
|
||||||
* @return String $plaintext
|
* @return string $plaintext
|
||||||
*/
|
*/
|
||||||
function decrypt($ciphertext)
|
function decrypt($ciphertext)
|
||||||
{
|
{
|
||||||
|
@ -305,12 +310,12 @@ class Crypt_RC4 extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Encrypts or decrypts a message.
|
* Encrypts or decrypts a message.
|
||||||
*
|
*
|
||||||
* @see Crypt_RC4::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_RC4::decrypt()
|
* @see self::decrypt()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $text
|
* @param string $text
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return String $text
|
* @return string $text
|
||||||
*/
|
*/
|
||||||
function _crypt($text, $mode)
|
function _crypt($text, $mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,8 +87,8 @@ if (!class_exists('Crypt_Hash')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_RSA::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_RSA::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding}
|
* Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding}
|
||||||
|
@ -96,8 +96,8 @@ if (!class_exists('Crypt_Hash')) {
|
||||||
*
|
*
|
||||||
* Uses sha1 by default.
|
* Uses sha1 by default.
|
||||||
*
|
*
|
||||||
* @see Crypt_RSA::setHash()
|
* @see self::setHash()
|
||||||
* @see Crypt_RSA::setMGFHash()
|
* @see self::setMGFHash()
|
||||||
*/
|
*/
|
||||||
define('CRYPT_RSA_ENCRYPTION_OAEP', 1);
|
define('CRYPT_RSA_ENCRYPTION_OAEP', 1);
|
||||||
/**
|
/**
|
||||||
|
@ -118,17 +118,17 @@ define('CRYPT_RSA_ENCRYPTION_NONE', 3);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_RSA::sign()
|
* @see self::sign()
|
||||||
* @see Crypt_RSA::verify()
|
* @see self::verify()
|
||||||
* @see Crypt_RSA::setHash()
|
* @see self::setHash()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Use the Probabilistic Signature Scheme for signing
|
* Use the Probabilistic Signature Scheme for signing
|
||||||
*
|
*
|
||||||
* Uses sha1 by default.
|
* Uses sha1 by default.
|
||||||
*
|
*
|
||||||
* @see Crypt_RSA::setSaltLength()
|
* @see self::setSaltLength()
|
||||||
* @see Crypt_RSA::setMGFHash()
|
* @see self::setMGFHash()
|
||||||
*/
|
*/
|
||||||
define('CRYPT_RSA_SIGNATURE_PSS', 1);
|
define('CRYPT_RSA_SIGNATURE_PSS', 1);
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ define('CRYPT_RSA_SIGNATURE_PKCS1', 2);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_RSA::createKey()
|
* @see self::createKey()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* ASN1 Integer
|
* ASN1 Integer
|
||||||
|
@ -168,7 +168,7 @@ define('CRYPT_RSA_ASN1_SEQUENCE', 48);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Crypt_RSA::Crypt_RSA()
|
* @see self::Crypt_RSA()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* To use the pure-PHP implementation
|
* To use the pure-PHP implementation
|
||||||
|
@ -189,8 +189,8 @@ define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__) . '/../openssl.cnf');
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_RSA::createKey()
|
* @see self::createKey()
|
||||||
* @see Crypt_RSA::setPrivateKeyFormat()
|
* @see self::setPrivateKeyFormat()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* PKCS#1 formatted private key
|
* PKCS#1 formatted private key
|
||||||
|
@ -209,13 +209,13 @@ define('CRYPT_RSA_PRIVATE_FORMAT_XML', 2);
|
||||||
/**
|
/**
|
||||||
* PKCS#8 formatted private key
|
* PKCS#8 formatted private key
|
||||||
*/
|
*/
|
||||||
define('CRYPT_RSA_PRIVATE_FORMAT_PKCS8', 3);
|
define('CRYPT_RSA_PRIVATE_FORMAT_PKCS8', 8);
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_RSA::createKey()
|
* @see self::createKey()
|
||||||
* @see Crypt_RSA::setPublicKeyFormat()
|
* @see self::setPublicKeyFormat()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Raw public key
|
* Raw public key
|
||||||
|
@ -282,7 +282,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Precomputed Zero
|
* Precomputed Zero
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $zero;
|
var $zero;
|
||||||
|
@ -290,7 +290,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Precomputed One
|
* Precomputed One
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $one;
|
var $one;
|
||||||
|
@ -298,7 +298,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Private Key Format
|
* Private Key Format
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $privateKeyFormat = CRYPT_RSA_PRIVATE_FORMAT_PKCS1;
|
var $privateKeyFormat = CRYPT_RSA_PRIVATE_FORMAT_PKCS1;
|
||||||
|
@ -306,7 +306,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Public Key Format
|
* Public Key Format
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS8;
|
var $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS8;
|
||||||
|
@ -338,7 +338,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Primes for Chinese Remainder Theorem (ie. p and q)
|
* Primes for Chinese Remainder Theorem (ie. p and q)
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $primes;
|
var $primes;
|
||||||
|
@ -346,7 +346,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Exponents for Chinese Remainder Theorem (ie. dP and dQ)
|
* Exponents for Chinese Remainder Theorem (ie. dP and dQ)
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $exponents;
|
var $exponents;
|
||||||
|
@ -354,7 +354,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Coefficients for Chinese Remainder Theorem (ie. qInv)
|
* Coefficients for Chinese Remainder Theorem (ie. qInv)
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $coefficients;
|
var $coefficients;
|
||||||
|
@ -362,7 +362,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Hash name
|
* Hash name
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $hashName;
|
var $hashName;
|
||||||
|
@ -378,7 +378,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Length of hash function output
|
* Length of hash function output
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $hLen;
|
var $hLen;
|
||||||
|
@ -386,7 +386,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Length of salt
|
* Length of salt
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sLen;
|
var $sLen;
|
||||||
|
@ -402,7 +402,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Length of MGF hash function output
|
* Length of MGF hash function output
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $mgfHLen;
|
var $mgfHLen;
|
||||||
|
@ -410,7 +410,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Encryption mode
|
* Encryption mode
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $encryptionMode = CRYPT_RSA_ENCRYPTION_OAEP;
|
var $encryptionMode = CRYPT_RSA_ENCRYPTION_OAEP;
|
||||||
|
@ -418,7 +418,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Signature mode
|
* Signature mode
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $signatureMode = CRYPT_RSA_SIGNATURE_PSS;
|
var $signatureMode = CRYPT_RSA_SIGNATURE_PSS;
|
||||||
|
@ -426,7 +426,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Public Exponent
|
* Public Exponent
|
||||||
*
|
*
|
||||||
* @var Mixed
|
* @var mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $publicExponent = false;
|
var $publicExponent = false;
|
||||||
|
@ -434,7 +434,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Password
|
* Password
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password = false;
|
var $password = false;
|
||||||
|
@ -445,8 +445,8 @@ class Crypt_RSA
|
||||||
* For use with parsing XML formatted keys. PHP's XML Parser functions use utilized - instead of PHP's DOM functions -
|
* For use with parsing XML formatted keys. PHP's XML Parser functions use utilized - instead of PHP's DOM functions -
|
||||||
* because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't.
|
* because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't.
|
||||||
*
|
*
|
||||||
* @see Crypt_RSA::_start_element_handler()
|
* @see self::_start_element_handler()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $components = array();
|
var $components = array();
|
||||||
|
@ -456,9 +456,9 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* For use with parsing XML formatted keys.
|
* For use with parsing XML formatted keys.
|
||||||
*
|
*
|
||||||
* @see Crypt_RSA::_character_handler()
|
* @see self::_character_handler()
|
||||||
* @see Crypt_RSA::_stop_element_handler()
|
* @see self::_stop_element_handler()
|
||||||
* @var Mixed
|
* @var mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $current;
|
var $current;
|
||||||
|
@ -467,8 +467,8 @@ class Crypt_RSA
|
||||||
* OpenSSL configuration file name.
|
* OpenSSL configuration file name.
|
||||||
*
|
*
|
||||||
* Set to null to use system configuration file.
|
* Set to null to use system configuration file.
|
||||||
* @see Crypt_RSA::createKey()
|
* @see self::createKey()
|
||||||
* @var Mixed
|
* @var mixed
|
||||||
* @Access public
|
* @Access public
|
||||||
*/
|
*/
|
||||||
var $configFile;
|
var $configFile;
|
||||||
|
@ -476,7 +476,7 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Public key comment field.
|
* Public key comment field.
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $comment = 'phpseclib-generated-key';
|
var $comment = 'phpseclib-generated-key';
|
||||||
|
@ -571,9 +571,9 @@ class Crypt_RSA
|
||||||
* Will need to be passed back to Crypt_RSA::createKey() as the third parameter for further processing.
|
* Will need to be passed back to Crypt_RSA::createKey() as the third parameter for further processing.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param optional Integer $bits
|
* @param int $bits
|
||||||
* @param optional Integer $timeout
|
* @param int $timeout
|
||||||
* @param optional Math_BigInteger $p
|
* @param Math_BigInteger $p
|
||||||
*/
|
*/
|
||||||
function createKey($bits = 1024, $timeout = false, $partial = array())
|
function createKey($bits = 1024, $timeout = false, $partial = array())
|
||||||
{
|
{
|
||||||
|
@ -751,9 +751,9 @@ class Crypt_RSA
|
||||||
* Convert a private key to the appropriate format.
|
* Convert a private key to the appropriate format.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @see setPrivateKeyFormat()
|
* @see self::setPrivateKeyFormat()
|
||||||
* @param String $RSAPrivateKey
|
* @param string $RSAPrivateKey
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients)
|
function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients)
|
||||||
{
|
{
|
||||||
|
@ -992,9 +992,9 @@ class Crypt_RSA
|
||||||
* Convert a public key to the appropriate format
|
* Convert a public key to the appropriate format
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @see setPublicKeyFormat()
|
* @see self::setPublicKeyFormat()
|
||||||
* @param String $RSAPrivateKey
|
* @param string $RSAPrivateKey
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _convertPublicKey($n, $e)
|
function _convertPublicKey($n, $e)
|
||||||
{
|
{
|
||||||
|
@ -1070,11 +1070,11 @@ class Crypt_RSA
|
||||||
* Break a public or private key down into its constituant components
|
* Break a public or private key down into its constituant components
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @see _convertPublicKey()
|
* @see self::_convertPublicKey()
|
||||||
* @see _convertPrivateKey()
|
* @see self::_convertPrivateKey()
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $type
|
* @param int $type
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _parseKey($key, $type)
|
function _parseKey($key, $type)
|
||||||
{
|
{
|
||||||
|
@ -1490,7 +1490,7 @@ class Crypt_RSA
|
||||||
* More specifically, this returns the size of the modulo in bits.
|
* More specifically, this returns the size of the modulo in bits.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getSize()
|
function getSize()
|
||||||
{
|
{
|
||||||
|
@ -1503,9 +1503,9 @@ class Crypt_RSA
|
||||||
* Called by xml_set_element_handler()
|
* Called by xml_set_element_handler()
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Resource $parser
|
* @param resource $parser
|
||||||
* @param String $name
|
* @param string $name
|
||||||
* @param Array $attribs
|
* @param array $attribs
|
||||||
*/
|
*/
|
||||||
function _start_element_handler($parser, $name, $attribs)
|
function _start_element_handler($parser, $name, $attribs)
|
||||||
{
|
{
|
||||||
|
@ -1544,8 +1544,8 @@ class Crypt_RSA
|
||||||
* Called by xml_set_element_handler()
|
* Called by xml_set_element_handler()
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Resource $parser
|
* @param resource $parser
|
||||||
* @param String $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
function _stop_element_handler($parser, $name)
|
function _stop_element_handler($parser, $name)
|
||||||
{
|
{
|
||||||
|
@ -1561,8 +1561,8 @@ class Crypt_RSA
|
||||||
* Called by xml_set_character_data_handler()
|
* Called by xml_set_character_data_handler()
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Resource $parser
|
* @param resource $parser
|
||||||
* @param String $data
|
* @param string $data
|
||||||
*/
|
*/
|
||||||
function _data_handler($parser, $data)
|
function _data_handler($parser, $data)
|
||||||
{
|
{
|
||||||
|
@ -1578,8 +1578,8 @@ class Crypt_RSA
|
||||||
* Returns true on success and false on failure (ie. an incorrect password was provided or the key was malformed)
|
* Returns true on success and false on failure (ie. an incorrect password was provided or the key was malformed)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
*/
|
*/
|
||||||
function loadKey($key, $type = false)
|
function loadKey($key, $type = false)
|
||||||
{
|
{
|
||||||
|
@ -1644,7 +1644,6 @@ class Crypt_RSA
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$components = $this->_parseKey($key, $type);
|
$components = $this->_parseKey($key, $type);
|
||||||
}
|
}
|
||||||
|
@ -1693,10 +1692,10 @@ class Crypt_RSA
|
||||||
* Private keys can be encrypted with a password. To unset the password, pass in the empty string or false.
|
* Private keys can be encrypted with a password. To unset the password, pass in the empty string or false.
|
||||||
* Or rather, pass in $password such that empty($password) && !is_string($password) is true.
|
* Or rather, pass in $password such that empty($password) && !is_string($password) is true.
|
||||||
*
|
*
|
||||||
* @see createKey()
|
* @see self::createKey()
|
||||||
* @see loadKey()
|
* @see self::loadKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $password
|
* @param string $password
|
||||||
*/
|
*/
|
||||||
function setPassword($password = false)
|
function setPassword($password = false)
|
||||||
{
|
{
|
||||||
|
@ -1718,11 +1717,11 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* Returns true on success, false on failure
|
* Returns true on success, false on failure
|
||||||
*
|
*
|
||||||
* @see getPublicKey()
|
* @see self::getPublicKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key optional
|
* @param string $key optional
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function setPublicKey($key = false, $type = false)
|
function setPublicKey($key = false, $type = false)
|
||||||
{
|
{
|
||||||
|
@ -1778,11 +1777,11 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* Returns true on success, false on failure
|
* Returns true on success, false on failure
|
||||||
*
|
*
|
||||||
* @see getPublicKey()
|
* @see self::getPublicKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key optional
|
* @param string $key optional
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function setPrivateKey($key = false, $type = false)
|
function setPrivateKey($key = false, $type = false)
|
||||||
{
|
{
|
||||||
|
@ -1809,10 +1808,10 @@ class Crypt_RSA
|
||||||
* or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this
|
* or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this
|
||||||
* function won't return it since this library, for the most part, doesn't distinguish between public and private keys.
|
* function won't return it since this library, for the most part, doesn't distinguish between public and private keys.
|
||||||
*
|
*
|
||||||
* @see getPublicKey()
|
* @see self::getPublicKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
*/
|
*/
|
||||||
function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
||||||
{
|
{
|
||||||
|
@ -1835,8 +1834,9 @@ class Crypt_RSA
|
||||||
* Example output (md5): "c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87" (as specified by RFC 4716)
|
* Example output (md5): "c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87" (as specified by RFC 4716)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $algorithm The hashing algorithm to be used. Valid options are 'md5' and 'sha256'. False is returned
|
* @param string $algorithm The hashing algorithm to be used. Valid options are 'md5' and 'sha256'. False is returned
|
||||||
* for invalid values.
|
* for invalid values.
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getPublicKeyFingerprint($algorithm = 'md5')
|
public function getPublicKeyFingerprint($algorithm = 'md5')
|
||||||
{
|
{
|
||||||
|
@ -1859,7 +1859,6 @@ class Crypt_RSA
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1867,10 +1866,11 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* The private key is only returned if the currently loaded key contains the constituent prime numbers.
|
* The private key is only returned if the currently loaded key contains the constituent prime numbers.
|
||||||
*
|
*
|
||||||
* @see getPublicKey()
|
* @see self::getPublicKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function getPrivateKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1)
|
function getPrivateKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1)
|
||||||
{
|
{
|
||||||
|
@ -1891,10 +1891,10 @@ class Crypt_RSA
|
||||||
* Returns the private key without the prime number constituants. Structurally identical to a public key that
|
* Returns the private key without the prime number constituants. Structurally identical to a public key that
|
||||||
* hasn't been set as the public key
|
* hasn't been set as the public key
|
||||||
*
|
*
|
||||||
* @see getPrivateKey()
|
* @see self::getPrivateKey()
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $key
|
* @param string $key
|
||||||
* @param Integer $type optional
|
* @param int $type optional
|
||||||
*/
|
*/
|
||||||
function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
||||||
{
|
{
|
||||||
|
@ -1913,6 +1913,7 @@ class Crypt_RSA
|
||||||
* __toString() magic method
|
* __toString() magic method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function __toString()
|
function __toString()
|
||||||
{
|
{
|
||||||
|
@ -1928,6 +1929,7 @@ class Crypt_RSA
|
||||||
* __clone() magic method
|
* __clone() magic method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @return Crypt_RSA
|
||||||
*/
|
*/
|
||||||
function __clone()
|
function __clone()
|
||||||
{
|
{
|
||||||
|
@ -1940,8 +1942,8 @@ class Crypt_RSA
|
||||||
* Generates the smallest and largest numbers requiring $bits bits
|
* Generates the smallest and largest numbers requiring $bits bits
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $bits
|
* @param int $bits
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _generateMinMax($bits)
|
function _generateMinMax($bits)
|
||||||
{
|
{
|
||||||
|
@ -1969,8 +1971,8 @@ class Crypt_RSA
|
||||||
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _decodeLength(&$string)
|
function _decodeLength(&$string)
|
||||||
{
|
{
|
||||||
|
@ -1990,8 +1992,8 @@ class Crypt_RSA
|
||||||
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encodeLength($length)
|
function _encodeLength($length)
|
||||||
{
|
{
|
||||||
|
@ -2008,9 +2010,9 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* Inspired by array_shift
|
* Inspired by array_shift
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _string_shift(&$string, $index = 1)
|
function _string_shift(&$string, $index = 1)
|
||||||
|
@ -2023,9 +2025,9 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Determines the private key format
|
* Determines the private key format
|
||||||
*
|
*
|
||||||
* @see createKey()
|
* @see self::createKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $format
|
* @param int $format
|
||||||
*/
|
*/
|
||||||
function setPrivateKeyFormat($format)
|
function setPrivateKeyFormat($format)
|
||||||
{
|
{
|
||||||
|
@ -2035,9 +2037,9 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Determines the public key format
|
* Determines the public key format
|
||||||
*
|
*
|
||||||
* @see createKey()
|
* @see self::createKey()
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $format
|
* @param int $format
|
||||||
*/
|
*/
|
||||||
function setPublicKeyFormat($format)
|
function setPublicKeyFormat($format)
|
||||||
{
|
{
|
||||||
|
@ -2051,7 +2053,7 @@ class Crypt_RSA
|
||||||
* decryption. If $hash isn't supported, sha1 is used.
|
* decryption. If $hash isn't supported, sha1 is used.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $hash
|
* @param string $hash
|
||||||
*/
|
*/
|
||||||
function setHash($hash)
|
function setHash($hash)
|
||||||
{
|
{
|
||||||
|
@ -2080,7 +2082,7 @@ class Crypt_RSA
|
||||||
* best if Hash and MGFHash are set to the same thing this is not a requirement.
|
* best if Hash and MGFHash are set to the same thing this is not a requirement.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $hash
|
* @param string $hash
|
||||||
*/
|
*/
|
||||||
function setMGFHash($hash)
|
function setMGFHash($hash)
|
||||||
{
|
{
|
||||||
|
@ -2109,7 +2111,7 @@ class Crypt_RSA
|
||||||
* of the hash function Hash) and 0.
|
* of the hash function Hash) and 0.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $format
|
* @param int $format
|
||||||
*/
|
*/
|
||||||
function setSaltLength($sLen)
|
function setSaltLength($sLen)
|
||||||
{
|
{
|
||||||
|
@ -2123,8 +2125,8 @@ class Crypt_RSA
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Math_BigInteger $x
|
* @param Math_BigInteger $x
|
||||||
* @param Integer $xLen
|
* @param int $xLen
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _i2osp($x, $xLen)
|
function _i2osp($x, $xLen)
|
||||||
{
|
{
|
||||||
|
@ -2142,7 +2144,7 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $x
|
* @param string $x
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
*/
|
*/
|
||||||
function _os2ip($x)
|
function _os2ip($x)
|
||||||
|
@ -2236,7 +2238,7 @@ class Crypt_RSA
|
||||||
* @access private
|
* @access private
|
||||||
* @param Math_BigInteger $x
|
* @param Math_BigInteger $x
|
||||||
* @param Math_BigInteger $r
|
* @param Math_BigInteger $r
|
||||||
* @param Integer $i
|
* @param int $i
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
*/
|
*/
|
||||||
function _blind($x, $r, $i)
|
function _blind($x, $r, $i)
|
||||||
|
@ -2261,9 +2263,9 @@ class Crypt_RSA
|
||||||
* Thanks for the heads up singpolyma!
|
* Thanks for the heads up singpolyma!
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $x
|
* @param string $x
|
||||||
* @param String $y
|
* @param string $y
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function _equals($x, $y)
|
function _equals($x, $y)
|
||||||
{
|
{
|
||||||
|
@ -2357,9 +2359,9 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $mgfSeed
|
* @param string $mgfSeed
|
||||||
* @param Integer $mgfLen
|
* @param int $mgfLen
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _mgf1($mgfSeed, $maskLen)
|
function _mgf1($mgfSeed, $maskLen)
|
||||||
{
|
{
|
||||||
|
@ -2382,9 +2384,9 @@ class Crypt_RSA
|
||||||
* {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}.
|
* {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @param String $l
|
* @param string $l
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsaes_oaep_encrypt($m, $l = '')
|
function _rsaes_oaep_encrypt($m, $l = '')
|
||||||
{
|
{
|
||||||
|
@ -2445,9 +2447,9 @@ class Crypt_RSA
|
||||||
* this document.
|
* this document.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $c
|
* @param string $c
|
||||||
* @param String $l
|
* @param string $l
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsaes_oaep_decrypt($c, $l = '')
|
function _rsaes_oaep_decrypt($c, $l = '')
|
||||||
{
|
{
|
||||||
|
@ -2504,8 +2506,8 @@ class Crypt_RSA
|
||||||
* Doesn't use padding and is not recommended.
|
* Doesn't use padding and is not recommended.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _raw_encrypt($m)
|
function _raw_encrypt($m)
|
||||||
{
|
{
|
||||||
|
@ -2520,8 +2522,8 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsaes_pkcs1_v1_5_encrypt($m)
|
function _rsaes_pkcs1_v1_5_encrypt($m)
|
||||||
{
|
{
|
||||||
|
@ -2579,8 +2581,8 @@ class Crypt_RSA
|
||||||
* not private key encrypted ciphertext's.
|
* not private key encrypted ciphertext's.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $c
|
* @param string $c
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsaes_pkcs1_v1_5_decrypt($c)
|
function _rsaes_pkcs1_v1_5_decrypt($c)
|
||||||
{
|
{
|
||||||
|
@ -2628,8 +2630,8 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @param Integer $emBits
|
* @param int $emBits
|
||||||
*/
|
*/
|
||||||
function _emsa_pss_encode($m, $emBits)
|
function _emsa_pss_encode($m, $emBits)
|
||||||
{
|
{
|
||||||
|
@ -2637,7 +2639,7 @@ class Crypt_RSA
|
||||||
// be output.
|
// be output.
|
||||||
|
|
||||||
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8)
|
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8)
|
||||||
$sLen = $this->sLen === false ? $this->hLen : $this->sLen;
|
$sLen = $this->sLen ? $this->sLen : $this->hLen;
|
||||||
|
|
||||||
$mHash = $this->hash->hash($m);
|
$mHash = $this->hash->hash($m);
|
||||||
if ($emLen < $this->hLen + $sLen + 2) {
|
if ($emLen < $this->hLen + $sLen + 2) {
|
||||||
|
@ -2664,10 +2666,10 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @param String $em
|
* @param string $em
|
||||||
* @param Integer $emBits
|
* @param int $emBits
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _emsa_pss_verify($m, $em, $emBits)
|
function _emsa_pss_verify($m, $em, $emBits)
|
||||||
{
|
{
|
||||||
|
@ -2675,7 +2677,7 @@ class Crypt_RSA
|
||||||
// be output.
|
// be output.
|
||||||
|
|
||||||
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8);
|
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8);
|
||||||
$sLen = $this->sLen === false ? $this->hLen : $this->sLen;
|
$sLen = $this->sLen ? $this->sLen : $this->hLen;
|
||||||
|
|
||||||
$mHash = $this->hash->hash($m);
|
$mHash = $this->hash->hash($m);
|
||||||
if ($emLen < $this->hLen + $sLen + 2) {
|
if ($emLen < $this->hLen + $sLen + 2) {
|
||||||
|
@ -2711,8 +2713,8 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsassa_pss_sign($m)
|
function _rsassa_pss_sign($m)
|
||||||
{
|
{
|
||||||
|
@ -2737,9 +2739,9 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @param String $s
|
* @param string $s
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsassa_pss_verify($m, $s)
|
function _rsassa_pss_verify($m, $s)
|
||||||
{
|
{
|
||||||
|
@ -2777,9 +2779,9 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @param Integer $emLen
|
* @param int $emLen
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _emsa_pkcs1_v1_5_encode($m, $emLen)
|
function _emsa_pkcs1_v1_5_encode($m, $emLen)
|
||||||
{
|
{
|
||||||
|
@ -2829,8 +2831,8 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsassa_pkcs1_v1_5_sign($m)
|
function _rsassa_pkcs1_v1_5_sign($m)
|
||||||
{
|
{
|
||||||
|
@ -2859,8 +2861,8 @@ class Crypt_RSA
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $m
|
* @param string $m
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _rsassa_pkcs1_v1_5_verify($m, $s)
|
function _rsassa_pkcs1_v1_5_verify($m, $s)
|
||||||
{
|
{
|
||||||
|
@ -2903,7 +2905,7 @@ class Crypt_RSA
|
||||||
* Valid values include CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1.
|
* Valid values include CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
*/
|
*/
|
||||||
function setEncryptionMode($mode)
|
function setEncryptionMode($mode)
|
||||||
{
|
{
|
||||||
|
@ -2916,7 +2918,7 @@ class Crypt_RSA
|
||||||
* Valid values include CRYPT_RSA_SIGNATURE_PSS and CRYPT_RSA_SIGNATURE_PKCS1
|
* Valid values include CRYPT_RSA_SIGNATURE_PSS and CRYPT_RSA_SIGNATURE_PKCS1
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
*/
|
*/
|
||||||
function setSignatureMode($mode)
|
function setSignatureMode($mode)
|
||||||
{
|
{
|
||||||
|
@ -2927,7 +2929,7 @@ class Crypt_RSA
|
||||||
* Set public key comment.
|
* Set public key comment.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $comment
|
* @param string $comment
|
||||||
*/
|
*/
|
||||||
function setComment($comment)
|
function setComment($comment)
|
||||||
{
|
{
|
||||||
|
@ -2938,7 +2940,7 @@ class Crypt_RSA
|
||||||
* Get public key comment.
|
* Get public key comment.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getComment()
|
function getComment()
|
||||||
{
|
{
|
||||||
|
@ -2952,10 +2954,10 @@ class Crypt_RSA
|
||||||
* If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will
|
* If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will
|
||||||
* be concatenated together.
|
* be concatenated together.
|
||||||
*
|
*
|
||||||
* @see decrypt()
|
* @see self::decrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function encrypt($plaintext)
|
function encrypt($plaintext)
|
||||||
{
|
{
|
||||||
|
@ -2998,10 +3000,10 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Decryption
|
* Decryption
|
||||||
*
|
*
|
||||||
* @see encrypt()
|
* @see self::encrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function decrypt($ciphertext)
|
function decrypt($ciphertext)
|
||||||
{
|
{
|
||||||
|
@ -3040,10 +3042,10 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Create a signature
|
* Create a signature
|
||||||
*
|
*
|
||||||
* @see verify()
|
* @see self::verify()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $message
|
* @param string $message
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function sign($message)
|
function sign($message)
|
||||||
{
|
{
|
||||||
|
@ -3063,11 +3065,11 @@ class Crypt_RSA
|
||||||
/**
|
/**
|
||||||
* Verifies a signature
|
* Verifies a signature
|
||||||
*
|
*
|
||||||
* @see sign()
|
* @see self::sign()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $message
|
* @param string $message
|
||||||
* @param String $signature
|
* @param string $signature
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function verify($message, $signature)
|
function verify($message, $signature)
|
||||||
{
|
{
|
||||||
|
@ -3088,8 +3090,8 @@ class Crypt_RSA
|
||||||
* Extract raw BER from Base64 encoding
|
* Extract raw BER from Base64 encoding
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $str
|
* @param string $str
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _extractBER($str)
|
function _extractBER($str)
|
||||||
{
|
{
|
||||||
|
@ -3102,7 +3104,7 @@ class Crypt_RSA
|
||||||
* subject=/O=organization/OU=org unit/CN=common name
|
* subject=/O=organization/OU=org unit/CN=common name
|
||||||
* issuer=/O=organization/CN=common name
|
* issuer=/O=organization/CN=common name
|
||||||
*/
|
*/
|
||||||
$temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1);
|
$temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
|
||||||
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
|
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
|
||||||
$temp = preg_replace('#-+[^-]+-+#', '', $temp);
|
$temp = preg_replace('#-+[^-]+-+#', '', $temp);
|
||||||
// remove new lines
|
// remove new lines
|
||||||
|
|
|
@ -61,16 +61,15 @@ if (!function_exists('crypt_random_string')) {
|
||||||
* microoptimizations because this function has the potential of being called a huge number of times.
|
* microoptimizations because this function has the potential of being called a huge number of times.
|
||||||
* eg. for RSA key generation.
|
* eg. for RSA key generation.
|
||||||
*
|
*
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function crypt_random_string($length)
|
function crypt_random_string($length)
|
||||||
{
|
{
|
||||||
if (CRYPT_RANDOM_IS_WINDOWS) {
|
if (CRYPT_RANDOM_IS_WINDOWS) {
|
||||||
// method 1. prior to PHP 5.3 this would call rand() on windows hence the function_exists('class_alias') call.
|
// method 1. prior to PHP 5.3, mcrypt_create_iv() would call rand() on windows
|
||||||
// ie. class_alias is a function that was introduced in PHP 5.3
|
if (extension_loaded('mcrypt') && version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||||
if (function_exists('mcrypt_create_iv') && function_exists('class_alias')) {
|
|
||||||
return mcrypt_create_iv($length);
|
return mcrypt_create_iv($length);
|
||||||
}
|
}
|
||||||
// method 2. openssl_random_pseudo_bytes was introduced in PHP 5.3.0 but prior to PHP 5.3.4 there was,
|
// method 2. openssl_random_pseudo_bytes was introduced in PHP 5.3.0 but prior to PHP 5.3.4 there was,
|
||||||
|
@ -86,12 +85,12 @@ if (!function_exists('crypt_random_string')) {
|
||||||
// https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/win32/winutil.c#L80
|
// https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/win32/winutil.c#L80
|
||||||
//
|
//
|
||||||
// we're calling it, all the same, in the off chance that the mcrypt extension is not available
|
// we're calling it, all the same, in the off chance that the mcrypt extension is not available
|
||||||
if (function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>=')) {
|
if (extension_loaded('openssl') && version_compare(PHP_VERSION, '5.3.4', '>=')) {
|
||||||
return openssl_random_pseudo_bytes($length);
|
return openssl_random_pseudo_bytes($length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// method 1. the fastest
|
// method 1. the fastest
|
||||||
if (function_exists('openssl_random_pseudo_bytes')) {
|
if (extension_loaded('openssl') && version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||||
return openssl_random_pseudo_bytes($length);
|
return openssl_random_pseudo_bytes($length);
|
||||||
}
|
}
|
||||||
// method 2
|
// method 2
|
||||||
|
@ -109,7 +108,7 @@ if (!function_exists('crypt_random_string')) {
|
||||||
// surprisingly slower than method 2. maybe that's because mcrypt_create_iv does a bunch of error checking that we're
|
// surprisingly slower than method 2. maybe that's because mcrypt_create_iv does a bunch of error checking that we're
|
||||||
// not doing. regardless, this'll only be called if this PHP script couldn't open /dev/urandom due to open_basedir
|
// not doing. regardless, this'll only be called if this PHP script couldn't open /dev/urandom due to open_basedir
|
||||||
// restrictions or some such
|
// restrictions or some such
|
||||||
if (function_exists('mcrypt_create_iv')) {
|
if (extension_loaded('mcrypt')) {
|
||||||
return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
|
return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +268,7 @@ if (!function_exists('phpseclib_resolve_include_path')) {
|
||||||
* PHP 5.3.2) with fallback implementation for earlier PHP versions.
|
* PHP 5.3.2) with fallback implementation for earlier PHP versions.
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return mixed Filename (string) on success, false otherwise.
|
* @return string|false
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function phpseclib_resolve_include_path($filename)
|
function phpseclib_resolve_include_path($filename)
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
*
|
*
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* If {@link Crypt_Rijndael::setBlockLength() setBlockLength()} isn't called, it'll be assumed to be 128 bits. If
|
* If {@link self::setBlockLength() setBlockLength()} isn't called, it'll be assumed to be 128 bits. If
|
||||||
* {@link Crypt_Rijndael::setKeyLength() setKeyLength()} isn't called, it'll be calculated from
|
* {@link self::setKeyLength() setKeyLength()} isn't called, it'll be calculated from
|
||||||
* {@link Crypt_Rijndael::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's
|
* {@link self::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's
|
||||||
* 136-bits it'll be null-padded to 192-bits and 192 bits will be the key length until
|
* 136-bits it'll be null-padded to 192-bits and 192 bits will be the key length until
|
||||||
* {@link Crypt_Rijndael::setKey() setKey()} is called, again, at which point, it'll be recalculated.
|
* {@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,
|
* 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.
|
* does not. AES, itself, only supports block lengths of 128 and key lengths of 128, 192, and 256.
|
||||||
|
@ -81,8 +81,8 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Rijndael::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Rijndael::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -127,21 +127,11 @@ define('CRYPT_RIJNDAEL_MODE_OFB', CRYPT_MODE_OFB);
|
||||||
*/
|
*/
|
||||||
class Crypt_Rijndael extends Crypt_Base
|
class Crypt_Rijndael extends Crypt_Base
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The default password key_size used by setPassword()
|
|
||||||
*
|
|
||||||
* @see Crypt_Base::password_key_size
|
|
||||||
* @see Crypt_Base::setPassword()
|
|
||||||
* @var Integer
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $password_key_size = 16;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'RIJNDAEL';
|
var $const_namespace = 'RIJNDAEL';
|
||||||
|
@ -149,15 +139,15 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* Mcrypt is useable for 128/192/256-bit $block_size/$key_size. For 160/224 not.
|
* Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not.
|
||||||
* Crypt_Rijndael determines automatically whether mcrypt is useable
|
* Crypt_Rijndael determines automatically whether mcrypt is useable
|
||||||
* or not for the current $block_size/$key_size.
|
* or not for the current $block_size/$key_length.
|
||||||
* In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
|
* In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @see Crypt_Base::engine
|
* @see Crypt_Base::engine
|
||||||
* @see isValidEngine()
|
* @see self::isValidEngine()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'rijndael-128';
|
var $cipher_name_mcrypt = 'rijndael-128';
|
||||||
|
@ -167,25 +157,16 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::password_default_salt
|
* @see Crypt_Base::password_default_salt
|
||||||
* @see Crypt_Base::setPassword()
|
* @see Crypt_Base::setPassword()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_default_salt = 'phpseclib';
|
var $password_default_salt = 'phpseclib';
|
||||||
|
|
||||||
/**
|
|
||||||
* Has the key length explicitly been set or should it be derived from the key, itself?
|
|
||||||
*
|
|
||||||
* @see setKeyLength()
|
|
||||||
* @var Boolean
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $explicit_key_length = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Key Schedule
|
* The Key Schedule
|
||||||
*
|
*
|
||||||
* @see _setup()
|
* @see self::_setup()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $w;
|
var $w;
|
||||||
|
@ -193,8 +174,8 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Inverse Key Schedule
|
* The Inverse Key Schedule
|
||||||
*
|
*
|
||||||
* @see _setup()
|
* @see self::_setup()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $dw;
|
var $dw;
|
||||||
|
@ -202,8 +183,8 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Block Length divided by 32
|
* The Block Length divided by 32
|
||||||
*
|
*
|
||||||
* @see setBlockLength()
|
* @see self::setBlockLength()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4. Exists in conjunction with $block_size
|
* @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4. Exists in conjunction with $block_size
|
||||||
* because the encryption / decryption / key schedule creation requires this number and not $block_size. We could
|
* because the encryption / decryption / key schedule creation requires this number and not $block_size. We could
|
||||||
|
@ -213,23 +194,23 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
var $Nb = 4;
|
var $Nb = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Key Length
|
* The Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* @see setKeyLength()
|
* @see self::setKeyLength()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
|
* @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
|
||||||
* because the encryption / decryption / key schedule creation requires this number and not $key_size. We could
|
* because the encryption / decryption / key schedule creation requires this number and not $key_length. We could
|
||||||
* derive this from $key_size or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
|
* derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
|
||||||
* of that, we'll just precompute it once.
|
* of that, we'll just precompute it once.
|
||||||
*/
|
*/
|
||||||
var $key_size = 16;
|
var $key_length = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Key Length divided by 32
|
* The Key Length divided by 32
|
||||||
*
|
*
|
||||||
* @see setKeyLength()
|
* @see self::setKeyLength()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4
|
* @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4
|
||||||
*/
|
*/
|
||||||
|
@ -238,7 +219,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Number of Rounds
|
* The Number of Rounds
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
* @internal The max value is 14, the min value is 10.
|
* @internal The max value is 14, the min value is 10.
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +228,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Shift offsets
|
* Shift offsets
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $c;
|
var $c;
|
||||||
|
@ -255,7 +236,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Holds the last used key- and block_size information
|
* Holds the last used key- and block_size information
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $kl;
|
var $kl;
|
||||||
|
@ -280,7 +261,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* If not explictly set, CRYPT_RIJNDAEL_MODE_CBC will be used.
|
* If not explictly set, CRYPT_RIJNDAEL_MODE_CBC will be used.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Crypt_Rijndael($mode = CRYPT_RIJNDAEL_MODE_CBC)
|
function Crypt_Rijndael($mode = CRYPT_RIJNDAEL_MODE_CBC)
|
||||||
|
@ -301,9 +282,9 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* Note: 160/224-bit keys must explicitly set by setKeyLength(), otherwise they will be round/pad up to 192/256 bits.
|
* Note: 160/224-bit keys must explicitly set by setKeyLength(), otherwise they will be round/pad up to 192/256 bits.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base:setKey()
|
* @see Crypt_Base:setKey()
|
||||||
* @see setKeyLength()
|
* @see self::setKeyLength()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKey($key)
|
||||||
{
|
{
|
||||||
|
@ -347,30 +328,28 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* This results then in slower encryption.
|
* This results then in slower encryption.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
*/
|
*/
|
||||||
function setKeyLength($length)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $length == 160:
|
|
||||||
$this->key_size = 20;
|
|
||||||
break;
|
|
||||||
case $length == 224:
|
|
||||||
$this->key_size = 28;
|
|
||||||
break;
|
|
||||||
case $length <= 128:
|
case $length <= 128:
|
||||||
$this->key_size = 16;
|
$this->key_length = 16;
|
||||||
|
break;
|
||||||
|
case $length <= 160:
|
||||||
|
$this->key_length = 20;
|
||||||
break;
|
break;
|
||||||
case $length <= 192:
|
case $length <= 192:
|
||||||
$this->key_size = 24;
|
$this->key_length = 24;
|
||||||
|
break;
|
||||||
|
case $length <= 224:
|
||||||
|
$this->key_length = 28;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->key_size = 32;
|
$this->key_length = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->explicit_key_length = true;
|
parent::setKeyLength($length);
|
||||||
$this->changed = true;
|
|
||||||
$this->_setEngine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -380,7 +359,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
|
* 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
*/
|
*/
|
||||||
function setBlockLength($length)
|
function setBlockLength($length)
|
||||||
{
|
{
|
||||||
|
@ -402,9 +381,9 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
|
@ -413,12 +392,12 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
if ($this->block_size != 16) {
|
if ($this->block_size != 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->cipher_name_openssl_ecb = 'aes-' . ($this->key_size << 3) . '-ecb';
|
$this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb';
|
||||||
$this->cipher_name_openssl = 'aes-' . ($this->key_size << 3) . '-' . $this->_openssl_translate_mode();
|
$this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->_openssl_translate_mode();
|
||||||
break;
|
break;
|
||||||
case CRYPT_ENGINE_MCRYPT:
|
case CRYPT_ENGINE_MCRYPT:
|
||||||
$this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3);
|
$this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3);
|
||||||
if ($this->key_size % 8) { // is it a 160/224-bit key?
|
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
|
// mcrypt is not usable for them, only for 128/192/256-bit keys
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -427,24 +406,12 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
return parent::isValidEngine($engine);
|
return parent::isValidEngine($engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the CRYPT_ENGINE_MCRYPT $engine
|
|
||||||
*
|
|
||||||
* @see Crypt_Base::_setupMcrypt()
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function _setupMcrypt()
|
|
||||||
{
|
|
||||||
$this->key = str_pad(substr($this->key, 0, $this->key_size), $this->key_size, "\0");
|
|
||||||
parent::_setupMcrypt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a block
|
* Encrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -544,8 +511,8 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* Decrypts a block
|
* Decrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -649,15 +616,13 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000
|
0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->key = str_pad(substr($this->key, 0, $this->key_size), $this->key_size, "\0");
|
if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_length === $this->kl['key_length'] && $this->block_size === $this->kl['block_size']) {
|
||||||
|
|
||||||
if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_size === $this->kl['key_size'] && $this->block_size === $this->kl['block_size']) {
|
|
||||||
// already expanded
|
// already expanded
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->kl = array('key' => $this->key, 'key_size' => $this->key_size, 'block_size' => $this->block_size);
|
$this->kl = array('key' => $this->key, 'key_length' => $this->key_length, 'block_size' => $this->block_size);
|
||||||
|
|
||||||
$this->Nk = $this->key_size >> 2;
|
$this->Nk = $this->key_length >> 2;
|
||||||
// see Rijndael-ammended.pdf#page=44
|
// see Rijndael-ammended.pdf#page=44
|
||||||
$this->Nr = max($this->Nk, $this->Nb) + 6;
|
$this->Nr = max($this->Nk, $this->Nb) + 6;
|
||||||
|
|
||||||
|
@ -749,13 +714,13 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* Performs S-Box substitutions
|
* Performs S-Box substitutions
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $word
|
* @param int $word
|
||||||
*/
|
*/
|
||||||
function _subWord($word)
|
function _subWord($word)
|
||||||
{
|
{
|
||||||
static $sbox;
|
static $sbox;
|
||||||
if (empty($sbox)) {
|
if (empty($sbox)) {
|
||||||
list(,,,, $sbox) = $this->_getTables();
|
list(, , , , $sbox) = $this->_getTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sbox[$word & 0x000000FF] |
|
return $sbox[$word & 0x000000FF] |
|
||||||
|
@ -771,7 +736,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* @see Crypt_Rijndael:_setupInlineCrypt()
|
* @see Crypt_Rijndael:_setupInlineCrypt()
|
||||||
* @see Crypt_Rijndael:_subWord()
|
* @see Crypt_Rijndael:_subWord()
|
||||||
* @access private
|
* @access private
|
||||||
* @return Array &$tables
|
* @return array &$tables
|
||||||
*/
|
*/
|
||||||
function &_getTables()
|
function &_getTables()
|
||||||
{
|
{
|
||||||
|
@ -860,7 +825,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
* @see Crypt_Rijndael:_setupInlineCrypt()
|
* @see Crypt_Rijndael:_setupInlineCrypt()
|
||||||
* @see Crypt_Rijndael:_setupKey()
|
* @see Crypt_Rijndael:_setupKey()
|
||||||
* @access private
|
* @access private
|
||||||
* @return Array &$tables
|
* @return array &$tables
|
||||||
*/
|
*/
|
||||||
function &_getInvTables()
|
function &_getInvTables()
|
||||||
{
|
{
|
||||||
|
@ -954,7 +919,7 @@ class Crypt_Rijndael extends Crypt_Base
|
||||||
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
||||||
// (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit)
|
// (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit)
|
||||||
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
|
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
|
||||||
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
|
$gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
|
||||||
|
|
||||||
// Generation of a uniqe hash for our generated code
|
// Generation of a uniqe hash for our generated code
|
||||||
$code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}";
|
$code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}";
|
||||||
|
|
|
@ -61,7 +61,7 @@ if (!class_exists('Crypt_DES')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_TripleDES::Crypt_TripleDES()
|
* @see self::Crypt_TripleDES()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using inner chaining
|
* Encrypt / decrypt using inner chaining
|
||||||
|
@ -95,22 +95,20 @@ define('CRYPT_DES_MODE_CBC3', CRYPT_MODE_CBC3);
|
||||||
class Crypt_TripleDES extends Crypt_DES
|
class Crypt_TripleDES extends Crypt_DES
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The default password key_size used by setPassword()
|
* Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::password_key_size
|
* @see Crypt_TripleDES::setKeyLength()
|
||||||
* @see Crypt_Base::password_key_size
|
* @var int
|
||||||
* @see Crypt_Base::setPassword()
|
|
||||||
* @var Integer
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_key_size = 24;
|
var $key_length = 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default salt used by setPassword()
|
* The default salt used by setPassword()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::password_default_salt
|
* @see Crypt_Base::password_default_salt
|
||||||
* @see Crypt_Base::setPassword()
|
* @see Crypt_Base::setPassword()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $password_default_salt = 'phpseclib';
|
var $password_default_salt = 'phpseclib';
|
||||||
|
@ -120,7 +118,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::const_namespace
|
* @see Crypt_DES::const_namespace
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'DES';
|
var $const_namespace = 'DES';
|
||||||
|
@ -130,7 +128,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::cipher_name_mcrypt
|
* @see Crypt_DES::cipher_name_mcrypt
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'tripledes';
|
var $cipher_name_mcrypt = 'tripledes';
|
||||||
|
@ -139,7 +137,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
* Optimizing value while CFB-encrypting
|
* Optimizing value while CFB-encrypting
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cfb_init_len
|
* @see Crypt_Base::cfb_init_len
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 750;
|
var $cfb_init_len = 750;
|
||||||
|
@ -147,17 +145,17 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
/**
|
/**
|
||||||
* max possible size of $key
|
* max possible size of $key
|
||||||
*
|
*
|
||||||
* @see Crypt_TripleDES::setKey()
|
* @see self::setKey()
|
||||||
* @see Crypt_DES::setKey()
|
* @see Crypt_DES::setKey()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $key_size_max = 24;
|
var $key_length_max = 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal flag whether using CRYPT_DES_MODE_3CBC or not
|
* Internal flag whether using CRYPT_DES_MODE_3CBC or not
|
||||||
*
|
*
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $mode_3cbc;
|
var $mode_3cbc;
|
||||||
|
@ -167,7 +165,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* Used only if $mode_3cbc === true
|
* Used only if $mode_3cbc === true
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $des;
|
var $des;
|
||||||
|
@ -195,7 +193,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_DES::Crypt_DES()
|
* @see Crypt_DES::Crypt_DES()
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Crypt_TripleDES($mode = CRYPT_MODE_CBC)
|
function Crypt_TripleDES($mode = CRYPT_MODE_CBC)
|
||||||
|
@ -231,9 +229,9 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
* This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isValidEngine($engine)
|
function isValidEngine($engine)
|
||||||
{
|
{
|
||||||
|
@ -254,7 +252,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::setIV()
|
* @see Crypt_Base::setIV()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $iv
|
* @param string $iv
|
||||||
*/
|
*/
|
||||||
function setIV($iv)
|
function setIV($iv)
|
||||||
{
|
{
|
||||||
|
@ -266,6 +264,32 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the key length.
|
||||||
|
*
|
||||||
|
* Valid key lengths are 64, 128 and 192
|
||||||
|
*
|
||||||
|
* @see Crypt_Base:setKeyLength()
|
||||||
|
* @access public
|
||||||
|
* @param int $length
|
||||||
|
*/
|
||||||
|
function setKeyLength($length)
|
||||||
|
{
|
||||||
|
$length >>= 3;
|
||||||
|
switch (true) {
|
||||||
|
case $length <= 8:
|
||||||
|
$this->key_length = 8;
|
||||||
|
break;
|
||||||
|
case $length <= 16:
|
||||||
|
$this->key_length = 16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->key_length = 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setKeyLength($length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* Sets the key.
|
||||||
*
|
*
|
||||||
|
@ -279,11 +303,11 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_DES::setKey()
|
* @see Crypt_DES::setKey()
|
||||||
* @see Crypt_Base::setKey()
|
* @see Crypt_Base::setKey()
|
||||||
* @param String $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKey($key)
|
||||||
{
|
{
|
||||||
$length = strlen($key);
|
$length = $this->explicit_key_length ? $this->key_length : strlen($key);
|
||||||
if ($length > 8) {
|
if ($length > 8) {
|
||||||
$key = str_pad(substr($key, 0, 24), 24, chr(0));
|
$key = str_pad(substr($key, 0, 24), 24, chr(0));
|
||||||
// if $key is between 64 and 128-bits, use the first 64-bits as the last, per this:
|
// if $key is between 64 and 128-bits, use the first 64-bits as the last, per this:
|
||||||
|
@ -310,8 +334,8 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::encrypt()
|
* @see Crypt_Base::encrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $plaintext
|
* @param string $plaintext
|
||||||
* @return String $cipertext
|
* @return string $cipertext
|
||||||
*/
|
*/
|
||||||
function encrypt($plaintext)
|
function encrypt($plaintext)
|
||||||
{
|
{
|
||||||
|
@ -337,8 +361,8 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::decrypt()
|
* @see Crypt_Base::decrypt()
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $ciphertext
|
* @param string $ciphertext
|
||||||
* @return String $plaintext
|
* @return string $plaintext
|
||||||
*/
|
*/
|
||||||
function decrypt($ciphertext)
|
function decrypt($ciphertext)
|
||||||
{
|
{
|
||||||
|
@ -392,7 +416,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
* however, they are also less intuitive and more likely to cause you problems.
|
* however, they are also less intuitive and more likely to cause you problems.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::enableContinuousBuffer()
|
* @see Crypt_Base::enableContinuousBuffer()
|
||||||
* @see Crypt_TripleDES::disableContinuousBuffer()
|
* @see self::disableContinuousBuffer()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function enableContinuousBuffer()
|
function enableContinuousBuffer()
|
||||||
|
@ -411,7 +435,7 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
* The default behavior.
|
* The default behavior.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::disableContinuousBuffer()
|
* @see Crypt_Base::disableContinuousBuffer()
|
||||||
* @see Crypt_TripleDES::enableContinuousBuffer()
|
* @see self::enableContinuousBuffer()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function disableContinuousBuffer()
|
function disableContinuousBuffer()
|
||||||
|
@ -464,9 +488,9 @@ class Crypt_TripleDES extends Crypt_DES
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::Crypt_Base()
|
* @see Crypt_Base::Crypt_Base()
|
||||||
* @see Crypt_Base::setPreferredEngine()
|
* @see Crypt_Base::setPreferredEngine()
|
||||||
* @param Integer $engine
|
* @param int $engine
|
||||||
* @access public
|
* @access public
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function setPreferredEngine($engine)
|
function setPreferredEngine($engine)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,8 +64,8 @@ if (!class_exists('Crypt_Base')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Twofish::encrypt()
|
* @see self::encrypt()
|
||||||
* @see Crypt_Twofish::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Encrypt / decrypt using the Counter mode.
|
* Encrypt / decrypt using the Counter mode.
|
||||||
|
@ -115,7 +115,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* The namespace used by the cipher for its constants.
|
* The namespace used by the cipher for its constants.
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::const_namespace
|
* @see Crypt_Base::const_namespace
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $const_namespace = 'TWOFISH';
|
var $const_namespace = 'TWOFISH';
|
||||||
|
@ -124,7 +124,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* The mcrypt specific name of the cipher
|
* The mcrypt specific name of the cipher
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cipher_name_mcrypt
|
* @see Crypt_Base::cipher_name_mcrypt
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher_name_mcrypt = 'twofish';
|
var $cipher_name_mcrypt = 'twofish';
|
||||||
|
@ -133,7 +133,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* Optimizing value while CFB-encrypting
|
* Optimizing value while CFB-encrypting
|
||||||
*
|
*
|
||||||
* @see Crypt_Base::cfb_init_len
|
* @see Crypt_Base::cfb_init_len
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cfb_init_len = 800;
|
var $cfb_init_len = 800;
|
||||||
|
@ -141,10 +141,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Q-Table
|
* Q-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $q0 = array (
|
var $q0 = array(
|
||||||
0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76,
|
0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76,
|
||||||
0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38,
|
0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38,
|
||||||
0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
|
0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
|
||||||
|
@ -182,10 +182,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Q-Table
|
* Q-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $q1 = array (
|
var $q1 = array(
|
||||||
0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8,
|
0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8,
|
||||||
0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B,
|
0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B,
|
||||||
0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
|
0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
|
||||||
|
@ -223,10 +223,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* M-Table
|
* M-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $m0 = array (
|
var $m0 = array(
|
||||||
0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8,
|
0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8,
|
||||||
0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B,
|
0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B,
|
||||||
0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1,
|
0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1,
|
||||||
|
@ -264,10 +264,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* M-Table
|
* M-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $m1 = array (
|
var $m1 = array(
|
||||||
0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4,
|
0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4,
|
||||||
0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A,
|
0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A,
|
||||||
0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141,
|
0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141,
|
||||||
|
@ -305,10 +305,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* M-Table
|
* M-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $m2 = array (
|
var $m2 = array(
|
||||||
0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA,
|
0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA,
|
||||||
0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7,
|
0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7,
|
||||||
0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783,
|
0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783,
|
||||||
|
@ -346,10 +346,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* M-Table
|
* M-Table
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $m3 = array (
|
var $m3 = array(
|
||||||
0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF,
|
0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF,
|
||||||
0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836,
|
0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836,
|
||||||
0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77,
|
0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77,
|
||||||
|
@ -387,7 +387,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key Schedule Array
|
* The Key Schedule Array
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $K = array();
|
var $K = array();
|
||||||
|
@ -395,7 +395,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key depended S-Table 0
|
* The Key depended S-Table 0
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $S0 = array();
|
var $S0 = array();
|
||||||
|
@ -403,7 +403,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key depended S-Table 1
|
* The Key depended S-Table 1
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $S1 = array();
|
var $S1 = array();
|
||||||
|
@ -411,7 +411,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key depended S-Table 2
|
* The Key depended S-Table 2
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $S2 = array();
|
var $S2 = array();
|
||||||
|
@ -419,7 +419,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* The Key depended S-Table 3
|
* The Key depended S-Table 3
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $S3 = array();
|
var $S3 = array();
|
||||||
|
@ -427,41 +427,42 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
/**
|
/**
|
||||||
* Holds the last used key
|
* Holds the last used key
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $kl;
|
var $kl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the key.
|
* The Key Length (in bytes)
|
||||||
*
|
*
|
||||||
* Keys can be of any length. Twofish, itself, requires the use of a key that's 128, 192 or 256-bits long.
|
* @see Crypt_Twofish::setKeyLength()
|
||||||
* If the key is less than 256-bits we round the length up to the closest valid key length,
|
* @var int
|
||||||
* padding $key with null bytes. If the key is more than 256-bits, we trim the excess bits.
|
* @access private
|
||||||
|
*/
|
||||||
|
var $key_length = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the key length.
|
||||||
*
|
*
|
||||||
* If the key is not explicitly set, it'll be assumed a 128 bits key to be all null bytes.
|
* Valid key lengths are 128, 192 or 256 bits
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @see Crypt_Base::setKey()
|
* @param int $length
|
||||||
* @param String $key
|
|
||||||
*/
|
*/
|
||||||
function setKey($key)
|
function setKeyLength($length)
|
||||||
{
|
{
|
||||||
$keylength = strlen($key);
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $keylength <= 16:
|
case $length <= 128:
|
||||||
$key = str_pad($key, 16, "\0");
|
$this->key_length = 16;
|
||||||
break;
|
break;
|
||||||
case $keylength <= 24:
|
case $length <= 192:
|
||||||
$key = str_pad($key, 24, "\0");
|
$this->key_length = 24;
|
||||||
break;
|
break;
|
||||||
case $keylength < 32:
|
default:
|
||||||
$key = str_pad($key, 32, "\0");
|
$this->key_length = 32;
|
||||||
break;
|
|
||||||
case $keylength > 32:
|
|
||||||
$key = substr($key, 0, 32);
|
|
||||||
}
|
}
|
||||||
parent::setKey($key);
|
|
||||||
|
parent::setKeyLength($length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,9 +493,9 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
|
|
||||||
switch (strlen($this->key)) {
|
switch (strlen($this->key)) {
|
||||||
case 16:
|
case 16:
|
||||||
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
||||||
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
||||||
for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) {
|
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
|
||||||
$A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^
|
$A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^
|
||||||
$m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
|
$m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
|
||||||
$m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
|
$m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
|
||||||
|
@ -515,9 +516,9 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
||||||
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
||||||
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]);
|
list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]);
|
||||||
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
|
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
|
||||||
$A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
|
$A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
|
||||||
$m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
|
$m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
|
||||||
|
@ -539,10 +540,10 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: // 32
|
default: // 32
|
||||||
list ($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
list($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]);
|
||||||
list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]);
|
||||||
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]);
|
list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]);
|
||||||
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]);
|
list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]);
|
||||||
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
|
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
|
||||||
$A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
|
$A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
|
||||||
$m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
|
$m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
|
||||||
|
@ -575,9 +576,9 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* _mdsrem function using by the twofish cipher algorithm
|
* _mdsrem function using by the twofish cipher algorithm
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $A
|
* @param string $A
|
||||||
* @param String $B
|
* @param string $B
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _mdsrem($A, $B)
|
function _mdsrem($A, $B)
|
||||||
{
|
{
|
||||||
|
@ -623,8 +624,8 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* Encrypts a block
|
* Encrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encryptBlock($in)
|
function _encryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -679,8 +680,8 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
* Decrypts a block
|
* Decrypts a block
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decryptBlock($in)
|
function _decryptBlock($in)
|
||||||
{
|
{
|
||||||
|
@ -743,7 +744,7 @@ class Crypt_Twofish extends Crypt_Base
|
||||||
|
|
||||||
// Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one.
|
// Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one.
|
||||||
// (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit)
|
// (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit)
|
||||||
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
|
$gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
|
||||||
|
|
||||||
// Generation of a uniqe hash for our generated code
|
// Generation of a uniqe hash for our generated code
|
||||||
$code_hash = "Crypt_Twofish, {$this->mode}";
|
$code_hash = "Crypt_Twofish, {$this->mode}";
|
||||||
|
|
|
@ -48,7 +48,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Max Width
|
* Max Width
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $max_x;
|
var $max_x;
|
||||||
|
@ -56,7 +56,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Max Height
|
* Max Height
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $max_y;
|
var $max_y;
|
||||||
|
@ -64,7 +64,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Max History
|
* Max History
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $max_history;
|
var $max_history;
|
||||||
|
@ -72,7 +72,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* History
|
* History
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $history;
|
var $history;
|
||||||
|
@ -80,7 +80,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* History Attributes
|
* History Attributes
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $history_attrs;
|
var $history_attrs;
|
||||||
|
@ -88,7 +88,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Current Column
|
* Current Column
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $x;
|
var $x;
|
||||||
|
@ -96,7 +96,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Current Row
|
* Current Row
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $y;
|
var $y;
|
||||||
|
@ -104,7 +104,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Old Column
|
* Old Column
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $old_x;
|
var $old_x;
|
||||||
|
@ -112,7 +112,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Old Row
|
* Old Row
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $old_y;
|
var $old_y;
|
||||||
|
@ -120,7 +120,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* An empty attribute cell
|
* An empty attribute cell
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $base_attr_cell;
|
var $base_attr_cell;
|
||||||
|
@ -128,7 +128,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* The current attribute cell
|
* The current attribute cell
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $attr_cell;
|
var $attr_cell;
|
||||||
|
@ -136,7 +136,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* An empty attribute row
|
* An empty attribute row
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $attr_row;
|
var $attr_row;
|
||||||
|
@ -144,7 +144,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* The current screen text
|
* The current screen text
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $screen;
|
var $screen;
|
||||||
|
@ -152,7 +152,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* The current screen attributes
|
* The current screen attributes
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $attrs;
|
var $attrs;
|
||||||
|
@ -160,7 +160,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Current ANSI code
|
* Current ANSI code
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $ansi;
|
var $ansi;
|
||||||
|
@ -168,7 +168,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Tokenization
|
* Tokenization
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $tokenization;
|
var $tokenization;
|
||||||
|
@ -200,8 +200,8 @@ class File_ANSI
|
||||||
*
|
*
|
||||||
* Resets the screen as well
|
* Resets the screen as well
|
||||||
*
|
*
|
||||||
* @param Integer $x
|
* @param int $x
|
||||||
* @param Integer $y
|
* @param int $y
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setDimensions($x, $y)
|
function setDimensions($x, $y)
|
||||||
|
@ -219,8 +219,8 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Set the number of lines that should be logged past the terminal height
|
* Set the number of lines that should be logged past the terminal height
|
||||||
*
|
*
|
||||||
* @param Integer $x
|
* @param int $x
|
||||||
* @param Integer $y
|
* @param int $y
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setHistory($history)
|
function setHistory($history)
|
||||||
|
@ -231,7 +231,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Load a string
|
* Load a string
|
||||||
*
|
*
|
||||||
* @param String $source
|
* @param string $source
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function loadString($source)
|
function loadString($source)
|
||||||
|
@ -243,7 +243,7 @@ class File_ANSI
|
||||||
/**
|
/**
|
||||||
* Appdend a string
|
* Appdend a string
|
||||||
*
|
*
|
||||||
* @param String $source
|
* @param string $source
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function appendString($source)
|
function appendString($source)
|
||||||
|
@ -474,7 +474,7 @@ class File_ANSI
|
||||||
* Returns the current coordinate without preformating
|
* Returns the current coordinate without preformating
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _processCoordinate($last_attr, $cur_attr, $char)
|
function _processCoordinate($last_attr, $cur_attr, $char)
|
||||||
{
|
{
|
||||||
|
@ -531,7 +531,7 @@ class File_ANSI
|
||||||
* Returns the current screen without preformating
|
* Returns the current screen without preformating
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _getScreen()
|
function _getScreen()
|
||||||
{
|
{
|
||||||
|
@ -555,7 +555,7 @@ class File_ANSI
|
||||||
* Returns the current screen
|
* Returns the current screen
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getScreen()
|
function getScreen()
|
||||||
{
|
{
|
||||||
|
@ -566,7 +566,7 @@ class File_ANSI
|
||||||
* Returns the current screen and the x previous lines
|
* Returns the current screen and the x previous lines
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getHistory()
|
function getHistory()
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ class File_ASN1_Element
|
||||||
/**
|
/**
|
||||||
* Raw element value
|
* Raw element value
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $element;
|
var $element;
|
||||||
|
@ -127,7 +127,7 @@ class File_ASN1_Element
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param String $encoded
|
* @param string $encoded
|
||||||
* @return File_ASN1_Element
|
* @return File_ASN1_Element
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +149,7 @@ class File_ASN1
|
||||||
/**
|
/**
|
||||||
* ASN.1 object identifier
|
* ASN.1 object identifier
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
* @link http://en.wikipedia.org/wiki/Object_identifier
|
* @link http://en.wikipedia.org/wiki/Object_identifier
|
||||||
*/
|
*/
|
||||||
|
@ -158,7 +158,7 @@ class File_ASN1
|
||||||
/**
|
/**
|
||||||
* Default date format
|
* Default date format
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
* @link http://php.net/class.datetime
|
* @link http://php.net/class.datetime
|
||||||
*/
|
*/
|
||||||
|
@ -167,10 +167,10 @@ class File_ASN1
|
||||||
/**
|
/**
|
||||||
* Default date format
|
* Default date format
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
* @see File_ASN1::setTimeFormat()
|
* @see self::setTimeFormat()
|
||||||
* @see File_ASN1::asn1map()
|
* @see self::asn1map()
|
||||||
* @link http://php.net/class.datetime
|
* @link http://php.net/class.datetime
|
||||||
*/
|
*/
|
||||||
var $encoded;
|
var $encoded;
|
||||||
|
@ -180,9 +180,9 @@ class File_ASN1
|
||||||
*
|
*
|
||||||
* If the mapping type is FILE_ASN1_TYPE_ANY what do we actually encode it as?
|
* If the mapping type is FILE_ASN1_TYPE_ANY what do we actually encode it as?
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
* @see File_ASN1::_encode_der()
|
* @see self::_encode_der()
|
||||||
*/
|
*/
|
||||||
var $filters;
|
var $filters;
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class File_ASN1
|
||||||
* Unambiguous types get the direct mapping (int/real/bool).
|
* Unambiguous types get the direct mapping (int/real/bool).
|
||||||
* Others are mapped as a choice, with an extra indexing level.
|
* Others are mapped as a choice, with an extra indexing level.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $ANYmap = array(
|
var $ANYmap = array(
|
||||||
|
@ -227,7 +227,7 @@ class File_ASN1
|
||||||
* Non-convertable types are absent from this table.
|
* Non-convertable types are absent from this table.
|
||||||
* size == 0 indicates variable length encoding.
|
* size == 0 indicates variable length encoding.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $stringTypeSize = array(
|
var $stringTypeSize = array(
|
||||||
|
@ -261,8 +261,8 @@ class File_ASN1
|
||||||
*
|
*
|
||||||
* Serves a similar purpose to openssl's asn1parse
|
* Serves a similar purpose to openssl's asn1parse
|
||||||
*
|
*
|
||||||
* @param String $encoded
|
* @param string $encoded
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function decodeBER($encoded)
|
function decodeBER($encoded)
|
||||||
|
@ -283,9 +283,9 @@ class File_ASN1
|
||||||
* $encoded is passed by reference for the recursive calls done for FILE_ASN1_TYPE_BIT_STRING and
|
* $encoded is passed by reference for the recursive calls done for FILE_ASN1_TYPE_BIT_STRING and
|
||||||
* FILE_ASN1_TYPE_OCTET_STRING. In those cases, the indefinite length is used.
|
* FILE_ASN1_TYPE_OCTET_STRING. In those cases, the indefinite length is used.
|
||||||
*
|
*
|
||||||
* @param String $encoded
|
* @param string $encoded
|
||||||
* @param Integer $start
|
* @param int $start
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _decode_ber($encoded, $start = 0)
|
function _decode_ber($encoded, $start = 0)
|
||||||
|
@ -543,10 +543,10 @@ class File_ASN1
|
||||||
*
|
*
|
||||||
* "Special" mappings may be applied on a per tag-name basis via $special.
|
* "Special" mappings may be applied on a per tag-name basis via $special.
|
||||||
*
|
*
|
||||||
* @param Array $decoded
|
* @param array $decoded
|
||||||
* @param Array $mapping
|
* @param array $mapping
|
||||||
* @param Array $special
|
* @param array $special
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function asn1map($decoded, $mapping, $special = array())
|
function asn1map($decoded, $mapping, $special = array())
|
||||||
|
@ -677,7 +677,7 @@ class File_ASN1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail mapping if all input items have not been consumed.
|
// Fail mapping if all input items have not been consumed.
|
||||||
return $i < $n? null: $map;
|
return $i < $n ? null: $map;
|
||||||
|
|
||||||
// the main diff between sets and sequences is the encapsulation of the foreach in another for loop
|
// the main diff between sets and sequences is the encapsulation of the foreach in another for loop
|
||||||
case FILE_ASN1_TYPE_SET:
|
case FILE_ASN1_TYPE_SET:
|
||||||
|
@ -835,10 +835,10 @@ class File_ASN1
|
||||||
*
|
*
|
||||||
* "Special" mappings can be applied via $special.
|
* "Special" mappings can be applied via $special.
|
||||||
*
|
*
|
||||||
* @param String $source
|
* @param string $source
|
||||||
* @param String $mapping
|
* @param string $mapping
|
||||||
* @param Integer $idx
|
* @param int $idx
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function encodeDER($source, $mapping, $special = array())
|
function encodeDER($source, $mapping, $special = array())
|
||||||
|
@ -850,10 +850,10 @@ class File_ASN1
|
||||||
/**
|
/**
|
||||||
* ASN.1 Encode (Helper function)
|
* ASN.1 Encode (Helper function)
|
||||||
*
|
*
|
||||||
* @param String $source
|
* @param string $source
|
||||||
* @param String $mapping
|
* @param string $mapping
|
||||||
* @param Integer $idx
|
* @param int $idx
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _encode_der($source, $mapping, $idx = null, $special = array())
|
function _encode_der($source, $mapping, $idx = null, $special = array())
|
||||||
|
@ -1150,8 +1150,8 @@ class File_ASN1
|
||||||
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encodeLength($length)
|
function _encodeLength($length)
|
||||||
{
|
{
|
||||||
|
@ -1169,9 +1169,9 @@ class File_ASN1
|
||||||
* Called by _decode_ber() and in the case of implicit tags asn1map().
|
* Called by _decode_ber() and in the case of implicit tags asn1map().
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $content
|
* @param string $content
|
||||||
* @param Integer $tag
|
* @param int $tag
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _decodeTime($content, $tag)
|
function _decodeTime($content, $tag)
|
||||||
{
|
{
|
||||||
|
@ -1218,7 +1218,7 @@ class File_ASN1
|
||||||
* Sets the time / date format for asn1map().
|
* Sets the time / date format for asn1map().
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param String $format
|
* @param string $format
|
||||||
*/
|
*/
|
||||||
function setTimeFormat($format)
|
function setTimeFormat($format)
|
||||||
{
|
{
|
||||||
|
@ -1231,7 +1231,7 @@ class File_ASN1
|
||||||
* Load the relevant OIDs for a particular ASN.1 semantic mapping.
|
* Load the relevant OIDs for a particular ASN.1 semantic mapping.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Array $oids
|
* @param array $oids
|
||||||
*/
|
*/
|
||||||
function loadOIDs($oids)
|
function loadOIDs($oids)
|
||||||
{
|
{
|
||||||
|
@ -1244,7 +1244,7 @@ class File_ASN1
|
||||||
* See File_X509, etc, for an example.
|
* See File_X509, etc, for an example.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Array $filters
|
* @param array $filters
|
||||||
*/
|
*/
|
||||||
function loadFilters($filters)
|
function loadFilters($filters)
|
||||||
{
|
{
|
||||||
|
@ -1256,9 +1256,9 @@ class File_ASN1
|
||||||
*
|
*
|
||||||
* Inspired by array_shift
|
* Inspired by array_shift
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _string_shift(&$string, $index = 1)
|
function _string_shift(&$string, $index = 1)
|
||||||
|
@ -1274,10 +1274,10 @@ class File_ASN1
|
||||||
* This is a lazy conversion, dealing only with character size.
|
* This is a lazy conversion, dealing only with character size.
|
||||||
* No real conversion table is used.
|
* No real conversion table is used.
|
||||||
*
|
*
|
||||||
* @param String $in
|
* @param string $in
|
||||||
* @param optional Integer $from
|
* @param int $from
|
||||||
* @param optional Integer $to
|
* @param int $to
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function convert($in, $from = FILE_ASN1_TYPE_UTF8_STRING, $to = FILE_ASN1_TYPE_UTF8_STRING)
|
function convert($in, $from = FILE_ASN1_TYPE_UTF8_STRING, $to = FILE_ASN1_TYPE_UTF8_STRING)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -72,27 +72,27 @@
|
||||||
* Reduction constants
|
* Reduction constants
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @see Math_BigInteger::_reduce()
|
* @see self::_reduce()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @see Math_BigInteger::_montgomery()
|
* @see self::_montgomery()
|
||||||
* @see Math_BigInteger::_prepMontgomery()
|
* @see self::_prepMontgomery()
|
||||||
*/
|
*/
|
||||||
define('MATH_BIGINTEGER_MONTGOMERY', 0);
|
define('MATH_BIGINTEGER_MONTGOMERY', 0);
|
||||||
/**
|
/**
|
||||||
* @see Math_BigInteger::_barrett()
|
* @see self::_barrett()
|
||||||
*/
|
*/
|
||||||
define('MATH_BIGINTEGER_BARRETT', 1);
|
define('MATH_BIGINTEGER_BARRETT', 1);
|
||||||
/**
|
/**
|
||||||
* @see Math_BigInteger::_mod2()
|
* @see self::_mod2()
|
||||||
*/
|
*/
|
||||||
define('MATH_BIGINTEGER_POWEROF2', 2);
|
define('MATH_BIGINTEGER_POWEROF2', 2);
|
||||||
/**
|
/**
|
||||||
* @see Math_BigInteger::_remainder()
|
* @see self::_remainder()
|
||||||
*/
|
*/
|
||||||
define('MATH_BIGINTEGER_CLASSIC', 3);
|
define('MATH_BIGINTEGER_CLASSIC', 3);
|
||||||
/**
|
/**
|
||||||
* @see Math_BigInteger::__clone()
|
* @see self::__clone()
|
||||||
*/
|
*/
|
||||||
define('MATH_BIGINTEGER_NONE', 4);
|
define('MATH_BIGINTEGER_NONE', 4);
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
@ -117,8 +117,8 @@ define('MATH_BIGINTEGER_SIGN', 1);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Math_BigInteger::_montgomery()
|
* @see self::_montgomery()
|
||||||
* @see Math_BigInteger::_barrett()
|
* @see self::_barrett()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Cache constants
|
* Cache constants
|
||||||
|
@ -136,7 +136,7 @@ define('MATH_BIGINTEGER_DATA', 1);
|
||||||
* Mode constants.
|
* Mode constants.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @see Math_BigInteger::Math_BigInteger()
|
* @see self::Math_BigInteger()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* To use the pure-PHP implementation
|
* To use the pure-PHP implementation
|
||||||
|
@ -178,7 +178,7 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Holds the BigInteger's value.
|
* Holds the BigInteger's value.
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $value;
|
var $value;
|
||||||
|
@ -186,23 +186,15 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Holds the BigInteger's magnitude.
|
* Holds the BigInteger's magnitude.
|
||||||
*
|
*
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $is_negative = false;
|
var $is_negative = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Random number generator function
|
|
||||||
*
|
|
||||||
* @see setRandomGenerator()
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $generator = 'mt_rand';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Precision
|
* Precision
|
||||||
*
|
*
|
||||||
* @see setPrecision()
|
* @see self::setPrecision()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $precision = -1;
|
var $precision = -1;
|
||||||
|
@ -210,7 +202,7 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Precision Bitmask
|
* Precision Bitmask
|
||||||
*
|
*
|
||||||
* @see setPrecision()
|
* @see self::setPrecision()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $bitmask = false;
|
var $bitmask = false;
|
||||||
|
@ -222,9 +214,9 @@ class Math_BigInteger
|
||||||
* a variable that'll be serializable regardless of whether or not extensions are being used. Unlike $this->value,
|
* a variable that'll be serializable regardless of whether or not extensions are being used. Unlike $this->value,
|
||||||
* however, $this->hex is only calculated when $this->__sleep() is called.
|
* however, $this->hex is only calculated when $this->__sleep() is called.
|
||||||
*
|
*
|
||||||
* @see __sleep()
|
* @see self::__sleep()
|
||||||
* @see __wakeup()
|
* @see self::__wakeup()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $hex;
|
var $hex;
|
||||||
|
@ -246,8 +238,8 @@ class Math_BigInteger
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param optional $x base-10 number or base-$base number if $base set.
|
* @param $x base-10 number or base-$base number if $base set.
|
||||||
* @param optional integer $base
|
* @param int $base
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -266,7 +258,7 @@ class Math_BigInteger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('openssl_public_encrypt') && !defined('MATH_BIGINTEGER_OPENSSL_DISABLE') && !defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
|
if (extension_loaded('openssl') && !defined('MATH_BIGINTEGER_OPENSSL_DISABLE') && !defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
|
||||||
// some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work
|
// some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work
|
||||||
ob_start();
|
ob_start();
|
||||||
@phpinfo();
|
@phpinfo();
|
||||||
|
@ -423,13 +415,13 @@ class Math_BigInteger
|
||||||
$this->is_negative = false;
|
$this->is_negative = false;
|
||||||
break;
|
break;
|
||||||
case MATH_BIGINTEGER_MODE_BCMATH:
|
case MATH_BIGINTEGER_MODE_BCMATH:
|
||||||
$x = ( strlen($x) & 1 ) ? '0' . $x : $x;
|
$x = (strlen($x) & 1) ? '0' . $x : $x;
|
||||||
$temp = new Math_BigInteger(pack('H*', $x), 256);
|
$temp = new Math_BigInteger(pack('H*', $x), 256);
|
||||||
$this->value = $this->is_negative ? '-' . $temp->value : $temp->value;
|
$this->value = $this->is_negative ? '-' . $temp->value : $temp->value;
|
||||||
$this->is_negative = false;
|
$this->is_negative = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$x = ( strlen($x) & 1 ) ? '0' . $x : $x;
|
$x = (strlen($x) & 1) ? '0' . $x : $x;
|
||||||
$temp = new Math_BigInteger(pack('H*', $x), 256);
|
$temp = new Math_BigInteger(pack('H*', $x), 256);
|
||||||
$this->value = $temp->value;
|
$this->value = $temp->value;
|
||||||
}
|
}
|
||||||
|
@ -524,8 +516,8 @@ class Math_BigInteger
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param Boolean $twos_compliment
|
* @param bool $twos_compliment
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Converts a base-2**26 number to base-2**8
|
* @internal Converts a base-2**26 number to base-2**8
|
||||||
*/
|
*/
|
||||||
|
@ -558,7 +550,7 @@ class Math_BigInteger
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = gmp_strval(gmp_abs($this->value), 16);
|
$temp = gmp_strval(gmp_abs($this->value), 16);
|
||||||
$temp = ( strlen($temp) & 1 ) ? '0' . $temp : $temp;
|
$temp = (strlen($temp) & 1) ? '0' . $temp : $temp;
|
||||||
$temp = pack('H*', $temp);
|
$temp = pack('H*', $temp);
|
||||||
|
|
||||||
return $this->precision > 0 ?
|
return $this->precision > 0 ?
|
||||||
|
@ -621,8 +613,8 @@ class Math_BigInteger
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param Boolean $twos_compliment
|
* @param bool $twos_compliment
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Converts a base-2**26 number to base-2**8
|
* @internal Converts a base-2**26 number to base-2**8
|
||||||
*/
|
*/
|
||||||
|
@ -648,8 +640,8 @@ class Math_BigInteger
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param Boolean $twos_compliment
|
* @param bool $twos_compliment
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Converts a base-2**26 number to base-2**2
|
* @internal Converts a base-2**26 number to base-2**2
|
||||||
*/
|
*/
|
||||||
|
@ -686,7 +678,7 @@ class Math_BigInteger
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Converts a base-2**26 number to base-10**7 (which is pretty much base-10)
|
* @internal Converts a base-2**26 number to base-10**7 (which is pretty much base-10)
|
||||||
*/
|
*/
|
||||||
|
@ -738,7 +730,7 @@ class Math_BigInteger
|
||||||
* {@link http://php.net/language.oop5.basic#51624}
|
* {@link http://php.net/language.oop5.basic#51624}
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @see __clone()
|
* @see self::__clone()
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
*/
|
*/
|
||||||
function copy()
|
function copy()
|
||||||
|
@ -746,7 +738,6 @@ class Math_BigInteger
|
||||||
$temp = new Math_BigInteger();
|
$temp = new Math_BigInteger();
|
||||||
$temp->value = $this->value;
|
$temp->value = $this->value;
|
||||||
$temp->is_negative = $this->is_negative;
|
$temp->is_negative = $this->is_negative;
|
||||||
$temp->generator = $this->generator;
|
|
||||||
$temp->precision = $this->precision;
|
$temp->precision = $this->precision;
|
||||||
$temp->bitmask = $this->bitmask;
|
$temp->bitmask = $this->bitmask;
|
||||||
return $temp;
|
return $temp;
|
||||||
|
@ -775,7 +766,7 @@ class Math_BigInteger
|
||||||
* call Math_BigInteger::copy(), instead.
|
* call Math_BigInteger::copy(), instead.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @see copy()
|
* @see self::copy()
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
*/
|
*/
|
||||||
function __clone()
|
function __clone()
|
||||||
|
@ -788,21 +779,17 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Will be called, automatically, when serialize() is called on a Math_BigInteger object.
|
* Will be called, automatically, when serialize() is called on a Math_BigInteger object.
|
||||||
*
|
*
|
||||||
* @see __wakeup()
|
* @see self::__wakeup()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __sleep()
|
function __sleep()
|
||||||
{
|
{
|
||||||
$this->hex = $this->toHex(true);
|
$this->hex = $this->toHex(true);
|
||||||
$vars = array('hex');
|
$vars = array('hex');
|
||||||
if ($this->generator != 'mt_rand') {
|
|
||||||
$vars[] = 'generator';
|
|
||||||
}
|
|
||||||
if ($this->precision > 0) {
|
if ($this->precision > 0) {
|
||||||
$vars[] = 'precision';
|
$vars[] = 'precision';
|
||||||
}
|
}
|
||||||
return $vars;
|
return $vars;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -810,7 +797,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Will be called, automatically, when unserialize() is called on a Math_BigInteger object.
|
* Will be called, automatically, when unserialize() is called on a Math_BigInteger object.
|
||||||
*
|
*
|
||||||
* @see __sleep()
|
* @see self::__sleep()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __wakeup()
|
function __wakeup()
|
||||||
|
@ -818,13 +805,45 @@ class Math_BigInteger
|
||||||
$temp = new Math_BigInteger($this->hex, -16);
|
$temp = new Math_BigInteger($this->hex, -16);
|
||||||
$this->value = $temp->value;
|
$this->value = $temp->value;
|
||||||
$this->is_negative = $temp->is_negative;
|
$this->is_negative = $temp->is_negative;
|
||||||
$this->setRandomGenerator($this->generator);
|
|
||||||
if ($this->precision > 0) {
|
if ($this->precision > 0) {
|
||||||
// recalculate $this->bitmask
|
// recalculate $this->bitmask
|
||||||
$this->setPrecision($this->precision);
|
$this->setPrecision($this->precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __debugInfo() magic method
|
||||||
|
*
|
||||||
|
* Will be called, automatically, when print_r() or var_dump() are called
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function __debugInfo()
|
||||||
|
{
|
||||||
|
$opts = array();
|
||||||
|
switch (MATH_BIGINTEGER_MODE) {
|
||||||
|
case MATH_BIGINTEGER_MODE_GMP:
|
||||||
|
$engine = 'gmp';
|
||||||
|
break;
|
||||||
|
case MATH_BIGINTEGER_MODE_BCMATH:
|
||||||
|
$engine = 'bcmath';
|
||||||
|
break;
|
||||||
|
case MATH_BIGINTEGER_MODE_INTERNAL:
|
||||||
|
$engine = 'internal';
|
||||||
|
$opts[] = PHP_INT_SIZE == 8 ? '64-bit' : '32-bit';
|
||||||
|
}
|
||||||
|
if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_GMP && defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
|
||||||
|
$opts[] = 'OpenSSL';
|
||||||
|
}
|
||||||
|
if (!empty($opts)) {
|
||||||
|
$engine.= ' (' . implode($opts, ', ') . ')';
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'value' => '0x' . $this->toHex(true),
|
||||||
|
'engine' => $engine
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds two BigIntegers.
|
* Adds two BigIntegers.
|
||||||
*
|
*
|
||||||
|
@ -874,11 +893,11 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Performs addition.
|
* Performs addition.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Boolean $x_negative
|
* @param bool $x_negative
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @param Boolean $y_negative
|
* @param bool $y_negative
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _add($x_value, $x_negative, $y_value, $y_negative)
|
function _add($x_value, $x_negative, $y_value, $y_negative)
|
||||||
|
@ -1005,11 +1024,11 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Performs subtraction.
|
* Performs subtraction.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Boolean $x_negative
|
* @param bool $x_negative
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @param Boolean $y_negative
|
* @param bool $y_negative
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _subtract($x_value, $x_negative, $y_value, $y_negative)
|
function _subtract($x_value, $x_negative, $y_value, $y_negative)
|
||||||
|
@ -1140,11 +1159,11 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Performs multiplication.
|
* Performs multiplication.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Boolean $x_negative
|
* @param bool $x_negative
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @param Boolean $y_negative
|
* @param bool $y_negative
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _multiply($x_value, $x_negative, $y_value, $y_negative)
|
function _multiply($x_value, $x_negative, $y_value, $y_negative)
|
||||||
|
@ -1179,9 +1198,9 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Modeled after 'multiply' in MutableBigInteger.java.
|
* Modeled after 'multiply' in MutableBigInteger.java.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _regularMultiply($x_value, $y_value)
|
function _regularMultiply($x_value, $y_value)
|
||||||
|
@ -1243,9 +1262,9 @@ class Math_BigInteger
|
||||||
* See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and
|
* See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and
|
||||||
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}.
|
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _karatsuba($x_value, $y_value)
|
function _karatsuba($x_value, $y_value)
|
||||||
|
@ -1282,8 +1301,8 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Performs squaring
|
* Performs squaring
|
||||||
*
|
*
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _square($x = false)
|
function _square($x = false)
|
||||||
|
@ -1300,8 +1319,8 @@ class Math_BigInteger
|
||||||
* {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} /
|
* {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} /
|
||||||
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information.
|
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information.
|
||||||
*
|
*
|
||||||
* @param Array $value
|
* @param array $value
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _baseSquare($value)
|
function _baseSquare($value)
|
||||||
|
@ -1339,8 +1358,8 @@ class Math_BigInteger
|
||||||
* See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and
|
* See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and
|
||||||
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}.
|
* {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}.
|
||||||
*
|
*
|
||||||
* @param Array $value
|
* @param array $value
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _karatsubaSquare($value)
|
function _karatsubaSquare($value)
|
||||||
|
@ -1396,7 +1415,7 @@ class Math_BigInteger
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $y
|
* @param Math_BigInteger $y
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
* @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}.
|
* @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}.
|
||||||
*/
|
*/
|
||||||
|
@ -1512,7 +1531,7 @@ class Math_BigInteger
|
||||||
);
|
);
|
||||||
$y_window = array(
|
$y_window = array(
|
||||||
$y_value[$y_max],
|
$y_value[$y_max],
|
||||||
( $y_max > 0 ) ? $y_value[$y_max - 1] : 0
|
($y_max > 0) ? $y_value[$y_max - 1] : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
$q_index = $i - $y_max - 1;
|
$q_index = $i - $y_max - 1;
|
||||||
|
@ -1576,9 +1595,9 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* abc / x = a00 / x + b0 / x + c / x
|
* abc / x = a00 / x + b0 / x + c / x
|
||||||
*
|
*
|
||||||
* @param Array $dividend
|
* @param array $dividend
|
||||||
* @param Array $divisor
|
* @param array $divisor
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _divide_digit($dividend, $divisor)
|
function _divide_digit($dividend, $divisor)
|
||||||
|
@ -1760,7 +1779,7 @@ class Math_BigInteger
|
||||||
$mod2->value = array(1);
|
$mod2->value = array(1);
|
||||||
$mod2->_lshift($j);
|
$mod2->_lshift($j);
|
||||||
|
|
||||||
$part1 = ( $mod1->value != array(1) ) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger();
|
$part1 = ($mod1->value != array(1)) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger();
|
||||||
$part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2);
|
$part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2);
|
||||||
|
|
||||||
$y1 = $mod2->modInverse($mod1);
|
$y1 = $mod2->modInverse($mod1);
|
||||||
|
@ -1803,7 +1822,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $e
|
* @param Math_BigInteger $e
|
||||||
* @param Math_BigInteger $n
|
* @param Math_BigInteger $n
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -1855,13 +1874,14 @@ class Math_BigInteger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($k = 0; $k <= $j; ++$k) {// eg. the length of substr($e_bits, $i, $j+1)
|
// eg. the length of substr($e_bits, $i, $j + 1)
|
||||||
|
for ($k = 0; $k <= $j; ++$k) {
|
||||||
$result = $this->_squareReduce($result, $n_value, $mode);
|
$result = $this->_squareReduce($result, $n_value, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode);
|
$result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode);
|
||||||
|
|
||||||
$i+=$j + 1;
|
$i += $j + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1876,12 +1896,12 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* For most $modes this will return the remainder.
|
* For most $modes this will return the remainder.
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _reduce($x, $n, $mode)
|
function _reduce($x, $n, $mode)
|
||||||
{
|
{
|
||||||
|
@ -1913,12 +1933,12 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Modular reduction preperation
|
* Modular reduction preperation
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _prepareReduce($x, $n, $mode)
|
function _prepareReduce($x, $n, $mode)
|
||||||
{
|
{
|
||||||
|
@ -1931,13 +1951,13 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Modular multiply
|
* Modular multiply
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $y
|
* @param array $y
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _multiplyReduce($x, $y, $n, $mode)
|
function _multiplyReduce($x, $y, $n, $mode)
|
||||||
{
|
{
|
||||||
|
@ -1951,12 +1971,12 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Modular square
|
* Modular square
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _squareReduce($x, $n, $mode)
|
function _squareReduce($x, $n, $mode)
|
||||||
{
|
{
|
||||||
|
@ -1972,7 +1992,7 @@ class Math_BigInteger
|
||||||
* Calculates $x%$n, where $n = 2**$e, for some $e. Since this is basically the same as doing $x & ($n-1),
|
* Calculates $x%$n, where $n = 2**$e, for some $e. Since this is basically the same as doing $x & ($n-1),
|
||||||
* we'll just use this function as a wrapper for doing that.
|
* we'll just use this function as a wrapper for doing that.
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Math_BigInteger
|
* @param Math_BigInteger
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
|
@ -2002,11 +2022,11 @@ class Math_BigInteger
|
||||||
* (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line
|
* (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line
|
||||||
* comments for details.
|
* comments for details.
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @param Array $m
|
* @param array $m
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _barrett($n, $m)
|
function _barrett($n, $m)
|
||||||
{
|
{
|
||||||
|
@ -2099,11 +2119,11 @@ class Math_BigInteger
|
||||||
* For numbers with more than four digits Math_BigInteger::_barrett() is faster. The difference between that and this
|
* For numbers with more than four digits Math_BigInteger::_barrett() is faster. The difference between that and this
|
||||||
* is that this function does not fold the denominator into a smaller form.
|
* is that this function does not fold the denominator into a smaller form.
|
||||||
*
|
*
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _regularBarrett($x, $n)
|
function _regularBarrett($x, $n)
|
||||||
{
|
{
|
||||||
|
@ -2170,13 +2190,13 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved.
|
* If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved.
|
||||||
*
|
*
|
||||||
* @see _regularBarrett()
|
* @see self::_regularBarrett()
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Boolean $x_negative
|
* @param bool $x_negative
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @param Boolean $y_negative
|
* @param bool $y_negative
|
||||||
* @param Integer $stop
|
* @param int $stop
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _multiplyLower($x_value, $x_negative, $y_value, $y_negative, $stop)
|
function _multiplyLower($x_value, $x_negative, $y_value, $y_negative, $stop)
|
||||||
|
@ -2251,12 +2271,12 @@ class Math_BigInteger
|
||||||
* improved upon (basically, by using the comba method). gcd($n, 2) must be equal to one for this function
|
* improved upon (basically, by using the comba method). gcd($n, 2) must be equal to one for this function
|
||||||
* to work correctly.
|
* to work correctly.
|
||||||
*
|
*
|
||||||
* @see _prepMontgomery()
|
* @see self::_prepMontgomery()
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _montgomery($x, $n)
|
function _montgomery($x, $n)
|
||||||
{
|
{
|
||||||
|
@ -2298,13 +2318,13 @@ class Math_BigInteger
|
||||||
* Interleaves the montgomery reduction and long multiplication algorithms together as described in
|
* Interleaves the montgomery reduction and long multiplication algorithms together as described in
|
||||||
* {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36}
|
* {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36}
|
||||||
*
|
*
|
||||||
* @see _prepMontgomery()
|
* @see self::_prepMontgomery()
|
||||||
* @see _montgomery()
|
* @see self::_montgomery()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $y
|
* @param array $y
|
||||||
* @param Array $m
|
* @param array $m
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _montgomeryMultiply($x, $y, $m)
|
function _montgomeryMultiply($x, $y, $m)
|
||||||
{
|
{
|
||||||
|
@ -2350,12 +2370,12 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Prepare a number for use in Montgomery Modular Reductions
|
* Prepare a number for use in Montgomery Modular Reductions
|
||||||
*
|
*
|
||||||
* @see _montgomery()
|
* @see self::_montgomery()
|
||||||
* @see _slidingWindow()
|
* @see self::_slidingWindow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @param Array $n
|
* @param array $n
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _prepMontgomery($x, $n)
|
function _prepMontgomery($x, $n)
|
||||||
{
|
{
|
||||||
|
@ -2389,10 +2409,10 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Thanks to Pedro Gimeno Fortea for input!
|
* Thanks to Pedro Gimeno Fortea for input!
|
||||||
*
|
*
|
||||||
* @see _montgomery()
|
* @see self::_montgomery()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Array $x
|
* @param array $x
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _modInverse67108864($x) // 2**26 == 67,108,864
|
function _modInverse67108864($x) // 2**26 == 67,108,864
|
||||||
{
|
{
|
||||||
|
@ -2430,7 +2450,7 @@ class Math_BigInteger
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $n
|
* @param Math_BigInteger $n
|
||||||
* @return mixed false, if no modular inverse exists, Math_BigInteger, otherwise.
|
* @return Math_BigInteger|false
|
||||||
* @access public
|
* @access public
|
||||||
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.
|
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.
|
||||||
*/
|
*/
|
||||||
|
@ -2441,7 +2461,7 @@ class Math_BigInteger
|
||||||
$temp = new Math_BigInteger();
|
$temp = new Math_BigInteger();
|
||||||
$temp->value = gmp_invert($this->value, $n->value);
|
$temp->value = gmp_invert($this->value, $n->value);
|
||||||
|
|
||||||
return ( $temp->value === false ) ? false : $this->_normalize($temp);
|
return ($temp->value === false) ? false : $this->_normalize($temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static $zero, $one;
|
static $zero, $one;
|
||||||
|
@ -2674,9 +2694,9 @@ class Math_BigInteger
|
||||||
* Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y).
|
* Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y).
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $y
|
* @param Math_BigInteger $y
|
||||||
* @return Integer < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.
|
* @return int < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.
|
||||||
* @access public
|
* @access public
|
||||||
* @see equals()
|
* @see self::equals()
|
||||||
* @internal Could return $this->subtract($x), but that's not as fast as what we do do.
|
* @internal Could return $this->subtract($x), but that's not as fast as what we do do.
|
||||||
*/
|
*/
|
||||||
function compare($y)
|
function compare($y)
|
||||||
|
@ -2694,24 +2714,24 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Compares two numbers.
|
* Compares two numbers.
|
||||||
*
|
*
|
||||||
* @param Array $x_value
|
* @param array $x_value
|
||||||
* @param Boolean $x_negative
|
* @param bool $x_negative
|
||||||
* @param Array $y_value
|
* @param array $y_value
|
||||||
* @param Boolean $y_negative
|
* @param bool $y_negative
|
||||||
* @return Integer
|
* @return int
|
||||||
* @see compare()
|
* @see self::compare()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _compare($x_value, $x_negative, $y_value, $y_negative)
|
function _compare($x_value, $x_negative, $y_value, $y_negative)
|
||||||
{
|
{
|
||||||
if ($x_negative != $y_negative) {
|
if ($x_negative != $y_negative) {
|
||||||
return ( !$x_negative && $y_negative ) ? 1 : -1;
|
return (!$x_negative && $y_negative) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $x_negative ? -1 : 1;
|
$result = $x_negative ? -1 : 1;
|
||||||
|
|
||||||
if (count($x_value) != count($y_value)) {
|
if (count($x_value) != count($y_value)) {
|
||||||
return ( count($x_value) > count($y_value) ) ? $result : -$result;
|
return (count($x_value) > count($y_value)) ? $result : -$result;
|
||||||
}
|
}
|
||||||
$size = max(count($x_value), count($y_value));
|
$size = max(count($x_value), count($y_value));
|
||||||
|
|
||||||
|
@ -2720,7 +2740,7 @@ class Math_BigInteger
|
||||||
|
|
||||||
for ($i = count($x_value) - 1; $i >= 0; --$i) {
|
for ($i = count($x_value) - 1; $i >= 0; --$i) {
|
||||||
if ($x_value[$i] != $y_value[$i]) {
|
if ($x_value[$i] != $y_value[$i]) {
|
||||||
return ( $x_value[$i] > $y_value[$i] ) ? $result : -$result;
|
return ($x_value[$i] > $y_value[$i]) ? $result : -$result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2733,9 +2753,9 @@ class Math_BigInteger
|
||||||
* If you need to see if one number is greater than or less than another number, use Math_BigInteger::compare()
|
* If you need to see if one number is greater than or less than another number, use Math_BigInteger::compare()
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $x
|
* @param Math_BigInteger $x
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
* @see compare()
|
* @see self::compare()
|
||||||
*/
|
*/
|
||||||
function equals($x)
|
function equals($x)
|
||||||
{
|
{
|
||||||
|
@ -2753,7 +2773,7 @@ class Math_BigInteger
|
||||||
* Some bitwise operations give different results depending on the precision being used. Examples include left
|
* Some bitwise operations give different results depending on the precision being used. Examples include left
|
||||||
* shift, not, and rotates.
|
* shift, not, and rotates.
|
||||||
*
|
*
|
||||||
* @param Integer $bits
|
* @param int $bits
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setPrecision($bits)
|
function setPrecision($bits)
|
||||||
|
@ -2902,6 +2922,9 @@ class Math_BigInteger
|
||||||
// calculuate "not" without regard to $this->precision
|
// calculuate "not" without regard to $this->precision
|
||||||
// (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0)
|
// (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0)
|
||||||
$temp = $this->toBytes();
|
$temp = $this->toBytes();
|
||||||
|
if ($temp == '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
$pre_msb = decbin(ord($temp[0]));
|
$pre_msb = decbin(ord($temp[0]));
|
||||||
$temp = ~$temp;
|
$temp = ~$temp;
|
||||||
$msb = decbin(ord($temp[0]));
|
$msb = decbin(ord($temp[0]));
|
||||||
|
@ -2931,7 +2954,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
|
* Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
* @internal The only version that yields any speed increases is the internal version.
|
* @internal The only version that yields any speed increases is the internal version.
|
||||||
|
@ -2969,7 +2992,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
|
* Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
* @internal The only version that yields any speed increases is the internal version.
|
* @internal The only version that yields any speed increases is the internal version.
|
||||||
|
@ -3007,7 +3030,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Instead of the top x bits being dropped they're appended to the shifted bit string.
|
* Instead of the top x bits being dropped they're appended to the shifted bit string.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -3052,7 +3075,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Instead of the bottom x bits being dropped they're prepended to the shifted bit string.
|
* Instead of the bottom x bits being dropped they're prepended to the shifted bit string.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -3066,7 +3089,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* This function is deprecated.
|
* This function is deprecated.
|
||||||
*
|
*
|
||||||
* @param String $generator
|
* @param string $generator
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setRandomGenerator($generator)
|
function setRandomGenerator($generator)
|
||||||
|
@ -3078,7 +3101,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Byte length is equal to $length. Uses crypt_random if it's loaded and mt_rand if it's not.
|
* Byte length is equal to $length. Uses crypt_random if it's loaded and mt_rand if it's not.
|
||||||
*
|
*
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -3113,7 +3136,7 @@ class Math_BigInteger
|
||||||
* $max->random($min)
|
* $max->random($min)
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $arg1
|
* @param Math_BigInteger $arg1
|
||||||
* @param optional Math_BigInteger $arg2
|
* @param Math_BigInteger $arg2
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access public
|
* @access public
|
||||||
* @internal The API for creating random numbers used to be $a->random($min, $max), where $a was a Math_BigInteger object.
|
* @internal The API for creating random numbers used to be $a->random($min, $max), where $a was a Math_BigInteger object.
|
||||||
|
@ -3190,13 +3213,13 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Generate a random prime number.
|
* Generate a random prime number.
|
||||||
*
|
*
|
||||||
* If there's not a prime within the given range, false will be returned. If more than $timeout seconds have elapsed,
|
* If there's not a prime within the given range, false will be returned.
|
||||||
* give up and return false.
|
* If more than $timeout seconds have elapsed, give up and return false.
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger $arg1
|
* @param Math_BigInteger $arg1
|
||||||
* @param optional Math_BigInteger $arg2
|
* @param Math_BigInteger $arg2
|
||||||
* @param optional Integer $timeout
|
* @param int $timeout
|
||||||
* @return Mixed
|
* @return Math_BigInteger|false
|
||||||
* @access public
|
* @access public
|
||||||
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}.
|
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}.
|
||||||
*/
|
*/
|
||||||
|
@ -3236,7 +3259,7 @@ class Math_BigInteger
|
||||||
$x = $this->random($min, $max);
|
$x = $this->random($min, $max);
|
||||||
|
|
||||||
// gmp_nextprime() requires PHP 5 >= 5.2.0 per <http://php.net/gmp-nextprime>.
|
// gmp_nextprime() requires PHP 5 >= 5.2.0 per <http://php.net/gmp-nextprime>.
|
||||||
if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && function_exists('gmp_nextprime')) {
|
if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && extension_loaded('gmp') && version_compare(PHP_VERSION, '5.2.0', '>=')) {
|
||||||
$p = new Math_BigInteger();
|
$p = new Math_BigInteger();
|
||||||
$p->value = gmp_nextprime($x->value);
|
$p->value = gmp_nextprime($x->value);
|
||||||
|
|
||||||
|
@ -3297,7 +3320,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* If the current number is odd it'll be unchanged. If it's even, one will be added to it.
|
* If the current number is odd it'll be unchanged. If it's even, one will be added to it.
|
||||||
*
|
*
|
||||||
* @see randomPrime()
|
* @see self::randomPrime()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _make_odd()
|
function _make_odd()
|
||||||
|
@ -3323,8 +3346,8 @@ class Math_BigInteger
|
||||||
* $t parameter is distributability. Math_BigInteger::randomPrime() can be distributed across multiple pageloads
|
* $t parameter is distributability. Math_BigInteger::randomPrime() can be distributed across multiple pageloads
|
||||||
* on a website instead of just one.
|
* on a website instead of just one.
|
||||||
*
|
*
|
||||||
* @param optional Math_BigInteger $t
|
* @param Math_BigInteger $t
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Uses the
|
* @internal Uses the
|
||||||
* {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. See
|
* {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. See
|
||||||
|
@ -3476,7 +3499,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Shifts BigInteger's by $shift bits.
|
* Shifts BigInteger's by $shift bits.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _lshift($shift)
|
function _lshift($shift)
|
||||||
|
@ -3511,7 +3534,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Shifts BigInteger's by $shift bits.
|
* Shifts BigInteger's by $shift bits.
|
||||||
*
|
*
|
||||||
* @param Integer $shift
|
* @param int $shift
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _rshift($shift)
|
function _rshift($shift)
|
||||||
|
@ -3547,7 +3570,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* @param Math_BigInteger
|
* @param Math_BigInteger
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @see _trim()
|
* @see self::_trim()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _normalize($result)
|
function _normalize($result)
|
||||||
|
@ -3557,7 +3580,7 @@ class Math_BigInteger
|
||||||
|
|
||||||
switch (MATH_BIGINTEGER_MODE) {
|
switch (MATH_BIGINTEGER_MODE) {
|
||||||
case MATH_BIGINTEGER_MODE_GMP:
|
case MATH_BIGINTEGER_MODE_GMP:
|
||||||
if (!empty($result->bitmask->value)) {
|
if ($this->bitmask !== false) {
|
||||||
$result->value = gmp_and($result->value, $result->bitmask->value);
|
$result->value = gmp_and($result->value, $result->bitmask->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3595,7 +3618,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* Removes leading zeros
|
* Removes leading zeros
|
||||||
*
|
*
|
||||||
* @param Array $value
|
* @param array $value
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -3616,7 +3639,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* @param $input Array
|
* @param $input Array
|
||||||
* @param $multiplier mixed
|
* @param $multiplier mixed
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _array_repeat($input, $multiplier)
|
function _array_repeat($input, $multiplier)
|
||||||
|
@ -3631,7 +3654,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* @param $x String
|
* @param $x String
|
||||||
* @param $shift Integer
|
* @param $shift Integer
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _base256_lshift(&$x, $shift)
|
function _base256_lshift(&$x, $shift)
|
||||||
|
@ -3660,7 +3683,7 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* @param $x String
|
* @param $x String
|
||||||
* @param $shift Integer
|
* @param $shift Integer
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _base256_rshift(&$x, $shift)
|
function _base256_rshift(&$x, $shift)
|
||||||
|
@ -3700,8 +3723,8 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Converts 32-bit integers to bytes.
|
* Converts 32-bit integers to bytes.
|
||||||
*
|
*
|
||||||
* @param Integer $x
|
* @param int $x
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _int2bytes($x)
|
function _int2bytes($x)
|
||||||
|
@ -3712,8 +3735,8 @@ class Math_BigInteger
|
||||||
/**
|
/**
|
||||||
* Converts bytes to 32-bit integers
|
* Converts bytes to 32-bit integers
|
||||||
*
|
*
|
||||||
* @param String $x
|
* @param string $x
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _bytes2int($x)
|
function _bytes2int($x)
|
||||||
|
@ -3727,10 +3750,10 @@ class Math_BigInteger
|
||||||
*
|
*
|
||||||
* The ability to DER-encode integers is needed to create RSA public keys for use with OpenSSL
|
* The ability to DER-encode integers is needed to create RSA public keys for use with OpenSSL
|
||||||
*
|
*
|
||||||
* @see modPow()
|
* @see self::modPow()
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $length
|
* @param int $length
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _encodeASN1Length($length)
|
function _encodeASN1Length($length)
|
||||||
{
|
{
|
||||||
|
@ -3751,9 +3774,9 @@ class Math_BigInteger
|
||||||
* we'll guarantee that the dividend is divisible by first subtracting the remainder.
|
* we'll guarantee that the dividend is divisible by first subtracting the remainder.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param Integer $x
|
* @param int $x
|
||||||
* @param Integer $y
|
* @param int $y
|
||||||
* @return Integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
function _safe_divide($x, $y)
|
function _safe_divide($x, $y)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SCP::put()
|
* @see self::put()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Reads data from a local file.
|
* Reads data from a local file.
|
||||||
|
@ -65,8 +65,8 @@ define('NET_SCP_STRING', 2);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Net_SCP::_send()
|
* @see self::_send()
|
||||||
* @see Net_SCP::_receive()
|
* @see self::_receive()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* SSH1 is being used.
|
* SSH1 is being used.
|
||||||
|
@ -90,7 +90,7 @@ class Net_SCP
|
||||||
/**
|
/**
|
||||||
* SSH Object
|
* SSH Object
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $ssh;
|
var $ssh;
|
||||||
|
@ -98,7 +98,7 @@ class Net_SCP
|
||||||
/**
|
/**
|
||||||
* Packet Size
|
* Packet Size
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_size;
|
var $packet_size;
|
||||||
|
@ -106,7 +106,7 @@ class Net_SCP
|
||||||
/**
|
/**
|
||||||
* Mode
|
* Mode
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $mode;
|
var $mode;
|
||||||
|
@ -116,9 +116,9 @@ class Net_SCP
|
||||||
*
|
*
|
||||||
* Connects to an SSH server
|
* Connects to an SSH server
|
||||||
*
|
*
|
||||||
* @param String $host
|
* @param string $host
|
||||||
* @param optional Integer $port
|
* @param int $port
|
||||||
* @param optional Integer $timeout
|
* @param int $timeout
|
||||||
* @return Net_SCP
|
* @return Net_SCP
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -157,11 +157,11 @@ class Net_SCP
|
||||||
* Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take
|
* Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take
|
||||||
* care of that, yourself.
|
* care of that, yourself.
|
||||||
*
|
*
|
||||||
* @param String $remote_file
|
* @param string $remote_file
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @param optional Callable $callback
|
* @param callable $callback
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function put($remote_file, $data, $mode = NET_SCP_STRING, $callback = null)
|
function put($remote_file, $data, $mode = NET_SCP_STRING, $callback = null)
|
||||||
|
@ -233,9 +233,9 @@ class Net_SCP
|
||||||
* the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the
|
* the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the
|
||||||
* operation
|
* operation
|
||||||
*
|
*
|
||||||
* @param String $remote_file
|
* @param string $remote_file
|
||||||
* @param optional String $local_file
|
* @param string $local_file
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function get($remote_file, $local_file = false)
|
function get($remote_file, $local_file = false)
|
||||||
|
@ -291,7 +291,7 @@ class Net_SCP
|
||||||
/**
|
/**
|
||||||
* Sends a packet to an SSH server
|
* Sends a packet to an SSH server
|
||||||
*
|
*
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _send($data)
|
function _send($data)
|
||||||
|
@ -309,7 +309,7 @@ class Net_SCP
|
||||||
/**
|
/**
|
||||||
* Receives a packet from an SSH server
|
* Receives a packet from an SSH server
|
||||||
*
|
*
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _receive()
|
function _receive()
|
||||||
|
|
|
@ -62,7 +62,7 @@ if (!class_exists('Net_SSH2')) {
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SFTP::getLog()
|
* @see self::getLog()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the message numbers
|
* Returns the message numbers
|
||||||
|
@ -91,7 +91,7 @@ define('NET_SFTP_CHANNEL', 0x100);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SFTP::put()
|
* @see self::put()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Reads data from a local file.
|
* Reads data from a local file.
|
||||||
|
@ -129,8 +129,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Packet Types
|
* Packet Types
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::Net_SFTP()
|
* @see self::Net_SFTP()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_types = array();
|
var $packet_types = array();
|
||||||
|
@ -138,8 +138,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Status Codes
|
* Status Codes
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::Net_SFTP()
|
* @see self::Net_SFTP()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $status_codes = array();
|
var $status_codes = array();
|
||||||
|
@ -150,8 +150,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
* The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support
|
* The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support
|
||||||
* concurrent actions, so it's somewhat academic, here.
|
* concurrent actions, so it's somewhat academic, here.
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @see Net_SFTP::_send_sftp_packet()
|
* @see self::_send_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $request_id = false;
|
var $request_id = false;
|
||||||
|
@ -162,8 +162,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
* The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support
|
* The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support
|
||||||
* concurrent actions, so it's somewhat academic, here.
|
* concurrent actions, so it's somewhat academic, here.
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see self::_get_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_type = -1;
|
var $packet_type = -1;
|
||||||
|
@ -171,8 +171,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Packet Buffer
|
* Packet Buffer
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see self::_get_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_buffer = '';
|
var $packet_buffer = '';
|
||||||
|
@ -180,8 +180,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Extensions supported by the server
|
* Extensions supported by the server
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @see Net_SFTP::_initChannel()
|
* @see self::_initChannel()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $extensions = array();
|
var $extensions = array();
|
||||||
|
@ -189,8 +189,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Server SFTP version
|
* Server SFTP version
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @see Net_SFTP::_initChannel()
|
* @see self::_initChannel()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $version;
|
var $version;
|
||||||
|
@ -198,9 +198,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Current working directory
|
* Current working directory
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @see Net_SFTP::_realpath()
|
* @see self::_realpath()
|
||||||
* @see Net_SFTP::chdir()
|
* @see self::chdir()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $pwd = false;
|
var $pwd = false;
|
||||||
|
@ -208,8 +208,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Packet Type Log
|
* Packet Type Log
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getLog()
|
* @see self::getLog()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_type_log = array();
|
var $packet_type_log = array();
|
||||||
|
@ -217,8 +217,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Packet Log
|
* Packet Log
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getLog()
|
* @see self::getLog()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_log = array();
|
var $packet_log = array();
|
||||||
|
@ -226,9 +226,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Error information
|
* Error information
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getSFTPErrors()
|
* @see self::getSFTPErrors()
|
||||||
* @see Net_SFTP::getLastSFTPError()
|
* @see self::getLastSFTPError()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sftp_errors = array();
|
var $sftp_errors = array();
|
||||||
|
@ -239,10 +239,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
* Rather than always having to open a directory and close it immediately there after to see if a file is a directory
|
* Rather than always having to open a directory and close it immediately there after to see if a file is a directory
|
||||||
* we'll cache the results.
|
* we'll cache the results.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_update_stat_cache()
|
* @see self::_update_stat_cache()
|
||||||
* @see Net_SFTP::_remove_from_stat_cache()
|
* @see self::_remove_from_stat_cache()
|
||||||
* @see Net_SFTP::_query_stat_cache()
|
* @see self::_query_stat_cache()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $stat_cache = array();
|
var $stat_cache = array();
|
||||||
|
@ -250,9 +250,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Max SFTP Packet Size
|
* Max SFTP Packet Size
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::Net_SFTP()
|
* @see self::Net_SFTP()
|
||||||
* @see Net_SFTP::get()
|
* @see self::get()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $max_sftp_packet;
|
var $max_sftp_packet;
|
||||||
|
@ -260,9 +260,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Stat Cache Flag
|
* Stat Cache Flag
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::disableStatCache()
|
* @see self::disableStatCache()
|
||||||
* @see Net_SFTP::enableStatCache()
|
* @see self::enableStatCache()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $use_stat_cache = true;
|
var $use_stat_cache = true;
|
||||||
|
@ -270,9 +270,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Sort Options
|
* Sort Options
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_comparator()
|
* @see self::_comparator()
|
||||||
* @see Net_SFTP::setListOrder()
|
* @see self::setListOrder()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sortOptions = array();
|
var $sortOptions = array();
|
||||||
|
@ -282,9 +282,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Connects to an SFTP server
|
* Connects to an SFTP server
|
||||||
*
|
*
|
||||||
* @param String $host
|
* @param string $host
|
||||||
* @param optional Integer $port
|
* @param int $port
|
||||||
* @param optional Integer $timeout
|
* @param int $timeout
|
||||||
* @return Net_SFTP
|
* @return Net_SFTP
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -420,9 +420,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Login
|
* Login
|
||||||
*
|
*
|
||||||
* @param String $username
|
* @param string $username
|
||||||
* @param optional String $password
|
* @param string $password
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function login($username)
|
function login($username)
|
||||||
|
@ -610,7 +610,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Returns the current directory name
|
* Returns the current directory name
|
||||||
*
|
*
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function pwd()
|
function pwd()
|
||||||
|
@ -621,8 +621,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Logs errors
|
* Logs errors
|
||||||
*
|
*
|
||||||
* @param String $response
|
* @param string $response
|
||||||
* @param optional Integer $status
|
* @param int $status
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _logError($response, $status = -1)
|
function _logError($response, $status = -1)
|
||||||
|
@ -647,9 +647,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
||||||
* the absolute (canonicalized) path.
|
* the absolute (canonicalized) path.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::chdir()
|
* @see self::chdir()
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _realpath($path)
|
function _realpath($path)
|
||||||
|
@ -704,8 +704,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Changes the current directory
|
* Changes the current directory
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function chdir($dir)
|
function chdir($dir)
|
||||||
|
@ -766,9 +766,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Returns a list of files in the given directory
|
* Returns a list of files in the given directory
|
||||||
*
|
*
|
||||||
* @param optional String $dir
|
* @param string $dir
|
||||||
* @param optional Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function nlist($dir = '.', $recursive = false)
|
function nlist($dir = '.', $recursive = false)
|
||||||
|
@ -779,10 +779,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Helper method for nlist
|
* Helper method for nlist
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @param Boolean $recursive
|
* @param bool $recursive
|
||||||
* @param String $relativeDir
|
* @param string $relativeDir
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _nlist_helper($dir, $recursive, $relativeDir)
|
function _nlist_helper($dir, $recursive, $relativeDir)
|
||||||
|
@ -815,9 +815,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Returns a detailed list of files in the given directory
|
* Returns a detailed list of files in the given directory
|
||||||
*
|
*
|
||||||
* @param optional String $dir
|
* @param string $dir
|
||||||
* @param optional Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function rawlist($dir = '.', $recursive = false)
|
function rawlist($dir = '.', $recursive = false)
|
||||||
|
@ -849,9 +849,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Reads a list, be it detailed or not, of files in the given directory
|
* Reads a list, be it detailed or not, of files in the given directory
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @param optional Boolean $raw
|
* @param bool $raw
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _list($dir, $raw = true)
|
function _list($dir, $raw = true)
|
||||||
|
@ -959,9 +959,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Intended for use with uasort()
|
* Intended for use with uasort()
|
||||||
*
|
*
|
||||||
* @param Array $a
|
* @param array $a
|
||||||
* @param Array $b
|
* @param array $b
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _comparator($a, $b)
|
function _comparator($a, $b)
|
||||||
|
@ -1059,8 +1059,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Files larger than 4GB will show up as being exactly 4GB.
|
* Files larger than 4GB will show up as being exactly 4GB.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function size($filename)
|
function size($filename)
|
||||||
|
@ -1079,8 +1079,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Save files / directories to cache
|
* Save files / directories to cache
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Mixed $value
|
* @param mixed $value
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _update_stat_cache($path, $value)
|
function _update_stat_cache($path, $value)
|
||||||
|
@ -1123,8 +1123,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Remove files / directories from cache
|
* Remove files / directories from cache
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _remove_from_stat_cache($path)
|
function _remove_from_stat_cache($path)
|
||||||
|
@ -1150,8 +1150,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Mainly used by file_exists
|
* Mainly used by file_exists
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _query_stat_cache($path)
|
function _query_stat_cache($path)
|
||||||
|
@ -1173,8 +1173,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Returns an array on success and false otherwise.
|
* Returns an array on success and false otherwise.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function stat($filename)
|
function stat($filename)
|
||||||
|
@ -1230,8 +1230,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Returns an array on success and false otherwise.
|
* Returns an array on success and false otherwise.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function lstat($filename)
|
function lstat($filename)
|
||||||
|
@ -1296,9 +1296,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
* Determines information without calling Net_SFTP::_realpath().
|
* Determines information without calling Net_SFTP::_realpath().
|
||||||
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param Integer $type
|
* @param int $type
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _stat($filename, $type)
|
function _stat($filename, $type)
|
||||||
|
@ -1325,9 +1325,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Truncates a file to a given length
|
* Truncates a file to a given length
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param Integer $new_size
|
* @param int $new_size
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function truncate($filename, $new_size)
|
function truncate($filename, $new_size)
|
||||||
|
@ -1342,10 +1342,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* If the file does not exist, it will be created.
|
* If the file does not exist, it will be created.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param optional Integer $time
|
* @param int $time
|
||||||
* @param optional Integer $atime
|
* @param int $atime
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function touch($filename, $time = null, $atime = null)
|
function touch($filename, $time = null, $atime = null)
|
||||||
|
@ -1393,10 +1393,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Returns true on success or false on error.
|
* Returns true on success or false on error.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param Integer $uid
|
* @param int $uid
|
||||||
* @param optional Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function chown($filename, $uid, $recursive = false)
|
function chown($filename, $uid, $recursive = false)
|
||||||
|
@ -1413,10 +1413,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Returns true on success or false on error.
|
* Returns true on success or false on error.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param Integer $gid
|
* @param int $gid
|
||||||
* @param optional Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function chgrp($filename, $gid, $recursive = false)
|
function chgrp($filename, $gid, $recursive = false)
|
||||||
|
@ -1432,10 +1432,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
* Returns the new file permissions on success or false on error.
|
* Returns the new file permissions on success or false on error.
|
||||||
* If $recursive is true than this just returns true or false.
|
* If $recursive is true than this just returns true or false.
|
||||||
*
|
*
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param optional Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function chmod($mode, $filename, $recursive = false)
|
function chmod($mode, $filename, $recursive = false)
|
||||||
|
@ -1454,6 +1454,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filename = $this->_realPath($filename);
|
||||||
// rather than return what the permissions *should* be, we'll return what they actually are. this will also
|
// rather than return what the permissions *should* be, we'll return what they actually are. this will also
|
||||||
// tell us if the file actually exists.
|
// tell us if the file actually exists.
|
||||||
// incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following:
|
// incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following:
|
||||||
|
@ -1479,10 +1480,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Sets information about a file
|
* Sets information about a file
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param string $filename
|
||||||
* @param String $attr
|
* @param string $attr
|
||||||
* @param Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _setstat($filename, $attr, $recursive)
|
function _setstat($filename, $attr, $recursive)
|
||||||
|
@ -1538,10 +1539,10 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Minimizes directory lookups and SSH_FXP_STATUS requests for speed.
|
* Minimizes directory lookups and SSH_FXP_STATUS requests for speed.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param String $attr
|
* @param string $attr
|
||||||
* @param Integer $i
|
* @param int $i
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _setstat_recursive($path, $attr, &$i)
|
function _setstat_recursive($path, $attr, &$i)
|
||||||
|
@ -1608,8 +1609,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Return the target of a symbolic link
|
* Return the target of a symbolic link
|
||||||
*
|
*
|
||||||
* @param String $link
|
* @param string $link
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function readlink($link)
|
function readlink($link)
|
||||||
|
@ -1651,9 +1652,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* symlink() creates a symbolic link to the existing target with the specified name link.
|
* symlink() creates a symbolic link to the existing target with the specified name link.
|
||||||
*
|
*
|
||||||
* @param String $target
|
* @param string $target
|
||||||
* @param String $link
|
* @param string $link
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function symlink($target, $link)
|
function symlink($target, $link)
|
||||||
|
@ -1688,8 +1689,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Creates a directory.
|
* Creates a directory.
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function mkdir($dir, $mode = -1, $recursive = false)
|
function mkdir($dir, $mode = -1, $recursive = false)
|
||||||
|
@ -1723,8 +1724,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Helper function for directory creation
|
* Helper function for directory creation
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _mkdir_helper($dir, $attr)
|
function _mkdir_helper($dir, $attr)
|
||||||
|
@ -1751,8 +1752,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Removes a directory.
|
* Removes a directory.
|
||||||
*
|
*
|
||||||
* @param String $dir
|
* @param string $dir
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function rmdir($dir)
|
function rmdir($dir)
|
||||||
|
@ -1829,13 +1830,13 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE.
|
* Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE.
|
||||||
*
|
*
|
||||||
* @param String $remote_file
|
* @param string $remote_file
|
||||||
* @param String|resource $data
|
* @param string|resource $data
|
||||||
* @param optional Integer $mode
|
* @param int $mode
|
||||||
* @param optional Integer $start
|
* @param int $start
|
||||||
* @param optional Integer $local_start
|
* @param int $local_start
|
||||||
* @param optional callable|null $progressCallback
|
* @param callable|null $progressCallback
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
* @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - Net_SFTP::setMode().
|
* @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - Net_SFTP::setMode().
|
||||||
*/
|
*/
|
||||||
|
@ -1917,10 +1918,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
|
|
||||||
if ($local_start >= 0) {
|
if ($local_start >= 0) {
|
||||||
fseek($fp, $local_start);
|
fseek($fp, $local_start);
|
||||||
} elseif ($mode & NET_SFTP_RESUME_START) {
|
$size-= $local_start;
|
||||||
// do nothing
|
|
||||||
} else {
|
|
||||||
fseek($fp, $offset);
|
|
||||||
}
|
}
|
||||||
} elseif ($dataCallback) {
|
} elseif ($dataCallback) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -1989,8 +1987,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
* Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i
|
* Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i
|
||||||
* SSH_FXP_WRITEs, in succession, and then reading $i responses.
|
* SSH_FXP_WRITEs, in succession, and then reading $i responses.
|
||||||
*
|
*
|
||||||
* @param Integer $i
|
* @param int $i
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _read_put_responses($i)
|
function _read_put_responses($i)
|
||||||
|
@ -2015,8 +2013,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Close handle
|
* Close handle
|
||||||
*
|
*
|
||||||
* @param String $handle
|
* @param string $handle
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _close_handle($handle)
|
function _close_handle($handle)
|
||||||
|
@ -2051,11 +2049,11 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* $offset and $length can be used to download files in chunks.
|
* $offset and $length can be used to download files in chunks.
|
||||||
*
|
*
|
||||||
* @param String $remote_file
|
* @param string $remote_file
|
||||||
* @param optional String $local_file
|
* @param string $local_file
|
||||||
* @param optional Integer $offset
|
* @param int $offset
|
||||||
* @param optional Integer $length
|
* @param int $length
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function get($remote_file, $local_file = false, $offset = 0, $length = -1)
|
function get($remote_file, $local_file = false, $offset = 0, $length = -1)
|
||||||
|
@ -2167,9 +2165,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Deletes a file on the SFTP server.
|
* Deletes a file on the SFTP server.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Boolean $recursive
|
* @param bool $recursive
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function delete($path, $recursive = true)
|
function delete($path, $recursive = true)
|
||||||
|
@ -2217,9 +2215,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Minimizes directory lookups and SSH_FXP_STATUS requests for speed.
|
* Minimizes directory lookups and SSH_FXP_STATUS requests for speed.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $i
|
* @param int $i
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _delete_recursive($path, &$i)
|
function _delete_recursive($path, &$i)
|
||||||
|
@ -2284,8 +2282,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Checks whether a file or directory exists
|
* Checks whether a file or directory exists
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function file_exists($path)
|
function file_exists($path)
|
||||||
|
@ -2307,8 +2305,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Tells whether the filename is a directory
|
* Tells whether the filename is a directory
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function is_dir($path)
|
function is_dir($path)
|
||||||
|
@ -2323,8 +2321,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Tells whether the filename is a regular file
|
* Tells whether the filename is a regular file
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function is_file($path)
|
function is_file($path)
|
||||||
|
@ -2339,8 +2337,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Tells whether the filename is a symbolic link
|
* Tells whether the filename is a symbolic link
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function is_link($path)
|
function is_link($path)
|
||||||
|
@ -2355,8 +2353,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets last access time of file
|
* Gets last access time of file
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function fileatime($path)
|
function fileatime($path)
|
||||||
|
@ -2367,8 +2365,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file modification time
|
* Gets file modification time
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function filemtime($path)
|
function filemtime($path)
|
||||||
|
@ -2379,8 +2377,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file permissions
|
* Gets file permissions
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function fileperms($path)
|
function fileperms($path)
|
||||||
|
@ -2391,8 +2389,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file owner
|
* Gets file owner
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function fileowner($path)
|
function fileowner($path)
|
||||||
|
@ -2403,8 +2401,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file group
|
* Gets file group
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function filegroup($path)
|
function filegroup($path)
|
||||||
|
@ -2415,8 +2413,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file size
|
* Gets file size
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function filesize($path)
|
function filesize($path)
|
||||||
|
@ -2427,8 +2425,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Gets file type
|
* Gets file type
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function filetype($path)
|
function filetype($path)
|
||||||
|
@ -2461,9 +2459,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Uses cache if appropriate.
|
* Uses cache if appropriate.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param String $prop
|
* @param string $prop
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _get_stat_cache_prop($path, $prop)
|
function _get_stat_cache_prop($path, $prop)
|
||||||
|
@ -2476,9 +2474,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Uses cache if appropriate.
|
* Uses cache if appropriate.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param String $prop
|
* @param string $prop
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _get_lstat_cache_prop($path, $prop)
|
function _get_lstat_cache_prop($path, $prop)
|
||||||
|
@ -2491,9 +2489,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Uses cache if appropriate.
|
* Uses cache if appropriate.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param String $prop
|
* @param string $prop
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _get_xstat_cache_prop($path, $prop, $type)
|
function _get_xstat_cache_prop($path, $prop, $type)
|
||||||
|
@ -2520,9 +2518,9 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Renames a file or a directory on the SFTP server
|
* Renames a file or a directory on the SFTP server
|
||||||
*
|
*
|
||||||
* @param String $oldname
|
* @param string $oldname
|
||||||
* @param String $newname
|
* @param string $newname
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function rename($oldname, $newname)
|
function rename($oldname, $newname)
|
||||||
|
@ -2570,8 +2568,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info.
|
* See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info.
|
||||||
*
|
*
|
||||||
* @param String $response
|
* @param string $response
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _parseAttributes(&$response)
|
function _parseAttributes(&$response)
|
||||||
|
@ -2624,8 +2622,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* Quoting the SFTP RFC, "Implementations MUST NOT send bits that are not defined" but they seem to anyway
|
* Quoting the SFTP RFC, "Implementations MUST NOT send bits that are not defined" but they seem to anyway
|
||||||
*
|
*
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _parseMode($mode)
|
function _parseMode($mode)
|
||||||
|
@ -2671,8 +2669,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* If the longname is in an unrecognized format bool(false) is returned.
|
* If the longname is in an unrecognized format bool(false) is returned.
|
||||||
*
|
*
|
||||||
* @param String $longname
|
* @param string $longname
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _parseLongname($longname)
|
function _parseLongname($longname)
|
||||||
|
@ -2700,11 +2698,11 @@ class Net_SFTP extends Net_SSH2
|
||||||
*
|
*
|
||||||
* See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.
|
* See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.
|
||||||
*
|
*
|
||||||
* @param Integer $type
|
* @param int $type
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see self::_get_sftp_packet()
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see Net_SSH2::_send_channel_packet()
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _send_sftp_packet($type, $data)
|
function _send_sftp_packet($type, $data)
|
||||||
|
@ -2744,8 +2742,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
* There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA
|
* There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA
|
||||||
* messages containing one SFTP packet.
|
* messages containing one SFTP packet.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_send_sftp_packet()
|
* @see self::_send_sftp_packet()
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _get_sftp_packet()
|
function _get_sftp_packet()
|
||||||
|
@ -2817,7 +2815,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
* Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING')
|
* Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING')
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String or Array
|
* @return string or Array
|
||||||
*/
|
*/
|
||||||
function getSFTPLog()
|
function getSFTPLog()
|
||||||
{
|
{
|
||||||
|
@ -2838,7 +2836,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Returns all errors
|
* Returns all errors
|
||||||
*
|
*
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getSFTPErrors()
|
function getSFTPErrors()
|
||||||
|
@ -2849,7 +2847,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Returns the last error
|
* Returns the last error
|
||||||
*
|
*
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getLastSFTPError()
|
function getLastSFTPError()
|
||||||
|
@ -2860,7 +2858,7 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Get supported SFTP versions
|
* Get supported SFTP versions
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getSupportedVersions()
|
function getSupportedVersions()
|
||||||
|
@ -2875,8 +2873,8 @@ class Net_SFTP extends Net_SSH2
|
||||||
/**
|
/**
|
||||||
* Disconnect
|
* Disconnect
|
||||||
*
|
*
|
||||||
* @param Integer $reason
|
* @param int $reason
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _disconnect($reason)
|
function _disconnect($reason)
|
||||||
|
|
|
@ -47,14 +47,14 @@ class Net_SFTP_Stream
|
||||||
*
|
*
|
||||||
* Rather than re-create the connection we re-use instances if possible
|
* Rather than re-create the connection we re-use instances if possible
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
*/
|
*/
|
||||||
static $instances;
|
static $instances;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SFTP instance
|
* SFTP instance
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $sftp;
|
var $sftp;
|
||||||
|
@ -62,7 +62,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Path
|
* Path
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $path;
|
var $path;
|
||||||
|
@ -70,7 +70,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Mode
|
* Mode
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $mode;
|
var $mode;
|
||||||
|
@ -78,7 +78,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Position
|
* Position
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $pos;
|
var $pos;
|
||||||
|
@ -86,7 +86,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Size
|
* Size
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $size;
|
var $size;
|
||||||
|
@ -94,7 +94,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Directory entries
|
* Directory entries
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $entries;
|
var $entries;
|
||||||
|
@ -102,7 +102,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* EOF flag
|
* EOF flag
|
||||||
*
|
*
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $eof;
|
var $eof;
|
||||||
|
@ -112,7 +112,7 @@ class Net_SFTP_Stream
|
||||||
*
|
*
|
||||||
* Technically this needs to be publically accessible so PHP can set it directly
|
* Technically this needs to be publically accessible so PHP can set it directly
|
||||||
*
|
*
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $context;
|
var $context;
|
||||||
|
@ -120,7 +120,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Notification callback function
|
* Notification callback function
|
||||||
*
|
*
|
||||||
* @var Callable
|
* @var callable
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $notification;
|
var $notification;
|
||||||
|
@ -128,8 +128,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Registers this class as a URL wrapper.
|
* Registers this class as a URL wrapper.
|
||||||
*
|
*
|
||||||
* @param optional String $protocol The wrapper name to be registered.
|
* @param string $protocol The wrapper name to be registered.
|
||||||
* @return Boolean True on success, false otherwise.
|
* @return bool True on success, false otherwise.
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
static function register($protocol = 'sftp')
|
static function register($protocol = 'sftp')
|
||||||
|
@ -165,13 +165,24 @@ class Net_SFTP_Stream
|
||||||
* If "notification" is set as a context parameter the message code for successful login is
|
* If "notification" is set as a context parameter the message code for successful login is
|
||||||
* NET_SSH2_MSG_USERAUTH_SUCCESS. For a failed login it's NET_SSH2_MSG_USERAUTH_FAILURE.
|
* NET_SSH2_MSG_USERAUTH_SUCCESS. For a failed login it's NET_SSH2_MSG_USERAUTH_FAILURE.
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _parse_path($path)
|
function _parse_path($path)
|
||||||
{
|
{
|
||||||
|
$orig = $path;
|
||||||
extract(parse_url($path) + array('port' => 22));
|
extract(parse_url($path) + array('port' => 22));
|
||||||
|
if (isset($query)) {
|
||||||
|
$path.= '?' . $query;
|
||||||
|
} elseif (preg_match('/(\?|\?#)$/', $orig)) {
|
||||||
|
$path.= '?';
|
||||||
|
}
|
||||||
|
if (isset($fragment)) {
|
||||||
|
$path.= '#' . $fragment;
|
||||||
|
} elseif ($orig[strlen($orig) - 1] == '#') {
|
||||||
|
$path.= '#';
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($host)) {
|
if (!isset($host)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -257,11 +268,11 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Opens file or URL
|
* Opens file or URL
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param String $mode
|
* @param string $mode
|
||||||
* @param Integer $options
|
* @param int $options
|
||||||
* @param String $opened_path
|
* @param string $opened_path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_open($path, $mode, $options, &$opened_path)
|
function _stream_open($path, $mode, $options, &$opened_path)
|
||||||
|
@ -302,8 +313,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Read from stream
|
* Read from stream
|
||||||
*
|
*
|
||||||
* @param Integer $count
|
* @param int $count
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_read($count)
|
function _stream_read($count)
|
||||||
|
@ -344,8 +355,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Write to stream
|
* Write to stream
|
||||||
*
|
*
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_write($data)
|
function _stream_write($data)
|
||||||
|
@ -379,7 +390,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Retrieve the current position of a stream
|
* Retrieve the current position of a stream
|
||||||
*
|
*
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_tell()
|
function _stream_tell()
|
||||||
|
@ -397,7 +408,7 @@ class Net_SFTP_Stream
|
||||||
* will return false. do fread($fp, 1) and feof() will then return true. do fseek($fp, 10) on ablank file and feof()
|
* will return false. do fread($fp, 1) and feof() will then return true. do fseek($fp, 10) on ablank file and feof()
|
||||||
* will return false. do fread($fp, 1) and feof() will then return true.
|
* will return false. do fread($fp, 1) and feof() will then return true.
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_eof()
|
function _stream_eof()
|
||||||
|
@ -408,9 +419,9 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Seeks to specific location in a stream
|
* Seeks to specific location in a stream
|
||||||
*
|
*
|
||||||
* @param Integer $offset
|
* @param int $offset
|
||||||
* @param Integer $whence
|
* @param int $whence
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_seek($offset, $whence)
|
function _stream_seek($offset, $whence)
|
||||||
|
@ -436,10 +447,10 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Change stream options
|
* Change stream options
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $option
|
* @param int $option
|
||||||
* @param Mixed $var
|
* @param mixed $var
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_metadata($path, $option, $var)
|
function _stream_metadata($path, $option, $var)
|
||||||
|
@ -470,8 +481,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Retrieve the underlaying resource
|
* Retrieve the underlaying resource
|
||||||
*
|
*
|
||||||
* @param Integer $cast_as
|
* @param int $cast_as
|
||||||
* @return Resource
|
* @return resource
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_cast($cast_as)
|
function _stream_cast($cast_as)
|
||||||
|
@ -482,8 +493,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Advisory file locking
|
* Advisory file locking
|
||||||
*
|
*
|
||||||
* @param Integer $operation
|
* @param int $operation
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_lock($operation)
|
function _stream_lock($operation)
|
||||||
|
@ -498,9 +509,9 @@ class Net_SFTP_Stream
|
||||||
* If newname exists, it will be overwritten. This is a departure from what Net_SFTP
|
* If newname exists, it will be overwritten. This is a departure from what Net_SFTP
|
||||||
* does.
|
* does.
|
||||||
*
|
*
|
||||||
* @param String $path_from
|
* @param string $path_from
|
||||||
* @param String $path_to
|
* @param string $path_to
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _rename($path_from, $path_to)
|
function _rename($path_from, $path_to)
|
||||||
|
@ -550,9 +561,9 @@ class Net_SFTP_Stream
|
||||||
* string longname
|
* string longname
|
||||||
* ATTRS attrs
|
* ATTRS attrs
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $options
|
* @param int $options
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _dir_opendir($path, $options)
|
function _dir_opendir($path, $options)
|
||||||
|
@ -569,7 +580,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Read entry from directory handle
|
* Read entry from directory handle
|
||||||
*
|
*
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _dir_readdir()
|
function _dir_readdir()
|
||||||
|
@ -583,7 +594,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Rewind directory handle
|
* Rewind directory handle
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _dir_rewinddir()
|
function _dir_rewinddir()
|
||||||
|
@ -595,7 +606,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Close directory handle
|
* Close directory handle
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _dir_closedir()
|
function _dir_closedir()
|
||||||
|
@ -608,10 +619,10 @@ class Net_SFTP_Stream
|
||||||
*
|
*
|
||||||
* Only valid $options is STREAM_MKDIR_RECURSIVE
|
* Only valid $options is STREAM_MKDIR_RECURSIVE
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @param Integer $options
|
* @param int $options
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _mkdir($path, $mode, $options)
|
function _mkdir($path, $mode, $options)
|
||||||
|
@ -632,10 +643,10 @@ class Net_SFTP_Stream
|
||||||
* STREAM_MKDIR_RECURSIVE is supposed to be set. Also, when I try it out with rmdir() I get 8 as
|
* STREAM_MKDIR_RECURSIVE is supposed to be set. Also, when I try it out with rmdir() I get 8 as
|
||||||
* $options. What does 8 correspond to?
|
* $options. What does 8 correspond to?
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @param Integer $options
|
* @param int $options
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _rmdir($path, $options)
|
function _rmdir($path, $options)
|
||||||
|
@ -653,7 +664,7 @@ class Net_SFTP_Stream
|
||||||
*
|
*
|
||||||
* See <http://php.net/fflush>. Always returns true because Net_SFTP doesn't cache stuff before writing
|
* See <http://php.net/fflush>. Always returns true because Net_SFTP doesn't cache stuff before writing
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_flush()
|
function _stream_flush()
|
||||||
|
@ -664,7 +675,7 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Retrieve information about a file resource
|
* Retrieve information about a file resource
|
||||||
*
|
*
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_stat()
|
function _stream_stat()
|
||||||
|
@ -679,8 +690,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Delete a file
|
* Delete a file
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _unlink($path)
|
function _unlink($path)
|
||||||
|
@ -700,9 +711,9 @@ class Net_SFTP_Stream
|
||||||
* might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll
|
* might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll
|
||||||
* cross that bridge when and if it's reached
|
* cross that bridge when and if it's reached
|
||||||
*
|
*
|
||||||
* @param String $path
|
* @param string $path
|
||||||
* @param Integer $flags
|
* @param int $flags
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _url_stat($path, $flags)
|
function _url_stat($path, $flags)
|
||||||
|
@ -723,8 +734,8 @@ class Net_SFTP_Stream
|
||||||
/**
|
/**
|
||||||
* Truncate stream
|
* Truncate stream
|
||||||
*
|
*
|
||||||
* @param Integer $new_size
|
* @param int $new_size
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_truncate($new_size)
|
function _stream_truncate($new_size)
|
||||||
|
@ -745,10 +756,10 @@ class Net_SFTP_Stream
|
||||||
* STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't.
|
* STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't.
|
||||||
* The other two aren't supported because of limitations in Net_SFTP.
|
* The other two aren't supported because of limitations in Net_SFTP.
|
||||||
*
|
*
|
||||||
* @param Integer $option
|
* @param int $option
|
||||||
* @param Integer $arg1
|
* @param int $arg1
|
||||||
* @param Integer $arg2
|
* @param int $arg2
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _stream_set_option($option, $arg1, $arg2)
|
function _stream_set_option($option, $arg1, $arg2)
|
||||||
|
@ -775,9 +786,9 @@ class Net_SFTP_Stream
|
||||||
* If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not
|
* If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not
|
||||||
* NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method.
|
* NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method.
|
||||||
*
|
*
|
||||||
* @param String
|
* @param string
|
||||||
* @param Array
|
* @param array
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __call($name, $arguments)
|
function __call($name, $arguments)
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
/**#@+
|
/**#@+
|
||||||
* Encryption Methods
|
* Encryption Methods
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedCiphers()
|
* @see self::getSupportedCiphers()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ define('NET_SSH1_CIPHER_BLOWFISH', 6);
|
||||||
/**#@+
|
/**#@+
|
||||||
* Authentication Methods
|
* Authentication Methods
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedAuthentications()
|
* @see self::getSupportedAuthentications()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +162,7 @@ define('NET_SSH1_TTY_OP_END', 0);
|
||||||
/**
|
/**
|
||||||
* The Response Type
|
* The Response Type
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see self::_get_binary_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
define('NET_SSH1_RESPONSE_TYPE', 1);
|
define('NET_SSH1_RESPONSE_TYPE', 1);
|
||||||
|
@ -170,7 +170,7 @@ define('NET_SSH1_RESPONSE_TYPE', 1);
|
||||||
/**
|
/**
|
||||||
* The Response Data
|
* The Response Data
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see self::_get_binary_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
define('NET_SSH1_RESPONSE_DATA', 2);
|
define('NET_SSH1_RESPONSE_DATA', 2);
|
||||||
|
@ -178,7 +178,7 @@ define('NET_SSH1_RESPONSE_DATA', 2);
|
||||||
/**#@+
|
/**#@+
|
||||||
* Execution Bitmap Masks
|
* Execution Bitmap Masks
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::bitmap
|
* @see self::bitmap
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
define('NET_SSH1_MASK_CONSTRUCTOR', 0x00000001);
|
define('NET_SSH1_MASK_CONSTRUCTOR', 0x00000001);
|
||||||
|
@ -189,7 +189,7 @@ define('NET_SSH1_MASK_SHELL', 0x00000008);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH1::getLog()
|
* @see self::getLog()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the message numbers
|
* Returns the message numbers
|
||||||
|
@ -211,7 +211,7 @@ define('NET_SSH1_LOG_REALTIME_FILE', 4);
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH1::read()
|
* @see self::read()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns when a string matching $expect exactly is found
|
* Returns when a string matching $expect exactly is found
|
||||||
|
@ -235,7 +235,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* The SSH identifier
|
* The SSH identifier
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $identifier = 'SSH-1.5-phpseclib';
|
var $identifier = 'SSH-1.5-phpseclib';
|
||||||
|
@ -243,7 +243,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* The Socket Object
|
* The Socket Object
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $fsock;
|
var $fsock;
|
||||||
|
@ -251,7 +251,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* The cryptography object
|
* The cryptography object
|
||||||
*
|
*
|
||||||
* @var Object
|
* @var object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $crypto = false;
|
var $crypto = false;
|
||||||
|
@ -262,7 +262,7 @@ class Net_SSH1
|
||||||
* The bits that are set represent functions that have been called already. This is used to determine
|
* The bits that are set represent functions that have been called already. This is used to determine
|
||||||
* if a requisite function has been successfully executed. If not, an error should be thrown.
|
* if a requisite function has been successfully executed. If not, an error should be thrown.
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $bitmap = 0;
|
var $bitmap = 0;
|
||||||
|
@ -272,8 +272,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerKeyPublicExponent()
|
* @see self::getServerKeyPublicExponent()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $server_key_public_exponent;
|
var $server_key_public_exponent;
|
||||||
|
@ -283,8 +283,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerKeyPublicModulus()
|
* @see self::getServerKeyPublicModulus()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $server_key_public_modulus;
|
var $server_key_public_modulus;
|
||||||
|
@ -294,8 +294,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getHostKeyPublicExponent()
|
* @see self::getHostKeyPublicExponent()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $host_key_public_exponent;
|
var $host_key_public_exponent;
|
||||||
|
@ -305,8 +305,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getHostKeyPublicModulus()
|
* @see self::getHostKeyPublicModulus()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $host_key_public_modulus;
|
var $host_key_public_modulus;
|
||||||
|
@ -316,8 +316,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedCiphers()
|
* @see self::getSupportedCiphers()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $supported_ciphers = array(
|
var $supported_ciphers = array(
|
||||||
|
@ -335,8 +335,8 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedAuthentications()
|
* @see self::getSupportedAuthentications()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $supported_authentications = array(
|
var $supported_authentications = array(
|
||||||
|
@ -349,8 +349,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Server Identification
|
* Server Identification
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerIdentification()
|
* @see self::getServerIdentification()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $server_identification = '';
|
var $server_identification = '';
|
||||||
|
@ -358,8 +358,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Protocol Flags
|
* Protocol Flags
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $protocol_flags = array();
|
var $protocol_flags = array();
|
||||||
|
@ -367,8 +367,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Protocol Flag Log
|
* Protocol Flag Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getLog()
|
* @see self::getLog()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $protocol_flag_log = array();
|
var $protocol_flag_log = array();
|
||||||
|
@ -376,8 +376,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Message Log
|
* Message Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getLog()
|
* @see self::getLog()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $message_log = array();
|
var $message_log = array();
|
||||||
|
@ -385,8 +385,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Real-time log file pointer
|
* Real-time log file pointer
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see self::_append_log()
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $realtime_log_file;
|
var $realtime_log_file;
|
||||||
|
@ -394,8 +394,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Real-time log file size
|
* Real-time log file size
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see self::_append_log()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $realtime_log_size;
|
var $realtime_log_size;
|
||||||
|
@ -403,8 +403,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Real-time log file wrap boolean
|
* Real-time log file wrap boolean
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see self::_append_log()
|
||||||
* @var Boolean
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $realtime_log_wrap;
|
var $realtime_log_wrap;
|
||||||
|
@ -412,8 +412,8 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Interactive Buffer
|
* Interactive Buffer
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::read()
|
* @see self::read()
|
||||||
* @var Array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $interactiveBuffer = '';
|
var $interactiveBuffer = '';
|
||||||
|
@ -421,7 +421,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Timeout
|
* Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::setTimeout()
|
* @see self::setTimeout()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $timeout;
|
var $timeout;
|
||||||
|
@ -429,7 +429,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Current Timeout
|
* Current Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_channel_packet()
|
* @see self::_get_channel_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $curTimeout;
|
var $curTimeout;
|
||||||
|
@ -437,7 +437,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Log Boundary
|
* Log Boundary
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see self::_format_log()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_boundary = ':';
|
var $log_boundary = ':';
|
||||||
|
@ -445,7 +445,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Log Long Width
|
* Log Long Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see self::_format_log()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_long_width = 65;
|
var $log_long_width = 65;
|
||||||
|
@ -453,7 +453,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Log Short Width
|
* Log Short Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see self::_format_log()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_short_width = 16;
|
var $log_short_width = 16;
|
||||||
|
@ -461,9 +461,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Hostname
|
* Hostname
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @see Net_SSH1::_connect()
|
* @see self::_connect()
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $host;
|
var $host;
|
||||||
|
@ -471,9 +471,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Port Number
|
* Port Number
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @see Net_SSH1::_connect()
|
* @see self::_connect()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $port;
|
var $port;
|
||||||
|
@ -486,9 +486,9 @@ class Net_SSH1
|
||||||
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
||||||
* 10 seconds. It is used by fsockopen() in that function.
|
* 10 seconds. It is used by fsockopen() in that function.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @see Net_SSH1::_connect()
|
* @see self::_connect()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $connectionTimeout;
|
var $connectionTimeout;
|
||||||
|
@ -496,9 +496,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Default cipher
|
* Default cipher
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @see Net_SSH1::_connect()
|
* @see self::_connect()
|
||||||
* @var Integer
|
* @var int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $cipher;
|
var $cipher;
|
||||||
|
@ -508,10 +508,10 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Connects to an SSHv1 server
|
* Connects to an SSHv1 server
|
||||||
*
|
*
|
||||||
* @param String $host
|
* @param string $host
|
||||||
* @param optional Integer $port
|
* @param int $port
|
||||||
* @param optional Integer $timeout
|
* @param int $timeout
|
||||||
* @param optional Integer $cipher
|
* @param int $cipher
|
||||||
* @return Net_SSH1
|
* @return Net_SSH1
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -560,7 +560,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Connect to an SSHv1 server
|
* Connect to an SSHv1 server
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _connect()
|
function _connect()
|
||||||
|
@ -727,9 +727,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Login
|
* Login
|
||||||
*
|
*
|
||||||
* @param String $username
|
* @param string $username
|
||||||
* @param optional String $password
|
* @param string $password
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function login($username, $password = '')
|
function login($username, $password = '')
|
||||||
|
@ -800,7 +800,7 @@ class Net_SSH1
|
||||||
* $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout.
|
* $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout.
|
||||||
* Setting $timeout to false or 0 will mean there is no timeout.
|
* Setting $timeout to false or 0 will mean there is no timeout.
|
||||||
*
|
*
|
||||||
* @param Mixed $timeout
|
* @param mixed $timeout
|
||||||
*/
|
*/
|
||||||
function setTimeout($timeout)
|
function setTimeout($timeout)
|
||||||
{
|
{
|
||||||
|
@ -821,9 +821,9 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Returns false on failure and the output, otherwise.
|
* Returns false on failure and the output, otherwise.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see self::interactiveRead()
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see self::interactiveWrite()
|
||||||
* @param String $cmd
|
* @param string $cmd
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -871,9 +871,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Creates an interactive shell
|
* Creates an interactive shell
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see self::interactiveRead()
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see self::interactiveWrite()
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _initShell()
|
function _initShell()
|
||||||
|
@ -915,9 +915,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Inputs a command into an interactive shell.
|
* Inputs a command into an interactive shell.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see self::interactiveWrite()
|
||||||
* @param String $cmd
|
* @param string $cmd
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function write($cmd)
|
function write($cmd)
|
||||||
|
@ -931,10 +931,10 @@ class Net_SSH1
|
||||||
* $expect can take the form of a string literal or, if $mode == NET_SSH1_READ_REGEX,
|
* $expect can take the form of a string literal or, if $mode == NET_SSH1_READ_REGEX,
|
||||||
* a regular expression.
|
* a regular expression.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::write()
|
* @see self::write()
|
||||||
* @param String $expect
|
* @param string $expect
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function read($expect, $mode = NET_SSH1_READ_SIMPLE)
|
function read($expect, $mode = NET_SSH1_READ_SIMPLE)
|
||||||
|
@ -971,9 +971,9 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Inputs a command into an interactive shell.
|
* Inputs a command into an interactive shell.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see self::interactiveRead()
|
||||||
* @param String $cmd
|
* @param string $cmd
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function interactiveWrite($cmd)
|
function interactiveWrite($cmd)
|
||||||
|
@ -1007,8 +1007,8 @@ class Net_SSH1
|
||||||
* does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user,
|
* does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user,
|
||||||
* there's not going to be much recourse.
|
* there's not going to be much recourse.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see self::interactiveRead()
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function interactiveRead()
|
function interactiveRead()
|
||||||
|
@ -1059,7 +1059,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Disconnect
|
* Disconnect
|
||||||
*
|
*
|
||||||
* @param String $msg
|
* @param string $msg
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _disconnect($msg = 'Client Quit')
|
function _disconnect($msg = 'Client Quit')
|
||||||
|
@ -1096,8 +1096,8 @@ class Net_SSH1
|
||||||
* Also, this function could be improved upon by adding detection for the following exploit:
|
* Also, this function could be improved upon by adding detection for the following exploit:
|
||||||
* http://www.securiteam.com/securitynews/5LP042K3FY.html
|
* http://www.securiteam.com/securitynews/5LP042K3FY.html
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_send_binary_packet()
|
* @see self::_send_binary_packet()
|
||||||
* @return Array
|
* @return array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _get_binary_packet()
|
function _get_binary_packet()
|
||||||
|
@ -1172,9 +1172,9 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see self::_get_binary_packet()
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _send_binary_packet($data)
|
function _send_binary_packet($data)
|
||||||
|
@ -1219,10 +1219,10 @@ class Net_SSH1
|
||||||
* we've reimplemented it. A more detailed discussion of the differences can be found after
|
* we've reimplemented it. A more detailed discussion of the differences can be found after
|
||||||
* $crc_lookup_table's initialization.
|
* $crc_lookup_table's initialization.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see self::_get_binary_packet()
|
||||||
* @see Net_SSH1::_send_binary_packet()
|
* @see self::_send_binary_packet()
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @return Integer
|
* @return int
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _crc($data)
|
function _crc($data)
|
||||||
|
@ -1317,9 +1317,9 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Inspired by array_shift
|
* Inspired by array_shift
|
||||||
*
|
*
|
||||||
* @param String $string
|
* @param string $string
|
||||||
* @param optional Integer $index
|
* @param int $index
|
||||||
* @return String
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _string_shift(&$string, $index = 1)
|
function _string_shift(&$string, $index = 1)
|
||||||
|
@ -1336,9 +1336,9 @@ class Net_SSH1
|
||||||
* should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that
|
* should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that
|
||||||
* calls this call modexp, instead, but I think this makes things clearer, maybe...
|
* calls this call modexp, instead, but I think this makes things clearer, maybe...
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::Net_SSH1()
|
* @see self::Net_SSH1()
|
||||||
* @param Math_BigInteger $m
|
* @param Math_BigInteger $m
|
||||||
* @param Array $key
|
* @param array $key
|
||||||
* @return Math_BigInteger
|
* @return Math_BigInteger
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -1391,7 +1391,7 @@ class Net_SSH1
|
||||||
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
||||||
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
||||||
*
|
*
|
||||||
* @param Array $array
|
* @param array $array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _define_array()
|
function _define_array()
|
||||||
|
@ -1414,7 +1414,7 @@ class Net_SSH1
|
||||||
* Returns a string if NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX, an array if NET_SSH1_LOGGING == NET_SSH1_LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING')
|
* Returns a string if NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX, an array if NET_SSH1_LOGGING == NET_SSH1_LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING')
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return String or Array
|
* @return array|false|string
|
||||||
*/
|
*/
|
||||||
function getLog()
|
function getLog()
|
||||||
{
|
{
|
||||||
|
@ -1437,10 +1437,10 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Formats a log for printing
|
* Formats a log for printing
|
||||||
*
|
*
|
||||||
* @param Array $message_log
|
* @param array $message_log
|
||||||
* @param Array $message_number_log
|
* @param array $message_number_log
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _format_log($message_log, $message_number_log)
|
function _format_log($message_log, $message_number_log)
|
||||||
{
|
{
|
||||||
|
@ -1473,9 +1473,9 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* For use with preg_replace_callback()
|
* For use with preg_replace_callback()
|
||||||
*
|
*
|
||||||
* @param Array $matches
|
* @param array $matches
|
||||||
* @access private
|
* @access private
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _format_log_helper($matches)
|
function _format_log_helper($matches)
|
||||||
{
|
{
|
||||||
|
@ -1488,8 +1488,8 @@ class Net_SSH1
|
||||||
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
||||||
* the raw bytes. This behavior is similar to PHP's md5() function.
|
* the raw bytes. This behavior is similar to PHP's md5() function.
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getServerKeyPublicExponent($raw_output = false)
|
function getServerKeyPublicExponent($raw_output = false)
|
||||||
|
@ -1503,8 +1503,8 @@ class Net_SSH1
|
||||||
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
||||||
* the raw bytes. This behavior is similar to PHP's md5() function.
|
* the raw bytes. This behavior is similar to PHP's md5() function.
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getServerKeyPublicModulus($raw_output = false)
|
function getServerKeyPublicModulus($raw_output = false)
|
||||||
|
@ -1518,8 +1518,8 @@ class Net_SSH1
|
||||||
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
||||||
* the raw bytes. This behavior is similar to PHP's md5() function.
|
* the raw bytes. This behavior is similar to PHP's md5() function.
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getHostKeyPublicExponent($raw_output = false)
|
function getHostKeyPublicExponent($raw_output = false)
|
||||||
|
@ -1533,8 +1533,8 @@ class Net_SSH1
|
||||||
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
* Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead,
|
||||||
* the raw bytes. This behavior is similar to PHP's md5() function.
|
* the raw bytes. This behavior is similar to PHP's md5() function.
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getHostKeyPublicModulus($raw_output = false)
|
function getHostKeyPublicModulus($raw_output = false)
|
||||||
|
@ -1549,8 +1549,8 @@ class Net_SSH1
|
||||||
* is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll
|
* is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll
|
||||||
* get array(NET_SSH1_CIPHER_3DES).
|
* get array(NET_SSH1_CIPHER_3DES).
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getSupportedCiphers($raw_output = false)
|
function getSupportedCiphers($raw_output = false)
|
||||||
|
@ -1565,8 +1565,8 @@ class Net_SSH1
|
||||||
* is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll
|
* is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll
|
||||||
* get array(NET_SSH1_AUTH_PASSWORD).
|
* get array(NET_SSH1_AUTH_PASSWORD).
|
||||||
*
|
*
|
||||||
* @param optional Boolean $raw_output
|
* @param bool $raw_output
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getSupportedAuthentications($raw_output = false)
|
function getSupportedAuthentications($raw_output = false)
|
||||||
|
@ -1577,7 +1577,7 @@ class Net_SSH1
|
||||||
/**
|
/**
|
||||||
* Return the server identification.
|
* Return the server identification.
|
||||||
*
|
*
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getServerIdentification()
|
function getServerIdentification()
|
||||||
|
@ -1590,7 +1590,7 @@ class Net_SSH1
|
||||||
*
|
*
|
||||||
* Makes sure that only the last 1MB worth of packets will be logged
|
* Makes sure that only the last 1MB worth of packets will be logged
|
||||||
*
|
*
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _append_log($protocol_flags, $message)
|
function _append_log($protocol_flags, $message)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,32 +101,32 @@ class System_SSH_Agent_Identity
|
||||||
*
|
*
|
||||||
* @var Crypt_RSA
|
* @var Crypt_RSA
|
||||||
* @access private
|
* @access private
|
||||||
* @see System_SSH_Agent_Identity::getPublicKey()
|
* @see self::getPublicKey()
|
||||||
*/
|
*/
|
||||||
var $key;
|
var $key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key Blob
|
* Key Blob
|
||||||
*
|
*
|
||||||
* @var String
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
* @see System_SSH_Agent_Identity::sign()
|
* @see self::sign()
|
||||||
*/
|
*/
|
||||||
var $key_blob;
|
var $key_blob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Socket Resource
|
* Socket Resource
|
||||||
*
|
*
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
* @see System_SSH_Agent_Identity::sign()
|
* @see self::sign()
|
||||||
*/
|
*/
|
||||||
var $fsock;
|
var $fsock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @param Resource $fsock
|
* @param resource $fsock
|
||||||
* @return System_SSH_Agent_Identity
|
* @return System_SSH_Agent_Identity
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -155,7 +155,7 @@ class System_SSH_Agent_Identity
|
||||||
* Called by System_SSH_Agent::requestIdentities(). The key blob could be extracted from $this->key
|
* Called by System_SSH_Agent::requestIdentities(). The key blob could be extracted from $this->key
|
||||||
* but this saves a small amount of computation.
|
* but this saves a small amount of computation.
|
||||||
*
|
*
|
||||||
* @param String $key_blob
|
* @param string $key_blob
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function setPublicKeyBlob($key_blob)
|
function setPublicKeyBlob($key_blob)
|
||||||
|
@ -168,8 +168,8 @@ class System_SSH_Agent_Identity
|
||||||
*
|
*
|
||||||
* Wrapper for $this->key->getPublicKey()
|
* Wrapper for $this->key->getPublicKey()
|
||||||
*
|
*
|
||||||
* @param Integer $format optional
|
* @param int $format optional
|
||||||
* @return Mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getPublicKey($format = null)
|
function getPublicKey($format = null)
|
||||||
|
@ -183,7 +183,7 @@ class System_SSH_Agent_Identity
|
||||||
* Doesn't do anything as ssh-agent doesn't let you pick and choose the signature mode. ie.
|
* Doesn't do anything as ssh-agent doesn't let you pick and choose the signature mode. ie.
|
||||||
* ssh-agent's only supported mode is CRYPT_RSA_SIGNATURE_PKCS1
|
* ssh-agent's only supported mode is CRYPT_RSA_SIGNATURE_PKCS1
|
||||||
*
|
*
|
||||||
* @param Integer $mode
|
* @param int $mode
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setSignatureMode($mode)
|
function setSignatureMode($mode)
|
||||||
|
@ -195,8 +195,8 @@ class System_SSH_Agent_Identity
|
||||||
*
|
*
|
||||||
* See "2.6.2 Protocol 2 private key signature request"
|
* See "2.6.2 Protocol 2 private key signature request"
|
||||||
*
|
*
|
||||||
* @param String $message
|
* @param string $message
|
||||||
* @return String
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function sign($message)
|
function sign($message)
|
||||||
|
@ -235,7 +235,7 @@ class System_SSH_Agent
|
||||||
/**
|
/**
|
||||||
* Socket Resource
|
* Socket Resource
|
||||||
*
|
*
|
||||||
* @var Resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $fsock;
|
var $fsock;
|
||||||
|
@ -295,7 +295,7 @@ class System_SSH_Agent
|
||||||
* See "2.5.2 Requesting a list of protocol 2 keys"
|
* See "2.5.2 Requesting a list of protocol 2 keys"
|
||||||
* Returns an array containing zero or more System_SSH_Agent_Identity objects
|
* Returns an array containing zero or more System_SSH_Agent_Identity objects
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function requestIdentities()
|
function requestIdentities()
|
||||||
|
@ -321,7 +321,9 @@ class System_SSH_Agent
|
||||||
$length = current(unpack('N', fread($this->fsock, 4)));
|
$length = current(unpack('N', fread($this->fsock, 4)));
|
||||||
$key_blob = fread($this->fsock, $length);
|
$key_blob = fread($this->fsock, $length);
|
||||||
$length = current(unpack('N', fread($this->fsock, 4)));
|
$length = current(unpack('N', fread($this->fsock, 4)));
|
||||||
|
if ($length) {
|
||||||
$key_comment = fread($this->fsock, $length);
|
$key_comment = fread($this->fsock, $length);
|
||||||
|
}
|
||||||
$length = current(unpack('N', substr($key_blob, 0, 4)));
|
$length = current(unpack('N', substr($key_blob, 0, 4)));
|
||||||
$key_type = substr($key_blob, 4, $length);
|
$key_type = substr($key_blob, 4, $length);
|
||||||
switch ($key_type) {
|
switch ($key_type) {
|
||||||
|
@ -354,7 +356,7 @@ class System_SSH_Agent
|
||||||
* be requested when a channel is opened
|
* be requested when a channel is opened
|
||||||
*
|
*
|
||||||
* @param Net_SSH2 $ssh
|
* @param Net_SSH2 $ssh
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function startSSHForwarding($ssh)
|
function startSSHForwarding($ssh)
|
||||||
|
@ -368,7 +370,7 @@ class System_SSH_Agent
|
||||||
* Request agent forwarding of remote server
|
* Request agent forwarding of remote server
|
||||||
*
|
*
|
||||||
* @param Net_SSH2 $ssh
|
* @param Net_SSH2 $ssh
|
||||||
* @return Boolean
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _request_forwarding($ssh)
|
function _request_forwarding($ssh)
|
||||||
|
@ -424,7 +426,7 @@ class System_SSH_Agent
|
||||||
/**
|
/**
|
||||||
* Forward data to SSH Agent and return data reply
|
* Forward data to SSH Agent and return data reply
|
||||||
*
|
*
|
||||||
* @param String $data
|
* @param string $data
|
||||||
* @return data from SSH Agent
|
* @return data from SSH Agent
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue