Passed
Pull Request — master (#18)
by
unknown
08:11
created

TpmEccParameters::getAlgorithm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace MadWizard\WebAuthn\Attestation\Tpm;
4
5
use MadWizard\WebAuthn\Format\ByteBuffer;
6
7
final class TpmEccParameters implements KeyParametersInterface
8
{
9
    /**
10
     * @var int
11
     */
12
    private $symmetric;
13
14
    /**
15
     * @var int
16
     */
17
    private $scheme;
18
19
    /**
20
     * @var int
21
     */
22
    private $curveId;
23
24
    /**
25
     * @var int
26
     */
27
    private $kdf;
28
29
    public function __construct(int $symmetric, int $scheme, int $curveId, int $kdf)
30
    {
31
        $this->symmetric = $symmetric;
32
        $this->scheme = $scheme;
33
        $this->curveId = $curveId;
34
        $this->kdf = $kdf;
35
    }
36
37
    public function getAlgorithm(): int
38
    {
39
        return TpmPublic::TPM_ALG_ECC;
40
    }
41
42
    public static function parse(ByteBuffer $buffer, int $offset, int &$endOffset): KeyParametersInterface
43
    {
44
        $symmetric = $buffer->getUint16Val($offset);
45
        $scheme = $buffer->getUint16Val($offset + 2);
46
        $curveId = $buffer->getUint16Val($offset + 4);
47
        $kdf = $buffer->getUint16Val($offset + 6);
48
        $endOffset = $offset + 8;
49
        return new self($symmetric, $scheme, $curveId, $kdf);
50
    }
51
52
    public function getSymmetric(): int
53
    {
54
        return $this->symmetric;
55
    }
56
57
    public function getScheme(): int
58
    {
59
        return $this->scheme;
60
    }
61
62
    public function getCurveId(): int
63
    {
64
        return $this->curveId;
65
    }
66
67
    public function getKdf(): int
68
    {
69
        return $this->kdf;
70
    }
71
}
72