PHPFatal: Call to a member function multiply() on a non-obj

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

PHPFatal: Call to a member function multiply() on a non-obj

Postby m4rc » Thu Feb 25, 2010 12:40 pm

Hello TerraFrost

It's me again, I went one step forward and repeated my test on AIX with the AIX SFTP server. The test failed with
Code: Select all
PHP Fatal error:  Call to a member function multiply() on a non-object in Net/SSH2.php on line 1047

this happens in the constructor of Net_SFTP
Code: Select all
$sftp = new Net_SFTP($this->host, $this->port);


As it seems something goes wrong when checking the server signature.

As a very dirty workaround i did the following (File SSH2.php, Lines 1045 - 1065 (most recent version from CVS!):

Code: Select all
                $w = $s->modInverse($q);

                // m4rC Hack
                if($w == false)
                {
                    user_error("Problem decoding server signature ... just skip it!", E_USER_NOTICE);
                }
                else
                {
                    // Original code
                    $u1 = $w->multiply(new Math_BigInteger(sha1($this->session_id), 16));
                    list(, $u1) = $u1->divide($q);

                    $u2 = $w->multiply($r);
                    list(, $u2) = $u2->divide($q);

                    $g = $g->modPow($u1, $p);
                    $y = $y->modPow($u2, $p);

                    $v = $g->multiply($y);
                    list(, $v) = $v->divide($p);
                    list(, $v) = $v->divide($q);

                    if (!$v->equals($r)) {
                        user_error('Bad server signature', E_USER_NOTICE);
                        return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE);
                    }
                    // END Original code
                } // END m4rC Hack

                break;


Did I miss a thing or what could be the problem? Any hints are highly welcome.

Thanks in advance.
m4rC
m4rc
Traveler
 
Posts: 6
Joined: Tue Feb 23, 2010 1:45 pm

Re: PHPFatal: Call to a member function multiply() on a non-obj

Postby TerraFrost » Fri Feb 26, 2010 6:23 am

$s->modInverse($q) will return false if the gcd between $s and $q is greater than one.

Code: Select all
                if ($r->compare($q) >= 0 || $s->compare($q) >= 0) {
                    user_error('Invalid signature', E_USER_NOTICE);
                    return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
                }

                $w = $s->modInverse($q);

Since $s is less than $q and $q is supposed to be prime, $s should never be false, but if you're getting the error that you are, it sounds like maybe it is - like maybe your server isn't giving you a prime $q.

What is your $s and $q? You can get them by doing echo serialize($s) . "\r\n\r\n" . serialize($q);
TerraFrost
Legendary Guard
 
Posts: 12243
Joined: Wed Dec 04, 2002 6:37 am

Re: PHPFatal: Call to a member function multiply() on a non-obj

Postby m4rc » Fri Feb 26, 2010 8:11 am

Code: Select all
$s=O:15:"Math_BigInteger":1:{s:3:"hex";s:42:"00aa2a300b5e6e5c1518cbc3647f9e2fd2f59aefe6";}
$q=O:15:"Math_BigInteger":1:{s:3:"hex";s:42:"00f60885e9f6241cef78641cef8c707fc46632a14f";}


Thats the output from the following code on line 1040 in SSH2.php (CVS from 24.2.2010):
Code: Select all
echo "\r\n\$s='" .serialize($s) . "'";
echo "\r\n\$q='" .serialize($q) . "'";


Thanks in advance for your support!
m4rC
m4rc
Traveler
 
Posts: 6
Joined: Tue Feb 23, 2010 1:45 pm

Re: PHPFatal: Call to a member function multiply() on a non-obj

Postby m4rc » Fri Feb 26, 2010 9:00 am

Hello TerraFrost

While reading your other posts, I saw, that you did some updates recently. I did a cvs-update and I re-checked my issue on the AIX server ...

tadaaa ... everything works as it should!

Thanks a lot!
m4rC
m4rc
Traveler
 
Posts: 6
Joined: Tue Feb 23, 2010 1:45 pm


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest