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

RSA   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\OpenSSL;
9
use SimpleSAML\XMLSecurity\Constants as C;
10
use SimpleSAML\XMLSecurity\Key\AsymmetricKey;
11
12
/**
13
 * Class implementing the RSA signature algorithm.
14
 *
15
 * @package simplesamlphp/xml-security
16
 */
17
final class RSA extends AbstractSigner implements SignatureAlgorithm
18
{
19
    /** @var string */
20
    protected string $default_backend = OpenSSL::class;
21
22
23
    /**
24
     * RSA constructor.
25
     *
26
     * @param \SimpleSAML\XMLSecurity\Key\AsymmetricKey $key The asymmetric key (either public or private) to use.
27
     * @param string $algId The identifier of this algorithm.
28
     */
29
    public function __construct(AsymmetricKey $key, string $algId = C::SIG_RSA_SHA256)
30
    {
31
        parent::__construct($key, $algId, C::$RSA_DIGESTS[$algId]);
32
    }
33
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public static function getSupportedAlgorithms(): array
39
    {
40
        return array_keys(C::$RSA_DIGESTS);
41
    }
42
}
43