1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-11 00:29:36 +01:00

Merge remote-tracking branch 'rrran/Bugfixes'

This commit is contained in:
terrafrost 2017-08-07 21:47:06 -05:00
commit 3fcce89f78
35 changed files with 60 additions and 57 deletions

View File

@ -299,7 +299,7 @@ abstract class AsymmetricKey
* @access private
* @param string $key
* @param string $type
* @return array
* @return array|bool
*/
protected function load($key, $type)
{
@ -339,7 +339,7 @@ abstract class AsymmetricKey
* @access private
* @param string $key
* @param string $type
* @return array
* @return array|bool
*/
protected function setPublicKey($key, $type)
{

View File

@ -64,7 +64,7 @@ abstract class OpenSSH
* @access public
* @param string $key
* @param string $type
* @return array
* @return array|bool
*/
public static function load($key, $type)
{

View File

@ -122,7 +122,7 @@ abstract class PKCS1 extends PKCS
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
protected static function load($key, $password)
{

View File

@ -320,7 +320,7 @@ abstract class PKCS8 extends PKCS
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
protected static function load($key, $password = '')
{

View File

@ -77,7 +77,7 @@ abstract class PuTTY
* @param string $publicHandler
* @param string $type
* @param string $password
* @return array
* @return array|bool
*/
protected static function load($key, $password)
{

View File

@ -33,7 +33,7 @@ abstract class Raw
*
* @access public
* @param array $sig
* @return array
* @return array|bool
*/
public static function load($sig)
{

View File

@ -109,7 +109,7 @@ class DSA extends AsymmetricKey
* @access public
* @param int $L
* @param int $N
* @return \phpseclib\Crypt\DSA
* @return \phpseclib\Crypt\DSA|bool
*/
static function createParameters($L = 2048, $N = 224)
{
@ -183,7 +183,7 @@ class DSA extends AsymmetricKey
* - 'publickey': The public key.
*
* @access public
* @return \phpseclib\Crypt\DSA
* @return array|DSA
*/
static function createKey()
{

View File

@ -37,7 +37,7 @@ abstract class OpenSSH extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -46,7 +46,7 @@ abstract class PKCS1 extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -69,7 +69,7 @@ abstract class PKCS8 extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -55,7 +55,7 @@ abstract class PuTTY extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -34,7 +34,7 @@ abstract class Raw
* @access public
* @param array $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -39,7 +39,7 @@ abstract class XML
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -36,7 +36,7 @@ abstract class PKCS
*
* @access public
* @param array $key
* @return array
* @return array|bool
*/
public static function load($sig)
{

View File

@ -134,7 +134,7 @@ class Hash
* Keys can be of any length.
*
* @access public
* @param string $key
* @param string|bool $key
*/
public function setKey($key = false)
{

View File

@ -71,7 +71,7 @@ abstract class MSBLOB
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -37,7 +37,7 @@ abstract class OpenSSH extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -44,7 +44,7 @@ abstract class PKCS1 extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -70,7 +70,7 @@ abstract class PKCS8 extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -50,7 +50,7 @@ abstract class PuTTY extends Progenitor
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -42,7 +42,7 @@ abstract class Raw
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{
@ -95,7 +95,7 @@ abstract class Raw
* @access public
* @param \phpseclib\Math\BigInteger $n
* @param \phpseclib\Math\BigInteger $e
* @return string
* @return array
*/
public static function savePublicKey(BigInteger $n, BigInteger $e)
{

View File

@ -40,7 +40,7 @@ abstract class XML
* @access public
* @param string $key
* @param string $password optional
* @return array
* @return array|bool
*/
public static function load($key, $password = '')
{

View File

@ -26,6 +26,7 @@ namespace phpseclib\File;
use ParagonIE\ConstantTime\Base64;
use phpseclib\File\ASN1\Element;
use phpseclib\Math\BigInteger;
use phpseclib\Common\Functions\Strings;
/**
* Pure-PHP ASN.1 Parser
@ -248,7 +249,7 @@ abstract class ASN1
* @param string $encoded
* @param int $start
* @param int $encoded_pos
* @return array
* @return array|bool
* @access private
*/
private static function decode_ber($encoded, $start = 0, $encoded_pos = 0)
@ -513,7 +514,7 @@ abstract class ASN1
* @param array $decoded
* @param array $mapping
* @param array $special
* @return array
* @return array|bool|Element
* @access public
*/
public static function asn1map($decoded, $mapping, $special = [])
@ -826,7 +827,7 @@ abstract class ASN1
* ASN.1 Encode (Helper function)
*
* @param string $source
* @param string $mapping
* @param array $mapping
* @param int $idx
* @return string
* @throws \RuntimeException if the input has an error in it

View File

@ -36,6 +36,7 @@ use phpseclib\File\ASN1\Element;
use phpseclib\Math\BigInteger;
use phpseclib\File\ASN1\Maps;
/**
* Pure-PHP X.509 Parser
*
@ -1564,7 +1565,7 @@ class X509
* @param mixed $format optional
* @param array $dn optional
* @access public
* @return bool
* @return array|bool
*/
public function getDN($format = self::DN_ARRAY, $dn = null)
{
@ -2796,7 +2797,7 @@ class X509
*/
if (strtolower($date) == 'lifetime') {
$temp = '99991231235959Z';
$temp = chr(ASN1::TYPE_GENERALIZED_TIME) . Functions::encodeLength(strlen($temp)) . $temp;
$temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp;
$this->endDate = new Element($temp);
} else {
$this->endDate = @date('D, d M Y H:i:s O', @strtotime($date));
@ -3117,12 +3118,13 @@ class X509
*
* @param string $id
* @param array $cert optional
* @param string $path
* @access public
* @return mixed
*/
public function getExtension($id, $cert = null)
public function getExtension($id, $cert = null, $path=null)
{
return $this->getExtensionHelper($id, $cert);
return $this->getExtensionHelper($id, $cert, $path);
}
/**
@ -3431,7 +3433,7 @@ class X509
* Format a public key as appropriate
*
* @access private
* @return array
* @return array|bool
*/
private function formatSubjectPublicKey()
{
@ -3603,7 +3605,7 @@ class X509
*
* @param array $crl optional
* @access public
* @return array
* @return array|bool
*/
public function listRevoked($crl = null)
{
@ -3677,7 +3679,7 @@ class X509
* @param string $serial
* @param array $crl optional
* @access public
* @return array
* @return array|bool
*/
public function getRevokedCertificateExtensions($serial, $crl = null)
{

View File

@ -60,7 +60,7 @@ abstract class Base extends BCMath
* @param string $class
* @return \phpseclib\Math\BigInteger\Engines\BCMath
*/
protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class)
public static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class)
{
if (empty($e->value)) {
$temp = new $class();

View File

@ -61,7 +61,7 @@ abstract class Barrett extends Base
*
* @param string $n
* @param string $m
* @return array
* @return array|string
*/
protected static function reduce($n, $m)
{

View File

@ -55,7 +55,7 @@ abstract class EvalBarrett extends Base
*
* @param array $m
* @param string $class
* @return callable
* @return callable|void
*/
protected static function generateCustomReduction(BCMath $m, $class)
{

View File

@ -396,7 +396,7 @@ abstract class Engine implements \Serializable
/**
* Logical Not
*
* @return \phpseclib\Math\BigInteger\Engines\Engine
* @return Engine|string
*/
public function bitwise_not()
{
@ -465,7 +465,7 @@ abstract class Engine implements \Serializable
* Instead of the top x bits being dropped they're appended to the shifted bit string.
*
* @param int $shift
* @return \phpseclib\Math\BigInteger\Engine\Engines
* @return \phpseclib\Math\BigInteger\Engines\Engine
*/
public function bitwise_leftRotate($shift)
{
@ -563,7 +563,7 @@ abstract class Engine implements \Serializable
/**
* Performs some pre-processing for powMod
*
* @return \phpseclib\Math\BigInteger\Engines\Engine
* @return bool|Engine
*/
protected function powModOuter(Engine $e, Engine $n)
{
@ -591,11 +591,11 @@ abstract class Engine implements \Serializable
* however, this function performs a modular reduction after every multiplication and squaring operation.
* As such, this function has the same preconditions that the reductions being used do.
*
* @param \phpseclib\Math\BigInteger\Engine $x
* @param \phpseclib\Math\BigInteger\Engine $e
* @param \phpseclib\Math\BigInteger\Engine $n
* @param \phpseclib\Math\BigInteger\Engines\Engine $x
* @param \phpseclib\Math\BigInteger\Engines\Engine $e
* @param \phpseclib\Math\BigInteger\Engines\Engine $n
* @param string $class
* @return \phpseclib\Math\BigInteger\Engine
* @return \phpseclib\Math\BigInteger\Engines\Engine
*/
protected static function slidingWindow(Engine $x, Engine $e, Engine $n, $class)
{
@ -691,7 +691,7 @@ abstract class Engine implements \Serializable
/**
* Performs some pre-processing for randomRangePrime
*
* @return \phpseclib\Math\BigInteger\Engines\Engine
* @return bool|Engine
*/
protected static function randomRangePrimeOuter(Engine $min, Engine $max)
{
@ -781,7 +781,7 @@ abstract class Engine implements \Serializable
/**
* Performs some post-processing for randomRangePrime
*
* @return \phpseclib\Math\BigInteger\Engine
* @return bool|Engine
*/
protected static function randomRangePrimeInner(Engine $x, Engine $min, Engine $max)
{

View File

@ -546,7 +546,7 @@ class GMP extends Engine
*
* Returns the nth root of a positive biginteger, where n defaults to 2
*
* @return \phpseclib\Math\BigInteger\Engines\Engine\GMP
* @return \phpseclib\Math\BigInteger\Engines\GMP
*/
protected function rootInner($n)
{

View File

@ -1314,7 +1314,7 @@ abstract class PHP extends Engine
protected function powHelper(PHP $n)
{
if ($n->compare(static::$zero) == 0) {
return new self(1);
return new static(1);
} // n^0 = 1

View File

@ -80,7 +80,7 @@ abstract class Base extends PHP
* @param string $class
* @return \phpseclib\Math\BigInteger\Engines\PHP
*/
protected static function powModHelper(PHP $x, PHP $e, PHP $n, $class)
public static function powModHelper(PHP $x, PHP $e, PHP $n, $class)
{
if (empty($e->value)) {
$temp = new $class();

View File

@ -46,7 +46,7 @@ abstract class Montgomery extends Base
* @param \phpseclib\Math\BigInteger\Engine $e
* @param \phpseclib\Math\BigInteger\Engine $n
* @param string $class
* @return \phpseclib\Math\BigInteger\Engine
* @return \phpseclib\Math\BigInteger\Engine|Engine
*/
protected static function slidingWindow(Engine $x, Engine $e, Engine $n, $class)
{

View File

@ -3024,7 +3024,7 @@ class SFTP extends SSH2
* Returns a string if NET_SFTP_LOGGING == self::LOG_COMPLEX, an array if NET_SFTP_LOGGING == self::LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING')
*
* @access public
* @return string or Array
* @return array|string
*/
public function getSFTPLog()
{
@ -3086,7 +3086,7 @@ class SFTP extends SSH2
* @return bool
* @access private
*/
private function disconnect_helper($reason)
protected function disconnect_helper($reason)
{
$this->pwd = false;
parent::disconnect_helper($reason);

View File

@ -1079,7 +1079,7 @@ class SSH1
* http://www.securiteam.com/securitynews/5LP042K3FY.html
*
* @see self::_send_binary_packet()
* @return array
* @return array|bool
* @access private
*/
private function get_binary_packet()

View File

@ -652,7 +652,7 @@ class SSH2
* @see self::_get_channel_packet()
* @access private
*/
private $curTimeout;
protected $curTimeout;
/**
* Real-time log file pointer
@ -906,7 +906,7 @@ class SSH2
* @param int $port
* @param int $timeout
* @see self::login()
* @return \phpseclib\Net\SSH2
* @return SSH2|void
* @access public
*/
public function __construct($host, $port = 22, $timeout = 10)
@ -3926,7 +3926,7 @@ class SSH2
* @return bool
* @access private
*/
private function disconnect_helper($reason)
protected function disconnect_helper($reason)
{
if ($this->bitmap & self::MASK_CONNECTED) {
$data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, '');