@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Traits\Crypto; |
14 | 14 | |
15 | -class SignKeypair extends CryptoKeypair{ |
|
15 | +class SignKeypair extends CryptoKeypair { |
|
16 | 16 | |
17 | 17 | /** @inheritdoc */ |
18 | 18 | public function create(string &$seed_bin = null):CryptoKeyInterface{ |
19 | 19 | |
20 | - if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES){ |
|
20 | + if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES) { |
|
21 | 21 | throw new CryptoException('invalid seed length'); |
22 | 22 | } |
23 | 23 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | sodium_memzero($keypair); |
33 | 33 | |
34 | - if($seed_bin !== null){ |
|
34 | + if ($seed_bin !== null) { |
|
35 | 35 | sodium_memzero($seed_bin); |
36 | 36 | } |
37 | 37 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Traits\Crypto; |
14 | 14 | |
15 | -class SealedBox extends CryptoBox{ |
|
15 | +class SealedBox extends CryptoBox { |
|
16 | 16 | |
17 | 17 | /** @inheritdoc */ |
18 | 18 | public function create(string &$message):CryptoBoxInterface{ |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | sodium_memzero($keypair); |
36 | 36 | sodium_memzero($box_bin); |
37 | 37 | |
38 | - if($this->message === false){ |
|
38 | + if ($this->message === false) { |
|
39 | 39 | throw new CryptoException('invalid box'); // @codeCoverageIgnore |
40 | 40 | } |
41 | 41 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Traits\Crypto; |
14 | 14 | |
15 | -trait CryptoTrait{ |
|
15 | +trait CryptoTrait { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @var \chillerlan\Traits\Crypto\CryptoKeyInterface |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return $this |
27 | 27 | */ |
28 | - protected function setBoxKeypair(string $secret_hex = null, string $public_hex = null){ |
|
28 | + protected function setBoxKeypair(string $secret_hex = null, string $public_hex = null) { |
|
29 | 29 | return $this->setCryptoKeyInterface(BoxKeypair::class, $secret_hex, $public_hex); |
30 | 30 | } |
31 | 31 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return $this |
37 | 37 | */ |
38 | - protected function setSignKeypair(string $secret_hex = null, string $public_hex = null){ |
|
38 | + protected function setSignKeypair(string $secret_hex = null, string $public_hex = null) { |
|
39 | 39 | return $this->setCryptoKeyInterface(SignKeypair::class, $secret_hex, $public_hex); |
40 | 40 | } |
41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return $this |
46 | 46 | */ |
47 | - protected function setKeypair(CryptoKeyInterface $keypair){ |
|
47 | + protected function setKeypair(CryptoKeyInterface $keypair) { |
|
48 | 48 | unset($this->cryptoKeyInterface); |
49 | 49 | |
50 | 50 | $this->cryptoKeyInterface = $keypair; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return $this |
61 | 61 | */ |
62 | - private function setCryptoKeyInterface(string $type_fqcn, string &$secret_hex = null, string &$public_hex = null){ |
|
62 | + private function setCryptoKeyInterface(string $type_fqcn, string &$secret_hex = null, string &$public_hex = null) { |
|
63 | 63 | unset($this->cryptoKeyInterface); |
64 | 64 | |
65 | 65 | $this->cryptoKeyInterface = new $type_fqcn([ |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | 'public' => !empty($public_hex) ? sodium_hex2bin($public_hex) : null, |
68 | 68 | ]); |
69 | 69 | |
70 | - if($secret_hex !== null){ |
|
70 | + if ($secret_hex !== null) { |
|
71 | 71 | sodium_memzero($secret_hex); |
72 | 72 | } |
73 | 73 | |
74 | - if($public_hex !== null){ |
|
74 | + if ($public_hex !== null) { |
|
75 | 75 | sodium_memzero($public_hex); |
76 | 76 | } |
77 | 77 |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Traits\Crypto; |
14 | 14 | |
15 | -class BoxKeypair extends CryptoKeypair{ |
|
15 | +class BoxKeypair extends CryptoKeypair { |
|
16 | 16 | |
17 | 17 | /** @inheritdoc */ |
18 | 18 | public function create(string &$seed_bin = null):CryptoKeyInterface{ |
19 | 19 | |
20 | - if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES){ |
|
20 | + if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES) { |
|
21 | 21 | throw new CryptoException('invalid seed length'); |
22 | 22 | } |
23 | 23 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | sodium_memzero($keypair); |
33 | 33 | |
34 | - if($seed_bin !== null){ |
|
34 | + if ($seed_bin !== null) { |
|
35 | 35 | sodium_memzero($seed_bin); |
36 | 36 | } |
37 | 37 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function createFromSecret(string &$secret_bin):CryptoKeyInterface{ |
48 | 48 | |
49 | - if(strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES){ |
|
49 | + if (strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES) { |
|
50 | 50 | throw new CryptoException('invalid secret key length'); |
51 | 51 | } |
52 | 52 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Traits\Crypto; |
14 | 14 | |
15 | -class SignedMessage extends CryptoBox{ |
|
15 | +class SignedMessage extends CryptoBox { |
|
16 | 16 | |
17 | 17 | /** @inheritdoc */ |
18 | 18 | public function create(string &$message):CryptoBoxInterface{ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | sodium_memzero($box_bin); |
35 | 35 | |
36 | - if($this->message === false){ |
|
36 | + if ($this->message === false) { |
|
37 | 37 | throw new CryptoException('invalid box'); // @codeCoverageIgnore |
38 | 38 | } |
39 | 39 |