Test Failed
Push — master ( 42e257...dadfc2 )
by Charles
02:28
created

EncryptionKey::getBoxSecretKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace ncryptf\Tests\mock;
4
5
use ncryptf\middleware\EncryptionKeyInterface;
6
use ncryptf\Keypair;
7
use ncryptf\Utils;
8
9
final class EncryptionKey implements EncryptionKeyInterface
10
{
11
    private $hashId;
12
    private $key;
13
    private $signingKey;
14
15
    public function getHashIdentifier() : string
16
    {
17
        return $this->hashId;
18
    }
19
20
    public function getBoxPublicKey() : string
21
    {
22
        return $this->key->getPublicKey();
23
    }
24
25
    public function getBoxSecretKey() : string
26
    {
27
        return $this->key->getSecretKey();
28
    }
29
30
    public function getBoxKeyPair() : Keypair
31
    {
32
        return $this->key;
33
    }
34
35
    public function getSigningPublicKey() : string
36
    {
37
        return $this->signingKey->getPublicKey();
38
    }
39
40
    public function getSigningSecretKey() : string
41
    {
42
        return $this->signingKey->getSecretKey();
43
    }
44
45
    public function getSigningKeyPair() : Keypair
46
    {
47
        return $this->signingKey;
48
    }
49
50
    public function isEphemeral() : bool
51
    {
52
        return false;
53
    }
54
55
    public static function generate($ephemeral = false) : EncryptionKeyInterface
56
    {
57
        $object = new static;
58
        $object->hashId = \bin2hex(\random_bytes(32));
59
        $object->key = Utils::generateKeyPair();
60
        $object->signingKey = Utils::generateSigningKeypair();
61
62
        return $object;
63
    }
64
}
65