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

AES::getSupportedAlgorithms()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Alg\Encryption;
6
7
use SimpleSAML\XMLSecurity\Backend\OpenSSL;
8
use SimpleSAML\XMLSecurity\Constants as C;
9
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
10
11
/**
12
 * Class implementing the AES family of encryption algorithms (both AES-CBC and AES-GCM).
13
 *
14
 * @package simplesamlphp/xml-security
15
 */
16
class AES extends AbstractEncryptor
17
{
18
    /** @var string */
19
    protected string $default_backend = OpenSSL::class;
20
21
22
    /**
23
     * AES constructor.
24
     *
25
     * @param \SimpleSAML\XMLSecurity\Key\SymmetricKey $key The symmetric key to use.
26
     * @param string $algId The identifier of this algorithm.
27
     */
28
    public function __construct(SymmetricKey $key, string $algId = C::BLOCK_ENC_AES256_GCM)
29
    {
30
        parent::__construct($key, $algId);
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public static function getSupportedAlgorithms(): array
37
    {
38
        return [
39
            C::BLOCK_ENC_AES128,
40
            C::BLOCK_ENC_AES192,
41
            C::BLOCK_ENC_AES256,
42
            C::BLOCK_ENC_AES128_GCM,
43
            C::BLOCK_ENC_AES192_GCM,
44
            C::BLOCK_ENC_AES256_GCM,
45
        ];
46
    }
47
}