CoreFiles by mySites.guru
Dir.php45 lines, 1,088 bytes, from Joomla_6.0.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 5.4.0-alpha3
md5
c64ad77c03609c4193729aea3a632f05
sha1
26a0da1f395a46c63c182989b580ac75e6f93ac6
sha256
2e50ff8787628670dd20a569a1891abeff224163a13f5e2b6f6899a0f15da56d
<?php

declare(strict_types=1);

namespace Jose\Component\Encryption\Algorithm\KeyEncryption;

use InvalidArgumentException;
use Jose\Component\Core\JWK;
use Jose\Component\Core\Util\Base64UrlSafe;
use function in_array;
use function is_string;

final class Dir implements DirectEncryption
{
    public function getCEK(JWK $key): string
    {
        if (! in_array($key->get('kty'), $this->allowedKeyTypes(), true)) {
            throw new InvalidArgumentException('Wrong key type.');
        }
        if (! $key->has('k')) {
            throw new InvalidArgumentException('The key parameter "k" is missing.');
        }
        $k = $key->get('k');
        if (! is_string($k)) {
            throw new InvalidArgumentException('The key parameter "k" is invalid.');
        }

        return Base64UrlSafe::decodeNoPadding($k);
    }

    public function name(): string
    {
        return 'dir';
    }

    public function allowedKeyTypes(): array
    {
        return ['oct'];
    }

    public function getKeyManagementMode(): string
    {
        return self::MODE_DIRECT;
    }
}

The same content is in 116 releases, Joomla 5.2.0-beta1 to 6.2.1. See them all, or every version of this file.