From cea5b176fc1b812bfaffe144f6e5d212633b486b Mon Sep 17 00:00:00 2001 From: Jason Gallavin Date: Mon, 10 Apr 2017 20:27:48 -0400 Subject: [PATCH] https://github.com/phpseclib/phpseclib/issues/1113 Add compatibility with phpseclib 2.0.3 - 2.0.4 --- .travis.yml | 2 ++ composer.json | 2 +- lib/openpgp_crypt_rsa.php | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae42734..3829874 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,5 +12,7 @@ env: - PHPSECLIB="2.0.0" - PHPSECLIB="2.0.1" - PHPSECLIB="2.0.2" + - PHPSECLIB="2.0.3" + - PHPSECLIB="2.0.4" before_script: 'sed -i "s/\"phpseclib\/phpseclib\": \"[^\"]*/\"phpseclib\/phpseclib\": \"$PHPSECLIB/" composer.json && composer install --prefer-source --dev' diff --git a/composer.json b/composer.json index 04a1109..6acc8c4 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "phpseclib/phpseclib": ">=2.0.0 <2.0.3" + "phpseclib/phpseclib": ">=2.0.0 <=2.0.4" }, "require-dev": { "phpunit/phpunit": "~4.0" diff --git a/lib/openpgp_crypt_rsa.php b/lib/openpgp_crypt_rsa.php index cd782bc..bce11e1 100644 --- a/lib/openpgp_crypt_rsa.php +++ b/lib/openpgp_crypt_rsa.php @@ -245,8 +245,18 @@ class OpenPGP_Crypt_RSA { $rsa = self::crypt_rsa_key($mod, $exp); if($private) { - if($packet->key['p'] && $packet->key['q']) $rsa->primes = array($packet->key['p'], $packet->key['q']); - if($packet->key['u']) $rsa->coefficients = array($packet->key['u']); + /** + * @see https://github.com/phpseclib/phpseclib/issues/1113 + * Primes and coefficients now use BigIntegers. + **/ + //set the primes + if($packet->key['p'] && $packet->key['q']) + $rsa->primes = array( + 1 => new Math_BigInteger($packet->key['p'], 256), + 2 => new Math_BigInteger($packet->key['q'], 256) + ); + // set the coefficients + if($packet->key['u']) $rsa->coefficients = array(2 => new Math_BigInteger($packet->key['u'], 256)); } return $rsa;