-
-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PrimeField requires a prime number be passed to the constructor #1928
Comments
I'm not able to reproduce it (nor is it even reproducible on the unit tests which do make SSH connections) so imma need more info.
Also, I'm about to head off to work so it'll at least 8h before I'm able to revisit this fyi. |
@terrafrost Thanks for quick support - I was just checking and this issue was introduced with 3.0.21. 3.0.20 is still fine. Trace:
$ssh->getLog()
$ssh->getAlgorithmsNegotiated()
|
So I guess on your system the following is returning false vs true? $temp = new BigInteger('FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF', 16);
echo $temp->isPrime() ? 'true' : 'false'; For me it returns true. I tried it on every engine phpseclib supports:
It did return false for me using the PHP32 engine but, based on your What does the following return for you?: print_r(BigInteger::getEngine()); For me it returns this (assuming that Array
(
[0] => GMP
[1] => DefaultEngine
) If that indicates that you're using the PHP32 engine then maybe fixing it for that engine would fix the problem for you but, like I said, all the evidence I'm seeing indicates that you're not using that engine... |
I mean, I guess posting your |
Dear @terrafrost
3.0.20: 3.0.21:
3.0.20: 3.0.21: I test this on PHP 8.1.11 as CLI (official Windows release), but I also have 8.0 and it also works this way. It's not the target environment though. What else can I check? Thank you! |
It's interesting, but I'm still not able to reproduce your problem. You write "I test this on PHP 8.1.11 as CLI (official Windows release), but I also have 8.0 and it also works this way". So I downloaded https://windows.php.net/downloads/releases/archives/php-8.1.11-nts-Win32-vs16-x64.zip and ran it on Windows 11 with the following php.ini:
And when ran on that the primality testing code I asked you to ran output Here's what
That's the same as you. Well, maybe your "Openssl default config" is different. Maybe you could post that? That said, the fact that it's using PHP64 / OpenSSL even tho you have GMP installed is an issue. I've implemented a fix for that at f01892a . That may well fix your issue but the fact that PHP64 / OpenSSL is unable to correctly identify prime numbers may be an indicator that you have other problems. |
Dear @terrafrost I'm posting my openssl.cnf:
|
@terrafrost I just tried f01892a |
I'm posting my php.ini, makes this makes a difference.
|
I'm able to reproduce the issue with your php.ini. Here's a simplified version that reproduces the problem:
ie. without the I wonder if this is a bug in PHP's JIT implementation. Before I'm prepared to definitively say that, however, I'm gonna have to do more investigating. In the meantime, thank you for helping me get to the bottom of this! And, in the meantime, I guess you have a solution you can use (the use of the GMP engine vs the PHP64 engine). |
Dear @terrafrost - your latest change works fine, so don't worry about me. Indeed this sounds like a possible php bug, it's worth creating a bugs.php.net ticket and see what information we can gather. |
See php/php-src#11917 for the bug report I filed (I was able to reduce the problem to code that doesn't require phpseclib). Seems like it's only an issue on Windows. |
I made a change that'll prevent phpseclib working on Windows systems with JIT enabled: When the next major version for phpseclib is released it'll (1) use GMP, in your case, vs the pure-PHP implementation, and (2) it'll error out, even with GMP, unless you do |
I have installed using composer and am receiving the same message. The server is Debian 10 with PHP 7.3, so if you need more info, let me know. From the above I tried Without any difference, Downloading the code from the commit here does work. Hope this helps |
PHP 7.3.31-1 deb10u5 (cli) (built: Sep 4 2023 21:49:25) ( NTS ) |
The code I have pulled is working, thank you |
@slowpoet - great to hear - thanks! I'm gonna try to do a release in the next few days with this and other fixes. |
@slowpoet - a new version (3.0.22) has been released. Thanks! |
Version: 3.0.21 & master
Code to reproduce:
$sftp = new phpseclib3\Net\SFTP('host', 1234);
$sftp->login('username', 'password');
Result:
UnexpectedValueException: PrimeField requires a prime number be passed to the constructor in vendor\phpseclib\phpseclib\phpseclib\Math\PrimeField.php:49
The text was updated successfully, but these errors were encountered: