Passed
Branch feature/php83 (e52173)
by Tim
33:00 queued 16:50
created

HMAC   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Alg\Signature;
6
7
use SimpleSAML\XMLSecurity\Backend;
8
use SimpleSAML\XMLSecurity\Constants as C;
9
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
10
11
/**
12
 * Class implementing the HMAC signature algorithm
13
 *
14
 * @package simplesamlphp/xml-security
15
 */
16
final class HMAC extends AbstractSigner implements SignatureAlgorithmInterface
17
{
18
    protected const string DEFAULT_BACKEND = Backend\HMAC::class;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 18 at column 27
Loading history...
19
20
21
    /**
22
     * HMAC constructor.
23
     *
24
     * @param \SimpleSAML\XMLSecurity\Key\SymmetricKey $key The symmetric key to use.
25
     * @param string $algId The identifier of this algorithm.
26
     */
27
    public function __construct(
28
        #[\SensitiveParameter]
29
        SymmetricKey $key,
30
        string $algId = C::SIG_HMAC_SHA256,
31
    ) {
32
        parent::__construct($key, $algId, C::$HMAC_DIGESTS[$algId]);
33
    }
34
35
36
    /**
37
     * @return string[]
38
     */
39
    public static function getSupportedAlgorithms(): array
40
    {
41
        return array_keys(C::$HMAC_DIGESTS);
42
    }
43
}
44