@@ -46,7 +46,7 @@ |
||
46 | 46 | * @return array |
47 | 47 | * @throws JWEInvalidCompactFormatException |
48 | 48 | */ |
49 | - static public function deserialize($input){ |
|
49 | + static public function deserialize($input) { |
|
50 | 50 | $parts = explode(IBasicJWT::SegmentSeparator, $input); |
51 | 51 | if (count($parts) !== 5) throw new JWEInvalidCompactFormatException; |
52 | 52 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | final class JWEJOSEHeaderFactory { |
23 | 23 | |
24 | - static protected function getProductClass(){ |
|
24 | + static protected function getProductClass() { |
|
25 | 25 | return '\jwe\impl\JWEJOSEHeader'; |
26 | 26 | } |
27 | 27 | |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | * @return IJWEJOSEHeader |
31 | 31 | * @throws \ReflectionException |
32 | 32 | */ |
33 | - public static function build(array $raw_headers){ |
|
33 | + public static function build(array $raw_headers) { |
|
34 | 34 | |
35 | 35 | $args = array(); |
36 | 36 | |
37 | - foreach(RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set as $header_name){ |
|
37 | + foreach (RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set as $header_name) { |
|
38 | 38 | $value = isset($raw_headers[$header_name]) ? $raw_headers[$header_name] : null; |
39 | 39 | $type = @RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
40 | - if(!is_null($value)) |
|
40 | + if (!is_null($value)) |
|
41 | 41 | { |
42 | - if(is_null($type)) continue; |
|
42 | + if (is_null($type)) continue; |
|
43 | 43 | $class = new \ReflectionClass($type); |
44 | 44 | $value = $class->newInstanceArgs(array($value)); |
45 | 45 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // unregistered headers |
55 | 55 | |
56 | - foreach($raw_headers as $k => $v){ |
|
56 | + foreach ($raw_headers as $k => $v) { |
|
57 | 57 | $basic_header->addHeader(new JOSEHeaderParam($k, new JsonValue($v))); |
58 | 58 | } |
59 | 59 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | private $algorithms = []; |
29 | 29 | |
30 | - private function __construct(){ |
|
30 | + private function __construct() { |
|
31 | 31 | |
32 | 32 | $this->algorithms[CompressionAlgorithmsNames::Deflate] = new Deflate; |
33 | 33 | $this->algorithms[CompressionAlgorithmsNames::GZip] = new GZip; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - private function __clone(){} |
|
38 | + private function __clone() {} |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @return CompressionAlgorithms_Registry |
42 | 42 | */ |
43 | - public static function getInstance(){ |
|
44 | - if(!is_object(self::$instance)){ |
|
43 | + public static function getInstance() { |
|
44 | + if (!is_object(self::$instance)) { |
|
45 | 45 | self::$instance = new CompressionAlgorithms_Registry(); |
46 | 46 | } |
47 | 47 | return self::$instance; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param string $alg |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function isSupported($alg){ |
|
54 | + public function isSupported($alg) { |
|
55 | 55 | return array_key_exists($alg, $this->algorithms); |
56 | 56 | } |
57 | 57 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @param $alg |
60 | 60 | * @return null|CompressionAlgorithm |
61 | 61 | */ |
62 | - public function get($alg){ |
|
63 | - if(!$this->isSupported($alg)) return null; |
|
62 | + public function get($alg) { |
|
63 | + if (!$this->isSupported($alg)) return null; |
|
64 | 64 | return $this->algorithms[$alg]; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -24,6 +24,6 @@ |
||
24 | 24 | */ |
25 | 25 | public function getPaddingMode() |
26 | 26 | { |
27 | - return RSA::SIGNATURE_PKCS1 ; |
|
27 | + return RSA::SIGNATURE_PKCS1; |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | private $algorithms = []; |
38 | 38 | |
39 | - private function __construct(){ |
|
39 | + private function __construct() { |
|
40 | 40 | |
41 | 41 | $this->algorithms[JSONWebSignatureAndEncryptionAlgorithms::HS256] = new HS256_Algorithm; |
42 | 42 | $this->algorithms[JSONWebSignatureAndEncryptionAlgorithms::HS384] = new HS384_Algorithm; |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | - private function __clone(){} |
|
55 | + private function __clone() {} |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @return DigitalSignatures_MACs_Registry |
59 | 59 | */ |
60 | - public static function getInstance(){ |
|
61 | - if(!is_object(self::$instance)){ |
|
60 | + public static function getInstance() { |
|
61 | + if (!is_object(self::$instance)) { |
|
62 | 62 | self::$instance = new DigitalSignatures_MACs_Registry(); |
63 | 63 | } |
64 | 64 | return self::$instance; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $alg |
69 | 69 | * @return bool |
70 | 70 | */ |
71 | - public function isSupported($alg){ |
|
71 | + public function isSupported($alg) { |
|
72 | 72 | return array_key_exists($alg, $this->algorithms); |
73 | 73 | } |
74 | 74 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param $alg |
77 | 77 | * @return null|DigitalSignatureAlgorithm|MAC_Algorithm |
78 | 78 | */ |
79 | - public function get($alg){ |
|
80 | - if(!$this->isSupported($alg)) return null; |
|
79 | + public function get($alg) { |
|
80 | + if (!$this->isSupported($alg)) return null; |
|
81 | 81 | return $this->algorithms[$alg]; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * AES Key Wrap using 256-bit key |
129 | 129 | */ |
130 | - const A256KW= 'A256KW'; |
|
130 | + const A256KW = 'A256KW'; |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Direct use of a shared symmetric key |
@@ -222,29 +222,29 @@ discard block |
||
222 | 222 | self::RS256, |
223 | 223 | self::RS384, |
224 | 224 | self::RS512, |
225 | - self::ES256 , |
|
225 | + self::ES256, |
|
226 | 226 | self::ES384, |
227 | - self::ES512 , |
|
227 | + self::ES512, |
|
228 | 228 | self::PS256, |
229 | - self::PS384 , |
|
229 | + self::PS384, |
|
230 | 230 | self::PS512, |
231 | 231 | self::None, |
232 | 232 | self::RSA1_5, |
233 | - self::RSA_OAEP , |
|
233 | + self::RSA_OAEP, |
|
234 | 234 | self::RSA_OAEP_256, |
235 | - self::A128KW , |
|
235 | + self::A128KW, |
|
236 | 236 | self::A192KW, |
237 | 237 | self::A192KW, |
238 | 238 | self::A256KW, |
239 | 239 | self::Dir, |
240 | 240 | self::ECDH_ES, |
241 | - self::ECDH_ES_A128KW , |
|
241 | + self::ECDH_ES_A128KW, |
|
242 | 242 | self::ECDH_ES_A192KW, |
243 | - self::ECDH_ES_A256KW , |
|
244 | - self::A128GCMKW , |
|
243 | + self::ECDH_ES_A256KW, |
|
244 | + self::A128GCMKW, |
|
245 | 245 | self::A192GCMKW, |
246 | - self::A256GCMKW , |
|
247 | - self::PBES2_HS256_A128KW , |
|
246 | + self::A256GCMKW, |
|
247 | + self::PBES2_HS256_A128KW, |
|
248 | 248 | self::PBES2_HS384_A192KW, |
249 | 249 | self::PBES2_HS512_A256KW, |
250 | 250 | ]; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @var array |
25 | 25 | */ |
26 | - private $info = []; |
|
26 | + private $info = []; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @var X509|null |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | private $original_pem = null; |
37 | 37 | |
38 | - public function __construct($pem){ |
|
38 | + public function __construct($pem) { |
|
39 | 39 | |
40 | 40 | $this->file = new X509(); |
41 | 41 | $this->info = $this->file->loadX509($pem); |
42 | - if($this->info === false) throw new InvalidX509CertificateException($pem); |
|
42 | + if ($this->info === false) throw new InvalidX509CertificateException($pem); |
|
43 | 43 | $this->original_pem = $pem; |
44 | 44 | } |
45 | 45 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | return $this->original_pem; |
52 | 52 | } |
53 | 53 | |
54 | - private function calculateThumbprint($alg){ |
|
55 | - $pem = str_replace( array("\n","\r"), '', trim($this->original_pem)); |
|
54 | + private function calculateThumbprint($alg) { |
|
55 | + $pem = str_replace(array("\n", "\r"), '', trim($this->original_pem)); |
|
56 | 56 | return strtoupper(hash($alg, base64_decode($pem))); |
57 | 57 | } |
58 | 58 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | public function getPublicKey() |
79 | 79 | { |
80 | 80 | $pem = (string)$this->file->getPublicKey(); |
81 | - $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/','',$pem); |
|
82 | - $pem = preg_replace('/\-+END PUBLIC KEY\-+/','',$pem); |
|
83 | - $pem = str_replace( array("\n","\r","\t"), '', trim($pem)); |
|
81 | + $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/', '', $pem); |
|
82 | + $pem = preg_replace('/\-+END PUBLIC KEY\-+/', '', $pem); |
|
83 | + $pem = str_replace(array("\n", "\r", "\t"), '', trim($pem)); |
|
84 | 84 | return $pem; |
85 | 85 | } |
86 | 86 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param PublicKey $public_key |
33 | 33 | * @param PrivateKey $private_key |
34 | 34 | */ |
35 | - public function __construct(PublicKey $public_key, PrivateKey $private_key){ |
|
35 | + public function __construct(PublicKey $public_key, PrivateKey $private_key) { |
|
36 | 36 | |
37 | 37 | $this->private_key = $private_key; |
38 | 38 | $this->public_key = $public_key; |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @return PublicKey |
43 | 43 | */ |
44 | - public function getPublic(){ return $this->public_key; } |
|
44 | + public function getPublic() { return $this->public_key; } |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @return PrivateKey |
48 | 48 | */ |
49 | - public function getPrivate(){ return $this->private_key; } |
|
49 | + public function getPrivate() { return $this->private_key; } |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function sign(PrivateKey $private_key, $message) |
41 | 41 | { |
42 | - if(!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
42 | + if (!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
43 | 43 | |
44 | - if($this->getMinKeyLen() > $private_key->getBitLength()) |
|
45 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
44 | + if ($this->getMinKeyLen() > $private_key->getBitLength()) |
|
45 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.', $this->getMinKeyLen(), $private_key->getBitLength())); |
|
46 | 46 | |
47 | - if($private_key->hasPassword()){ |
|
47 | + if ($private_key->hasPassword()) { |
|
48 | 48 | $this->rsa_impl->setPassword($private_key->getPassword()); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $res = $this->rsa_impl->loadKey($private_key->getEncoded()); |
52 | 52 | |
53 | - if(!$res) |
|
53 | + if (!$res) |
|
54 | 54 | throw new InvalidKeyTypeAlgorithmException; |
55 | 55 | |
56 | 56 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function verify(Key $key, $message, $signature) |
71 | 71 | { |
72 | - if(!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
72 | + if (!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
73 | 73 | |
74 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
75 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
74 | + if ($this->getMinKeyLen() > $key->getBitLength()) |
|
75 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.', $this->getMinKeyLen(), $key->getBitLength())); |
|
76 | 76 | |
77 | 77 | $res = $this->rsa_impl->loadKey($key->getEncoded()); |
78 | 78 | |
79 | - if(!$res) throw new InvalidKeyTypeAlgorithmException; |
|
79 | + if (!$res) throw new InvalidKeyTypeAlgorithmException; |
|
80 | 80 | |
81 | 81 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
82 | 82 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |