@@ -40,7 +40,9 @@ |
||
| 40 | 40 | $type = @RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
| 41 | 41 | if(!is_null($value)) |
| 42 | 42 | { |
| 43 | - if(is_null($type)) continue; |
|
| 43 | + if(is_null($type)) { |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 44 | 46 | $class = new \ReflectionClass($type); |
| 45 | 47 | $value = $class->newInstanceArgs(array($value)); |
| 46 | 48 | } |
@@ -50,8 +50,9 @@ |
||
| 50 | 50 | |
| 51 | 51 | $this->set[RegisteredJWEJOSEHeaderNames::EncryptionAlgorithm] = $enc; |
| 52 | 52 | |
| 53 | - if(!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) |
|
| 54 | - $this->set[RegisteredJWEJOSEHeaderNames::CompressionAlgorithm] = $zip; |
|
| 53 | + if(!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) { |
|
| 54 | + $this->set[RegisteredJWEJOSEHeaderNames::CompressionAlgorithm] = $zip; |
|
| 55 | + } |
|
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | /** |
@@ -47,7 +47,9 @@ |
||
| 47 | 47 | |
| 48 | 48 | static public function deserialize($input){ |
| 49 | 49 | $parts = explode(IBasicJWT::SegmentSeparator, $input); |
| 50 | - if (count($parts) !== 5) throw new JWEInvalidCompactFormatException; |
|
| 50 | + if (count($parts) !== 5) { |
|
| 51 | + throw new JWEInvalidCompactFormatException; |
|
| 52 | + } |
|
| 51 | 53 | |
| 52 | 54 | $header = JWEJOSEHeaderSerializer::deserialize($parts[0]); |
| 53 | 55 | $enc_cek = JWTRawSerializer::deserialize($parts[1]); |
@@ -66,11 +66,13 @@ |
||
| 66 | 66 | public function __construct(IJWK $key, StringOrURI $alg, StringOrURI $enc, $payload, JsonValue $zip = null) |
| 67 | 67 | { |
| 68 | 68 | |
| 69 | - if(is_null($key)) |
|
| 70 | - throw new JWEInvalidRecipientKeyException(); |
|
| 69 | + if(is_null($key)) { |
|
| 70 | + throw new JWEInvalidRecipientKeyException(); |
|
| 71 | + } |
|
| 71 | 72 | |
| 72 | - if(is_null($payload)) |
|
| 73 | - throw new JWEInvalidPayloadException('missing payload'); |
|
| 73 | + if(is_null($payload)) { |
|
| 74 | + throw new JWEInvalidPayloadException('missing payload'); |
|
| 75 | + } |
|
| 74 | 76 | |
| 75 | 77 | $this->key = $key; |
| 76 | 78 | $this->alg = $alg; |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | if($spec instanceof IJWE_ParamsSpecification) |
| 41 | 41 | { |
| 42 | 42 | |
| 43 | - if($spec->getRecipientKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Encryption) |
|
| 44 | - throw new InvalidJWKType |
|
| 43 | + if($spec->getRecipientKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Encryption) { |
|
| 44 | + throw new InvalidJWKType |
|
| 45 | 45 | ( |
| 46 | 46 | sprintf |
| 47 | 47 | ( |
@@ -49,9 +49,10 @@ discard block |
||
| 49 | 49 | $spec->getRecipientKey()->getKeyUse()->getString() |
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | + } |
|
| 52 | 53 | |
| 53 | - if($spec->getAlg()->getString() !== $spec->getRecipientKey()->getAlgorithm()->getString()) |
|
| 54 | - throw new InvalidJWKAlgorithm |
|
| 54 | + if($spec->getAlg()->getString() !== $spec->getRecipientKey()->getAlgorithm()->getString()) { |
|
| 55 | + throw new InvalidJWKAlgorithm |
|
| 55 | 56 | ( |
| 56 | 57 | sprintf |
| 57 | 58 | ( |
@@ -60,6 +61,7 @@ discard block |
||
| 60 | 61 | $spec->getRecipientKey()->getAlgorithm()->getString() |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | $header = new JWEJOSEHeader |
| 65 | 67 | ( |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | //set zip alg |
| 72 | 74 | $zip = $spec->getZip(); |
| 73 | 75 | |
| 74 | - if(!is_null($zip)) |
|
| 75 | - $header->setCompressionAlgorithm($zip); |
|
| 76 | + if(!is_null($zip)) { |
|
| 77 | + $header->setCompressionAlgorithm($zip); |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | $jwe = JWE::fromHeaderAndPayload($header, $spec->getPayload()); |
| 78 | 81 | |
@@ -64,7 +64,9 @@ |
||
| 64 | 64 | * @return null|CompressionAlgorithm |
| 65 | 65 | */ |
| 66 | 66 | public function get($alg){ |
| 67 | - if(!$this->isSupported($alg)) return null; |
|
| 67 | + if(!$this->isSupported($alg)) { |
|
| 68 | + return null; |
|
| 69 | + } |
|
| 68 | 70 | return $this->algorithms[$alg]; |
| 69 | 71 | } |
| 70 | 72 | } |
| 71 | 73 | \ No newline at end of file |
@@ -37,8 +37,9 @@ |
||
| 37 | 37 | |
| 38 | 38 | parent::__construct($pem_format, $password); |
| 39 | 39 | $this->d = $this->rsa_imp->exponent; |
| 40 | - if($this->d->toString() === $this->e->toString()) |
|
| 41 | - throw new RSABadPEMFormat(sprintf('pem %s is a public key!', $pem_format)); |
|
| 40 | + if($this->d->toString() === $this->e->toString()) { |
|
| 41 | + throw new RSABadPEMFormat(sprintf('pem %s is a public key!', $pem_format)); |
|
| 42 | + } |
|
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | /** |
@@ -48,12 +48,15 @@ |
||
| 48 | 48 | $this->pem_format = $pem_format; |
| 49 | 49 | $this->rsa_imp = new \Crypt_RSA(); |
| 50 | 50 | |
| 51 | - if(!empty($password)) |
|
| 52 | - $this->rsa_imp->setPassword($password); |
|
| 51 | + if(!empty($password)) { |
|
| 52 | + $this->rsa_imp->setPassword($password); |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | 55 | $res = $this->rsa_imp->loadKey($this->pem_format, CRYPT_RSA_PRIVATE_FORMAT_PKCS1); |
| 55 | 56 | |
| 56 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 57 | + if(!$res) { |
|
| 58 | + throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | $this->n = $this->rsa_imp->modulus; |
| 59 | 62 | } |
@@ -43,7 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | $this->file = new \File_X509(); |
| 45 | 45 | $this->info = $this->file->loadX509($pem); |
| 46 | - if($this->info === false) throw new InvalidX509CertificateException($pem); |
|
| 46 | + if($this->info === false) { |
|
| 47 | + throw new InvalidX509CertificateException($pem); |
|
| 48 | + } |
|
| 47 | 49 | $this->original_pem = $pem; |
| 48 | 50 | } |
| 49 | 51 | |