Skip to content

Commit

Permalink
Merge ECC to jwt-core (#507)
Browse files Browse the repository at this point in the history
Merge ECC to jwt-core
  • Loading branch information
Spomky authored Jan 30, 2024
1 parent 1e1ab7a commit 4eb3429
Show file tree
Hide file tree
Showing 74 changed files with 882 additions and 1,319 deletions.
11 changes: 1 addition & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,7 @@
"Jose\\Component\\Checker\\": "src/Component/Checker/",
"Jose\\Component\\Console\\": "src/Component/Console/",
"Jose\\Component\\Core\\": "src/Component/Core/",
"Jose\\Component\\Core\\Util\\Ecc\\": [
"src/Ecc",
"src/Ecc/"
],
"Jose\\Component\\Encryption\\": "src/Component/Encryption/",
"Jose\\Component\\Encryption\\Algorithm\\": [
"src/EncryptionAlgorithm/Experimental",
"src/EncryptionAlgorithm/Experimental/"
],
"Jose\\Component\\Encryption\\Algorithm\\ContentEncryption\\": [
"src/EncryptionAlgorithm/ContentEncryption/AESCBC",
"src/EncryptionAlgorithm/ContentEncryption/AESCBC/",
Expand Down Expand Up @@ -119,7 +111,6 @@
"ext-curl": "*",
"ext-gmp": "*",
"bjeavons/zxcvbn-php": "^1.3",
"blackfire/php-sdk": "^2.0",
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.27",
"matthiasnoback/symfony-config-test": "^5.0",
Expand All @@ -134,7 +125,7 @@
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^10.1",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^0.18",
"rector/rector": "^0.19",
"roave/security-advisories": "dev-latest",
"symfony/browser-kit": "^6.1|^7.0",
"symfony/finder": "^6.1|^7.0",
Expand Down
1,823 changes: 844 additions & 979 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
Expand All @@ -12,6 +11,7 @@
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $config): void {
$config->import(SetList::DEAD_CODE);
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Checker/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Console/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Core/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
4 changes: 3 additions & 1 deletion src/Component/Core/Util/ECSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public static function fromAsn1(string $signature, int $length): string
$pointR = self::retrievePositiveInteger(self::readAsn1Integer($message, $position));
$pointS = self::retrievePositiveInteger(self::readAsn1Integer($message, $position));

$bin = hex2bin(str_pad($pointR, $length, '0', STR_PAD_LEFT) . str_pad($pointS, $length, '0', STR_PAD_LEFT));
$bin = hex2bin(
str_pad($pointR, $length, '0', STR_PAD_LEFT) . str_pad($pointS, $length, '0', STR_PAD_LEFT)
);
if (! is_string($bin)) {
throw new InvalidArgumentException('Unable to parse the data');
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/Component/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@
},
"conflict": {
"spomky-labs/jose": "*"
},
"suggest": {
"ext-gmp": "GMP or BCMath is highly recommended to improve the library performance",
"ext-bcmath": "GMP or BCMath is highly recommended to improve the library performance"
}
}
2 changes: 1 addition & 1 deletion src/Component/Encryption/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
9 changes: 0 additions & 9 deletions src/Component/KeyManagement/Analyzer/ESKeyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,11 @@
use Brick\Math\BigInteger;
use Jose\Component\Core\JWK;
use Jose\Component\Core\Util\Ecc\Curve;
use Jose\Component\Core\Util\Ecc\NistCurve;
use ParagonIE\ConstantTime\Base64UrlSafe;
use RuntimeException;
use function is_string;

abstract class ESKeyAnalyzer implements KeyAnalyzer
{
public function __construct()
{
if (! class_exists(NistCurve::class)) {
throw new RuntimeException('Please install web-token/jwt-util-ecc to use this key analyzer');
}
}

public function analyze(JWK $jwk, MessageBag $bag): void
{
if ($jwk->get('kty') !== 'EC') {
Expand Down
2 changes: 1 addition & 1 deletion src/Component/KeyManagement/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
1 change: 0 additions & 1 deletion src/Component/KeyManagement/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
},
"suggest": {
"ext-sodium": "Sodium is required for OKP key creation, EdDSA signature algorithm and ECDH-ES key encryption with OKP keys",
"web-token/jwt-util-ecc": "To use EC key analyzers.",
"php-http/message-factory": "To enable JKU/X5U support.",
"php-http/httplug": "To enable JKU/X5U support."
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/NestedToken/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Signature/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Ecc/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
14 changes: 2 additions & 12 deletions src/Ecc/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-token/jwt-util-ecc",
"description": "ECC Tools for the JWT Framework.",
"description": "[DEPRECATED] Please use web-token/jwt-core instead.",
"type": "library",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -32,17 +32,7 @@
"homepage": "https://github.com/web-token/jwt-framework/contributors"
}
],
"autoload": {
"psr-4": {
"Jose\\Component\\Core\\Util\\Ecc\\": ""
}
},
"require": {
"php": ">=8.1",
"brick/math": "^0.9|^0.10|^0.11|^0.12"
},
"suggest": {
"ext-gmp": "GMP or BCMath is highly recommended to improve the library performance",
"ext-bcmath": "GMP or BCMath is highly recommended to improve the library performance"
"web-token/jwt-core": "^3.3"
}
}
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/ContentEncryption/AESCBC/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/ContentEncryption/AESGCM/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/Experimental/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/AESGCMKW/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/AESKW/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/Direct/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/ECDHES/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/ECDHES/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"ext-openssl": "*",
"spomky-labs/aes-key-wrap": "^7.0",
"web-token/jwt-encryption": "^3.2",
"web-token/jwt-util-ecc": "^3.2"
"web-token/jwt-core": "^3.3"
}
}
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/PBES2/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionAlgorithm/KeyEncryption/RSA/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Experimental/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
2 changes: 1 addition & 1 deletion src/Experimental/Signature/RS1.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Jose\Experimental\Signature;

use Jose\Experimental\RSAPKCS1;
use Jose\Component\Signature\Algorithm\RSAPKCS1;

final class RS1 extends RSAPKCS1
{
Expand Down
2 changes: 1 addition & 1 deletion src/JoseFramework/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2019 Spomky-Labs
Copyright (c) 2014-2024 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128CBCHS256;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A192CBCHS384;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A192GCM;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192GCMKW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192KW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
declare(strict_types=1);

use Jose\Component\Encryption\Algorithm\KeyEncryption\Dir;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHSSA128KW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHSSA192KW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHSSA256KW;
/*
* 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.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
Expand Down
Loading

0 comments on commit 4eb3429

Please sign in to comment.