BigInteger undefined offset
Good evening, I was trying to adapt your implementation of SRP in my application, and found up that during the login, in the challenge phase the BigInteger after the execution of this line:
srp = new ThinbusSrp($SRP6CryptoParams["N_base10"], $SRP6CryptoParams["g_base10"], $SRP6CryptoParams["k_base16"], $SRP6CryptoParams["H"]);
outputs a lot of notices such as "Undefined offset: n in ...BigInteger.php line 3421 (or 1132)", after which it goes in timeout. Here is the exact output:
By what could it be caused?
Comments (13)
-
repo owner -
repo owner changing to a task as its not clear that either of the demo code or the library code as an issue on the setup in question.
-
Account Deleted reporter http://pastebin.com/7R8B1SEb Yes, I got the demo. The sign up is ok, but when I try to sign in this happens. Here is my phpinfo(): http://pastebin.com/TipyxdSp
-
repo owner looks like you are using php7 and that that is failing to parse the big integer math library script that i am using. i don't have a server with php7 to had to take a look. until I can get a php7 install to take a look i would suggest you check if there any any backwards compatibility flags that you can set to have php7 parse files which work on php5x.
-
repo owner I pushed some tweaks to make it easier to run the PHP unit test up to master.
Running with a local copy of PHP 7.0.5:
php --version PHP 7.0.5 (cli) (built: Mar 31 2016 06:38:53) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
The php tests run successfully with only a deprecated warning:
php phpunit.phar ThibusTest.php PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; BigInteger has a deprecated constructor in /Users/simon/projects/thinbus-php/thinbus/BigInteger.php on line 190 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; BigInteger has a deprecated constructor in /Users/simon/projects/thinbus-php/thinbus/BigInteger.php on line 190 PHPUnit 5.3.2 by Sebastian Bergmann and contributors. ..... 5 / 5 (100%) Time: 7.29 seconds, Memory: 8.00Mb OK (5 tests, 204 assertions)
You are running 7.0.4 so the fact that the unit tests run with 7.0.5 shows that I was wrong about it being an issue parsing the BigInteger.php file.
-
repo owner @vandr01y I have pushed a fix to the deprecated constructor in BigInteger.php
now if i use the built in php local web server with
php -S localhost:8000
I can register and login. before the fix things were broken as the ajax calls saw the php warning before the json so the browser failed to parse the json in the ajax.please try updating your BigInteger.php file to the latest in git.
-
repo owner I have created and fixed issue
#7based on this discussion. -
repo owner - changed status to resolved
Closing as no activity after having made changes to work on php7.
-
I also have this problem now.
Have been using the library for a long time on a CentOS server with many different PHP versions including version 7.1 - no problems
Now I moved the code to an Ubuntu 16.04 server with PHP version 7.0.18 and got the problem. I upgraded to version 7.1.11 with the same problem?
I get a lot of warnings like this during login: PHP Notice: Undefined offset: 66 in /var/www/html/lib/srp6a/BigInteger.php on line 3578
In the end the script terminates because it exceed the limit of Maximum execution time
NB: Also a single line with: Undefined offset: 6
Any suggestions about how to fix this?
-
I don't get a problem on Ubuntu 16.04 with PHP version 7.0.13 or 7.0.22:
$ docker pull fauria/lamp $ docker run -i -t --rm fauria/lamp bash # php --version PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS ) # git clone https://bitbucket.org/simon_massey/thinbus-php.git # cd thinbus-php # apt-get update # apt install wget # wget https://phar.phpunit.de/phpunit-5.7.phar # php phpunit-5.7.phar ThibusTest.php OK (15 tests, 235 assertions) # apt-get dist-upgrade # php --version PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) # php phpunit-5.7.phar ThibusTest.php OK (15 tests, 235 assertions)
In that I didn't paste a lot of lines (there was some spurious stuff php was outputting before it got to "PHPUnit 5.7.23 by Sebastian Bergmann and contributors.").
-
I will try to investigate a bit more and return!
-
This may be related : https://github.com/phpseclib/phpseclib/issues/491
-
It look as if bcmath was not installed and this was the problem !!
- Log in to comment
Do you have the demo code working on your server? The first step is to deploy the demo code and see that working. If it doesn't work then thats a bug in the library code (or the demo code). If the demo code does work on your server then but your own code doesn't then you need to debug your own code relative to the demo code (e.g. look on the developer console of the browser) to figure out if you are not passing the correct data.