Passed
Pull Request — master (#2)
by Jaime Pérez
02:11
created

HMAC   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getSupportedAlgorithms() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Alg\Signature;
6
7
use SimpleSAML\XMLSecurity\Alg\SignatureAlgorithm;
8
use SimpleSAML\XMLSecurity\Backend\HMAC as HMAC_Backend;
9
use SimpleSAML\XMLSecurity\Constants as C;
10
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
11
12
/**
13
 * Class implementing the HMAC signature algorithm
14
 *
15
 * @package simplesamlphp/xml-security
16
 */
17
final class HMAC extends AbstractSigner implements SignatureAlgorithm
18
{
19
    /** @var string */
20
    protected string $default_backend = HMAC_Backend::class;
21
22
23
    /**
24
     * HMAC constructor.
25
     *
26
     * @param \SimpleSAML\XMLSecurity\Key\SymmetricKey $key The symmetric key to use.
27
     * @param string $algId The identifier of this algorithm.
28
     */
29
    public function __construct(SymmetricKey $key, string $algId = C::SIG_HMAC_SHA256)
30
    {
31
        parent::__construct($key, $algId, C::$HMAC_DIGESTS[$algId]);
32
    }
33
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public static function getSupportedAlgorithms(): array
39
    {
40
        return array_keys(C::$HMAC_DIGESTS);
41
    }
42
}
43