pssht  latest
SSH server library written in PHP
Base96.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\MAC;
13 
17 
22 abstract class Base96 implements
26 {
28  protected $subhash;
29 
30  final public function __construct($key)
31  {
32  $cls = static::getBaseClass();
33  $this->subhash = new $cls($key);
34  }
35 
36  public static function getName()
37  {
38  $cls = static::getBaseClass();
39  return $cls::getName() . '-96';
40  }
41 
42  final public function compute($seqno, $data)
43  {
44  return substr(
45  $this->subhash->compute($seqno, $data),
46  0,
47  $this->getSize()
48  );
49  }
50 
51  final public static function getKeySize()
52  {
53  $cls = static::getBaseClass();
54  return $cls::getKeySize();
55  }
56 
57  final public static function getSize()
58  {
59  return 96 >> 3;
60  }
61 
62  final public static function isAvailable()
63  {
64  $cls = static::getBaseClass();
65  if ($cls instanceof AvailabilityInterface) {
66  return $cls::isAvailable();
67  }
68  return true;
69  }
70 }
$subhash
Subhash performing the real MAC operation.
Definition: Base96.php:28
compute($seqno, $data)
Definition: Base96.php:42
static getName()
Return the name of the algorithm.
Definition: Base96.php:36