pssht  latest
SSH server library written in PHP
Base.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 
12 namespace fpoirotte\Pssht\KEX\ECDH;
13 
18 abstract class Base implements
20  \fpoirotte\Pssht\Algorithms\AvailabilityInterface,
22 {
23  public static function addHandlers(\fpoirotte\Pssht\Transport $transport)
24  {
25  $transport->setHandler(
26  \fpoirotte\Pssht\Messages\KEX\ECDH\INIT\RFC5656::getMessageId(),
27  new \fpoirotte\Pssht\Handlers\KEX\ECDH\INIT\RFC5656()
28  );
29  }
30 
31  public function hash($data)
32  {
33  return hash(static::getHashName(), $data, true);
34  }
35 
36  public static function isAvailable()
37  {
38  if (!function_exists('hash_algos') || !function_exists('hash')) {
39  return false;
40  }
41  return in_array(static::getHashName(), hash_algos(), true);
42  }
43 }