@@ -23,7 +23,7 @@ class JWK
23
23
/**
24
24
* Parse a set of JWK keys
25
25
*
26
- * @param array $jwks The JSON Web Key Set as an associative array
26
+ * @param array<mixed> $jwks The JSON Web Key Set as an associative array
27
27
*
28
28
* @return array<string, Key> An associative array of key IDs (kid) to Key objects
29
29
*
@@ -48,7 +48,7 @@ public static function parseKeySet(array $jwks): array
48
48
foreach ($ jwks ['keys ' ] as $ k => $ v ) {
49
49
$ kid = isset ($ v ['kid ' ]) ? $ v ['kid ' ] : $ k ;
50
50
if ($ key = self ::parseKey ($ v )) {
51
- $ keys [$ kid ] = $ key ;
51
+ $ keys [( string ) $ kid ] = $ key ;
52
52
}
53
53
}
54
54
@@ -62,7 +62,7 @@ public static function parseKeySet(array $jwks): array
62
62
/**
63
63
* Parse a JWK key
64
64
*
65
- * @param array $jwk An individual JWK
65
+ * @param array<mixed> $jwk An individual JWK
66
66
*
67
67
* @return Key The key object for the JWK
68
68
*
@@ -124,22 +124,22 @@ public static function parseKey(array $jwk): ?Key
124
124
*
125
125
* @uses encodeLength
126
126
*/
127
- private static function createPemFromModulusAndExponent ($ n , $ e )
128
- {
129
- $ modulus = JWT ::urlsafeB64Decode ($ n );
130
- $ publicExponent = JWT ::urlsafeB64Decode ($ e );
127
+ private static function createPemFromModulusAndExponent (
128
+ string $ n ,
129
+ string $ e
130
+ ): string {
131
+ $ mod = JWT ::urlsafeB64Decode ($ n );
132
+ $ exp = JWT ::urlsafeB64Decode ($ e );
131
133
132
- $ components = [
133
- 'modulus ' => \pack ('Ca*a* ' , 2 , self ::encodeLength (\strlen ($ modulus )), $ modulus ),
134
- 'publicExponent ' => \pack ('Ca*a* ' , 2 , self ::encodeLength (\strlen ($ publicExponent )), $ publicExponent )
135
- ];
134
+ $ modulus = \pack ('Ca*a* ' , 2 , self ::encodeLength (\strlen ($ mod )), $ mod );
135
+ $ publicExponent = \pack ('Ca*a* ' , 2 , self ::encodeLength (\strlen ($ exp )), $ exp );
136
136
137
137
$ rsaPublicKey = \pack (
138
138
'Ca*a*a* ' ,
139
139
48 ,
140
- self ::encodeLength (\strlen ($ components [ ' modulus ' ] ) + \strlen ($ components [ ' publicExponent ' ] )),
141
- $ components [ ' modulus ' ] ,
142
- $ components [ ' publicExponent ' ]
140
+ self ::encodeLength (\strlen ($ modulus ) + \strlen ($ publicExponent )),
141
+ $ modulus ,
142
+ $ publicExponent
143
143
);
144
144
145
145
// sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption.
@@ -170,7 +170,7 @@ private static function createPemFromModulusAndExponent($n, $e)
170
170
* @param int $length
171
171
* @return string
172
172
*/
173
- private static function encodeLength ($ length )
173
+ private static function encodeLength (int $ length ): string
174
174
{
175
175
if ($ length <= 0x7F ) {
176
176
return \chr ($ length );
0 commit comments