pssht  latest
SSH server library written in PHP
Curve25519.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 
19 {
20  public static function addHandlers(\fpoirotte\Pssht\Transport $transport)
21  {
22  $transport->setHandler(
23  \fpoirotte\Pssht\Messages\KEX\ECDH\INIT\Curve25519::getMessageId(),
24  new \fpoirotte\Pssht\Handlers\KEX\ECDH\INIT\Curve25519()
25  );
26  }
27 
28  public static function getName()
29  {
30  return 'curve25519-sha256@libssh.org';
31  }
32 
33  public function hash($data)
34  {
35  return hash('sha256', $data, true);
36  }
37 
38  public static function isAvailable()
39  {
40  if (!function_exists('hash_algos') || !function_exists('hash')) {
41  return false;
42  }
43  return in_array('sha256', hash_algos(), true);
44  }
45 }
static getName()
Return the name of the algorithm.
Definition: Curve25519.php:28