【问题标题】:phpseclib SSH2 hangs at Math_BigInteger::modPow()phpseclib SSH2 在 Math_BigInteger::modPow() 处挂起
【发布时间】:2014-05-12 10:41:09
【问题描述】:

我已经尝试了 SSH2 的基本示例,但它挂起。

<?php
ini_set('display_errors', 1);

include('Net/SSH2.php');
$host = '192.168.100.101';
$ssh = new Net_SSH2($host);

如果我设置时间限制,例如1000秒:

<?php
ini_set('display_errors', 1);
set_time_limit(1000);

include('Net/SSH2.php');
$host = '192.168.100.101';
$ssh = new Net_SSH2($host);

我会得到:

Fatal error: Maximum execution time of 1000 seconds exceeded in /path/to/Math/BigInteger.php on line 1060
Stack trace:
#  Time      Memory  Function                           Location
1  0.0014    647704  {main}( )                          ../index.php:0
2  0.0219    2203280 Net_SSH2->Net_SSH2( )              ../index.php:14
3  0.1114    4439056 Net_SSH2->_key_exchange( )         ../SSH2.php:952
4  0.1837    4520224 Math_BigInteger->modPow( )         ../SSH2.php:1309
5  0.1840    4521888 Math_BigInteger->_slidingWindow( ) ../BigInteger.php:1723
6  0.1842    4523144 Math_BigInteger->_prepareReduce( ) ../BigInteger.php:1817
7  0.1842    4523144 Math_BigInteger->_reduce( )        ../BigInteger.php:1912
8  0.1842    4523144 Math_BigInteger->_barrett( )       ../BigInteger.php:1876
9  0.1844    4536024 Math_BigInteger->divide( )         ../BigInteger.php:2032
10 1001.4549 4577384 Math_BigInteger->subtract( )       ../BigInteger.php:1497
11 1001.4549 4586584 Math_BigInteger->_subtract( )      ../BigInteger.php:991

有人知道是什么原因造成的吗?

提前致谢。

更多信息: 我在 Linux x86_64 上使用 PHP 5.3.28 作为 Apache 2.2.10 的一个模块。

【问题讨论】:

  • 看起来像一个无限循环,也许你的密钥中的数字比 phpseclib 预期的要大。如果你用--with-openssl编译PHP,你应该使用那些函数。

标签: php phpseclib


【解决方案1】:

您正在使用最慢的 phpseclib 模式,所以这不会有帮助。不过话说回来……

尝试最新的 git 版本。特别是,这个提交应该会导致轻微的加速:

https://github.com/phpseclib/phpseclib/commit/e4ff01f05475e81a56681ebfdb5473a07099e5ea

【讨论】:

  • 这是最新的 0.3.6 版本:phpseclib.sourceforge.net。无论如何,您说的最新 git 版本运行良好。谢谢。
猜你喜欢
  • 2020-10-22
  • 2023-03-13
  • 2018-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多