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

RSA::getSupportedAlgorithms()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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