1
0
mirror of https://github.com/danog/tgseclib.git synced 2025-01-22 05:51:20 +01:00

- password protected PuTTY keys error out ungracefully when a bad password is used to decrypt

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@176 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2011-08-17 00:12:42 +00:00
parent 023e0e0540
commit 2676ca1d91

View File

@ -1080,10 +1080,19 @@ class Crypt_RSA {
} }
extract(unpack('Nlength', $this->_string_shift($private, 4))); extract(unpack('Nlength', $this->_string_shift($private, 4)));
if (strlen($private) < $length) {
return false;
}
$components['privateExponent'] = new Math_BigInteger($this->_string_shift($private, $length), -256); $components['privateExponent'] = new Math_BigInteger($this->_string_shift($private, $length), -256);
extract(unpack('Nlength', $this->_string_shift($private, 4))); extract(unpack('Nlength', $this->_string_shift($private, 4)));
if (strlen($private) < $length) {
return false;
}
$components['primes'] = array(1 => new Math_BigInteger($this->_string_shift($private, $length), -256)); $components['primes'] = array(1 => new Math_BigInteger($this->_string_shift($private, $length), -256));
extract(unpack('Nlength', $this->_string_shift($private, 4))); extract(unpack('Nlength', $this->_string_shift($private, 4)));
if (strlen($private) < $length) {
return false;
}
$components['primes'][] = new Math_BigInteger($this->_string_shift($private, $length), -256); $components['primes'][] = new Math_BigInteger($this->_string_shift($private, $length), -256);
$temp = $components['primes'][1]->subtract($this->one); $temp = $components['primes'][1]->subtract($this->one);
@ -1092,6 +1101,9 @@ class Crypt_RSA {
$components['exponents'][] = $components['publicExponent']->modInverse($temp); $components['exponents'][] = $components['publicExponent']->modInverse($temp);
extract(unpack('Nlength', $this->_string_shift($private, 4))); extract(unpack('Nlength', $this->_string_shift($private, 4)));
if (strlen($private) < $length) {
return false;
}
$components['coefficients'] = array(2 => new Math_BigInteger($this->_string_shift($private, $length), -256)); $components['coefficients'] = array(2 => new Math_BigInteger($this->_string_shift($private, $length), -256));
return $components; return $components;