- improved handling of malformed RSA keys: part II

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@172 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2011-07-11 00:37:46 +00:00
parent d4a3d61ff5
commit a5d702346a

View File

@ -1009,12 +1009,12 @@ class Crypt_RSA {
return false;
}
extract(unpack('Nlength', $this->_string_shift($key, 4)));
return array(
return strlen($key) ? false : array(
'modulus' => new Math_BigInteger($this->_string_shift($key, $length), -256),
'publicExponent' => $modulus
);
} else {
return array(
return strlen($key) ? false : array(
'modulus' => $modulus,
'publicExponent' => $publicExponent
);
@ -1033,7 +1033,7 @@ class Crypt_RSA {
return false;
}
return $this->components;
return isset($this->components['modulus']) && isset($this->components['publicExponent']) ? $this->components : false;
// from PuTTY's SSHPUBK.C
case CRYPT_RSA_PRIVATE_FORMAT_PUTTY:
$components = array();