@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | namespace chillerlan\Traits\Crypto; |
| 14 | 14 | |
| 15 | 15 | |
| 16 | -class Box extends CryptoBox{ |
|
| 16 | +class Box extends CryptoBox { |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param string $message |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | sodium_memzero($keypair); |
| 35 | 35 | sodium_memzero($message); |
| 36 | 36 | |
| 37 | - if($nonce_bin !== null){ |
|
| 37 | + if ($nonce_bin !== null) { |
|
| 38 | 38 | sodium_memzero($nonce_bin); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | sodium_memzero($box_bin); |
| 60 | 60 | sodium_memzero($nonce_bin); |
| 61 | 61 | |
| 62 | - if($this->message === false){ |
|
| 62 | + if ($this->message === false) { |
|
| 63 | 63 | throw new CryptoException('invalid box'); // @codeCoverageIgnore |
| 64 | 64 | } |
| 65 | 65 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\Traits\Crypto; |
| 14 | 14 | |
| 15 | -class SecretBox extends CryptoBox{ |
|
| 15 | +class SecretBox extends CryptoBox { |
|
| 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 | throw new CryptoException('invalid box'); // @codeCoverageIgnore |
| 53 | 53 | } |
| 54 | 54 | |
@@ -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 @@ |
||
| 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 |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @throws \chillerlan\Traits\Crypto\CryptoException |
| 55 | 55 | */ |
| 56 | - public function __construct(array $properties = null){ |
|
| 56 | + public function __construct(array $properties = null) { |
|
| 57 | 57 | |
| 58 | - if(!extension_loaded('sodium') || !function_exists('sodium_memzero')){ |
|
| 58 | + if (!extension_loaded('sodium') || !function_exists('sodium_memzero')) { |
|
| 59 | 59 | throw new CryptoException('sodium extension (PHP 7.2+) required!'); // @codeCoverageIgnore |
| 60 | 60 | } |
| 61 | 61 | |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | * @throws \chillerlan\Traits\Crypto\CryptoException |
| 71 | 71 | */ |
| 72 | - protected function checkKeypair(int $secretLength = null, int $PublicLength = null){ |
|
| 72 | + protected function checkKeypair(int $secretLength = null, int $PublicLength = null) { |
|
| 73 | 73 | |
| 74 | - if($secretLength !== null){ |
|
| 75 | - if(!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength){ |
|
| 74 | + if ($secretLength !== null) { |
|
| 75 | + if (!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength) { |
|
| 76 | 76 | throw new CryptoException('invalid secret key'); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($PublicLength !== null){ |
|
| 81 | - if(!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength){ |
|
| 80 | + if ($PublicLength !== null) { |
|
| 81 | + if (!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength) { |
|
| 82 | 82 | throw new CryptoException('invalid public key'); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | protected function checkMessage(string $message):string { |
| 95 | 95 | $message = trim($message); |
| 96 | 96 | |
| 97 | - if(empty($message)){ |
|
| 97 | + if (empty($message)) { |
|
| 98 | 98 | throw new CryptoException('invalid message'); |
| 99 | 99 | } |
| 100 | 100 | |