1
0
mirror of https://github.com/danog/phpseclib.git synced 2025-01-22 04:51:19 +01:00

SSH/Agent: fix bad merge

This commit is contained in:
terrafrost 2018-05-27 11:03:16 -05:00
parent 03f9a4dc7e
commit ffb21d7622
3 changed files with 19 additions and 30 deletions

View File

@ -60,6 +60,7 @@ use phpseclib\Crypt\TripleDES;
use phpseclib\Crypt\Twofish;
use phpseclib\Math\BigInteger; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification.
use phpseclib\System\SSH\Agent;
use phpseclib\System\SSH\Agent\Identity as AgentIdentity;
use phpseclib\Exception\NoSupportedAlgorithmsException;
use phpseclib\Common\Functions\Strings;
use phpseclib\Common\Functions\Objects;
@ -2642,19 +2643,24 @@ class SSH2
}
$packet = $part1 . chr(1) . $part2;
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';
if ($privatekey instanceof AgentIdentity) {
$hash = 'sha1';
$type = 'ssh-rsa';
} else {
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);
$signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet), RSA::PADDING_PKCS1);

View File

@ -323,7 +323,6 @@ class Agent
return pack('Na*', $agent_reply_bytes, $agent_reply_data);
}
<<<<<<< HEAD
/**
* Forward data to SSH Agent and return data reply
@ -339,6 +338,3 @@ class Agent
Objects::setVar($ssh, 'channel_status', $temp);
}
}
=======
}
>>>>>>> 2.0

View File

@ -122,7 +122,6 @@ class Identity
* ssh-agent only supports signatures with sha1 hashes but to maintain BC with RSA.php this function exists
*
* @param string $hash optional
* @throws \phpseclib\Exception\UnsupportedAlgorithmException if the algorithm is unsupported
* @access public
*/
public function setHash($hash = 'sha1')
@ -132,18 +131,6 @@ class Identity
}
}
/**
* Set Hash
*
* ssh-agent doesn't support using hashes for RSA other than SHA1
*
* @param string $hash
* @access public
*/
function setHash($hash)
{
}
/**
* Create a signature
*