-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHMAC.php
More file actions
43 lines (35 loc) · 1.01 KB
/
HMAC.php
File metadata and controls
43 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace SimpleSAML\XMLSecurity\Alg\Signature;
use SimpleSAML\XMLSecurity\Backend;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
/**
* Class implementing the HMAC signature algorithm
*
* @package simplesamlphp/xml-security
*/
final class HMAC extends AbstractSigner implements SignatureAlgorithmInterface
{
protected const string DEFAULT_BACKEND = Backend\HMAC::class;
/**
* HMAC constructor.
*
* @param \SimpleSAML\XMLSecurity\Key\SymmetricKey $key The symmetric key to use.
* @param string $algId The identifier of this algorithm.
*/
public function __construct(
#[\SensitiveParameter]
SymmetricKey $key,
string $algId = C::SIG_HMAC_SHA256,
) {
parent::__construct($key, $algId, C::$HMAC_DIGESTS[$algId]);
}
/**
* @return string[]
*/
public static function getSupportedAlgorithms(): array
{
return array_keys(C::$HMAC_DIGESTS);
}
}