summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/phpseclib-0.3.9/Crypt/AES.php (renamed from libs/phpseclib-0.3.7/Crypt/AES.php)52
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Base.php (renamed from libs/phpseclib-0.3.7/Crypt/Base.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Blowfish.php (renamed from libs/phpseclib-0.3.7/Crypt/Blowfish.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/DES.php (renamed from libs/phpseclib-0.3.7/Crypt/DES.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Hash.php (renamed from libs/phpseclib-0.3.7/Crypt/Hash.php)11
-rw-r--r--libs/phpseclib-0.3.9/Crypt/RC2.php (renamed from libs/phpseclib-0.3.7/Crypt/RC2.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/RC4.php (renamed from libs/phpseclib-0.3.7/Crypt/RC4.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/RSA.php (renamed from libs/phpseclib-0.3.7/Crypt/RSA.php)40
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Random.php (renamed from libs/phpseclib-0.3.7/Crypt/Random.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Rijndael.php (renamed from libs/phpseclib-0.3.7/Crypt/Rijndael.php)6
-rw-r--r--libs/phpseclib-0.3.9/Crypt/TripleDES.php (renamed from libs/phpseclib-0.3.7/Crypt/TripleDES.php)0
-rw-r--r--libs/phpseclib-0.3.9/Crypt/Twofish.php (renamed from libs/phpseclib-0.3.7/Crypt/Twofish.php)0
-rw-r--r--libs/phpseclib-0.3.9/File/ANSI.php (renamed from libs/phpseclib-0.3.7/File/ANSI.php)0
-rw-r--r--libs/phpseclib-0.3.9/File/ASN1.php (renamed from libs/phpseclib-0.3.7/File/ASN1.php)412
-rw-r--r--libs/phpseclib-0.3.9/File/X509.php (renamed from libs/phpseclib-0.3.7/File/X509.php)0
-rw-r--r--libs/phpseclib-0.3.9/Math/BigInteger.php (renamed from libs/phpseclib-0.3.7/Math/BigInteger.php)17
-rw-r--r--libs/phpseclib-0.3.9/Net/SCP.php (renamed from libs/phpseclib-0.3.7/Net/SCP.php)0
-rw-r--r--libs/phpseclib-0.3.9/Net/SFTP.php (renamed from libs/phpseclib-0.3.7/Net/SFTP.php)114
-rw-r--r--libs/phpseclib-0.3.9/Net/SFTP/Stream.php (renamed from libs/phpseclib-0.3.7/Net/SFTP/Stream.php)0
-rw-r--r--libs/phpseclib-0.3.9/Net/SSH1.php (renamed from libs/phpseclib-0.3.7/Net/SSH1.php)0
-rw-r--r--libs/phpseclib-0.3.9/Net/SSH2.php (renamed from libs/phpseclib-0.3.7/Net/SSH2.php)128
-rw-r--r--libs/phpseclib-0.3.9/System/SSH/Agent.php (renamed from libs/phpseclib-0.3.7/System/SSH/Agent.php)0
-rw-r--r--libs/phpseclib-0.3.9/System/SSH_Agent.php (renamed from libs/phpseclib-0.3.7/System/SSH_Agent.php)0
-rw-r--r--libs/phpseclib-0.3.9/openssl.cnf (renamed from libs/phpseclib-0.3.7/openssl.cnf)0
24 files changed, 455 insertions, 325 deletions
diff --git a/libs/phpseclib-0.3.7/Crypt/AES.php b/libs/phpseclib-0.3.9/Crypt/AES.php
index 67fc5e4..832be25 100644
--- a/libs/phpseclib-0.3.7/Crypt/AES.php
+++ b/libs/phpseclib-0.3.9/Crypt/AES.php
@@ -152,4 +152,56 @@ class Crypt_AES extends Crypt_Rijndael
{
return;
}
+
+ /**
+ * Sets the key length
+ *
+ * Valid key lengths are 128, 192, and 256. If the length is less than 128, it will be rounded up to
+ * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
+ *
+ * @see Crypt_Rijndael:setKeyLength()
+ * @access public
+ * @param Integer $length
+ */
+ function setKeyLength($length)
+ {
+ switch ($length) {
+ case 160:
+ $length = 192;
+ break;
+ case 224:
+ $length = 256;
+ }
+ parent::setKeyLength($length);
+ }
+
+ /**
+ * Sets the key.
+ *
+ * Rijndael supports five different key lengths, AES only supports three.
+ *
+ * @see Crypt_Rijndael:setKey()
+ * @see setKeyLength()
+ * @access public
+ * @param String $key
+ */
+ function setKey($key)
+ {
+ parent::setKey($key);
+
+ if (!$this->explicit_key_length) {
+ $length = strlen($key);
+ switch (true) {
+ case $length <= 16:
+ $this->key_size = 16;
+ break;
+ case $length <= 24:
+ $this->key_size = 24;
+ break;
+ default:
+ $this->key_size = 32;
+ }
+ $this->_setupEngine();
+ }
+ }
}
diff --git a/libs/phpseclib-0.3.7/Crypt/Base.php b/libs/phpseclib-0.3.9/Crypt/Base.php
index ec1788f..ec1788f 100644
--- a/libs/phpseclib-0.3.7/Crypt/Base.php
+++ b/libs/phpseclib-0.3.9/Crypt/Base.php
diff --git a/libs/phpseclib-0.3.7/Crypt/Blowfish.php b/libs/phpseclib-0.3.9/Crypt/Blowfish.php
index 7d4987c..7d4987c 100644
--- a/libs/phpseclib-0.3.7/Crypt/Blowfish.php
+++ b/libs/phpseclib-0.3.9/Crypt/Blowfish.php
diff --git a/libs/phpseclib-0.3.7/Crypt/DES.php b/libs/phpseclib-0.3.9/Crypt/DES.php
index f8e6a83..f8e6a83 100644
--- a/libs/phpseclib-0.3.7/Crypt/DES.php
+++ b/libs/phpseclib-0.3.9/Crypt/DES.php
diff --git a/libs/phpseclib-0.3.7/Crypt/Hash.php b/libs/phpseclib-0.3.9/Crypt/Hash.php
index d748bad..d6e81e8 100644
--- a/libs/phpseclib-0.3.7/Crypt/Hash.php
+++ b/libs/phpseclib-0.3.9/Crypt/Hash.php
@@ -5,7 +5,7 @@
*
* Uses hash() or mhash() if available and an internal implementation, otherwise. Currently supports the following:
*
- * md2, md5, md5-96, sha1, sha1-96, sha256, sha384, and sha512
+ * 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
* the hash. If no valid algorithm is provided, sha1 will be used.
@@ -207,6 +207,9 @@ class Crypt_Hash
switch ($hash) {
case 'md5-96':
case 'sha1-96':
+ case 'sha256-96':
+ case 'sha512-96':
+ $hash = substr($hash, 0, -3);
$this->l = 12; // 96 / 8 = 12
break;
case 'md2':
@@ -243,14 +246,12 @@ class Crypt_Hash
case CRYPT_HASH_MODE_MHASH:
switch ($hash) {
case 'md5':
- case 'md5-96':
$this->hash = MHASH_MD5;
break;
case 'sha256':
$this->hash = MHASH_SHA256;
break;
case 'sha1':
- case 'sha1-96':
default:
$this->hash = MHASH_SHA1;
}
@@ -258,7 +259,6 @@ class Crypt_Hash
case CRYPT_HASH_MODE_HASH:
switch ($hash) {
case 'md5':
- case 'md5-96':
$this->hash = 'md5';
return;
case 'md2':
@@ -268,7 +268,6 @@ class Crypt_Hash
$this->hash = $hash;
return;
case 'sha1':
- case 'sha1-96':
default:
$this->hash = 'sha1';
}
@@ -281,7 +280,6 @@ class Crypt_Hash
$this->hash = array($this, '_md2');
break;
case 'md5':
- case 'md5-96':
$this->b = 64;
$this->hash = array($this, '_md5');
break;
@@ -295,7 +293,6 @@ class Crypt_Hash
$this->hash = array($this, '_sha512');
break;
case 'sha1':
- case 'sha1-96':
default:
$this->b = 64;
$this->hash = array($this, '_sha1');
diff --git a/libs/phpseclib-0.3.7/Crypt/RC2.php b/libs/phpseclib-0.3.9/Crypt/RC2.php
index f98dc2c..f98dc2c 100644
--- a/libs/phpseclib-0.3.7/Crypt/RC2.php
+++ b/libs/phpseclib-0.3.9/Crypt/RC2.php
diff --git a/libs/phpseclib-0.3.7/Crypt/RC4.php b/libs/phpseclib-0.3.9/Crypt/RC4.php
index 24ae0a9..24ae0a9 100644
--- a/libs/phpseclib-0.3.7/Crypt/RC4.php
+++ b/libs/phpseclib-0.3.9/Crypt/RC4.php
diff --git a/libs/phpseclib-0.3.7/Crypt/RSA.php b/libs/phpseclib-0.3.9/Crypt/RSA.php
index 3ccf16f..823044b 100644
--- a/libs/phpseclib-0.3.7/Crypt/RSA.php
+++ b/libs/phpseclib-0.3.9/Crypt/RSA.php
@@ -493,14 +493,13 @@ class Crypt_RSA
$this->configFile = CRYPT_RSA_OPENSSL_CONFIG;
if ( !defined('CRYPT_RSA_MODE') ) {
- // Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular,
- // Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger
- // can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either.
- if ( defined('MATH_BIGINTEGER_OPENSSL_DISABLE') ) {
- define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
- }
-
- switch ( !defined('CRYPT_RSA_MODE') ) { // ie. only run this if the above didn't set CRYPT_RSA_MODE already
+ switch (true) {
+ // Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular,
+ // Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger
+ // can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either.
+ case defined('MATH_BIGINTEGER_OPENSSL_DISABLE'):
+ define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
+ break;
// openssl_pkey_get_details - which is used in the only place Crypt/RSA.php uses OpenSSL - was introduced in PHP 5.2.0
case !function_exists('openssl_pkey_get_details'):
define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
@@ -533,7 +532,7 @@ class Crypt_RSA
define('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
}
break;
- case true:
+ default:
define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
}
}
@@ -743,17 +742,18 @@ class Crypt_RSA
*/
function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients)
{
+ $signed = $this->privateKeyFormat != CRYPT_RSA_PRIVATE_FORMAT_XML;
$num_primes = count($primes);
$raw = array(
'version' => $num_primes == 2 ? chr(0) : chr(1), // two-prime vs. multi
- 'modulus' => $n->toBytes(true),
- 'publicExponent' => $e->toBytes(true),
- 'privateExponent' => $d->toBytes(true),
- 'prime1' => $primes[1]->toBytes(true),
- 'prime2' => $primes[2]->toBytes(true),
- 'exponent1' => $exponents[1]->toBytes(true),
- 'exponent2' => $exponents[2]->toBytes(true),
- 'coefficient' => $coefficients[2]->toBytes(true)
+ 'modulus' => $n->toBytes($signed),
+ 'publicExponent' => $e->toBytes($signed),
+ 'privateExponent' => $d->toBytes($signed),
+ 'prime1' => $primes[1]->toBytes($signed),
+ 'prime2' => $primes[2]->toBytes($signed),
+ 'exponent1' => $exponents[1]->toBytes($signed),
+ 'exponent2' => $exponents[2]->toBytes($signed),
+ 'coefficient' => $coefficients[2]->toBytes($signed)
);
// if the format in question does not support multi-prime rsa and multi-prime rsa was used,
@@ -942,8 +942,10 @@ class Crypt_RSA
*/
function _convertPublicKey($n, $e)
{
- $modulus = $n->toBytes(true);
- $publicExponent = $e->toBytes(true);
+ $signed = $this->publicKeyFormat != CRYPT_RSA_PUBLIC_FORMAT_XML;
+
+ $modulus = $n->toBytes($signed);
+ $publicExponent = $e->toBytes($signed);
switch ($this->publicKeyFormat) {
case CRYPT_RSA_PUBLIC_FORMAT_RAW:
diff --git a/libs/phpseclib-0.3.7/Crypt/Random.php b/libs/phpseclib-0.3.9/Crypt/Random.php
index 5a3d28c..5a3d28c 100644
--- a/libs/phpseclib-0.3.7/Crypt/Random.php
+++ b/libs/phpseclib-0.3.9/Crypt/Random.php
diff --git a/libs/phpseclib-0.3.7/Crypt/Rijndael.php b/libs/phpseclib-0.3.9/Crypt/Rijndael.php
index d0f9172..3631972 100644
--- a/libs/phpseclib-0.3.7/Crypt/Rijndael.php
+++ b/libs/phpseclib-0.3.9/Crypt/Rijndael.php
@@ -702,9 +702,15 @@ class Crypt_Rijndael extends Crypt_Base
case $length <= 16:
$this->key_size = 16;
break;
+ case $length <= 20:
+ $this->key_size = 20;
+ break;
case $length <= 24:
$this->key_size = 24;
break;
+ case $length <= 28:
+ $this->key_size = 28;
+ break;
default:
$this->key_size = 32;
}
diff --git a/libs/phpseclib-0.3.7/Crypt/TripleDES.php b/libs/phpseclib-0.3.9/Crypt/TripleDES.php
index 175b3ac..175b3ac 100644
--- a/libs/phpseclib-0.3.7/Crypt/TripleDES.php
+++ b/libs/phpseclib-0.3.9/Crypt/TripleDES.php
diff --git a/libs/phpseclib-0.3.7/Crypt/Twofish.php b/libs/phpseclib-0.3.9/Crypt/Twofish.php
index 4099a01..4099a01 100644
--- a/libs/phpseclib-0.3.7/Crypt/Twofish.php
+++ b/libs/phpseclib-0.3.9/Crypt/Twofish.php
diff --git a/libs/phpseclib-0.3.7/File/ANSI.php b/libs/phpseclib-0.3.9/File/ANSI.php
index ef2ccbe..ef2ccbe 100644
--- a/libs/phpseclib-0.3.7/File/ANSI.php
+++ b/libs/phpseclib-0.3.9/File/ANSI.php
diff --git a/libs/phpseclib-0.3.7/File/ASN1.php b/libs/phpseclib-0.3.9/File/ASN1.php
index 2ca8bc8..159a89c 100644
--- a/libs/phpseclib-0.3.7/File/ASN1.php
+++ b/libs/phpseclib-0.3.9/File/ASN1.php
@@ -272,7 +272,8 @@ class File_ASN1
}
$this->encoded = $encoded;
- return $this->_decode_ber($encoded);
+ // encapsulate in an array for BC with the old decodeBER
+ return array($this->_decode_ber($encoded));
}
/**
@@ -287,215 +288,238 @@ class File_ASN1
* @return Array
* @access private
*/
- function _decode_ber(&$encoded, $start = 0)
+ function _decode_ber($encoded, $start = 0)
{
- $decoded = array();
-
- while ( strlen($encoded) ) {
- $current = array('start' => $start);
-
- $type = ord($this->_string_shift($encoded));
- $start++;
-
- $constructed = ($type >> 5) & 1;
-
- $tag = $type & 0x1F;
- if ($tag == 0x1F) {
- $tag = 0;
- // process septets (since the eighth bit is ignored, it's not an octet)
- do {
- $loop = ord($encoded[0]) >> 7;
- $tag <<= 7;
- $tag |= ord($this->_string_shift($encoded)) & 0x7F;
- $start++;
- } while ( $loop );
- }
+ $current = array('start' => $start);
+
+ $type = ord($this->_string_shift($encoded));
+ $start++;
+
+ $constructed = ($type >> 5) & 1;
+
+ $tag = $type & 0x1F;
+ if ($tag == 0x1F) {
+ $tag = 0;
+ // process septets (since the eighth bit is ignored, it's not an octet)
+ do {
+ $loop = ord($encoded[0]) >> 7;
+ $tag <<= 7;
+ $tag |= ord($this->_string_shift($encoded)) & 0x7F;
+ $start++;
+ } while ( $loop );
+ }
+
+ // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
+ $length = ord($this->_string_shift($encoded));
+ $start++;
+ if ( $length == 0x80 ) { // indefinite length
+ // "[A sender shall] use the indefinite form (see 8.1.3.6) if the encoding is constructed and is not all
+ // immediately available." -- paragraph 8.1.3.2.c
+ $length = strlen($encoded);
+ } elseif ( $length & 0x80 ) { // definite length, long form
+ // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only
+ // support it up to four.
+ $length&= 0x7F;
+ $temp = $this->_string_shift($encoded, $length);
+ // tags of indefinte length don't really have a header length; this length includes the tag
+ $current+= array('headerlength' => $length + 2);
+ $start+= $length;
+ extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
+ } else {
+ $current+= array('headerlength' => 2);
+ }
+
+ $content = $this->_string_shift($encoded, $length);
+
+ // at this point $length can be overwritten. it's only accurate for definite length things as is
+
+ /* Class is UNIVERSAL, APPLICATION, PRIVATE, or CONTEXT-SPECIFIC. The UNIVERSAL class is restricted to the ASN.1
+ built-in types. It defines an application-independent data type that must be distinguishable from all other
+ data types. The other three classes are user defined. The APPLICATION class distinguishes data types that
+ have a wide, scattered use within a particular presentation context. PRIVATE distinguishes data types within
+ a particular organization or country. CONTEXT-SPECIFIC distinguishes members of a sequence or set, the
+ alternatives of a CHOICE, or universally tagged set members. Only the class number appears in braces for this
+ data type; the term CONTEXT-SPECIFIC does not appear.
+
+ -- http://www.obj-sys.com/asn1tutorial/node12.html */
+ $class = ($type >> 6) & 3;
+ switch ($class) {
+ case FILE_ASN1_CLASS_APPLICATION:
+ case FILE_ASN1_CLASS_PRIVATE:
+ case FILE_ASN1_CLASS_CONTEXT_SPECIFIC:
+ if ($constructed) {
+ $newcontent = $this->_decode_ber($content, $start);
+ $length = $newcontent['length'];
+ if (substr($content, $length, 2) == "\0\0") {
+ $length+= 2;
+ }
+
+ // the array encapsulation is for BC with the old format
+ $content = array($newcontent);
+ }
- // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
- $length = ord($this->_string_shift($encoded));
- $start++;
- if ( $length == 0x80 ) { // indefinite length
- // "[A sender shall] use the indefinite form (see 8.1.3.6) if the encoding is constructed and is not all
- // immediately available." -- paragraph 8.1.3.2.c
- //if ( !$constructed ) {
- // return false;
- //}
- $length = strlen($encoded);
- } elseif ( $length & 0x80 ) { // definite length, long form
- // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only
- // support it up to four.
- $length&= 0x7F;
- $temp = $this->_string_shift($encoded, $length);
- // tags of indefinite length don't really have a header length; this length includes the tag
- $current+= array('headerlength' => $length + 2);
$start+= $length;
- extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
- } else {
- $current+= array('headerlength' => 2);
- }
- // End-of-content, see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2
- if (!$type && !$length) {
- return $decoded;
- }
- $content = $this->_string_shift($encoded, $length);
-
- /* Class is UNIVERSAL, APPLICATION, PRIVATE, or CONTEXT-SPECIFIC. The UNIVERSAL class is restricted to the ASN.1
- built-in types. It defines an application-independent data type that must be distinguishable from all other
- data types. The other three classes are user defined. The APPLICATION class distinguishes data types that
- have a wide, scattered use within a particular presentation context. PRIVATE distinguishes data types within
- a particular organization or country. CONTEXT-SPECIFIC distinguishes members of a sequence or set, the
- alternatives of a CHOICE, or universally tagged set members. Only the class number appears in braces for this
- data type; the term CONTEXT-SPECIFIC does not appear.
-
- -- http://www.obj-sys.com/asn1tutorial/node12.html */
- $class = ($type >> 6) & 3;
- switch ($class) {
- case FILE_ASN1_CLASS_APPLICATION:
- case FILE_ASN1_CLASS_PRIVATE:
- case FILE_ASN1_CLASS_CONTEXT_SPECIFIC:
- $decoded[] = array(
- 'type' => $class,
- 'constant' => $tag,
- 'content' => $constructed ? $this->_decode_ber($content, $start) : $content,
- 'length' => $length + $start - $current['start']
- ) + $current;
- $start+= $length;
- continue 2;
- }
+ return array(
+ 'type' => $class,
+ 'constant' => $tag,
+ // the array encapsulation is for BC with the old format
+ 'content' => $content,
+ // the only time when $content['headerlength'] isn't defined is when the length is indefinite.
+ // the absence of $content['headerlength'] is how we know if something is indefinite or not.
+ // technically, it could be defined to be 2 and then another indicator could be used but whatever.
+ 'length' => $start - $current['start']
+ ) + $current;
+ }
- $current+= array('type' => $tag);
+ $current+= array('type' => $tag);
- // decode UNIVERSAL tags
- switch ($tag) {
- case FILE_ASN1_TYPE_BOOLEAN:
- // "The contents octets shall consist of a single octet." -- paragraph 8.2.1
- //if (strlen($content) != 1) {
- // return false;
- //}
- $current['content'] = (bool) ord($content[0]);
- break;
- case FILE_ASN1_TYPE_INTEGER:
- case FILE_ASN1_TYPE_ENUMERATED:
- $current['content'] = new Math_BigInteger($content, -256);
- break;
- case FILE_ASN1_TYPE_REAL: // not currently supported
- return false;
- case FILE_ASN1_TYPE_BIT_STRING:
- // The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit,
- // the number of unused bits in the final subsequent octet. The number shall be in the range zero to
- // seven.
- if (!$constructed) {
- $current['content'] = $content;
- } else {
- $temp = $this->_decode_ber($content, $start);
- $length-= strlen($content);
- $last = count($temp) - 1;
- for ($i = 0; $i < $last; $i++) {
- // all subtags should be bit strings
- //if ($temp[$i]['type'] != FILE_ASN1_TYPE_BIT_STRING) {
- // return false;
- //}
- $current['content'].= substr($temp[$i]['content'], 1);
- }
+ // decode UNIVERSAL tags
+ switch ($tag) {
+ case FILE_ASN1_TYPE_BOOLEAN:
+ // "The contents octets shall consist of a single octet." -- paragraph 8.2.1
+ //if (strlen($content) != 1) {
+ // return false;
+ //}
+ $current['content'] = (bool) ord($content[0]);
+ break;
+ case FILE_ASN1_TYPE_INTEGER:
+ case FILE_ASN1_TYPE_ENUMERATED:
+ $current['content'] = new Math_BigInteger($content, -256);
+ break;
+ case FILE_ASN1_TYPE_REAL: // not currently supported
+ return false;
+ case FILE_ASN1_TYPE_BIT_STRING:
+ // The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit,
+ // the number of unused bits in the final subsequent octet. The number shall be in the range zero to
+ // seven.
+ if (!$constructed) {
+ $current['content'] = $content;
+ } else {
+ $temp = $this->_decode_ber($content, $start);
+ $length-= strlen($content);
+ $last = count($temp) - 1;
+ for ($i = 0; $i < $last; $i++) {
// all subtags should be bit strings
- //if ($temp[$last]['type'] != FILE_ASN1_TYPE_BIT_STRING) {
+ //if ($temp[$i]['type'] != FILE_ASN1_TYPE_BIT_STRING) {
// return false;
//}
- $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1);
+ $current['content'].= substr($temp[$i]['content'], 1);
}
- break;
- case FILE_ASN1_TYPE_OCTET_STRING:
- if (!$constructed) {
- $current['content'] = $content;
- } else {
- $temp = $this->_decode_ber($content, $start);
- $length-= strlen($content);
- for ($i = 0, $size = count($temp); $i < $size; $i++) {
- // all subtags should be octet strings
- //if ($temp[$i]['type'] != FILE_ASN1_TYPE_OCTET_STRING) {
- // return false;
- //}
- $current['content'].= $temp[$i]['content'];
- }
- // $length =
- }
- break;
- case FILE_ASN1_TYPE_NULL:
- // "The contents octets shall not contain any octets." -- paragraph 8.8.2
- //if (strlen($content)) {
+ // all subtags should be bit strings
+ //if ($temp[$last]['type'] != FILE_ASN1_TYPE_BIT_STRING) {
// return false;
//}
- break;
- case FILE_ASN1_TYPE_SEQUENCE:
- case FILE_ASN1_TYPE_SET:
- $current['content'] = $this->_decode_ber($content, $start);
- break;
- case FILE_ASN1_TYPE_OBJECT_IDENTIFIER:
+ $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1);
+ }
+ break;
+ case FILE_ASN1_TYPE_OCTET_STRING:
+ if (!$constructed) {
+ $current['content'] = $content;
+ } else {
+ $current['content'] = '';
+ $length = 0;
+ while (substr($content, 0, 2) != "\0\0") {
+ $temp = $this->_decode_ber($content, $length + $start);
+ $this->_string_shift($content, $temp['length']);
+ // all subtags should be octet strings
+ //if ($temp['type'] != FILE_ASN1_TYPE_OCTET_STRING) {
+ // return false;
+ //}
+ $current['content'].= $temp['content'];
+ $length+= $temp['length'];
+ }
+ if (substr($content, 0, 2) == "\0\0") {
+ $length+= 2; // +2 for the EOC
+ }
+ }
+ break;
+ case FILE_ASN1_TYPE_NULL:
+ // "The contents octets shall not contain any octets." -- paragraph 8.8.2
+ //if (strlen($content)) {
+ // return false;
+ //}
+ break;
+ case FILE_ASN1_TYPE_SEQUENCE:
+ case FILE_ASN1_TYPE_SET:
+ $offset = 0;
+ $current['content'] = array();
+ while (strlen($content)) {
+ // if indefinite length construction was used and we have an end-of-content string next
+ // see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2
+ if (!isset($current['headerlength']) && substr($content, 0, 2) == "\0\0") {
+ $length = $offset + 2; // +2 for the EOC
+ break 2;
+ }
+ $temp = $this->_decode_ber($content, $start + $offset);
+ $this->_string_shift($content, $temp['length']);
+ $current['content'][] = $temp;
+ $offset+= $temp['length'];
+ }
+ break;
+ case FILE_ASN1_TYPE_OBJECT_IDENTIFIER:
+ $temp = ord($this->_string_shift($content));
+ $current['content'] = sprintf('%d.%d', floor($temp / 40), $temp % 40);
+ $valuen = 0;
+ // process septets
+ while (strlen($content)) {
$temp = ord($this->_string_shift($content));
- $current['content'] = sprintf('%d.%d', floor($temp / 40), $temp % 40);
- $valuen = 0;
- // process septets
- while (strlen($content)) {
- $temp = ord($this->_string_shift($content));
- $valuen <<= 7;
- $valuen |= $temp & 0x7F;
- if (~$temp & 0x80) {
- $current['content'].= ".$valuen";
- $valuen = 0;
- }
+ $valuen <<= 7;
+ $valuen |= $temp & 0x7F;
+ if (~$temp & 0x80) {
+ $current['content'].= ".$valuen";
+ $valuen = 0;
}
- // the eighth bit of the last byte should not be 1
- //if ($temp >> 7) {
- // return false;
- //}
- break;
- /* Each character string type shall be encoded as if it had been declared:
- [UNIVERSAL x] IMPLICIT OCTET STRING
-
- -- X.690-0207.pdf#page=23 (paragraph 8.21.3)
-
- Per that, we're not going to do any validation. If there are any illegal characters in the string,
- we don't really care */
- case FILE_ASN1_TYPE_NUMERIC_STRING:
- // 0,1,2,3,4,5,6,7,8,9, and space
- case FILE_ASN1_TYPE_PRINTABLE_STRING:
- // Upper and lower case letters, digits, space, apostrophe, left/right parenthesis, plus sign, comma,
- // hyphen, full stop, solidus, colon, equal sign, question mark
- case FILE_ASN1_TYPE_TELETEX_STRING:
- // The Teletex character set in CCITT's T61, space, and delete
- // see http://en.wikipedia.org/wiki/Teletex#Character_sets
- case FILE_ASN1_TYPE_VIDEOTEX_STRING:
- // The Videotex character set in CCITT's T.100 and T.101, space, and delete
- case FILE_ASN1_TYPE_VISIBLE_STRING:
- // Printing character sets of international ASCII, and space
- case FILE_ASN1_TYPE_IA5_STRING:
- // International Alphabet 5 (International ASCII)
- case FILE_ASN1_TYPE_GRAPHIC_STRING:
- // All registered G sets, and space
- case FILE_ASN1_TYPE_GENERAL_STRING:
- // All registered C and G sets, space and delete
- case FILE_ASN1_TYPE_UTF8_STRING:
- // ????
- case FILE_ASN1_TYPE_BMP_STRING:
- $current['content'] = $content;
- break;
- case FILE_ASN1_TYPE_UTC_TIME:
- case FILE_ASN1_TYPE_GENERALIZED_TIME:
- $current['content'] = $this->_decodeTime($content, $tag);
- default:
+ }
+ // the eighth bit of the last byte should not be 1
+ //if ($temp >> 7) {
+ // return false;
+ //}
+ break;
+ /* Each character string type shall be encoded as if it had been declared:
+ [UNIVERSAL x] IMPLICIT OCTET STRING
- }
+ -- X.690-0207.pdf#page=23 (paragraph 8.21.3)
- $start+= $length;
- $decoded[] = $current + array('length' => $start - $current['start']);
+ Per that, we're not going to do any validation. If there are any illegal characters in the string,
+ we don't really care */
+ case FILE_ASN1_TYPE_NUMERIC_STRING:
+ // 0,1,2,3,4,5,6,7,8,9, and space
+ case FILE_ASN1_TYPE_PRINTABLE_STRING:
+ // Upper and lower case letters, digits, space, apostrophe, left/right parenthesis, plus sign, comma,
+ // hyphen, full stop, solidus, colon, equal sign, question mark
+ case FILE_ASN1_TYPE_TELETEX_STRING:
+ // The Teletex character set in CCITT's T61, space, and delete
+ // see http://en.wikipedia.org/wiki/Teletex#Character_sets
+ case FILE_ASN1_TYPE_VIDEOTEX_STRING:
+ // The Videotex character set in CCITT's T.100 and T.101, space, and delete
+ case FILE_ASN1_TYPE_VISIBLE_STRING:
+ // Printing character sets of international ASCII, and space
+ case FILE_ASN1_TYPE_IA5_STRING:
+ // International Alphabet 5 (International ASCII)
+ case FILE_ASN1_TYPE_GRAPHIC_STRING:
+ // All registered G sets, and space
+ case FILE_ASN1_TYPE_GENERAL_STRING:
+ // All registered C and G sets, space and delete
+ case FILE_ASN1_TYPE_UTF8_STRING:
+ // ????
+ case FILE_ASN1_TYPE_BMP_STRING:
+ $current['content'] = $content;
+ break;
+ case FILE_ASN1_TYPE_UTC_TIME:
+ case FILE_ASN1_TYPE_GENERALIZED_TIME:
+ $current['content'] = $this->_decodeTime($content, $tag);
+ default:
}
- return $decoded;
+ $start+= $length;
+
+ // ie. length is the length of the full TLV encoding - it's not just the length of the value
+ return $current + array('length' => $start - $current['start']);
}
/**
- * ASN.1 Decode
+ * ASN.1 Map
*
* Provides an ASN.1 semantic mapping ($mapping) from a parsed BER-encoding to a human readable format.
*
@@ -809,16 +833,6 @@ class File_ASN1
* ASN.1 Encode (Helper function)
*
* @param String $source
- * @param Array $mapping
- * @param Integer $idx
- * @param Array $special
- * @return String
- * @access private
- */
- /**
- * ASN.1 Encode (Helper function)
- *
- * @param String $source
* @param String $mapping
* @param Integer $idx
* @return String
diff --git a/libs/phpseclib-0.3.7/File/X509.php b/libs/phpseclib-0.3.9/File/X509.php
index 1d07f67..1d07f67 100644
--- a/libs/phpseclib-0.3.7/File/X509.php
+++ b/libs/phpseclib-0.3.9/File/X509.php
diff --git a/libs/phpseclib-0.3.7/Math/BigInteger.php b/libs/phpseclib-0.3.9/Math/BigInteger.php
index 39c8d5f..64955bf 100644
--- a/libs/phpseclib-0.3.7/Math/BigInteger.php
+++ b/libs/phpseclib-0.3.9/Math/BigInteger.php
@@ -329,9 +329,12 @@ class Math_BigInteger
switch ( MATH_BIGINTEGER_MODE ) {
case MATH_BIGINTEGER_MODE_GMP:
- if (is_resource($x) && get_resource_type($x) == 'GMP integer') {
- $this->value = $x;
- return;
+ switch (true) {
+ case is_resource($x) && get_resource_type($x) == 'GMP integer':
+ // PHP 5.6 switched GMP from using resources to objects
+ case is_object($x) && get_class($x) == 'GMP':
+ $this->value = $x;
+ return;
}
$this->value = gmp_init(0);
break;
@@ -912,7 +915,7 @@ class Math_BigInteger
$value = $x_value;
}
- $value[] = 0; // just in case the carry adds an extra digit
+ $value[count($value)] = 0; // just in case the carry adds an extra digit
$carry = 0;
for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) {
@@ -2134,7 +2137,7 @@ class Math_BigInteger
if ($this->_compare($result, false, $temp[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_SIGN]) < 0) {
$corrector_value = $this->_array_repeat(0, $n_length + 1);
- $corrector_value[] = 1;
+ $corrector_value[count($corrector_value)] = 1;
$result = $this->_add($result, false, $corrector_value, false);
$result = $result[MATH_BIGINTEGER_VALUE];
}
@@ -2904,7 +2907,7 @@ class Math_BigInteger
$leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3);
$this->_base256_lshift($leading_ones, $current_bits);
- $temp = str_pad($temp, ceil($this->bits / 8), chr(0), STR_PAD_LEFT);
+ $temp = str_pad($temp, strlen($leading_ones), chr(0), STR_PAD_LEFT);
return $this->_normalize(new Math_BigInteger($leading_ones | $temp, 256));
}
@@ -3479,7 +3482,7 @@ class Math_BigInteger
}
if ( $carry ) {
- $this->value[] = $carry;
+ $this->value[count($this->value)] = $carry;
}
while ($num_digits--) {
diff --git a/libs/phpseclib-0.3.7/Net/SCP.php b/libs/phpseclib-0.3.9/Net/SCP.php
index 2668164..2668164 100644
--- a/libs/phpseclib-0.3.7/Net/SCP.php
+++ b/libs/phpseclib-0.3.9/Net/SCP.php
diff --git a/libs/phpseclib-0.3.7/Net/SFTP.php b/libs/phpseclib-0.3.9/Net/SFTP.php
index ddfc931..cc62705 100644
--- a/libs/phpseclib-0.3.7/Net/SFTP.php
+++ b/libs/phpseclib-0.3.9/Net/SFTP.php
@@ -1061,12 +1061,14 @@ class Net_SFTP extends Net_SSH2
$dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path));
$temp = &$this->stat_cache;
- foreach ($dirs as $dir) {
+ $max = count($dirs) - 1;
+ foreach ($dirs as $i=>$dir) {
if (!isset($temp[$dir])) {
$temp[$dir] = array();
}
- if ($dir == end($dirs)) {
+ if ($i === $max) {
$temp[$dir] = $value;
+ break;
}
$temp = &$temp[$dir];
}
@@ -1084,8 +1086,9 @@ class Net_SFTP extends Net_SSH2
$dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path));
$temp = &$this->stat_cache;
- foreach ($dirs as $dir) {
- if ($dir == end($dirs)) {
+ $max = count($dirs) - 1;
+ foreach ($dirs as $i=>$dir) {
+ if ($i === $max) {
unset($temp[$dir]);
return true;
}
@@ -1501,7 +1504,7 @@ class Net_SFTP extends Net_SSH2
return false;
}
$i = 0;
- $entries = $this->_list($path, true, false);
+ $entries = $this->_list($path, true);
if ($entries === false) {
return $this->_setstat($path, $attr, false);
@@ -1513,11 +1516,8 @@ class Net_SFTP extends Net_SSH2
return false;
}
+ unset($entries['.'], $entries['..']);
foreach ($entries as $filename=>$props) {
- if ($filename == '.' || $filename == '..') {
- continue;
- }
-
if (!isset($props['type'])) {
return false;
}
@@ -1757,6 +1757,8 @@ class Net_SFTP extends Net_SSH2
* contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how
* large $remote_file will be, as well.
*
+ * If $data is a resource then it'll be used as a resource instead.
+ *
* 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.
*
@@ -1778,7 +1780,7 @@ 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.
*
* @param String $remote_file
- * @param String $data
+ * @param String|resource $data
* @param optional Integer $mode
* @param optional Integer $start
* @param optional Integer $local_start
@@ -1834,16 +1836,25 @@ class Net_SFTP extends Net_SSH2
}
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.3
- if ($mode & NET_SFTP_LOCAL_FILE) {
- if (!is_file($data)) {
- user_error("$data is not a valid file");
- return false;
- }
- $fp = @fopen($data, 'rb');
- if (!$fp) {
- return false;
- }
- $size = filesize($data);
+ switch (true) {
+ case is_resource($data):
+ $mode = $mode & ~NET_SFTP_LOCAL_FILE;
+ $fp = $data;
+ break;
+ case $mode & NET_SFTP_LOCAL_FILE:
+ if (!is_file($data)) {
+ user_error("$data is not a valid file");
+ return false;
+ }
+ $fp = @fopen($data, 'rb');
+ if (!$fp) {
+ return false;
+ }
+ }
+
+ if (isset($fp)) {
+ $stat = fstat($fp);
+ $size = $stat['size'];
if ($local_start >= 0) {
fseek($fp, $local_start);
@@ -1864,11 +1875,13 @@ class Net_SFTP extends Net_SSH2
$sftp_packet_size-= strlen($handle) + 25;
$i = 0;
while ($sent < $size) {
- $temp = $mode & NET_SFTP_LOCAL_FILE ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size);
+ $temp = isset($fp) ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size);
$subtemp = $offset + $sent;
$packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp);
if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) {
- fclose($fp);
+ if ($mode & NET_SFTP_LOCAL_FILE) {
+ fclose($fp);
+ }
return false;
}
$sent+= strlen($temp);
@@ -2003,21 +2016,30 @@ class Net_SFTP extends Net_SSH2
return false;
}
- if ($local_file !== false) {
- $fp = fopen($local_file, 'wb');
- if (!$fp) {
- return false;
- }
+ if (is_resource($local_file)) {
+ $fp = $local_file;
+ $stat = fstat($fp);
+ $res_offset = $stat['size'];
} else {
- $content = '';
+ $res_offset = 0;
+ if ($local_file !== false) {
+ $fp = fopen($local_file, 'wb');
+ if (!$fp) {
+ return false;
+ }
+ } else {
+ $content = '';
+ }
}
+ $fclose_check = $local_file !== false && !is_resource($local_file);
+
$start = $offset;
$size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length;
while (true) {
$packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size);
if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) {
- if ($local_file !== false) {
+ if ($fclose_check) {
fclose($fp);
}
return false;
@@ -2040,7 +2062,7 @@ class Net_SFTP extends Net_SSH2
break 2;
default:
user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS');
- if ($local_file !== false) {
+ if ($fclose_check) {
fclose($fp);
}
return false;
@@ -2055,11 +2077,11 @@ class Net_SFTP extends Net_SSH2
if ($local_file === false) {
$content = substr($content, 0, $length);
} else {
- ftruncate($fp, $length);
+ ftruncate($fp, $length + $res_offset);
}
}
- if ($local_file !== false) {
+ if ($fclose_check) {
fclose($fp);
}
@@ -2135,7 +2157,7 @@ class Net_SFTP extends Net_SSH2
return false;
}
$i = 0;
- $entries = $this->_list($path, true, false);
+ $entries = $this->_list($path, true);
// normally $entries would have at least . and .. but it might not if the directories
// permissions didn't allow reading
@@ -2143,11 +2165,8 @@ class Net_SFTP extends Net_SSH2
return false;
}
+ unset($entries['.'], $entries['..']);
foreach ($entries as $filename=>$props) {
- if ($filename == '.' || $filename == '..') {
- continue;
- }
-
if (!isset($props['type'])) {
return false;
}
@@ -2205,7 +2224,7 @@ class Net_SFTP extends Net_SSH2
$result = $this->_query_stat_cache($path);
if (isset($result)) {
- // return true if $result is an array or if it's int(1)
+ // return true if $result is an array or if it's an stdClass object
return $result !== false;
}
}
@@ -2348,7 +2367,7 @@ class Net_SFTP extends Net_SSH2
}
switch ($type) {
- case NET_SFTP_BLOCK_DEVICE: return 'block';
+ case NET_SFTP_TYPE_BLOCK_DEVICE: return 'block';
case NET_SFTP_TYPE_CHAR_DEVICE: return 'char';
case NET_SFTP_TYPE_DIRECTORY: return 'dir';
case NET_SFTP_TYPE_FIFO: return 'fifo';
@@ -2454,14 +2473,13 @@ class Net_SFTP extends Net_SSH2
foreach ($this->attributes as $key => $value) {
switch ($flags & $key) {
case NET_SFTP_ATTR_SIZE: // 0x00000001
- // size is represented by a 64-bit integer, so we perhaps ought to be doing the following:
- // $attr['size'] = new Math_BigInteger($this->_string_shift($response, 8), 256);
- // of course, you shouldn't be using Net_SFTP to transfer files that are in excess of 4GB
- // (0xFFFFFFFF bytes), anyway. as such, we'll just represent all file sizes that are bigger than
- // 4GB as being 4GB.
- extract(unpack('Nupper/Nsize', $this->_string_shift($response, 8)));
- $attr['size'] = $upper ? 4294967296 * $upper : 0;
- $attr['size']+= $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size;
+ // The size attribute is defined as an unsigned 64-bit integer.
+ // The following will use floats on 32-bit platforms, if necessary.
+ // As can be seen in the BigInteger class, floats are generally
+ // IEEE 754 binary64 "double precision" on such platforms and
+ // as such can represent integers of at least 2^50 without loss
+ // of precision. Interpreted in filesize, 2^50 bytes = 1024 TiB.
+ $attr['size'] = hexdec(bin2hex($this->_string_shift($response, 8)));
break;
case NET_SFTP_ATTR_UIDGID: // 0x00000002 (SFTPv3 only)
$attr+= unpack('Nuid/Ngid', $this->_string_shift($response, 8));
@@ -2521,7 +2539,7 @@ class Net_SFTP extends Net_SSH2
case 0020000: // character special
return NET_SFTP_TYPE_CHAR_DEVICE;
case 0060000: // block special
- return NET_SFTP_BLOCK_DEVICE;
+ return NET_SFTP_TYPE_BLOCK_DEVICE;
case 0140000: // socket
return NET_SFTP_TYPE_SOCKET;
case 0160000: // whiteout
diff --git a/libs/phpseclib-0.3.7/Net/SFTP/Stream.php b/libs/phpseclib-0.3.9/Net/SFTP/Stream.php
index 0c84ab4..0c84ab4 100644
--- a/libs/phpseclib-0.3.7/Net/SFTP/Stream.php
+++ b/libs/phpseclib-0.3.9/Net/SFTP/Stream.php
diff --git a/libs/phpseclib-0.3.7/Net/SSH1.php b/libs/phpseclib-0.3.9/Net/SSH1.php
index 35e6d5e..35e6d5e 100644
--- a/libs/phpseclib-0.3.7/Net/SSH1.php
+++ b/libs/phpseclib-0.3.9/Net/SSH1.php
diff --git a/libs/phpseclib-0.3.7/Net/SSH2.php b/libs/phpseclib-0.3.9/Net/SSH2.php
index 8f31f86..dfe0a79 100644
--- a/libs/phpseclib-0.3.7/Net/SSH2.php
+++ b/libs/phpseclib-0.3.9/Net/SSH2.php
@@ -191,100 +191,100 @@ class Net_SSH2
* Server Identifier
*
* @see Net_SSH2::getServerIdentification()
- * @var String
+ * @var mixed false or Array
* @access private
*/
- var $server_identifier = '';
+ var $server_identifier = false;
/**
* Key Exchange Algorithms
*
* @see Net_SSH2::getKexAlgorithims()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $kex_algorithms;
+ var $kex_algorithms = false;
/**
* Server Host Key Algorithms
*
* @see Net_SSH2::getServerHostKeyAlgorithms()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $server_host_key_algorithms;
+ var $server_host_key_algorithms = false;
/**
* Encryption Algorithms: Client to Server
*
* @see Net_SSH2::getEncryptionAlgorithmsClient2Server()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $encryption_algorithms_client_to_server;
+ var $encryption_algorithms_client_to_server = false;
/**
* Encryption Algorithms: Server to Client
*
* @see Net_SSH2::getEncryptionAlgorithmsServer2Client()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $encryption_algorithms_server_to_client;
+ var $encryption_algorithms_server_to_client = false;
/**
* MAC Algorithms: Client to Server
*
* @see Net_SSH2::getMACAlgorithmsClient2Server()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $mac_algorithms_client_to_server;
+ var $mac_algorithms_client_to_server = false;
/**
* MAC Algorithms: Server to Client
*
* @see Net_SSH2::getMACAlgorithmsServer2Client()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $mac_algorithms_server_to_client;
+ var $mac_algorithms_server_to_client = false;
/**
* Compression Algorithms: Client to Server
*
* @see Net_SSH2::getCompressionAlgorithmsClient2Server()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $compression_algorithms_client_to_server;
+ var $compression_algorithms_client_to_server = false;
/**
* Compression Algorithms: Server to Client
*
* @see Net_SSH2::getCompressionAlgorithmsServer2Client()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $compression_algorithms_server_to_client;
+ var $compression_algorithms_server_to_client = false;
/**
* Languages: Server to Client
*
* @see Net_SSH2::getLanguagesServer2Client()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $languages_server_to_client;
+ var $languages_server_to_client = false;
/**
* Languages: Client to Server
*
* @see Net_SSH2::getLanguagesClient2Server()
- * @var Array
+ * @var mixed false or Array
* @access private
*/
- var $languages_client_to_server;
+ var $languages_client_to_server = false;
/**
* Block Size for Server to Client Encryption
@@ -820,7 +820,7 @@ class Net_SSH2
/**
* Number of columns for terminal window size
- *
+ *
* @see Net_SSH2::getWindowColumns()
* @see Net_SSH2::setWindowColumns()
* @see Net_SSH2::setWindowSize()
@@ -831,7 +831,7 @@ class Net_SSH2
/**
* Number of columns for terminal window size
- *
+ *
* @see Net_SSH2::getWindowRows()
* @see Net_SSH2::setWindowRows()
* @see Net_SSH2::setWindowSize()
@@ -949,6 +949,12 @@ class Net_SSH2
*/
function _connect()
{
+ if ($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) {
+ return false;
+ }
+
+ $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR;
+
$timeout = $this->connectionTimeout;
$host = $this->host . ':' . $this->port;
@@ -965,7 +971,7 @@ class Net_SSH2
$timeout-= $elapsed;
if ($timeout <= 0) {
- user_error(rtrim("Cannot connect to $host. Timeout error"));
+ user_error("Cannot connect to $host. Timeout error");
return false;
}
@@ -978,7 +984,7 @@ class Net_SSH2
// on windows this returns a "Warning: Invalid CRT parameters detected" error
// the !count() is done as a workaround for <https://bugs.php.net/42682>
if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) {
- user_error(rtrim("Cannot connect to $host. Banner timeout"));
+ user_error("Cannot connect to $host. Banner timeout");
return false;
}
@@ -1038,7 +1044,7 @@ class Net_SSH2
return false;
}
- $this->bitmap = NET_SSH2_MASK_CONNECTED;
+ $this->bitmap|= NET_SSH2_MASK_CONNECTED;
return true;
}
@@ -1098,7 +1104,7 @@ class Net_SSH2
'arcfour256',
'arcfour128',
- 'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key
+ //'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key
// CTR modes from <http://tools.ietf.org/html/rfc4344#section-4>:
'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key
@@ -1126,7 +1132,7 @@ class Net_SSH2
'3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode
'3des-cbc', // REQUIRED three-key 3DES in CBC mode
- 'none' // OPTIONAL no encryption; NOT RECOMMENDED
+ //'none' // OPTIONAL no encryption; NOT RECOMMENDED
);
if (phpseclib_resolve_include_path('Crypt/RC4.php') === false) {
@@ -1163,11 +1169,14 @@ class Net_SSH2
}
$mac_algorithms = array(
+ // from <http://www.ietf.org/rfc/rfc6668.txt>:
+ 'hmac-sha2-256',// RECOMMENDED HMAC-SHA256 (digest length = key length = 32)
+
'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20)
'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20)
'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16)
'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16)
- 'none' // OPTIONAL no MAC; NOT RECOMMENDED
+ //'none' // OPTIONAL no MAC; NOT RECOMMENDED
);
static $compression_algorithms = array(
@@ -1692,6 +1701,10 @@ class Net_SSH2
$createKeyLength = 0; // ie. $mac_algorithms[$i] == 'none'
switch ($mac_algorithms[$i]) {
+ case 'hmac-sha2-256':
+ $this->hmac_create = new Crypt_Hash('sha256');
+ $createKeyLength = 32;
+ break;
case 'hmac-sha1':
$this->hmac_create = new Crypt_Hash('sha1');
$createKeyLength = 20;
@@ -1718,6 +1731,11 @@ class Net_SSH2
$checkKeyLength = 0;
$this->hmac_size = 0;
switch ($mac_algorithms[$i]) {
+ case 'hmac-sha2-256':
+ $this->hmac_check = new Crypt_Hash('sha256');
+ $checkKeyLength = 32;
+ $this->hmac_size = 32;
+ break;
case 'hmac-sha1':
$this->hmac_check = new Crypt_Hash('sha1');
$checkKeyLength = 20;
@@ -1799,7 +1817,6 @@ class Net_SSH2
function _login($username)
{
if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) {
- $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR;
if (!$this->_connect()) {
return false;
}
@@ -2062,7 +2079,6 @@ class Net_SSH2
if (!count($responses) && $num_prompts) {
$this->last_interactive_response = $orig;
- $this->bitmap |= NET_SSH_MASK_LOGIN_INTERACTIVE;
return false;
}
@@ -2654,11 +2670,12 @@ class Net_SSH2
/**
* Is the connection still active?
*
+ * @return boolean
* @access public
*/
function isConnected()
{
- return $this->bitmap & NET_SSH2_MASK_LOGIN;
+ return (bool) ($this->bitmap & NET_SSH2_MASK_CONNECTED);
}
/**
@@ -2968,7 +2985,7 @@ class Net_SSH2
extract(unpack('Ctype/Nchannel', $this->_string_shift($response, 5)));
- $this->window_size_server_to_client[$channel]-= strlen($response) + 4;
+ $this->window_size_server_to_client[$channel]-= strlen($response);
// resize the window, if appropriate
if ($this->window_size_server_to_client[$channel] < 0) {
@@ -3266,7 +3283,7 @@ class Net_SSH2
$max_size = min(
$this->packet_size_client_to_server[$client_channel],
$this->window_size_client_to_server[$client_channel]
- ) - 4;
+ );
while (strlen($data) > $max_size) {
if (!$this->window_size_client_to_server[$client_channel]) {
$this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST;
@@ -3276,7 +3293,7 @@ class Net_SSH2
$max_size = min(
$this->packet_size_client_to_server[$client_channel],
$this->window_size_client_to_server[$client_channel]
- ) - 4;
+ );
}
$temp = $this->_string_shift($data, $max_size);
@@ -3287,20 +3304,20 @@ class Net_SSH2
$temp
);
- $this->window_size_client_to_server[$client_channel]-= strlen($temp) + 4;
+ $this->window_size_client_to_server[$client_channel]-= strlen($temp);
if (!$this->_send_binary_packet($packet)) {
return false;
}
}
- if (strlen($data) >= $this->window_size_client_to_server[$client_channel] - 4) {
+ if (strlen($data) >= $this->window_size_client_to_server[$client_channel]) {
$this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST;
$this->_get_channel_packet(-1);
$this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST;
}
- $this->window_size_client_to_server[$client_channel]-= strlen($data) + 4;
+ $this->window_size_client_to_server[$client_channel]-= strlen($data);
return $this->_send_binary_packet(pack('CN2a*',
NET_SSH2_MSG_CHANNEL_DATA,
@@ -3509,6 +3526,8 @@ class Net_SSH2
*/
function getServerIdentification()
{
+ $this->_connect();
+
return $this->server_identifier;
}
@@ -3520,6 +3539,8 @@ class Net_SSH2
*/
function getKexAlgorithms()
{
+ $this->_connect();
+
return $this->kex_algorithms;
}
@@ -3531,6 +3552,8 @@ class Net_SSH2
*/
function getServerHostKeyAlgorithms()
{
+ $this->_connect();
+
return $this->server_host_key_algorithms;
}
@@ -3542,6 +3565,8 @@ class Net_SSH2
*/
function getEncryptionAlgorithmsClient2Server()
{
+ $this->_connect();
+
return $this->encryption_algorithms_client_to_server;
}
@@ -3553,6 +3578,8 @@ class Net_SSH2
*/
function getEncryptionAlgorithmsServer2Client()
{
+ $this->_connect();
+
return $this->encryption_algorithms_server_to_client;
}
@@ -3564,6 +3591,8 @@ class Net_SSH2
*/
function getMACAlgorithmsClient2Server()
{
+ $this->_connect();
+
return $this->mac_algorithms_client_to_server;
}
@@ -3575,6 +3604,8 @@ class Net_SSH2
*/
function getMACAlgorithmsServer2Client()
{
+ $this->_connect();
+
return $this->mac_algorithms_server_to_client;
}
@@ -3586,6 +3617,8 @@ class Net_SSH2
*/
function getCompressionAlgorithmsClient2Server()
{
+ $this->_connect();
+
return $this->compression_algorithms_client_to_server;
}
@@ -3597,6 +3630,8 @@ class Net_SSH2
*/
function getCompressionAlgorithmsServer2Client()
{
+ $this->_connect();
+
return $this->compression_algorithms_server_to_client;
}
@@ -3608,6 +3643,8 @@ class Net_SSH2
*/
function getLanguagesServer2Client()
{
+ $this->_connect();
+
return $this->languages_server_to_client;
}
@@ -3619,6 +3656,8 @@ class Net_SSH2
*/
function getLanguagesClient2Server()
{
+ $this->_connect();
+
return $this->languages_client_to_server;
}
@@ -3648,7 +3687,6 @@ class Net_SSH2
function getServerPublicHostKey()
{
if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) {
- $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR;
if (!$this->_connect()) {
return false;
}
@@ -3800,7 +3838,7 @@ class Net_SSH2
/**
* Returns the number of columns for the terminal window size.
- *
+ *
* @return Integer
* @access public
*/
@@ -3811,7 +3849,7 @@ class Net_SSH2
/**
* Returns the number of rows for the terminal window size.
- *
+ *
* @return Integer
* @access public
*/
@@ -3822,7 +3860,7 @@ class Net_SSH2
/**
* Sets the number of columns for the terminal window size.
- *
+ *
* @param Integer $value
* @access public
*/
@@ -3833,7 +3871,7 @@ class Net_SSH2
/**
* Sets the number of rows for the terminal window size.
- *
+ *
* @param Integer $value
* @access public
*/
@@ -3844,7 +3882,7 @@ class Net_SSH2
/**
* Sets the number of columns and rows for the terminal window size.
- *
+ *
* @param Integer $columns
* @param Integer $rows
* @access public
diff --git a/libs/phpseclib-0.3.7/System/SSH/Agent.php b/libs/phpseclib-0.3.9/System/SSH/Agent.php
index d5088ba..d5088ba 100644
--- a/libs/phpseclib-0.3.7/System/SSH/Agent.php
+++ b/libs/phpseclib-0.3.9/System/SSH/Agent.php
diff --git a/libs/phpseclib-0.3.7/System/SSH_Agent.php b/libs/phpseclib-0.3.9/System/SSH_Agent.php
index 0784179..0784179 100644
--- a/libs/phpseclib-0.3.7/System/SSH_Agent.php
+++ b/libs/phpseclib-0.3.9/System/SSH_Agent.php
diff --git a/libs/phpseclib-0.3.7/openssl.cnf b/libs/phpseclib-0.3.9/openssl.cnf
index 58a1261..58a1261 100644
--- a/libs/phpseclib-0.3.7/openssl.cnf
+++ b/libs/phpseclib-0.3.9/openssl.cnf