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