mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-06-16 07:12:23 +00:00
- make Net_SSH2 return more printer friendly server public host keys
This commit is contained in:
parent
1417463eba
commit
f292931aed
|
@ -1110,8 +1110,9 @@ class Crypt_RSA {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
extract(unpack('Nlength', $this->_string_shift($key, 4)));
|
extract(unpack('Nlength', $this->_string_shift($key, 4)));
|
||||||
|
$realModulus = new Math_BigInteger($this->_string_shift($key, $length), -256);
|
||||||
return strlen($key) ? false : array(
|
return strlen($key) ? false : array(
|
||||||
'modulus' => new Math_BigInteger($this->_string_shift($key, $length), -256),
|
'modulus' => $realModulus,
|
||||||
'publicExponent' => $modulus
|
'publicExponent' => $modulus
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -198,7 +198,7 @@ class Net_SSH2 {
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $identifier = 'SSH-2.0-phpseclib_0.2';
|
var $identifier = 'SSH-2.0-phpseclib_0.3';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Socket Object
|
* The Socket Object
|
||||||
|
@ -671,6 +671,14 @@ class Net_SSH2 {
|
||||||
*/
|
*/
|
||||||
var $realtime_log_size;
|
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
|
* Real-time log file wrap boolean
|
||||||
*
|
*
|
||||||
|
@ -2773,6 +2781,14 @@ class Net_SSH2 {
|
||||||
extract(unpack('Nlength', $this->_string_shift($server_public_host_key, 4)));
|
extract(unpack('Nlength', $this->_string_shift($server_public_host_key, 4)));
|
||||||
$this->_string_shift($server_public_host_key, $length);
|
$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) {
|
switch ($this->signature_format) {
|
||||||
case 'ssh-dss':
|
case 'ssh-dss':
|
||||||
$temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4));
|
$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);
|
user_error('Bad server signature', E_USER_NOTICE);
|
||||||
return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user