first commit
This commit is contained in:
61
libraries/vendor/web-token/jwt-signature-algorithm-experimental/Blake2b.php
vendored
Normal file
61
libraries/vendor/web-token/jwt-signature-algorithm-experimental/Blake2b.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Signature\Algorithm;
|
||||
|
||||
use function in_array;
|
||||
use InvalidArgumentException;
|
||||
use function is_string;
|
||||
use Jose\Component\Core\JWK;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
|
||||
/**
|
||||
* @see \Jose\Tests\Component\Signature\Algorithm\Blake2bTest
|
||||
*/
|
||||
final class Blake2b implements MacAlgorithm
|
||||
{
|
||||
private const MINIMUM_KEY_LENGTH = 32;
|
||||
|
||||
public function allowedKeyTypes(): array
|
||||
{
|
||||
return ['oct'];
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'BLAKE2B';
|
||||
}
|
||||
|
||||
public function verify(JWK $key, string $input, string $signature): bool
|
||||
{
|
||||
return hash_equals($this->hash($key, $input), $signature);
|
||||
}
|
||||
|
||||
public function hash(JWK $key, string $input): string
|
||||
{
|
||||
$k = $this->getKey($key);
|
||||
|
||||
return sodium_crypto_generichash($input, $k);
|
||||
}
|
||||
|
||||
private function getKey(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.');
|
||||
}
|
||||
$key = Base64UrlSafe::decode($k);
|
||||
if (mb_strlen($key, '8bit') < self::MINIMUM_KEY_LENGTH) {
|
||||
throw new InvalidArgumentException('Key provided is shorter than 256 bits.');
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
23
libraries/vendor/web-token/jwt-signature-algorithm-experimental/ES256K.php
vendored
Normal file
23
libraries/vendor/web-token/jwt-signature-algorithm-experimental/ES256K.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Signature\Algorithm;
|
||||
|
||||
final class ES256K extends ECDSA
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'ES256K';
|
||||
}
|
||||
|
||||
protected function getHashAlgorithm(): string
|
||||
{
|
||||
return 'sha256';
|
||||
}
|
||||
|
||||
protected function getSignaturePartLength(): int
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
18
libraries/vendor/web-token/jwt-signature-algorithm-experimental/HS1.php
vendored
Normal file
18
libraries/vendor/web-token/jwt-signature-algorithm-experimental/HS1.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Signature\Algorithm;
|
||||
|
||||
final class HS1 extends HMAC
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'HS1';
|
||||
}
|
||||
|
||||
protected function getHashAlgorithm(): string
|
||||
{
|
||||
return 'sha1';
|
||||
}
|
||||
}
|
||||
27
libraries/vendor/web-token/jwt-signature-algorithm-experimental/HS256_64.php
vendored
Normal file
27
libraries/vendor/web-token/jwt-signature-algorithm-experimental/HS256_64.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Signature\Algorithm;
|
||||
|
||||
use Jose\Component\Core\JWK;
|
||||
|
||||
final class HS256_64 extends HMAC
|
||||
{
|
||||
public function hash(JWK $key, string $input): string
|
||||
{
|
||||
$signature = parent::hash($key, $input);
|
||||
|
||||
return mb_substr($signature, 0, 8, '8bit');
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'HS256/64';
|
||||
}
|
||||
|
||||
protected function getHashAlgorithm(): string
|
||||
{
|
||||
return 'sha256';
|
||||
}
|
||||
}
|
||||
21
libraries/vendor/web-token/jwt-signature-algorithm-experimental/LICENSE
vendored
Normal file
21
libraries/vendor/web-token/jwt-signature-algorithm-experimental/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2019 Spomky-Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
18
libraries/vendor/web-token/jwt-signature-algorithm-experimental/RS1.php
vendored
Normal file
18
libraries/vendor/web-token/jwt-signature-algorithm-experimental/RS1.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Signature\Algorithm;
|
||||
|
||||
final class RS1 extends RSAPKCS1
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'RS1';
|
||||
}
|
||||
|
||||
protected function getAlgorithm(): string
|
||||
{
|
||||
return 'sha1';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user