PBEWithMD5AndDESCBCAlgorithmIdentifier   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 36
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hashFunc() 0 3 1
A name() 0 3 1
A __construct() 0 4 1
A blockCipher() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\PKCS5\ASN1\AlgorithmIdentifier;
6
7
use Sop\CryptoTypes\AlgorithmIdentifier\Cipher\BlockCipherAlgorithmIdentifier;
8
use Sop\CryptoTypes\AlgorithmIdentifier\Cipher\DESCBCAlgorithmIdentifier;
9
use Sop\PKCS5\HashFunc\HashFunc;
10
use Sop\PKCS5\HashFunc\MD5;
11
12
/**
13
 * Algorithm identifier for password-based encryption scheme with MD5 and DES.
14
 *
15
 * @see https://tools.ietf.org/html/rfc2898#appendix-A.3
16
 */
17
class PBEWithMD5AndDESCBCAlgorithmIdentifier extends PBES1PKCS5AlgorithmIdentifier
18
{
19
    /**
20
     * Constructor.
21
     *
22
     * @param string $salt            Salt
23
     * @param int    $iteration_count Iteration count
24
     */
25 4
    public function __construct(string $salt, int $iteration_count)
26
    {
27 4
        parent::__construct($salt, $iteration_count);
28 3
        $this->_oid = self::OID_PBE_WITH_MD5_AND_DES_CBC;
29 3
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function name(): string
35
    {
36 1
        return 'pbeWithMD5AndDES-CBC';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function hashFunc(): HashFunc
43
    {
44 2
        return new MD5();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 2
    public function blockCipher(): BlockCipherAlgorithmIdentifier
51
    {
52 2
        return new DESCBCAlgorithmIdentifier();
53
    }
54
}
55