-
-
Notifications
You must be signed in to change notification settings - Fork 885
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
Breaking change in 2.0.3? #1113
Comments
It looks like you're setting all the parameters directly. eg. 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']); Prior to #984 phpseclib did this to determine if it should do plain old modular exponentiation or if it could use the chinese remainder theorem to speed things up: if (empty($this->primes) || empty($this->coefficients) || empty($this->exponents)) { This was refined in #984 to this: switch (true) {
case empty($this->primes):
case $this->primes[1]->equals($this->zero):
case empty($this->coefficients):
case $this->coefficients[2]->equals($this->zero):
case empty($this->exponents):
case $this->exponents[1]->equals($this->zero):
return $x->modPow($this->exponent, $this->modulus); You don't appear to be setting the exponent so, with the old code, modular exponentiation wasn't taking place. With the new code it... well now it's checking more things. Here's how I'd set the keys: if($packet->key['p'] && $packet->key['q'])
$rsa->primes = array(
1=> new BigInteger($packet->key['p'], 256),
new BigInteger($packet->key['q'], 256)
);
if($packet->key['u']) $rsa->coefficients = array(2 => new BigInteger($packet->key['u'])); ie. they're BigInteger's - not strings. Also, the initial index is 1 or 2 - not 0. $this->components needs to be set as well. PuTTY keys do not have the components but they're calculated on key load thusly: $temp = $components['primes'][1]->subtract($this->one);
$components['exponents'] = array(1 => $components['publicExponent']->modInverse($temp));
$temp = $components['primes'][2]->subtract($this->one);
$components['exponents'][] = $components['publicExponent']->modInverse($temp); So I'd do something like that as well. As is, however, with 2.0.2 and earlier, you're not actually getting the speedup that the Chinese Remainder Theorem (CRT) provides for since you're not setting all the parameters that you need. And it's just kinda silently failing on you and falling back to the non-CRT approach. In dev-master all they key formats are handled via a plugin system so for the master branch (which isn't really ready for general use) I'd suggest just developing a custom plugin but, for the time being, the approach you're using works fine. |
Add compatibility with phpseclib 2.0.3 - 2.0.4
Add compatibility with phpseclib 2.0.3 - 2.0.4
Thanks so much for the help! |
cea5b17 on 11 Apr @jasekiw jasekiw phpseclib/phpseclib#1113
cea5b17 on 11 Apr @jasekiw jasekiw phpseclib/phpseclib#1113
It has come to my attention that something in the 2.0.3 release of phpseclib breaks my library. See the test failure here: https://travis-ci.org/singpolyma/openpgp-php/jobs/220055163
The same code works fine on 2.0.0, 2.0.1, and 2.0.2
Was the return type of something changed accidentally?
The text was updated successfully, but these errors were encountered: