Conditions | 9 |
Paths | 17 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function analyze(JWKSet $jwkset, MessageBag $bag): void |
||
21 | { |
||
22 | if (0 === $jwkset->count()) { |
||
23 | return; |
||
24 | } |
||
25 | |||
26 | $hasPublicKeys = false; |
||
27 | $hasPrivateKeys = false; |
||
28 | |||
29 | foreach ($jwkset as $jwk) { |
||
30 | switch ($jwk->get('kty')) { |
||
31 | case 'OKP': |
||
32 | case 'RSA': |
||
33 | case 'EC': |
||
34 | if ($jwk->has('d')) { |
||
35 | $hasPrivateKeys = true; |
||
36 | } else { |
||
37 | $hasPublicKeys = true; |
||
38 | } |
||
39 | |||
40 | break; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | if ($hasPrivateKeys && $hasPublicKeys) { |
||
45 | $bag->add(Message::high('This key set mixes public and private keys.')); |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 |