pssht  latest
SSH server library written in PHP
RFC5656.php
1 <?php
2 
3 /*
4 * This file is part of pssht.
5 *
6 * (c) François Poirotte <clicky@erebot.net>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 
13 
18 {
19  protected function createResponse(
20  \fpoirotte\Pssht\Wire\Decoder $decoder,
21  \fpoirotte\Pssht\Transport $transport,
22  array &$context,
23  $hostAlgo
24  ) {
25  $kexAlgo = $context['kexAlgo'];
26  $kexAlgo = new $kexAlgo();
27  $curveName = str_replace('ecdh-sha2-', '', $kexAlgo::getName());
28  $cls = str_replace('nist', 'NIST', $curveName);
29  $cls = "\\fpoirotte\\Pssht\\Messages\\KEX\\ECDH\\INIT\\$cls";
30  $message = $cls::unserialize($decoder);
31  $curve = \fpoirotte\Pssht\ECC\Curve::getCurve($curveName);
32 
33  return new \fpoirotte\Pssht\Messages\KEX\ECDH\REPLY\RFC5656(
34  $curve,
35  $message,
36  $context['serverKeys'][$hostAlgo],
37  $transport->getEncryptor(),
38  $kexAlgo,
39  $context['kex']['server'],
40  $context['kex']['client'],
41  $context['identity']['server'],
42  $context['identity']['client']
43  );
44  }
45 }