Skip to content

Commit 339c88a

Browse files
authored
Merge branch 'master' into v2.1
2 parents 7ab2d1a + 7b61ef7 commit 339c88a

File tree

14 files changed

+181
-70
lines changed

14 files changed

+181
-70
lines changed

src/Bundle/JoseFramework/DependencyInjection/Source/Signature/SignatureSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Jose\Component\Signature\Algorithm\HMAC;
2222
use Jose\Component\Signature\Algorithm\HS1;
2323
use Jose\Component\Signature\Algorithm\None;
24-
use Jose\Component\Signature\Algorithm\RSA;
24+
use Jose\Component\Signature\Algorithm\RSAPSS;
2525
use Jose\Component\Signature\JWSBuilderFactory;
2626
use Jose\Component\Signature\JWSVerifierFactory;
2727
use Symfony\Component\Config\Definition\Builder\NodeDefinition;

src/Bundle/JoseFramework/Resources/config/Algorithms/signature_rsa.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@
3333
->tag('jose.algorithm', ['alias' => 'RS512'])
3434
;
3535

36-
$container->set(Algorithm\PS256::class)
37-
->tag('jose.algorithm', ['alias' => 'PS256'])
38-
;
39-
40-
$container->set(Algorithm\PS384::class)
41-
->tag('jose.algorithm', ['alias' => 'PS384'])
42-
;
43-
44-
$container->set(Algorithm\PS512::class)
45-
->tag('jose.algorithm', ['alias' => 'PS512'])
46-
;
36+
if (extension_loaded('gmp')) {
37+
$container->set(Algorithm\PS256::class)
38+
->tag('jose.algorithm', ['alias' => 'PS256'])
39+
;
40+
41+
$container->set(Algorithm\PS384::class)
42+
->tag('jose.algorithm', ['alias' => 'PS384'])
43+
;
44+
45+
$container->set(Algorithm\PS512::class)
46+
->tag('jose.algorithm', ['alias' => 'PS512'])
47+
;
48+
}
4749
};

src/SignatureAlgorithm/Experimental/RS1.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class RS1 extends RSA
16+
final class RS1 extends RSAPKCS1
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha1';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PKCS1;
33-
}
3427
}

src/SignatureAlgorithm/RSA/PS256.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class PS256 extends RSA
16+
final class PS256 extends RSAPSS
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha256';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PSS;
33-
}
3427
}

src/SignatureAlgorithm/RSA/PS384.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class PS384 extends RSA
16+
final class PS384 extends RSAPSS
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha384';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PSS;
33-
}
3427
}

src/SignatureAlgorithm/RSA/PS512.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class PS512 extends RSA
16+
final class PS512 extends RSAPSS
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha512';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PSS;
33-
}
3427
}

src/SignatureAlgorithm/RSA/RS256.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class RS256 extends RSA
16+
final class RS256 extends RSAPKCS1
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha256';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PKCS1;
33-
}
3427
}

src/SignatureAlgorithm/RSA/RS384.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class RS384 extends RSA
16+
final class RS384 extends RSAPKCS1
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha384';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PKCS1;
33-
}
3427
}

src/SignatureAlgorithm/RSA/RS512.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Jose\Component\Signature\Algorithm;
1515

16-
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
17-
18-
final class RS512 extends RSA
16+
final class RS512 extends RSAPKCS1
1917
{
2018
public function name(): string
2119
{
@@ -26,9 +24,4 @@ protected function getAlgorithm(): string
2624
{
2725
return 'sha512';
2826
}
29-
30-
protected function getSignatureMethod(): int
31-
{
32-
return JoseRSA::SIGNATURE_PKCS1;
33-
}
3427
}

src/SignatureAlgorithm/RSA/RSA.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@
1717
use Jose\Component\Core\JWK;
1818
use Jose\Component\Core\Util\RSAKey;
1919
use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA;
20+
use RuntimeException;
2021

22+
/**
23+
* @deprecated Please use either RSAPSS or RSAPKCS1 depending on the padding mode
24+
*/
2125
abstract class RSA implements SignatureAlgorithm
2226
{
27+
public function __construct()
28+
{
29+
if (!\extension_loaded('gmp')) {
30+
throw new RuntimeException(static::class.' requires gmp extension');
31+
}
32+
}
33+
2334
public function allowedKeyTypes(): array
2435
{
2536
return ['RSA'];

0 commit comments

Comments
 (0)