pssht
latest
SSH server library written in PHP
Main Page
Classes
Files
File List
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\MAC
;
13
14
use
fpoirotte\Pssht\MAC\MACInterface
;
15
use
fpoirotte\Pssht\Algorithms\AvailabilityInterface
;
16
use
fpoirotte\Pssht\MAC\BaseInterface
;
17
21
abstract
class
Base
implements
22
MACInterface
,
23
AvailabilityInterface
,
24
BaseInterface
25
{
27
protected
$key
;
28
29
final
public
function
__construct
(
$key
)
30
{
31
$this->key =
$key
;
32
}
33
34
final
public
function
compute
($seqno, $data)
35
{
36
$cls = get_called_class();
37
return
hash_hmac($cls::getHash(), pack(
'N'
, $seqno) . $data, $this->key,
true
);
38
}
39
40
final
public
static
function
getKeySize
()
41
{
42
$cls = get_called_class();
43
return
strlen(hash($cls::getHash(),
''
,
true
));
44
}
45
46
final
public
static
function
getSize
()
47
{
48
return
static::getKeySize();
49
}
50
51
final
public
static
function
isAvailable
()
52
{
53
if
(!function_exists(
'hash_algos'
) ||
54
!function_exists(
'hash'
) ||
55
!function_exists(
'hash_hmac'
)) {
56
return
false
;
57
}
58
$cls = get_called_class();
59
return
in_array($cls::getHash(), hash_algos(),
true
);
60
}
61
}
fpoirotte\Pssht\MAC\Base\compute
compute($seqno, $data)
Definition:
Base.php:34
fpoirotte\Pssht\MAC\Base\isAvailable
static isAvailable()
Definition:
Base.php:51
fpoirotte\Pssht\MAC\Base\$key
$key
Secret key for MAC operations.
Definition:
Base.php:27
fpoirotte\Pssht\MAC\Base\__construct
__construct($key)
Definition:
Base.php:29
fpoirotte\Pssht\MAC
Definition:
Base.php:12
fpoirotte\Pssht\MAC\Base
Definition:
Base.php:21
AvailabilityInterface
fpoirotte\Pssht\MAC\Base\getKeySize
static getKeySize()
Definition:
Base.php:40
fpoirotte\Pssht\MAC\BaseInterface
Definition:
BaseInterface.php:18
MACInterface
BaseInterface
fpoirotte\Pssht\MAC\Base\getSize
static getSize()
Definition:
Base.php:46
fpoirotte\Pssht\MAC\MACInterface
Definition:
MACInterface.php:17
fpoirotte\Pssht\Algorithms\AvailabilityInterface
Definition:
AvailabilityInterface.php:18
src
MAC
Base.php
Generated on Tue May 9 2017 12:09:55 for pssht by
1.8.11