GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1f9c3d...35fc1b )
by sebastian
03:29
created
src/jwe/impl/JWE.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 
17 17
 use jwa\cryptographic_algorithms\ContentEncryptionAlgorithms_Registry;
18 18
 use jwa\cryptographic_algorithms\EncryptionAlgorithm;
19
-use jwa\cryptographic_algorithms\exceptions\InvalidAuthenticationTagException;
20 19
 use jwa\cryptographic_algorithms\exceptions\InvalidKeyTypeAlgorithmException;
21 20
 use jwa\cryptographic_algorithms\key_management\modes\DirectEncryption;
22 21
 use jwa\cryptographic_algorithms\key_management\modes\DirectKeyAgreement;
Please login to merge, or discard this patch.
Braces   +60 added lines, -39 removed lines patch added patch discarded remove patch
@@ -98,8 +98,9 @@  discard block
 block discarded – undo
98 98
     protected function __construct(IJWEJOSEHeader $header, IJWSPayloadSpec $payload = null)
99 99
     {
100 100
         $this->header = $header;
101
-        if(!is_null($payload))
102
-            $this->setPayload($payload);
101
+        if(!is_null($payload)) {
102
+                    $this->setPayload($payload);
103
+        }
103 104
     }
104 105
 
105 106
     /**
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
             $this->decrypt();
156 157
         }
157 158
 
158
-        if (is_null($this->payload))
159
-            $this->payload = JWSPayloadFactory::build('');
159
+        if (is_null($this->payload)) {
160
+                    $this->payload = JWSPayloadFactory::build('');
161
+        }
160 162
 
161 163
         return $this->payload->getRaw();
162 164
     }
@@ -212,16 +214,21 @@  discard block
 block discarded – undo
212 214
      */
213 215
     private function getKeyManagementMode(EncryptionAlgorithm $alg)
214 216
     {
215
-        if($alg instanceof KeyEncryption)
216
-            return KeyManagementModeValues::KeyEncryption;
217
-        if($alg instanceof KeyWrapping)
218
-            return KeyManagementModeValues::KeyWrapping;
219
-        if($alg instanceof DirectKeyAgreement)
220
-            return KeyManagementModeValues::DirectKeyAgreement;
221
-        if($alg instanceof KeyAgreementWithKeyWrapping)
222
-            return KeyManagementModeValues::KeyAgreementWithKeyWrapping;
223
-        if($alg instanceof DirectEncryption)
224
-            return KeyManagementModeValues::DirectEncryption;
217
+        if($alg instanceof KeyEncryption) {
218
+                    return KeyManagementModeValues::KeyEncryption;
219
+        }
220
+        if($alg instanceof KeyWrapping) {
221
+                    return KeyManagementModeValues::KeyWrapping;
222
+        }
223
+        if($alg instanceof DirectKeyAgreement) {
224
+                    return KeyManagementModeValues::DirectKeyAgreement;
225
+        }
226
+        if($alg instanceof KeyAgreementWithKeyWrapping) {
227
+                    return KeyManagementModeValues::KeyAgreementWithKeyWrapping;
228
+        }
229
+        if($alg instanceof DirectEncryption) {
230
+                    return KeyManagementModeValues::DirectEncryption;
231
+        }
225 232
     }
226 233
 
227 234
     /**
@@ -236,11 +243,12 @@  discard block
 block discarded – undo
236 243
     private function encrypt()
237 244
     {
238 245
 
239
-        if (is_null($this->jwk))
240
-            throw new JWEInvalidRecipientKeyException;
246
+        if (is_null($this->jwk)) {
247
+                    throw new JWEInvalidRecipientKeyException;
248
+        }
241 249
 
242
-        if($this->jwk->getAlgorithm()->getValue()!== $this->header->getAlgorithm()->getString())
243
-            throw new InvalidJWKAlgorithm
250
+        if($this->jwk->getAlgorithm()->getValue()!== $this->header->getAlgorithm()->getString()) {
251
+                    throw new InvalidJWKAlgorithm
244 252
             (
245 253
                 sprintf
246 254
                 (
@@ -249,16 +257,18 @@  discard block
 block discarded – undo
249 257
                     $this->header->getAlgorithm()->getString()
250 258
                 )
251 259
             );
260
+        }
252 261
 
253 262
         $recipient_public_key     = $this->jwk->getKey(JSONWebKeyKeyOperationsValues::EncryptContent);
254 263
 
255 264
         $key_management_algorithm = KeyManagementAlgorithms_Registry::getInstance()->get($this->header->getAlgorithm()->getString());
256 265
 
257
-        if (is_null($key_management_algorithm))
258
-            throw new JWEUnsupportedKeyManagementAlgorithmException(sprintf('alg %s', $this->header->getAlgorithm()->getString()));
266
+        if (is_null($key_management_algorithm)) {
267
+                    throw new JWEUnsupportedKeyManagementAlgorithmException(sprintf('alg %s', $this->header->getAlgorithm()->getString()));
268
+        }
259 269
 
260
-        if($key_management_algorithm->getKeyType() !== $recipient_public_key->getAlgorithm())
261
-            throw new InvalidKeyTypeAlgorithmException
270
+        if($key_management_algorithm->getKeyType() !== $recipient_public_key->getAlgorithm()) {
271
+                    throw new InvalidKeyTypeAlgorithmException
262 272
             (
263 273
                 sprintf
264 274
                 (
@@ -267,14 +277,15 @@  discard block
 block discarded – undo
267 277
                     $recipient_public_key->getAlgorithm()
268 278
                 )
269 279
             );
280
+        }
270 281
 
271 282
         $content_encryption_algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get
272 283
         (
273 284
             $this->header->getEncryptionAlgorithm()->getString()
274 285
         );
275 286
 
276
-        if (is_null($content_encryption_algorithm))
277
-            throw new JWEUnsupportedContentEncryptionAlgorithmException
287
+        if (is_null($content_encryption_algorithm)) {
288
+                    throw new JWEUnsupportedContentEncryptionAlgorithmException
278 289
             (
279 290
                 sprintf
280 291
                 (
@@ -282,6 +293,7 @@  discard block
 block discarded – undo
282 293
                     $this->header->getEncryptionAlgorithm()->getString()
283 294
                 )
284 295
             );
296
+        }
285 297
 
286 298
         $key_management_mode = $this->getKeyManagementMode($key_management_algorithm);
287 299
 
@@ -354,8 +366,8 @@  discard block
 block discarded – undo
354 366
         $key_management_mode   = $this->getKeyManagementMode($alg);
355 367
         $recipient_private_key = $this->jwk->getKey(JSONWebKeyKeyOperationsValues::DecryptContentAndValidateDecryption);
356 368
 
357
-        if($alg->getKeyType() !== $recipient_private_key->getAlgorithm())
358
-            throw new InvalidKeyTypeAlgorithmException
369
+        if($alg->getKeyType() !== $recipient_private_key->getAlgorithm()) {
370
+                    throw new InvalidKeyTypeAlgorithmException
359 371
             (
360 372
                 sprintf
361 373
                 (
@@ -364,6 +376,7 @@  discard block
 block discarded – undo
364 376
                     $recipient_private_key->getAlgorithm()
365 377
                 )
366 378
             );
379
+        }
367 380
 
368 381
         switch($key_management_mode){
369 382
             /**
@@ -387,13 +400,15 @@  discard block
 block discarded – undo
387 400
              * symmetric key.
388 401
              */
389 402
             case KeyManagementModeValues::DirectEncryption:
390
-                if(!empty($this->enc_cek))
391
-                    throw new JWEInvalidCompactFormatException('JWE Encrypted Key value is not an empty octetsequence.');
403
+                if(!empty($this->enc_cek)) {
404
+                                    throw new JWEInvalidCompactFormatException('JWE Encrypted Key value is not an empty octetsequence.');
405
+                }
392 406
                 return $recipient_private_key;
393 407
             break;
394 408
             case KeyManagementModeValues::DirectKeyAgreement:
395
-                if(!empty($this->enc_cek))
396
-                    throw new JWEInvalidCompactFormatException('JWE Encrypted Key value is not an empty octetsequence.');
409
+                if(!empty($this->enc_cek)) {
410
+                                    throw new JWEInvalidCompactFormatException('JWE Encrypted Key value is not an empty octetsequence.');
411
+                }
397 412
                 throw new \Exception('unsupported Key Management Mode!');
398 413
             break;
399 414
         }
@@ -412,13 +427,16 @@  discard block
 block discarded – undo
412 427
      */
413 428
     private function decrypt()
414 429
     {
415
-        if (is_null($this->jwk))
416
-            throw new JWEInvalidRecipientKeyException();
430
+        if (is_null($this->jwk)) {
431
+                    throw new JWEInvalidRecipientKeyException();
432
+        }
417 433
 
418
-        if (!$this->should_decrypt) return $this;
434
+        if (!$this->should_decrypt) {
435
+         return $this;
436
+        }
419 437
 
420
-        if($this->jwk->getAlgorithm()->getValue()!== $this->header->getAlgorithm()->getString())
421
-            throw new InvalidJWKAlgorithm
438
+        if($this->jwk->getAlgorithm()->getValue()!== $this->header->getAlgorithm()->getString()) {
439
+                    throw new InvalidJWKAlgorithm
422 440
             (
423 441
                 sprintf
424 442
                 (
@@ -427,14 +445,15 @@  discard block
 block discarded – undo
427 445
                     $this->header->getAlgorithm()->getString()
428 446
                 )
429 447
             );
448
+        }
430 449
 
431 450
         $key_management_algorithm = KeyManagementAlgorithms_Registry::getInstance()->get
432 451
         (
433 452
             $this->header->getAlgorithm()->getString()
434 453
         );
435 454
 
436
-        if (is_null($key_management_algorithm))
437
-            throw new JWEUnsupportedKeyManagementAlgorithmException
455
+        if (is_null($key_management_algorithm)) {
456
+                    throw new JWEUnsupportedKeyManagementAlgorithmException
438 457
             (
439 458
                 sprintf
440 459
                 (
@@ -442,14 +461,15 @@  discard block
 block discarded – undo
442 461
                     $this->header->getAlgorithm()->getString()
443 462
                 )
444 463
             );
464
+        }
445 465
 
446 466
         $content_encryption_algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get
447 467
         (
448 468
             $this->header->getEncryptionAlgorithm()->getString()
449 469
         );
450 470
 
451
-        if (is_null($content_encryption_algorithm))
452
-            throw new JWEUnsupportedContentEncryptionAlgorithmException
471
+        if (is_null($content_encryption_algorithm)) {
472
+                    throw new JWEUnsupportedContentEncryptionAlgorithmException
453 473
             (
454 474
                 sprintf
455 475
                 (
@@ -457,6 +477,7 @@  discard block
 block discarded – undo
457 477
                     $this->header->getEncryptionAlgorithm()->getString()
458 478
                 )
459 479
             );
480
+        }
460 481
 
461 482
         $this->cek = $this->decryptJWEEncryptedKey($key_management_algorithm);
462 483
 
Please login to merge, or discard this patch.
src/jws/impl/JWS.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,6 @@
 block discarded – undo
39 39
 use jwt\utils\JOSEHeaderSerializer;
40 40
 use jwt\utils\JWTClaimSetSerializer;
41 41
 use jwt\utils\JWTRawSerializer;
42
-use utils\json_types\JsonArray;
43 42
 use utils\json_types\JsonValue;
44 43
 use utils\json_types\StringOrURI;
45 44
 
Please login to merge, or discard this patch.
Braces   +42 added lines, -32 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@  discard block
 block discarded – undo
79 79
 
80 80
         parent::__construct($header, $claim_set);
81 81
 
82
-        if(!is_null($payload))
83
-            $this->setPayload($payload);
82
+        if(!is_null($payload)) {
83
+                    $this->setPayload($payload);
84
+        }
84 85
 
85 86
         $this->signature = $signature;
86 87
     }
@@ -100,8 +101,9 @@  discard block
 block discarded – undo
100 101
      */
101 102
     public function toCompactSerialization()
102 103
     {
103
-        if(!is_null($this->jwk->getId()))
104
-            $this->header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::KeyID, $this->jwk->getId()));
104
+        if(!is_null($this->jwk->getId())) {
105
+                    $this->header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::KeyID, $this->jwk->getId()));
106
+        }
105 107
 
106 108
         if($this->jwk instanceof IAsymmetricJWK)
107 109
         {
@@ -134,16 +136,19 @@  discard block
 block discarded – undo
134 136
     public function sign()
135 137
     {
136 138
 
137
-        if(is_null($this->jwk))
138
-            throw new JWSInvalidJWKException;
139
+        if(is_null($this->jwk)) {
140
+                    throw new JWSInvalidJWKException;
141
+        }
139 142
 
140
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
141
-            throw new JWSInvalidJWKException(sprintf('use %s not supported.', $this->jwk->getKeyUse()->getString()));
143
+        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) {
144
+                    throw new JWSInvalidJWKException(sprintf('use %s not supported.', $this->jwk->getKeyUse()->getString()));
145
+        }
142 146
 
143 147
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($this->header->getAlgorithm()->getString());
144 148
 
145
-        if(is_null($alg))
146
-            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
149
+        if(is_null($alg)) {
150
+                    throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
151
+        }
147 152
 
148 153
         $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
149 154
 
@@ -152,12 +157,10 @@  discard block
 block discarded – undo
152 157
         if($alg instanceof DigitalSignatureAlgorithm)
153 158
         {
154 159
             $this->signature = $alg->sign($key, $secured_input_bytes);
155
-        }
156
-        else if($alg instanceof MAC_Algorithm )
160
+        } else if($alg instanceof MAC_Algorithm )
157 161
         {
158 162
             $this->signature = $alg->digest($key, $secured_input_bytes);
159
-        }
160
-        else
163
+        } else
161 164
         {
162 165
             throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
163 166
         }
@@ -171,15 +174,15 @@  discard block
 block discarded – undo
171 174
      */
172 175
     public function getEncodedPayload()
173 176
     {
174
-        if(is_null($this->payload))
175
-            throw new JWSInvalidPayloadException('payload is not set!');
177
+        if(is_null($this->payload)) {
178
+                    throw new JWSInvalidPayloadException('payload is not set!');
179
+        }
176 180
 
177 181
         $enc_payload = '';
178 182
         if($this->payload->isClaimSet() && $this->payload instanceof IJWSPayloadClaimSetSpec)
179 183
         {
180 184
             $enc_payload = JWTClaimSetSerializer::serialize($this->payload->getClaimSet());
181
-        }
182
-        else
185
+        } else
183 186
         {
184 187
             $enc_payload = JWTRawSerializer::serialize($this->payload->getRaw());
185 188
         }
@@ -233,11 +236,12 @@  discard block
 block discarded – undo
233 236
      */
234 237
     public function verify($original_alg)
235 238
     {
236
-        if(is_null($this->jwk))
237
-            throw new JWSInvalidJWKException;
239
+        if(is_null($this->jwk)) {
240
+                    throw new JWSInvalidJWKException;
241
+        }
238 242
 
239
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
240
-            throw new JWSInvalidJWKException
243
+        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) {
244
+                    throw new JWSInvalidJWKException
241 245
             (
242 246
                 sprintf
243 247
                 (
@@ -245,12 +249,14 @@  discard block
 block discarded – undo
245 249
                     $this->jwk->getKeyUse()->getString()
246 250
                 )
247 251
             );
252
+        }
248 253
 
249
-        if(is_null($this->jwk->getAlgorithm()))
250
-            throw new InvalidJWKAlgorithm('algorithm intended for use with the key is not set! ');
254
+        if(is_null($this->jwk->getAlgorithm())) {
255
+                    throw new InvalidJWKAlgorithm('algorithm intended for use with the key is not set! ');
256
+        }
251 257
 
252
-        if(!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue())
253
-            throw new JWSInvalidJWKException
258
+        if(!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue()) {
259
+                    throw new JWSInvalidJWKException
254 260
             (
255 261
                 sprintf
256 262
                 (
@@ -259,16 +265,18 @@  discard block
 block discarded – undo
259 265
                     $this->jwk->getId()->getValue()
260 266
                 )
261 267
             );
268
+        }
262 269
 
263 270
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($original_alg);
264 271
 
265
-        if(is_null($alg))
266
-            throw new JWSNotSupportedAlgorithm(sprintf('algo %s', $original_alg));
272
+        if(is_null($alg)) {
273
+                    throw new JWSNotSupportedAlgorithm(sprintf('algo %s', $original_alg));
274
+        }
267 275
 
268 276
         $former_alg = $this->header->getAlgorithm()->getString();
269 277
 
270
-        if($former_alg != $original_alg)
271
-            throw new JWSNotSupportedAlgorithm
278
+        if($former_alg != $original_alg) {
279
+                    throw new JWSNotSupportedAlgorithm
272 280
             (
273 281
                 sprintf
274 282
                 (
@@ -277,9 +285,10 @@  discard block
 block discarded – undo
277 285
                     $original_alg
278 286
                 )
279 287
             );
288
+        }
280 289
 
281
-        if($this->jwk->getAlgorithm()->getValue() !==  $original_alg)
282
-            throw new InvalidJWKAlgorithm
290
+        if($this->jwk->getAlgorithm()->getValue() !==  $original_alg) {
291
+                    throw new InvalidJWKAlgorithm
283 292
             (
284 293
                 sprintf
285 294
                 (
@@ -288,6 +297,7 @@  discard block
 block discarded – undo
288 297
                     $original_alg
289 298
                 )
290 299
             );
300
+        }
291 301
 
292 302
         $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
293 303
 
Please login to merge, or discard this patch.
src/jwa/cryptographic_algorithms/KeyManagementAlgorithms_Registry.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@
 block discarded – undo
72 72
      */
73 73
     public function get($alg)
74 74
     {
75
-        if(!$this->isSupported($alg)) return null;
75
+        if(!$this->isSupported($alg)) {
76
+         return null;
77
+        }
76 78
         return $this->algorithms[$alg];
77 79
     }
78 80
 }
79 81
\ No newline at end of file
Please login to merge, or discard this patch.
src/jwa/cryptographic_algorithms/DigitalSignatures_MACs_Registry.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@
 block discarded – undo
81 81
      * @return null|DigitalSignatureAlgorithm|MAC_Algorithm
82 82
      */
83 83
     public function get($alg){
84
-        if(!$this->isSupported($alg)) return null;
84
+        if(!$this->isSupported($alg)) {
85
+         return null;
86
+        }
85 87
         return $this->algorithms[$alg];
86 88
     }
87 89
 }
88 90
\ No newline at end of file
Please login to merge, or discard this patch.
src/jwa/cryptographic_algorithms/macs/HSMAC_Algorithm.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function digest(SharedKey $key, $message){
39 39
 
40
-        if($this->getMinKeyLen() > $key->getBitLength())
41
-            throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength()));
40
+        if($this->getMinKeyLen() > $key->getBitLength()) {
41
+                    throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength()));
42
+        }
42 43
 
43 44
         return hash_hmac($this->getHashingAlgorithm(), $message, $key->getSecret(), true);
44 45
     }
@@ -52,7 +53,9 @@  discard block
 block discarded – undo
52 53
      * @throws InvalidKeyTypeAlgorithmException
53 54
      */
54 55
     public function verify(Key $key, $message, $digest){
55
-        if(!($key instanceof SharedKey)) throw new InvalidKeyTypeAlgorithmException;
56
+        if(!($key instanceof SharedKey)) {
57
+         throw new InvalidKeyTypeAlgorithmException;
58
+        }
56 59
 
57 60
         return $digest === $this->digest($key, $message);
58 61
     }
Please login to merge, or discard this patch.
src/jwa/cryptographic_algorithms/ContentEncryptionAlgorithms_Registry.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@
 block discarded – undo
68 68
      * @return null|ContentEncryptionAlgorithm
69 69
      */
70 70
     public function get($alg) {
71
-        if (!$this->isSupported($alg)) return null;
71
+        if (!$this->isSupported($alg)) {
72
+         return null;
73
+        }
72 74
         return $this->algorithms[$alg];
73 75
     }
74 76
 }
75 77
\ No newline at end of file
Please login to merge, or discard this patch.
src/jwa/cryptographic_algorithms/digital_signatures/rsa/RSA_Algorithm.php 1 patch
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,14 +45,19 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function sign(PrivateKey $private_key, $message)
47 47
     {
48
-        if(!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException;
48
+        if(!($private_key instanceof RSAPrivateKey)) {
49
+         throw new InvalidKeyTypeAlgorithmException;
50
+        }
49 51
 
50
-        if($this->getMinKeyLen() > $private_key->getBitLength())
51
-            throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength()));
52
+        if($this->getMinKeyLen() > $private_key->getBitLength()) {
53
+                    throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength()));
54
+        }
52 55
 
53 56
         $res = $this->rsa_impl->loadKey($private_key->getEncoded());
54 57
 
55
-        if(!$res) throw new InvalidKeyTypeAlgorithmException;
58
+        if(!$res) {
59
+         throw new InvalidKeyTypeAlgorithmException;
60
+        }
56 61
 
57 62
         $this->rsa_impl->setHash($this->getHashingAlgorithm());
58 63
         $this->rsa_impl->setMGFHash($this->getHashingAlgorithm());
@@ -70,14 +75,19 @@  discard block
 block discarded – undo
70 75
      */
71 76
     public function verify(Key $key, $message, $signature)
72 77
     {
73
-        if(!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException;
78
+        if(!($key instanceof RSAPublicKey)) {
79
+         throw new InvalidKeyTypeAlgorithmException;
80
+        }
74 81
 
75
-        if($this->getMinKeyLen() > $key->getBitLength())
76
-            throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength()));
82
+        if($this->getMinKeyLen() > $key->getBitLength()) {
83
+                    throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength()));
84
+        }
77 85
 
78 86
         $res = $this->rsa_impl->loadKey($key->getEncoded());
79 87
 
80
-        if(!$res) throw new InvalidKeyTypeAlgorithmException;
88
+        if(!$res) {
89
+         throw new InvalidKeyTypeAlgorithmException;
90
+        }
81 91
 
82 92
         $this->rsa_impl->setHash($this->getHashingAlgorithm());
83 93
         $this->rsa_impl->setMGFHash($this->getHashingAlgorithm());
Please login to merge, or discard this patch.
cryptographic_algorithms/key_management/rsa/RSA_KeyManagementAlgorithm.php 1 patch
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,19 +47,23 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function encrypt(Key $key, $message)
49 49
     {
50
-        if(!($key instanceof RSAPublicKey))
51
-            throw new InvalidKeyTypeAlgorithmException('key is not public');
50
+        if(!($key instanceof RSAPublicKey)) {
51
+                    throw new InvalidKeyTypeAlgorithmException('key is not public');
52
+        }
52 53
 
53
-        if($key->getFormat() !== 'PKCS8')
54
-            throw new InvalidKeyTypeAlgorithmException('keys is not on PKCS1 format');
54
+        if($key->getFormat() !== 'PKCS8') {
55
+                    throw new InvalidKeyTypeAlgorithmException('keys is not on PKCS1 format');
56
+        }
55 57
 
56 58
         $res = $this->rsa_impl->loadKey($key->getEncoded());
57 59
 
58
-        if(!$res)
59
-            throw new InvalidKeyTypeAlgorithmException('could not parse the key');
60
+        if(!$res) {
61
+                    throw new InvalidKeyTypeAlgorithmException('could not parse the key');
62
+        }
60 63
 
61
-        if($this->rsa_impl->getSize() < $this->getMinKeyLen())
62
-            throw new InvalidKeyTypeAlgorithmException('len is invalid');
64
+        if($this->rsa_impl->getSize() < $this->getMinKeyLen()) {
65
+                    throw new InvalidKeyTypeAlgorithmException('len is invalid');
66
+        }
63 67
 
64 68
         return $this->rsa_impl->encrypt($message);
65 69
     }
@@ -72,20 +76,24 @@  discard block
 block discarded – undo
72 76
      */
73 77
     public function decrypt(Key $key, $enc_message){
74 78
 
75
-        if(!($key instanceof RSAPrivateKey))
76
-            throw new InvalidKeyTypeAlgorithmException('key is not private');
79
+        if(!($key instanceof RSAPrivateKey)) {
80
+                    throw new InvalidKeyTypeAlgorithmException('key is not private');
81
+        }
77 82
 
78 83
 
79
-        if($key->getFormat() !== 'PKCS1')
80
-            throw new InvalidKeyTypeAlgorithmException('keys is not on PKCS1 format');
84
+        if($key->getFormat() !== 'PKCS1') {
85
+                    throw new InvalidKeyTypeAlgorithmException('keys is not on PKCS1 format');
86
+        }
81 87
 
82 88
         $res = $this->rsa_impl->loadKey($key->getEncoded());
83 89
 
84
-        if(!$res)
85
-            throw new InvalidKeyTypeAlgorithmException('could not parse the key');
90
+        if(!$res) {
91
+                    throw new InvalidKeyTypeAlgorithmException('could not parse the key');
92
+        }
86 93
 
87
-        if($this->rsa_impl->getSize() < $this->getMinKeyLen())
88
-            throw new InvalidKeyTypeAlgorithmException('len is invalid');
94
+        if($this->rsa_impl->getSize() < $this->getMinKeyLen()) {
95
+                    throw new InvalidKeyTypeAlgorithmException('len is invalid');
96
+        }
89 97
 
90 98
         return $this->rsa_impl->decrypt($enc_message);
91 99
     }
Please login to merge, or discard this patch.
content_encryption/AES_CBC_HS/AES_CBC_HMAC_SHA2_Algorithm.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $key_len = strlen($key);
62 62
 
63
-        if($this->getMinKeyLen() > ByteUtil::bitLength($key_len))
64
-            throw new InvalidKeyLengthAlgorithmException;
63
+        if($this->getMinKeyLen() > ByteUtil::bitLength($key_len)) {
64
+                    throw new InvalidKeyLengthAlgorithmException;
65
+        }
65 66
 
66 67
         $enc_key_len = $key_len / 2;
67 68
         // ENC_KEY = final ENC_KEY_LEN octets of K
@@ -133,8 +134,9 @@  discard block
 block discarded – undo
133 134
      */
134 135
     public function decrypt($cypher_text, $key, $iv, $aad, $tag)
135 136
     {
136
-        if(!$this->checkAuthenticationTag($cypher_text, $key, $iv, $aad, $tag))
137
-            throw new InvalidAuthenticationTagException;
137
+        if(!$this->checkAuthenticationTag($cypher_text, $key, $iv, $aad, $tag)) {
138
+                    throw new InvalidAuthenticationTagException;
139
+        }
138 140
 
139 141
         $enc_key_len = strlen($key) / 2;
140 142
         // ENC_KEY = final ENC_KEY_LEN octets of K
Please login to merge, or discard this patch.