26 $ident = $decoder->getBuffer()->get(
"\r\n");
27 if ($ident === null) {
28 throw new \RuntimeException();
30 $context[
'identity'][
'client'] = (string) substr($ident, 0, -2);
31 if (strncmp($ident,
'SSH-2.0-', 8) !== 0) {
32 throw new \fpoirotte\Pssht\Messages\DISCONNECT();
35 $context[
'rekeying'] =
'server';
36 return $this->handleKEXINIT($transport, $context);
39 public function handleKEXINIT(
46 $random = new \fpoirotte\Pssht\Random\OpenSSL();
49 $kexAlgos = $algos->getAlgorithms(
'KEX');
50 if (!count($kexAlgos)) {
51 throw new \RuntimeException();
55 $serverHostKeyAlgos = array_intersect(
56 $algos->getAlgorithms(
'Key'),
57 array_keys($context[
'serverKeys'])
59 if (!count($serverHostKeyAlgos)) {
60 throw new \RuntimeException();
64 $encAlgosC2S = array_diff(
65 $algos->getAlgorithms(
'Encryption'),
68 $encAlgosS2C = $encAlgosC2S;
69 if (!count($encAlgosC2S)) {
70 throw new \RuntimeException();
74 $macAlgosC2S = array_diff($algos->getAlgorithms(
'MAC'), array(
'none'));
75 $macAlgosS2C = $macAlgosC2S;
76 if (!count($macAlgosC2S)) {
77 throw new \RuntimeException();
81 $compAlgosC2S = $algos->getAlgorithms(
'Compression');
82 $compAlgosS2C = $compAlgosC2S;
83 if (!count($compAlgosC2S)) {
84 throw new \RuntimeException();
87 $kex = new \fpoirotte\Pssht\Messages\KEXINIT(
98 $context[
'kex'][
'server'] = $kex;
99 $transport->writeMessage($kex);
handle($msgType,\fpoirotte\Pssht\Wire\Decoder $decoder,\fpoirotte\Pssht\Transport $transport, array &$context)