Skip to content

Commit

Permalink
Update and improve RSA keys handling and support (#548)
Browse files Browse the repository at this point in the history
* Update and improve RSA keys handling and support

This update enhances the RSA keys handling in the KeyConverter class, adding support for RSASSA-PSS encryption. It includes a new test case for RSASSA-PSS keys and upgrades the "spomky-labs/pki-framework" dependency, which provides underlying support for encryption algorithms. Key errors are now clarified with enhanced exception handling.

* Update PHPStan baseline with new types rules

The PHPStan baseline is updated to include newly identified type issues concerning return value types in iterable arrays for getSupportedTypes() method in both JWESerializer and JWSSerializer classes. Also, remove irrelevant default property type issues of various command classes thus reducing noise in the baseline file.
  • Loading branch information
Spomky authored Apr 3, 2024
1 parent 7347442 commit c755aaa
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 272 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"spomky-labs/aes-key-wrap": "^7.0",
"spomky-labs/pki-framework": "^1.0",
"spomky-labs/pki-framework": "^1.2.1",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
Expand Down
260 changes: 10 additions & 250 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,11 @@ parameters:
count: 1
path: src/Bundle/Serializer/JWESerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:getSupportedTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWESerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1041,6 +1046,11 @@ parameters:
count: 1
path: src/Bundle/Serializer/JWSSerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:getSupportedTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWSSerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1278,86 +1288,16 @@ parameters:
count: 1
path: src/Library/Checker/IssuerChecker.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/AddKeyIntoKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/AddKeyIntoKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/EcKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/EcKeyGeneratorCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: src/Library/Console/EcKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/EcKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/EcKeysetGeneratorCommand.php

-
message: "#^Method Jose\\\\Component\\\\Console\\\\GeneratorCommand\\:\\:getOptions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Library/Console/GeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/GetThumbprintCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/GetThumbprintCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/JKULoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/JKULoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/KeyAnalyzerCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/KeyAnalyzerCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/KeyFileLoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/KeyFileLoaderCommand.php

-
message: "#^Parameter \\#1 \\$jwk of method Jose\\\\Component\\\\KeyManagement\\\\Analyzer\\\\KeyAnalyzerManager\\:\\:analyze\\(\\) expects Jose\\\\Component\\\\Core\\\\JWK, mixed given\\.$#"
count: 1
Expand All @@ -1368,211 +1308,31 @@ parameters:
count: 1
path: src/Library/Console/KeysetAnalyzerCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/KeysetAnalyzerCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/KeysetAnalyzerCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/MergeKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/MergeKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/NoneKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/NoneKeyGeneratorCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: src/Library/Console/OctKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/OctKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/OctKeyGeneratorCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 2
path: src/Library/Console/OctKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/OctKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/OctKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/OkpKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/OkpKeyGeneratorCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: src/Library/Console/OkpKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/OkpKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/OkpKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/OptimizeRsaKeyCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/OptimizeRsaKeyCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/P12CertificateLoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/P12CertificateLoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/PemConverterCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/PemConverterCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/PublicKeyCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/PublicKeyCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/PublicKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/PublicKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/RotateKeysetCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/RotateKeysetCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: src/Library/Console/RsaKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/RsaKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/RsaKeyGeneratorCommand.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 2
path: src/Library/Console/RsaKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/RsaKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/RsaKeysetGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/SecretKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/SecretKeyGeneratorCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/X509CertificateLoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/X509CertificateLoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
count: 1
path: src/Library/Console/X5ULoaderCommand.php

-
message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
count: 1
path: src/Library/Console/X5ULoaderCommand.php

-
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Deprecated/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ext-mbstring": "*",
"brick/math": "^0.9|^0.10|^0.11|^0.12",
"paragonie/constant_time_encoding": "^2.6",
"spomky-labs/pki-framework": "^1.0",
"spomky-labs/pki-framework": "^1.2.1",
"web-token/jwt-library": "^3.3"
}
}
Loading

0 comments on commit c755aaa

Please sign in to comment.