Passed
Push — master ( 3c151b...b5e885 )
by Charles
03:04
created

EncryptionKey::getSignPublicKey()   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 getSignPublicKey() : string
36
    {
37
        return $this->signingKey->getPublicKey();
38
    }
39
40
    public function getSignSecretKey() : string
41
    {
42
        return $this->signingKey->getSecretKey();
43
    }
44
45
    public function getSignKeyPair() : Keypair
46
    {
47
        return $this->signingKey;
48
    }
49
50
    public function isEphemeral() : bool
51
    {
52
        return false;
53
    }
54
55
    public function getPublicKeyExpiration() : int
56
    {
57
        return \time();
58
    }
59
60
    public static function generate($ephemeral = false) : EncryptionKeyInterface
61
    {
62
        $object = new static;
63
        $object->hashId = \bin2hex(\random_bytes(32));
64
        $object->key = Utils::generateKeyPair();
65
        $object->signingKey = Utils::generateSigningKeypair();
66
67
        return $object;
68
    }
69
}
70