@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @link https://paragonie.com/book/pecl-libsodium/read/00-intro.md |
17 | 17 | * @link https://paragonie.com/book/pecl-libsodium/read/01-quick-start.md |
18 | 18 | */ |
19 | -abstract class CryptoKeypairAbstract implements CryptoKeypairInterface{ |
|
19 | +abstract class CryptoKeypairAbstract implements CryptoKeypairInterface { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var string |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string|null $secret_bin |
40 | 40 | * @param string|null $public_bin |
41 | 41 | */ |
42 | - public function __construct(string $secret_bin = null, string $public_bin = null){ |
|
42 | + public function __construct(string $secret_bin = null, string $public_bin = null) { |
|
43 | 43 | $this->secret = $secret_bin; |
44 | 44 | $this->public = $public_bin; |
45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return mixed|null |
51 | 51 | */ |
52 | - public function __get(string $property){ |
|
52 | + public function __get(string $property) { |
|
53 | 53 | return property_exists($this, $property) ? $this->{$property} : null; |
54 | 54 | } |
55 | 55 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @property string $nonce |
19 | 19 | * @property string $message |
20 | 20 | */ |
21 | -interface CryptoBoxInterface{ |
|
21 | +interface CryptoBoxInterface { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param string $message |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Cryptobox; |
14 | 14 | |
15 | -class SealedBox extends CryptoBoxAbstract{ |
|
15 | +class SealedBox extends CryptoBoxAbstract { |
|
16 | 16 | |
17 | 17 | /** @inheritdoc */ |
18 | 18 | public function create(string $message):CryptoBoxInterface{ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | sodium_memzero($keypair); |
40 | 40 | sodium_memzero($box_bin); |
41 | 41 | |
42 | - if($this->message !== false){ |
|
42 | + if ($this->message !== false) { |
|
43 | 43 | return $this; |
44 | 44 | } |
45 | 45 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Cryptobox; |
14 | 14 | |
15 | -class Box extends CryptoBoxAbstract{ |
|
15 | +class Box extends CryptoBoxAbstract { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @param string $message |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | sodium_memzero($keypair); |
32 | 32 | sodium_memzero($message); |
33 | 33 | |
34 | - if($nonce_bin !== null){ |
|
34 | + if ($nonce_bin !== null) { |
|
35 | 35 | sodium_memzero($nonce_bin); |
36 | 36 | } |
37 | 37 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | sodium_memzero($box_bin); |
56 | 56 | sodium_memzero($nonce_bin); |
57 | 57 | |
58 | - if($this->message !== false){ |
|
58 | + if ($this->message !== false) { |
|
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Cryptobox; |
14 | 14 | |
15 | -class SecretBox extends CryptoBoxAbstract{ |
|
15 | +class SecretBox extends CryptoBoxAbstract { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @param string $message |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | sodium_memzero($message); |
31 | 31 | |
32 | - if($nonce_bin !== null){ |
|
32 | + if ($nonce_bin !== null) { |
|
33 | 33 | sodium_memzero($nonce_bin); |
34 | 34 | } |
35 | 35 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $this->message = sodium_crypto_secretbox_open($box_bin, $nonce_bin, $this->keypair->secret); |
50 | 50 | |
51 | - if($this->message !== false){ |
|
51 | + if ($this->message !== false) { |
|
52 | 52 | return $this; |
53 | 53 | } |
54 | 54 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @link https://paragonie.com/book/pecl-libsodium/read/00-intro.md |
17 | 17 | * @link https://paragonie.com/book/pecl-libsodium/read/01-quick-start.md |
18 | 18 | */ |
19 | -abstract class CryptoBoxAbstract implements CryptoBoxInterface{ |
|
19 | +abstract class CryptoBoxAbstract implements CryptoBoxInterface { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var \chillerlan\Cryptobox\CryptoKeypairInterface |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param \chillerlan\Cryptobox\CryptoKeypairInterface|null $keypair |
45 | 45 | */ |
46 | - public function __construct(CryptoKeypairInterface $keypair = null){ |
|
46 | + public function __construct(CryptoKeypairInterface $keypair = null) { |
|
47 | 47 | $this->keypair = $keypair; |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return mixed|null |
54 | 54 | */ |
55 | - public function __get(string $property){ |
|
55 | + public function __get(string $property) { |
|
56 | 56 | return property_exists($this, $property) ? $this->{$property} : null; |
57 | 57 | } |
58 | 58 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function checkKeypair(int $secretLength = null, int $PublicLength = null):void{ |
67 | 67 | |
68 | - if($secretLength !== null){ |
|
69 | - if(!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength){ |
|
68 | + if ($secretLength !== null) { |
|
69 | + if (!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength) { |
|
70 | 70 | throw new CryptoException('invalid secret key'); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if($PublicLength !== null){ |
|
75 | - if(!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength){ |
|
74 | + if ($PublicLength !== null) { |
|
75 | + if (!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength) { |
|
76 | 76 | throw new CryptoException('invalid public key'); |
77 | 77 | } |
78 | 78 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected function checkMessage(string $message):string{ |
89 | 89 | $message = trim($message); |
90 | 90 | |
91 | - if(empty($message)){ |
|
91 | + if (empty($message)) { |
|
92 | 92 | throw new CryptoException('invalid message'); |
93 | 93 | } |
94 | 94 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Cryptobox; |
14 | 14 | |
15 | -class SignKeypair extends CryptoKeypairAbstract{ |
|
15 | +class SignKeypair extends CryptoKeypairAbstract { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @inheritdoc |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function create(string $seed_bin = null):CryptoKeypairInterface{ |
23 | 23 | |
24 | - if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES){ |
|
24 | + if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES) { |
|
25 | 25 | throw new CryptoException('invalid seed length'); |
26 | 26 | } |
27 | 27 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | sodium_memzero($keypair); |
37 | 37 | |
38 | - if($seed_bin !== null){ |
|
38 | + if ($seed_bin !== null) { |
|
39 | 39 | sodium_memzero($seed_bin); |
40 | 40 | } |
41 | 41 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @property string $secret |
18 | 18 | * @property string $public |
19 | 19 | */ |
20 | -interface CryptoKeypairInterface{ |
|
20 | +interface CryptoKeypairInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @param string|null $seed_bin |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Cryptobox; |
14 | 14 | |
15 | -class BoxKeypair extends CryptoKeypairAbstract{ |
|
15 | +class BoxKeypair extends CryptoKeypairAbstract { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @inheritdoc |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function create(string $seed_bin = null):CryptoKeypairInterface{ |
23 | 23 | |
24 | - if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES){ |
|
24 | + if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES) { |
|
25 | 25 | throw new CryptoException('invalid seed length'); |
26 | 26 | } |
27 | 27 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $this->secret = sodium_crypto_box_secretkey($this->keypair); |
33 | 33 | $this->public = sodium_crypto_box_publickey($this->keypair); |
34 | 34 | |
35 | - if($seed_bin !== null){ |
|
35 | + if ($seed_bin !== null) { |
|
36 | 36 | sodium_memzero($seed_bin); |
37 | 37 | } |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function createFromSecret(string $secret_bin):CryptoKeypairInterface{ |
49 | 49 | |
50 | - if(strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES){ |
|
50 | + if (strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES) { |
|
51 | 51 | throw new CryptoException('invalid secret key length'); |
52 | 52 | } |
53 | 53 |