- make Net_SSH2 return more printer friendly server public host keys

This commit is contained in:
terrafrost 2012-07-04 13:36:26 -05:00
parent 1417463eba
commit f292931aed
2 changed files with 24 additions and 3 deletions

View File

@ -1110,8 +1110,9 @@ class Crypt_RSA {
return false;
}
extract(unpack('Nlength', $this->_string_shift($key, 4)));
$realModulus = new Math_BigInteger($this->_string_shift($key, $length), -256);
return strlen($key) ? false : array(
'modulus' => new Math_BigInteger($this->_string_shift($key, $length), -256),
'modulus' => $realModulus,
'publicExponent' => $modulus
);
} else {

View File

@ -198,7 +198,7 @@ class Net_SSH2 {
* @var String
* @access private
*/
var $identifier = 'SSH-2.0-phpseclib_0.2';
var $identifier = 'SSH-2.0-phpseclib_0.3';
/**
* The Socket Object
@ -671,6 +671,14 @@ class Net_SSH2 {
*/
var $realtime_log_size;
/**
* Has the signature been validated?
*
* @see Net_SSH2::getServerPublicHostKey()
* @access private
*/
var $signature_validated = false;
/**
* Real-time log file wrap boolean
*
@ -2773,6 +2781,14 @@ class Net_SSH2 {
extract(unpack('Nlength', $this->_string_shift($server_public_host_key, 4)));
$this->_string_shift($server_public_host_key, $length);
if ($this->signature_validated) {
return $this->bitmap ?
$this->signature_format . ' ' . base64_encode($this->server_public_host_key) :
false;
}
$this->signature_validated = true;
switch ($this->signature_format) {
case 'ssh-dss':
$temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4));
@ -2874,8 +2890,12 @@ class Net_SSH2 {
user_error('Bad server signature', E_USER_NOTICE);
return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE);
}
break;
default:
user_error('Unsupported signature format', E_USER_NOTICE);
return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE);
}
return $this->server_public_host_key;
return $this->signature_format . ' ' . base64_encode($this->server_public_host_key);
}
}