CoreFiles by mySites.guru
HS256.php43 lines, 852 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
f7efb80462b9727df31c4b6b81ab3fb1
sha1
ebb373415d07c4687f98c25ac6a0882188d9b81b
sha256
9ceeb933e88df7a2dac2587862ea1ce4462d5c20191348642d66464fa445d6d7
<?php

declare(strict_types=1);

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2020 Spomky-Labs
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace Jose\Component\Signature\Algorithm;

use InvalidArgumentException;
use Jose\Component\Core\JWK;

final class HS256 extends HMAC
{
    public function name(): string
    {
        return 'HS256';
    }

    protected function getHashAlgorithm(): string
    {
        return 'sha256';
    }

    /**
     * @throws InvalidArgumentException if the key is invalid
     */
    protected function getKey(JWK $key): string
    {
        $k = parent::getKey($key);
        if (mb_strlen($k, '8bit') < 32) {
            throw new InvalidArgumentException('Invalid key length.');
        }

        return $k;
    }
}

The same content is in 75 releases, Joomla 4.2.0-beta3 to 4.4.14. See them all, or every version of this file.