@@ -50,7 +50,7 @@ public static function parseKeySet(array $jwks)
5050 }
5151 }
5252
53- if (0 === count ($ keys )) {
53+ if (0 === \ count ($ keys )) {
5454 throw new UnexpectedValueException ('No supported algorithms found in JWK Set ' );
5555 }
5656
@@ -81,18 +81,18 @@ private static function parseKey(array $jwk)
8181
8282 switch ($ jwk ['kty ' ]) {
8383 case 'RSA ' :
84- if (array_key_exists ('d ' , $ jwk )) {
84+ if (\ array_key_exists ('d ' , $ jwk )) {
8585 throw new UnexpectedValueException ('RSA private keys are not supported ' );
8686 }
8787 if (!isset ($ jwk ['n ' ]) || !isset ($ jwk ['e ' ])) {
8888 throw new UnexpectedValueException ('RSA keys must contain values for both "n" and "e" ' );
8989 }
9090
9191 $ pem = self ::createPemFromModulusAndExponent ($ jwk ['n ' ], $ jwk ['e ' ]);
92- $ publicKey = openssl_pkey_get_public ($ pem );
92+ $ publicKey = \ openssl_pkey_get_public ($ pem );
9393 if (false === $ publicKey ) {
9494 throw new DomainException (
95- 'OpenSSL error: ' . openssl_error_string ()
95+ 'OpenSSL error: ' . \ openssl_error_string ()
9696 );
9797 }
9898 return $ publicKey ;
@@ -118,32 +118,32 @@ private static function createPemFromModulusAndExponent($n, $e)
118118 $ publicExponent = JWT ::urlsafeB64Decode ($ e );
119119
120120 $ components = array (
121- 'modulus ' => pack ('Ca*a* ' , 2 , self ::encodeLength (strlen ($ modulus )), $ modulus ),
122- 'publicExponent ' => pack ('Ca*a* ' , 2 , self ::encodeLength (strlen ($ publicExponent )), $ publicExponent )
121+ 'modulus ' => \ pack ('Ca*a* ' , 2 , self ::encodeLength (\ strlen ($ modulus )), $ modulus ),
122+ 'publicExponent ' => \ pack ('Ca*a* ' , 2 , self ::encodeLength (\ strlen ($ publicExponent )), $ publicExponent )
123123 );
124124
125- $ rsaPublicKey = pack (
125+ $ rsaPublicKey = \ pack (
126126 'Ca*a*a* ' ,
127127 48 ,
128- self ::encodeLength (strlen ($ components ['modulus ' ]) + strlen ($ components ['publicExponent ' ])),
128+ self ::encodeLength (\ strlen ($ components ['modulus ' ]) + \ strlen ($ components ['publicExponent ' ])),
129129 $ components ['modulus ' ],
130130 $ components ['publicExponent ' ]
131131 );
132132
133133 // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption.
134- $ rsaOID = pack ('H* ' , '300d06092a864886f70d0101010500 ' ); // hex version of MA0GCSqGSIb3DQEBAQUA
135- $ rsaPublicKey = chr (0 ) . $ rsaPublicKey ;
136- $ rsaPublicKey = chr (3 ) . self ::encodeLength (strlen ($ rsaPublicKey )) . $ rsaPublicKey ;
134+ $ rsaOID = \ pack ('H* ' , '300d06092a864886f70d0101010500 ' ); // hex version of MA0GCSqGSIb3DQEBAQUA
135+ $ rsaPublicKey = \ chr (0 ) . $ rsaPublicKey ;
136+ $ rsaPublicKey = \ chr (3 ) . self ::encodeLength (\ strlen ($ rsaPublicKey )) . $ rsaPublicKey ;
137137
138- $ rsaPublicKey = pack (
138+ $ rsaPublicKey = \ pack (
139139 'Ca*a* ' ,
140140 48 ,
141- self ::encodeLength (strlen ($ rsaOID . $ rsaPublicKey )),
141+ self ::encodeLength (\ strlen ($ rsaOID . $ rsaPublicKey )),
142142 $ rsaOID . $ rsaPublicKey
143143 );
144144
145145 $ rsaPublicKey = "-----BEGIN PUBLIC KEY----- \r\n" .
146- chunk_split (base64_encode ($ rsaPublicKey ), 64 ) .
146+ \ chunk_split (\ base64_encode ($ rsaPublicKey ), 64 ) .
147147 '-----END PUBLIC KEY----- ' ;
148148
149149 return $ rsaPublicKey ;
@@ -161,11 +161,11 @@ private static function createPemFromModulusAndExponent($n, $e)
161161 private static function encodeLength ($ length )
162162 {
163163 if ($ length <= 0x7F ) {
164- return chr ($ length );
164+ return \ chr ($ length );
165165 }
166166
167- $ temp = ltrim (pack ('N ' , $ length ), chr (0 ));
167+ $ temp = \ ltrim (\ pack ('N ' , $ length ), \ chr (0 ));
168168
169- return pack ('Ca* ' , 0x80 | strlen ($ temp ), $ temp );
169+ return \ pack ('Ca* ' , 0x80 | \ strlen ($ temp ), $ temp );
170170 }
171171}
0 commit comments