mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 02:07:09 +00:00
Merge branch '1.0' into 2.0
This commit is contained in:
commit
31fbdb96e0
@ -2587,6 +2587,21 @@ class SSH2
|
|||||||
$publickey['n']
|
$publickey['n']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
switch ($this->signature_format) {
|
||||||
|
case 'rsa-sha2-512':
|
||||||
|
$hash = 'sha512';
|
||||||
|
$signatureType = 'rsa-sha2-512';
|
||||||
|
break;
|
||||||
|
case 'rsa-sha2-256':
|
||||||
|
$hash = 'sha256';
|
||||||
|
$signatureType = 'rsa-sha2-256';
|
||||||
|
break;
|
||||||
|
//case 'ssh-rsa':
|
||||||
|
default:
|
||||||
|
$hash = 'sha1';
|
||||||
|
$signatureType = 'ssh-rsa';
|
||||||
|
}
|
||||||
|
|
||||||
$part1 = pack(
|
$part1 = pack(
|
||||||
'CNa*Na*Na*',
|
'CNa*Na*Na*',
|
||||||
NET_SSH2_MSG_USERAUTH_REQUEST,
|
NET_SSH2_MSG_USERAUTH_REQUEST,
|
||||||
@ -2597,7 +2612,7 @@ class SSH2
|
|||||||
strlen('publickey'),
|
strlen('publickey'),
|
||||||
'publickey'
|
'publickey'
|
||||||
);
|
);
|
||||||
$part2 = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey), $publickey);
|
$part2 = pack('Na*Na*', strlen($signatureType), $signatureType, strlen($publickey), $publickey);
|
||||||
|
|
||||||
$packet = $part1 . chr(0) . $part2;
|
$packet = $part1 . chr(0) . $part2;
|
||||||
if (!$this->_send_binary_packet($packet)) {
|
if (!$this->_send_binary_packet($packet)) {
|
||||||
@ -2638,23 +2653,9 @@ class SSH2
|
|||||||
|
|
||||||
$packet = $part1 . chr(1) . $part2;
|
$packet = $part1 . chr(1) . $part2;
|
||||||
$privatekey->setSignatureMode(RSA::SIGNATURE_PKCS1);
|
$privatekey->setSignatureMode(RSA::SIGNATURE_PKCS1);
|
||||||
switch ($this->signature_format) {
|
|
||||||
case 'rsa-sha2-512':
|
|
||||||
$hash = 'sha512';
|
|
||||||
$type = 'rsa-sha2-512';
|
|
||||||
break;
|
|
||||||
case 'rsa-sha2-256':
|
|
||||||
$hash = 'sha256';
|
|
||||||
$type = 'rsa-sha2-256';
|
|
||||||
break;
|
|
||||||
//case 'ssh-rsa':
|
|
||||||
default:
|
|
||||||
$hash = 'sha1';
|
|
||||||
$type = 'ssh-rsa';
|
|
||||||
}
|
|
||||||
$privatekey->setHash($hash);
|
$privatekey->setHash($hash);
|
||||||
$signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet));
|
$signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet));
|
||||||
$signature = pack('Na*Na*', strlen($type), $type, strlen($signature), $signature);
|
$signature = pack('Na*Na*', strlen($signatureType), $signatureType, strlen($signature), $signature);
|
||||||
$packet.= pack('Na*', strlen($signature), $signature);
|
$packet.= pack('Na*', strlen($signature), $signature);
|
||||||
|
|
||||||
if (!$this->_send_binary_packet($packet)) {
|
if (!$this->_send_binary_packet($packet)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user