CoreFiles by mySites.guru
MixedPublicAndPrivateKeys.php39 lines, 942 bytes, from Joomla_5.4.4-Stable-Full_Package.zip
Raw History Compare with 5.4.3
md5
089675f12843cd2374545b605fc5abab
sha1
152a1b801b32a5d0717472e32b9b4e2fba5659de
sha256
864dba4037075f1b452c00a1c39f8f6bf512a59175d0866ab237479d64a15f9e
<?php

declare(strict_types=1);

namespace Jose\Component\KeyManagement\Analyzer;

use Jose\Component\Core\JWKSet;

final class MixedPublicAndPrivateKeys implements KeysetAnalyzer
{
    public function analyze(JWKSet $jwkset, MessageBag $bag): void
    {
        if ($jwkset->count() === 0) {
            return;
        }

        $hasPublicKeys = false;
        $hasPrivateKeys = false;

        foreach ($jwkset as $jwk) {
            switch ($jwk->get('kty')) {
                case 'OKP':
                case 'RSA':
                case 'EC':
                    if ($jwk->has('d')) {
                        $hasPrivateKeys = true;
                    } else {
                        $hasPublicKeys = true;
                    }

                    break;
            }
        }

        if ($hasPrivateKeys && $hasPublicKeys) {
            $bag->add(Message::high('This key set mixes public and private keys.'));
        }
    }
}

The same content is in 136 releases, Joomla 5.1.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.