Skip to content
Permalink
Browse files

Upgrade phpseclib to 1.0.14.

  • Loading branch information...
respawner committed Jan 31, 2019
1 parent 6c8c70c commit 32eaa0c7cd6ffccbbd0aa9097fd973d9517b615a
Showing with 411 additions and 84 deletions.
  1. +1 −1 auth/authentication.php
  2. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/AES.php
  3. +4 −4 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Base.php
  4. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Blowfish.php
  5. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/DES.php
  6. +78 −20 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Hash.php
  7. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/RC2.php
  8. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/RC4.php
  9. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/RSA.php
  10. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Random.php
  11. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Rijndael.php
  12. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/TripleDES.php
  13. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Crypt/Twofish.php
  14. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/File/ANSI.php
  15. +12 −0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/File/ASN1.php
  16. +14 −8 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/File/X509.php
  17. +0 −1 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Math/BigInteger.php
  18. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Net/SCP.php
  19. +11 −1 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Net/SFTP.php
  20. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Net/SFTP/Stream.php
  21. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Net/SSH1.php
  22. +197 −30 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/Net/SSH2.php
  23. +94 −19 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/System/SSH/Agent.php
  24. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/System/SSH_Agent.php
  25. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/bootstrap.php
  26. 0 libs/{phpseclib-1.0.11 → phpseclib-1.0.14}/openssl.cnf
@@ -19,7 +19,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
ini_set('include_path', ini_get('include_path').':./libs/phpseclib-1.0.11');
ini_set('include_path', ini_get('include_path').':./libs/phpseclib-1.0.14');
require_once('ssh.php');
require_once('telnet.php');
File renamed without changes.
@@ -661,7 +661,7 @@ function setPassword($password, $method = 'pbkdf2')
$count = isset($func_args[4]) ? $func_args[4] : 1000;
// Keylength
if (isset($func_args[5])) {
if (isset($func_args[5]) && $func_args[5] > 0) {
$dkLen = $func_args[5];
} else {
$dkLen = $method == 'pbkdf1' ? 2 * $this->key_length : $this->key_length;
@@ -696,10 +696,10 @@ function setPassword($password, $method = 'pbkdf2')
include_once 'Crypt/Hash.php';
}
$i = 1;
$hmac = new Crypt_Hash();
$hmac->setHash($hash);
$hmac->setKey($password);
while (strlen($key) < $dkLen) {
$hmac = new Crypt_Hash();
$hmac->setHash($hash);
$hmac->setKey($password);
$f = $u = $hmac->hash($salt . pack('N', $i++));
for ($j = 2; $j <= $count; ++$j) {
$u = $hmac->hash($u);
File renamed without changes.
File renamed without changes.
@@ -126,6 +126,15 @@ class Crypt_Hash
*/
var $key = false;
/**
* Computed Key
*
* @see self::_computeKey()
* @var string
* @access private
*/
var $computedKey = false;
/**
* Outer XOR (Internal HMAC)
*
@@ -192,6 +201,43 @@ function Crypt_Hash($hash = 'sha1')
function setKey($key = false)
{
$this->key = $key;
$this->_computeKey();
}
/**
* Pre-compute the key used by the HMAC
*
* Quoting http://tools.ietf.org/html/rfc2104#section-2, "Applications that use keys longer than B bytes
* will first hash the key using H and then use the resultant L byte string as the actual key to HMAC."
*
* As documented in https://www.reddit.com/r/PHP/comments/9nct2l/symfonypolyfill_hash_pbkdf2_correct_fix_for/
* when doing an HMAC multiple times it's faster to compute the hash once instead of computing it during
* every call
*
* @access private
*/
function _computeKey()
{
if ($this->key === false) {
$this->computedKey = false;
return;
}
if (strlen($this->key) <= $this->b) {
$this->computedKey = $this->key;
return;
}
switch ($mode) {
case CRYPT_HASH_MODE_MHASH:
$this->computedKey = mhash($this->hash, $this->key);
break;
case CRYPT_HASH_MODE_HASH:
$this->computedKey = hash($this->hash, $this->key, true);
break;
case CRYPT_HASH_MODE_INTERNAL:
$this->computedKey = call_user_func($this->hash, $this->key);
}
}
/**
@@ -241,6 +287,25 @@ function setHash($hash)
$this->l = 64;
}
switch ($hash) {
case 'md2-96':
case 'md2':
$this->b = 16;
case 'md5-96':
case 'sha1-96':
case 'sha224-96':
case 'sha256-96':
case 'md2':
case 'md5':
case 'sha1':
case 'sha224':
case 'sha256':
$this->b = 64;
break;
default:
$this->b = 128;
}
switch ($hash) {
case 'md2':
$mode = CRYPT_HASH_MODE == CRYPT_HASH_MODE_HASH && in_array('md2', hash_algos()) ?
@@ -267,6 +332,7 @@ function setHash($hash)
default:
$this->hash = MHASH_SHA1;
}
$this->_computeKey();
return;
case CRYPT_HASH_MODE_HASH:
switch ($hash) {
@@ -283,35 +349,33 @@ function setHash($hash)
default:
$this->hash = 'sha1';
}
$this->_computeKey();
return;
}
switch ($hash) {
case 'md2':
$this->b = 16;
$this->hash = array($this, '_md2');
break;
case 'md5':
$this->b = 64;
$this->hash = array($this, '_md5');
break;
case 'sha256':
$this->b = 64;
$this->hash = array($this, '_sha256');
break;
case 'sha384':
case 'sha512':
$this->b = 128;
$this->hash = array($this, '_sha512');
break;
case 'sha1':
default:
$this->b = 64;
$this->hash = array($this, '_sha1');
}
$this->ipad = str_repeat(chr(0x36), $this->b);
$this->opad = str_repeat(chr(0x5C), $this->b);
$this->_computeKey();
}
/**
@@ -328,25 +392,19 @@ function hash($text)
if (!empty($this->key) || is_string($this->key)) {
switch ($mode) {
case CRYPT_HASH_MODE_MHASH:
$output = mhash($this->hash, $text, $this->key);
$output = mhash($this->hash, $text, $this->computedKey);
break;
case CRYPT_HASH_MODE_HASH:
$output = hash_hmac($this->hash, $text, $this->key, true);
$output = hash_hmac($this->hash, $text, $this->computedKey, true);
break;
case CRYPT_HASH_MODE_INTERNAL:
/* "Applications that use keys longer than B bytes will first hash the key using H and then use the
resultant L byte string as the actual key to HMAC."
-- http://tools.ietf.org/html/rfc2104#section-2 */
$key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key;
$key = str_pad($key, $this->b, chr(0)); // step 1
$temp = $this->ipad ^ $key; // step 2
$temp .= $text; // step 3
$temp = call_user_func($this->hash, $temp); // step 4
$output = $this->opad ^ $key; // step 5
$output.= $temp; // step 6
$output = call_user_func($this->hash, $output); // step 7
$key = str_pad($this->computedKey, $this->b, chr(0)); // step 1
$temp = $this->ipad ^ $key; // step 2
$temp .= $text; // step 3
$temp = call_user_func($this->hash, $temp); // step 4
$output = $this->opad ^ $key; // step 5
$output.= $temp; // step 6
$output = call_user_func($this->hash, $output); // step 7
}
} else {
switch ($mode) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -390,6 +390,9 @@ function _decode_ber($encoded, $start = 0, $encoded_pos = 0)
$remainingLength = $length;
while ($remainingLength > 0) {
$temp = $this->_decode_ber($content, $start, $content_pos);
if ($temp === false) {
break;
}
$length = $temp['length'];
// end-of-content octets - see paragraph 8.1.5
if (substr($content, $content_pos + $length, 2) == "\0\0") {
@@ -441,6 +444,9 @@ function _decode_ber($encoded, $start = 0, $encoded_pos = 0)
$current['content'] = substr($content, $content_pos);
} else {
$temp = $this->_decode_ber($content, $start, $content_pos);
if ($temp === false) {
return false;
}
$length-= (strlen($content) - $content_pos);
$last = count($temp) - 1;
for ($i = 0; $i < $last; $i++) {
@@ -465,6 +471,9 @@ function _decode_ber($encoded, $start = 0, $encoded_pos = 0)
$length = 0;
while (substr($content, $content_pos, 2) != "\0\0") {
$temp = $this->_decode_ber($content, $length + $start, $content_pos);
if ($temp === false) {
return false;
}
$content_pos += $temp['length'];
// all subtags should be octet strings
//if ($temp['type'] != FILE_ASN1_TYPE_OCTET_STRING) {
@@ -497,6 +506,9 @@ function _decode_ber($encoded, $start = 0, $encoded_pos = 0)
break 2;
}
$temp = $this->_decode_ber($content, $start + $offset, $content_pos);
if ($temp === false) {
return false;
}
$content_pos += $temp['length'];
$current['content'][] = $temp;
$offset+= $temp['length'];
@@ -2122,7 +2122,7 @@ function validateURL($url)
*
* If $date isn't defined it is assumed to be the current date.
*
* @param int $date optional
* @param \DateTime|int|string $date optional
* @access public
*/
function validateDate($date = null)
@@ -2133,7 +2133,7 @@ function validateDate($date = null)
if (!isset($date)) {
$date = class_exists('DateTime') ?
new DateTime($date, new DateTimeZone(@date_default_timezone_get())) :
new DateTime(null, new DateTimeZone(@date_default_timezone_get())) :
time();
}
@@ -2143,12 +2143,18 @@ function validateDate($date = null)
$notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter'];
$notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime'];
if (class_exists('DateTime')) {
$notBefore = new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get()));
$notAfter = new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get()));
} else {
$notBefore = @strtotime($notBefore);
$notAfter = @strtotime($notAfter);
switch (true) {
case is_string($date) && class_exists('DateTime'):
$date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
case is_object($date) && strtolower(get_class($date)) == 'datetime':
$notBefore = new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get()));
$notAfter = new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get()));
break;
case is_string($date):
$date = @strtotime($date);
default:
$notBefore = @strtotime($notBefore);
$notAfter = @strtotime($notAfter);
}
switch (true) {
@@ -65,7 +65,6 @@
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2006 Jim Wigginton
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link http://pear.php.net/package/Math_BigInteger
*/
/**#@+
File renamed without changes.
@@ -919,7 +919,17 @@ function rawlist($dir = '.', $recursive = false)
unset($files[$key]);
continue;
}
if ($key != '.' && $key != '..' && is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $key)))) {
$is_directory = false;
if ($key != '.' && $key != '..') {
if ($this->use_stat_cache) {
$is_directory = is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $key)));
} else {
$stat = $this->lstat($dir . '/' . $key);
$is_directory = $stat && $stat['type'] === NET_SFTP_TYPE_DIRECTORY;
}
}
if ($is_directory) {
$depth++;
$files[$key] = $this->rawlist($dir . '/' . $key, true);
$depth--;
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit 32eaa0c

Please sign in to comment.
You can’t perform that action at this time.