I was just trying to use phpseclib and encountered a fatal error in the key generator routine in a very simple setup.

Code:

- Code: Select all
`$includeFolder = getcwd() . DIRECTORY_SEPARATOR . 'be_inc' . DIRECTORY_SEPARATOR . 'crypto';`

set_include_path(get_include_path(). PATH_SEPARATOR . $includeFolder);

require 'Crypt/RSA.php';

define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);

$rsa = new Crypt_RSA();

$rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);

$rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);

define('CRYPT_RSA_EXPONENT', 36075);

define('CRYPT_RSA_SMALLEST_PRIME', 64);

$rsa->createKey(2048);

Result:

Fatal error: Cannot use object of type Math_BigInteger as array in H:\xampp\htdocs\drhhp\be_inc\crypto\Crypt\RSA.php on line 639

On this line the variable $lcm is a Math_BigInteger itself instead splitting a top and bottom part, so $lcm['top'] is causing this error. When adding

- Code: Select all
`if($lcm instanceOf Math_BigInteger)`

$lcm = array('top' => $lcm, 'bottom' => false);

on the line above, the script runs ages and returns even more errors:

- Code: Select all
`Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3088`

Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3092

Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3088

Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3092

Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3088

Warning: Division by zero in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 3092

Fatal error: Maximum execution time of 30 seconds exceeded in H:\xampp\htdocs\drhhp\be_inc\crypto\Math\BigInteger.php on line 348

Before I keep on messing around with stuff I don't fully understand I would like to know, if I was missing something obvious or if this is really a bug?

Thanks in advance,

Kevin