diff --git a/performance/JWE/EncryptionBench.php b/performance/JWE/EncryptionBench.php index f7b47579e..f5922763e 100644 --- a/performance/JWE/EncryptionBench.php +++ b/performance/JWE/EncryptionBench.php @@ -48,8 +48,6 @@ abstract class EncryptionBench { private AlgorithmManager $algorithmsManager; - private CompressionMethodManager $compressionMethodsManager; - private JWESerializerManager $serializerManager; public function init(): void @@ -96,7 +94,7 @@ public function init(): void */ public function encryption(array $params): void { - $jweBuilder = new JWEBuilder($this->getAlgorithmsManager(), $this->getCompressionMethodsManager()); + $jweBuilder = new JWEBuilder($this->getAlgorithmsManager()); $jweBuilder ->withPayload($params['payload']) ->withAAD($this->getAAD()) @@ -113,7 +111,7 @@ public function encryption(array $params): void */ public function decryption(array $params): void { - $jweLoader = new JWEDecrypter($this->getAlgorithmsManager(), $this->getCompressionMethodsManager()); + $jweLoader = new JWEDecrypter($this->getAlgorithmsManager()); $jwe = $this->serializerManager->unserialize($params['input']); $keyset = JWKSet::createFromKeyData($params['recipient_keys']); $jweLoader->decryptUsingKeySet($jwe, $keyset, 0); @@ -138,9 +136,4 @@ private function getAlgorithmsManager(): AlgorithmManager { return $this->algorithmsManager; } - - private function getCompressionMethodsManager(): CompressionMethodManager - { - return $this->compressionMethodsManager; - } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6a45691fd..a51042964 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -751,7 +751,7 @@ parameters: path: src/Bundle/Helper/ConfigurationHelper.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Helper\\\\ConfigurationHelper\\:\\:addJWEBuilder\\(\\) has parameter \\$keyEncryptionAlgorithm with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Helper\\\\ConfigurationHelper\\:\\:addJWEBuilder\\(\\) has parameter \\$encryptionAlgorithm with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Helper/ConfigurationHelper.php @@ -771,7 +771,7 @@ parameters: path: src/Bundle/Helper/ConfigurationHelper.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Helper\\\\ConfigurationHelper\\:\\:addJWEDecrypter\\(\\) has parameter \\$keyEncryptionAlgorithm with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Helper\\\\ConfigurationHelper\\:\\:addJWEDecrypter\\(\\) has parameter \\$encryptionAlgorithm with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Helper/ConfigurationHelper.php @@ -1095,21 +1095,6 @@ parameters: count: 1 path: src/Bundle/Services/JWEDecrypter.php - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$compressionMethods with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWEDecrypterFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$contentEncryptionAlgorithms with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWEDecrypterFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWEDecrypterFactory.php - - message: """ #^Parameter \\$compressionMethodManagerFactory of method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:__construct\\(\\) has typehint with deprecated class Jose\\\\Component\\\\Encryption\\\\Compression\\\\CompressionMethodManagerFactory\\: @@ -1123,31 +1108,6 @@ parameters: count: 1 path: src/Bundle/Services/JWELoader.php - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$compressionMethods with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWELoaderFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$contentEncryptionAlgorithms with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWELoaderFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWELoaderFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWELoaderFactory.php - - - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$serializers with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Bundle/Services/JWELoaderFactory.php - - message: "#^Parameter \\#4 \\$signature of class Jose\\\\Bundle\\\\JoseFramework\\\\Event\\\\JWSLoadingSuccessEvent constructor expects int, int\\|null given\\.$#" count: 1 @@ -1189,17 +1149,17 @@ parameters: path: src/Bundle/Services/NestedTokenBuilderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$jwe_serializers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$encryptionAlgorithms with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenBuilderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$jws_serializers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$jwe_serializers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenBuilderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenBuilderFactory\\:\\:create\\(\\) has parameter \\$jws_serializers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenBuilderFactory.php @@ -1224,27 +1184,27 @@ parameters: path: src/Bundle/Services/NestedTokenLoaderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jweHeaderCheckers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$encryptionAlgorithms with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenLoaderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jweSerializers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jweHeaderCheckers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenLoaderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jwsHeaderCheckers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jweSerializers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenLoaderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jwsSerializers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jwsHeaderCheckers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenLoaderFactory.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\NestedTokenLoaderFactory\\:\\:create\\(\\) has parameter \\$jwsSerializers with no value type specified in iterable type array\\.$#" count: 1 path: src/Bundle/Services/NestedTokenLoaderFactory.php @@ -1779,12 +1739,12 @@ parameters: path: src/Library/Encryption/JWELoaderFactory.php - - message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$encryptionAlgorithms with no value type specified in iterable type array\\.$#" count: 1 path: src/Library/Encryption/JWELoaderFactory.php - - message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#" + message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#" count: 1 path: src/Library/Encryption/JWELoaderFactory.php diff --git a/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php b/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php index a162eb891..461a1db22 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php @@ -33,15 +33,18 @@ public function getNodeDefinition(NodeDefinition $node): void ->arrayNode('content_encryption_algorithms') ->info('A list of supported content encryption algorithms.') ->useAttributeAsKey('name') - ->isRequired() - ->requiresAtLeastOneElement() + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() ->arrayNode('compression_methods') ->info('A list of supported compression methods.') ->useAttributeAsKey('name') - ->defaultValue(['DEF']) + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php b/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php index 8a586c4af..2e5c8fe4e 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php @@ -26,8 +26,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setFactory([new Reference(JWEBuilderFactory::class), 'create']) ->setArguments([ $itemConfig['key_encryption_algorithms'], - $itemConfig['content_encryption_algorithms'], - $itemConfig['compression_methods'], + $itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'], + $itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'], ]) ->addTag('jose.jwe_builder') ->setPublic($itemConfig['is_public']); diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php b/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php index 212240ccb..66588aa4d 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php @@ -26,8 +26,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setFactory([new Reference(JWEDecrypterFactory::class), 'create']) ->setArguments([ $itemConfig['key_encryption_algorithms'], - $itemConfig['content_encryption_algorithms'], - $itemConfig['compression_methods'], + $itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'], + $itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'], ]) ->addTag('jose.jwe_decrypter') ->setPublic($itemConfig['is_public']); diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php b/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php index bf1ec4fb8..dde501ea1 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php @@ -29,8 +29,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setArguments([ $itemConfig['serializers'], $itemConfig['key_encryption_algorithms'], - $itemConfig['content_encryption_algorithms'], - $itemConfig['compression_methods'], + $itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'], + $itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'], $itemConfig['header_checkers'], ]) ->addTag('jose.jwe_loader') @@ -67,14 +67,18 @@ public function getNodeDefinition(NodeDefinition $node): void ->arrayNode('content_encryption_algorithms') ->info('A list of key encryption algorithm aliases.') ->useAttributeAsKey('name') - ->isRequired() + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() ->arrayNode('compression_methods') ->info('A list of compression method aliases.') ->useAttributeAsKey('name') - ->defaultValue(['DEF']) + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() diff --git a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php index cd08c901d..05c03f53b 100644 --- a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php +++ b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php @@ -29,8 +29,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setArguments([ $itemConfig['jwe_serializers'], $itemConfig['key_encryption_algorithms'], - $itemConfig['content_encryption_algorithms'], - $itemConfig['compression_methods'], + $itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'], + $itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'], $itemConfig['jws_serializers'], $itemConfig['signature_algorithms'], ]) @@ -74,14 +74,18 @@ public function getNodeDefinition(NodeDefinition $node): void ->arrayNode('content_encryption_algorithms') ->info('A list of key encryption algorithm aliases.') ->useAttributeAsKey('name') - ->isRequired() + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() ->arrayNode('compression_methods') ->info('A list of compression method aliases.') ->useAttributeAsKey('name') - ->defaultValue(['DEF']) + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() diff --git a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php index 85957aa01..077f35ef7 100644 --- a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php +++ b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php @@ -29,8 +29,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setArguments([ $itemConfig['jwe_serializers'], $itemConfig['key_encryption_algorithms'], - $itemConfig['content_encryption_algorithms'], - $itemConfig['compression_methods'], + $itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'], + $itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'], $itemConfig['jwe_header_checkers'], $itemConfig['jws_serializers'], $itemConfig['signature_algorithms'], @@ -76,14 +76,18 @@ public function getNodeDefinition(NodeDefinition $node): void ->arrayNode('content_encryption_algorithms') ->info('A list of key encryption algorithm aliases.') ->useAttributeAsKey('name') - ->isRequired() + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() ->arrayNode('compression_methods') ->info('A list of compression method aliases.') ->useAttributeAsKey('name') - ->defaultValue(['DEF']) + ->treatNullLike([]) + ->treatFalseLike([]) + ->defaultValue([]) ->scalarPrototype() ->end() ->end() diff --git a/src/Bundle/Helper/ConfigurationHelper.php b/src/Bundle/Helper/ConfigurationHelper.php index 1d840ca48..869dc7b80 100644 --- a/src/Bundle/Helper/ConfigurationHelper.php +++ b/src/Bundle/Helper/ConfigurationHelper.php @@ -18,7 +18,7 @@ public static function addJWSBuilder( ContainerBuilder $container, string $name, array $signatureAlgorithms, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -26,7 +26,7 @@ public static function addJWSBuilder( 'jws' => [ 'builders' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'signature_algorithms' => $signatureAlgorithms, 'tags' => $tags, ], @@ -44,7 +44,7 @@ public static function addJWSVerifier( ContainerBuilder $container, string $name, array $signatureAlgorithms, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -52,7 +52,7 @@ public static function addJWSVerifier( 'jws' => [ 'verifiers' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'signature_algorithms' => $signatureAlgorithms, 'tags' => $tags, ], @@ -71,7 +71,7 @@ public static function addJWSSerializer( ContainerBuilder $container, string $name, array $serializers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -79,7 +79,7 @@ public static function addJWSSerializer( 'jws' => [ 'serializers' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'serializers' => $serializers, 'tags' => $tags, ], @@ -93,16 +93,16 @@ public static function addJWSSerializer( /** * @param string[] $serializers - * @param string[] $signature_algorithms + * @param string[] $signatureAlgorithms * @param string[] $header_checkers */ public static function addJWSLoader( ContainerBuilder $container, string $name, array $serializers, - array $signature_algorithms, + array $signatureAlgorithms, array $header_checkers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -110,9 +110,9 @@ public static function addJWSLoader( 'jws' => [ 'loaders' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'serializers' => $serializers, - 'signature_algorithms' => $signature_algorithms, + 'signature_algorithms' => $signatureAlgorithms, 'header_checkers' => $header_checkers, 'tags' => $tags, ], @@ -125,43 +125,46 @@ public static function addJWSLoader( } /** - * @param string[] $jwe_serializers - * @param string[] $key_encryption_algorithms - * @param string[] $content_encryption_algorithms - * @param null|string[] $compression_methods - * @param string[] $jwe_header_checkers - * @param string[] $jws_serializers - * @param string[] $signature_algorithms - * @param string[] $jws_header_checkers + * @param string[] $jweSerializers + * @param string[] $encryptionAlgorithms + * @param null|string[] $contentEncryptionAlgorithms + * @param null|string[] $compressionMethods + * @param string[] $jweHeaderCheckers + * @param string[] $jwsSerializers + * @param string[] $signatureAlgorithms + * @param string[] $jwsHeaderCheckers */ public static function addNestedTokenLoader( ContainerBuilder $container, string $name, - array $jwe_serializers, - array $key_encryption_algorithms, - array $content_encryption_algorithms, - null|array $compression_methods, - array $jwe_header_checkers, - array $jws_serializers, - array $signature_algorithms, - array $jws_header_checkers, - bool $is_public = true, + array $jweSerializers, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, + null|array $compressionMethods, + array $jweHeaderCheckers, + array $jwsSerializers, + array $signatureAlgorithms, + array $jwsHeaderCheckers, + bool $isPublic = true, array $tags = [] ): void { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $config = [ self::BUNDLE_ALIAS => [ 'nested_token' => [ 'loaders' => [ $name => [ - 'is_public' => $is_public, - 'jwe_serializers' => $jwe_serializers, - 'key_encryption_algorithms' => $key_encryption_algorithms, - 'content_encryption_algorithms' => $content_encryption_algorithms, - 'compression_methods' => $compression_methods, - 'jwe_header_checkers' => $jwe_header_checkers, - 'jws_serializers' => $jws_serializers, - 'signature_algorithms' => $signature_algorithms, - 'jws_header_checkers' => $jws_header_checkers, + 'is_public' => $isPublic, + 'jwe_serializers' => $jweSerializers, + 'key_encryption_algorithms' => $encryptionAlgorithms, + 'content_encryption_algorithms' => null, + 'compression_methods' => $compressionMethods, + 'jwe_header_checkers' => $jweHeaderCheckers, + 'jws_serializers' => $jwsSerializers, + 'signature_algorithms' => $signatureAlgorithms, + 'jws_header_checkers' => $jwsHeaderCheckers, 'tags' => $tags, ], ], @@ -173,37 +176,40 @@ public static function addNestedTokenLoader( } /** - * @param string[] $jwe_serializers - * @param string[] $key_encryption_algorithms - * @param string[] $content_encryption_algorithms - * @param null|string[] $compression_methods - * @param string[] $jws_serializers - * @param string[] $signature_algorithms + * @param string[] $jweSerializers + * @param string[] $encryptionAlgorithms + * @param null|string[] $contentEncryptionAlgorithms + * @param null|string[] $compressionMethods + * @param string[] $jwsSerializers + * @param string[] $signatureAlgorithms */ public static function addNestedTokenBuilder( ContainerBuilder $container, string $name, - array $jwe_serializers, - array $key_encryption_algorithms, - array $content_encryption_algorithms, - null|array $compression_methods, - array $jws_serializers, - array $signature_algorithms, - bool $is_public = true, + array $jweSerializers, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, + null|array $compressionMethods, + array $jwsSerializers, + array $signatureAlgorithms, + bool $isPublic = true, array $tags = [] ): void { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $config = [ self::BUNDLE_ALIAS => [ 'nested_token' => [ 'builders' => [ $name => [ - 'is_public' => $is_public, - 'jwe_serializers' => $jwe_serializers, - 'key_encryption_algorithms' => $key_encryption_algorithms, - 'content_encryption_algorithms' => $content_encryption_algorithms, - 'compression_methods' => $compression_methods, - 'jws_serializers' => $jws_serializers, - 'signature_algorithms' => $signature_algorithms, + 'is_public' => $isPublic, + 'jwe_serializers' => $jweSerializers, + 'key_encryption_algorithms' => $encryptionAlgorithms, + 'content_encryption_algorithms' => null, + 'compression_methods' => $compressionMethods, + 'jws_serializers' => $jwsSerializers, + 'signature_algorithms' => $signatureAlgorithms, 'tags' => $tags, ], ], @@ -221,7 +227,7 @@ public static function addJWESerializer( ContainerBuilder $container, string $name, array $serializers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -229,7 +235,7 @@ public static function addJWESerializer( 'jwe' => [ 'serializers' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'serializers' => $serializers, 'tags' => $tags, ], @@ -243,32 +249,35 @@ public static function addJWESerializer( /** * @param string[] $serializers - * @param string[] $key_encryption_algorithms - * @param string[] $content_encryption_algorithms - * @param null|string[] $compression_methods + * @param string[] $encryptionAlgorithms + * @param null|string[] $contentEncryptionAlgorithms + * @param null|string[] $compressionMethods * @param string[] $header_checkers */ public static function addJWELoader( ContainerBuilder $container, string $name, array $serializers, - array $key_encryption_algorithms, - array $content_encryption_algorithms, - null|array $compression_methods, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, + null|array $compressionMethods, array $header_checkers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $config = [ self::BUNDLE_ALIAS => [ 'jwe' => [ 'loaders' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'serializers' => $serializers, - 'key_encryption_algorithms' => $key_encryption_algorithms, - 'content_encryption_algorithms' => $content_encryption_algorithms, - 'compression_methods' => $compression_methods, + 'key_encryption_algorithms' => $encryptionAlgorithms, + 'content_encryption_algorithms' => null, + 'compression_methods' => $compressionMethods, 'header_checkers' => $header_checkers, 'tags' => $tags, ], @@ -287,7 +296,7 @@ public static function addClaimChecker( ContainerBuilder $container, string $name, array $claimCheckers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -295,7 +304,7 @@ public static function addClaimChecker( 'checkers' => [ 'claims' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'claims' => $claimCheckers, 'tags' => $tags, ], @@ -314,7 +323,7 @@ public static function addHeaderChecker( ContainerBuilder $container, string $name, array $headerCheckers, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { $config = [ @@ -322,7 +331,7 @@ public static function addHeaderChecker( 'checkers' => [ 'headers' => [ $name => [ - 'is_public' => $is_public, + 'is_public' => $isPublic, 'headers' => $headerCheckers, 'tags' => $tags, ], @@ -339,10 +348,10 @@ public static function addKey( string $name, string $type, array $parameters, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { - $parameters['is_public'] = $is_public; + $parameters['is_public'] = $isPublic; $parameters['tags'] = $tags; $config = [ self::BUNDLE_ALIAS => [ @@ -362,10 +371,10 @@ public static function addKeyset( string $name, string $type, array $parameters, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { - $parameters['is_public'] = $is_public; + $parameters['is_public'] = $isPublic; $parameters['tags'] = $tags; $config = [ self::BUNDLE_ALIAS => [ @@ -384,10 +393,10 @@ public static function addKeyUri( ContainerBuilder $container, string $name, array $parameters, - bool $is_public = true, + bool $isPublic = true, array $tags = [] ): void { - $parameters['is_public'] = $is_public; + $parameters['is_public'] = $isPublic; $parameters['tags'] = $tags; $config = [ self::BUNDLE_ALIAS => [ @@ -403,20 +412,24 @@ public static function addKeyUri( public static function addJWEBuilder( ContainerBuilder $container, string $name, - array $keyEncryptionAlgorithm, - array $contentEncryptionAlgorithms, - array $compressionMethods = ['DEF'], - bool $is_public = true, + array $encryptionAlgorithm, + null|array $contentEncryptionAlgorithms = null, + null|array $compressionMethods = null, + bool $isPublic = true, array $tags = [] ): void { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithm = array_merge($encryptionAlgorithm, $contentEncryptionAlgorithms); + } + $config = [ self::BUNDLE_ALIAS => [ 'jwe' => [ 'builders' => [ $name => [ - 'is_public' => $is_public, - 'key_encryption_algorithms' => $keyEncryptionAlgorithm, - 'content_encryption_algorithms' => $contentEncryptionAlgorithms, + 'is_public' => $isPublic, + 'key_encryption_algorithms' => $encryptionAlgorithm, + 'content_encryption_algorithms' => null, 'compression_methods' => $compressionMethods, 'tags' => $tags, ], @@ -431,20 +444,24 @@ public static function addJWEBuilder( public static function addJWEDecrypter( ContainerBuilder $container, string $name, - array $keyEncryptionAlgorithm, - array $contentEncryptionAlgorithms, - array $compressionMethods = ['DEF'], - bool $is_public = true, + array $encryptionAlgorithm, + null|array $contentEncryptionAlgorithms, + null|array $compressionMethods = null, + bool $isPublic = true, array $tags = [] ): void { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithm = array_merge($encryptionAlgorithm, $contentEncryptionAlgorithms); + } + $config = [ self::BUNDLE_ALIAS => [ 'jwe' => [ 'decrypters' => [ $name => [ - 'is_public' => $is_public, - 'key_encryption_algorithms' => $keyEncryptionAlgorithm, - 'content_encryption_algorithms' => $contentEncryptionAlgorithms, + 'is_public' => $isPublic, + 'key_encryption_algorithms' => $encryptionAlgorithm, + 'content_encryption_algorithms' => null, 'compression_methods' => $compressionMethods, 'tags' => $tags, ], diff --git a/src/Bundle/Resources/config/compression_methods.php b/src/Bundle/Resources/config/compression_methods.php index 91d0aca4b..6a976d179 100644 --- a/src/Bundle/Resources/config/compression_methods.php +++ b/src/Bundle/Resources/config/compression_methods.php @@ -16,7 +16,7 @@ $container->set(CompressionMethodManagerFactory::class) ->deprecate( 'web-token/jwt-bundle', - '3.3.X', + '3.3.0', 'The "%service_id%" service is deprecated and will be removed in version 4.0. Compression is not recommended for the JWE.' ) ->public(); @@ -24,7 +24,7 @@ $container->set(Deflate::class) ->deprecate( 'web-token/jwt-bundle', - '3.3.X', + '3.3.0', 'The "%service_id%" service is deprecated and will be removed in version 4.0. Compression is not recommended for the JWE.' ) ->tag('jose.compression_method', [ diff --git a/src/Bundle/Services/JWEBuilderFactory.php b/src/Bundle/Services/JWEBuilderFactory.php index eef507812..f1367d173 100644 --- a/src/Bundle/Services/JWEBuilderFactory.php +++ b/src/Bundle/Services/JWEBuilderFactory.php @@ -27,18 +27,24 @@ public function __construct( /** * This method creates a JWEBuilder using the given algorithm aliases. * - * @param string[] $keyEncryptionAlgorithms + * @param string[] $encryptionAlgorithms * @param string[] $contentEncryptionAlgorithms * @param null|string[] $compressionMethods */ public function create( - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms = null, null|array $compressionMethods = null ): JWEBuilder { - $algorithmManager = $this->algorithmManagerFactory->create( - array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms) - ); + if ($contentEncryptionAlgorithms !== null) { + trigger_deprecation( + 'web-token/jwt-library', + '3.3.0', + 'The parameter "$contentEncryptionAlgorithms" is deprecated and will be removed in 4.0.0. Please set "null" instead.' + ); + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } + $algorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); if ($compressionMethods !== null) { trigger_deprecation( 'web-token/jwt-library', diff --git a/src/Bundle/Services/JWEDecrypter.php b/src/Bundle/Services/JWEDecrypter.php index f1fc05c65..844654b4b 100644 --- a/src/Bundle/Services/JWEDecrypter.php +++ b/src/Bundle/Services/JWEDecrypter.php @@ -17,12 +17,12 @@ final class JWEDecrypter extends BaseJWEDecrypter { public function __construct( - AlgorithmManager $keyEncryptionAlgorithmManager, - AlgorithmManager $contentEncryptionAlgorithmManager, + AlgorithmManager $algorithmManager, + null|AlgorithmManager $contentEncryptionAlgorithmManager, null|CompressionMethodManager $compressionMethodManager, private readonly EventDispatcherInterface $eventDispatcher ) { - parent::__construct($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager); + parent::__construct($algorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager); } public function decryptUsingKeySet( diff --git a/src/Bundle/Services/JWEDecrypterFactory.php b/src/Bundle/Services/JWEDecrypterFactory.php index 16e6d67ca..4e32d65f5 100644 --- a/src/Bundle/Services/JWEDecrypterFactory.php +++ b/src/Bundle/Services/JWEDecrypterFactory.php @@ -24,13 +24,26 @@ public function __construct( } } + /** + * @param array $encryptionAlgorithms + * @param null|array $contentEncryptionAlgorithms + * @param null|array $compressionMethods + */ public function create( - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms = null, null|array $compressionMethods = null ): JWEDecrypter { - $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms); - $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithms); + if ($contentEncryptionAlgorithms !== null) { + trigger_deprecation( + 'web-token/jwt-library', + '3.3.0', + 'The parameter "$contentEncryptionAlgorithms" is deprecated and will be removed in 4.0.0. Please set all algorithms in the first argument and set "null" instead.' + ); + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } + + $encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); if ($compressionMethods !== null) { trigger_deprecation( 'web-token/jwt-library', @@ -43,8 +56,8 @@ public function create( ); return new JWEDecrypter( - $keyEncryptionAlgorithmManager, - $contentEncryptionAlgorithmManager, + $encryptionAlgorithmManager, + null, $compressionMethodManager, $this->eventDispatcher ); diff --git a/src/Bundle/Services/JWELoaderFactory.php b/src/Bundle/Services/JWELoaderFactory.php index 349cacf4c..20e03436b 100644 --- a/src/Bundle/Services/JWELoaderFactory.php +++ b/src/Bundle/Services/JWELoaderFactory.php @@ -17,19 +17,30 @@ public function __construct( ) { } + /** + * @param array $serializers + * @param array $encryptionAlgorithms + * @param array|null $contentEncryptionAlgorithms + * @param array|null $compressionMethods + * @param array $headerCheckers + */ public function create( array $serializers, - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, - null|array $compressionMethods, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms = null, + null|array $compressionMethods = null, array $headerCheckers = [] ): JWELoader { + if ($contentEncryptionAlgorithms !== null) { + trigger_deprecation( + 'web-token/jwt-library', + '3.3.0', + 'The parameter "$contentEncryptionAlgorithms" is deprecated and will be removed in 4.0.0. Please set "null" instead.' + ); + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $serializerManager = $this->jweSerializerManagerFactory->create($serializers); - $jweDecrypter = $this->jweDecrypterFactory->create( - $keyEncryptionAlgorithms, - $contentEncryptionAlgorithms, - $compressionMethods - ); + $jweDecrypter = $this->jweDecrypterFactory->create($encryptionAlgorithms, null, $compressionMethods); if ($this->headerCheckerManagerFactory !== null) { $headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers); } else { diff --git a/src/Bundle/Services/NestedTokenBuilderFactory.php b/src/Bundle/Services/NestedTokenBuilderFactory.php index f0badc204..e49f7de4c 100644 --- a/src/Bundle/Services/NestedTokenBuilderFactory.php +++ b/src/Bundle/Services/NestedTokenBuilderFactory.php @@ -21,17 +21,16 @@ public function __construct( public function create( array $jwe_serializers, - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, null|array $compressionMethods, array $jws_serializers, array $signatureAlgorithms ): NestedTokenBuilder { - $jweBuilder = $this->jweBuilderFactory->create( - $keyEncryptionAlgorithms, - $contentEncryptionAlgorithms, - $compressionMethods - ); + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } + $jweBuilder = $this->jweBuilderFactory->create($encryptionAlgorithms, null, $compressionMethods); $jweSerializerManager = $this->jweSerializerManagerFactory->create($jwe_serializers); $jwsBuilder = $this->jwsBuilderFactory->create($signatureAlgorithms); $jwsSerializerManager = $this->jwsSerializerManagerFactory->create($jws_serializers); diff --git a/src/Bundle/Services/NestedTokenLoaderFactory.php b/src/Bundle/Services/NestedTokenLoaderFactory.php index f00be3627..8b5840be1 100644 --- a/src/Bundle/Services/NestedTokenLoaderFactory.php +++ b/src/Bundle/Services/NestedTokenLoaderFactory.php @@ -17,18 +17,21 @@ public function __construct( public function create( array $jweSerializers, - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, null|array $compressionMethods, array $jweHeaderCheckers, array $jwsSerializers, array $signatureAlgorithms, array $jwsHeaderCheckers ): NestedTokenLoader { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $jweLoader = $this->jweLoaderFactory->create( $jweSerializers, - $keyEncryptionAlgorithms, - $contentEncryptionAlgorithms, + $encryptionAlgorithms, + null, $compressionMethods, $jweHeaderCheckers ); diff --git a/src/Library/Encryption/JWEBuilder.php b/src/Library/Encryption/JWEBuilder.php index 73d70d451..0d3421807 100644 --- a/src/Library/Encryption/JWEBuilder.php +++ b/src/Library/Encryption/JWEBuilder.php @@ -51,7 +51,7 @@ class JWEBuilder public function __construct( AlgorithmManager $algorithmManager, - null|AlgorithmManager $contentEncryptionAlgorithmManager, + null|AlgorithmManager $contentEncryptionAlgorithmManager = null, private readonly null|CompressionMethodManager $compressionManager = null ) { if ($compressionManager !== null) { diff --git a/src/Library/Encryption/JWEBuilderFactory.php b/src/Library/Encryption/JWEBuilderFactory.php index 23f8de942..038050898 100644 --- a/src/Library/Encryption/JWEBuilderFactory.php +++ b/src/Library/Encryption/JWEBuilderFactory.php @@ -26,25 +26,28 @@ public function __construct( * Creates a JWE Builder object using the given key encryption algorithms, content encryption algorithms and * compression methods. * - * @param string[] $keyEncryptionAlgorithms - * @param string[] $contentEncryptionAlgorithm + * @param array $encryptionAlgorithms + * @param null|array $contentEncryptionAlgorithm * @param null|string[] $compressionMethods */ public function create( - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithm, - null|array $compressionMethods + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithm = null, + null|array $compressionMethods = null ): JWEBuilder { - $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms); - $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm); + if ($contentEncryptionAlgorithm !== null) { + trigger_deprecation( + 'web-token/jwt-library', + '3.3.0', + 'The parameter "$contentEncryptionAlgorithm" is deprecated and will be removed in 4.0.0. Please set "null" instead.' + ); + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithm); + } + $encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); $compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create( $compressionMethods ); - return new JWEBuilder( - $keyEncryptionAlgorithmManager, - $contentEncryptionAlgorithmManager, - $compressionMethodManager - ); + return new JWEBuilder($encryptionAlgorithmManager, null, $compressionMethodManager); } } diff --git a/src/Library/Encryption/JWEDecrypterFactory.php b/src/Library/Encryption/JWEDecrypterFactory.php index f4e72ac84..0df9b7dae 100644 --- a/src/Library/Encryption/JWEDecrypterFactory.php +++ b/src/Library/Encryption/JWEDecrypterFactory.php @@ -26,18 +26,20 @@ public function __construct( * Creates a JWE Decrypter object using the given key encryption algorithms, content encryption algorithms and * compression methods. * - * @param string[] $keyEncryptionAlgorithms - * @param string[] $contentEncryptionAlgorithms + * @param string[] $encryptionAlgorithms + * @param null|string[] $contentEncryptionAlgorithms * @param null|string[] $compressionMethods */ public function create( - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, - null|array $compressionMethods + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms = null, + null|array $compressionMethods = null ): JWEDecrypter { - $algorithmManager = $this->algorithmManagerFactory->create( - array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms) - ); + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } + + $algorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); $compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create( $compressionMethods ); diff --git a/src/Library/Encryption/JWELoaderFactory.php b/src/Library/Encryption/JWELoaderFactory.php index dca68bbd3..98159109a 100644 --- a/src/Library/Encryption/JWELoaderFactory.php +++ b/src/Library/Encryption/JWELoaderFactory.php @@ -22,17 +22,16 @@ public function __construct( */ public function create( array $serializers, - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, - null|array $compressionMethods, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms = null, + null|array $compressionMethods = null, array $headerCheckers = [] ): JWELoader { + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } $serializerManager = $this->jweSerializerManagerFactory->create($serializers); - $jweDecrypter = $this->jweDecrypterFactory->create( - $keyEncryptionAlgorithms, - $contentEncryptionAlgorithms, - $compressionMethods - ); + $jweDecrypter = $this->jweDecrypterFactory->create($encryptionAlgorithms, null, $compressionMethods); if ($this->headerCheckerManagerFactory !== null) { $headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers); } else { diff --git a/src/Library/NestedToken/NestedTokenBuilderFactory.php b/src/Library/NestedToken/NestedTokenBuilderFactory.php index a1167d914..f3f9259ff 100644 --- a/src/Library/NestedToken/NestedTokenBuilderFactory.php +++ b/src/Library/NestedToken/NestedTokenBuilderFactory.php @@ -24,25 +24,24 @@ public function __construct( * compression methods. * * @param array $jwe_serializers - * @param array $keyEncryptionAlgorithms - * @param array $contentEncryptionAlgorithms + * @param array $encryptionAlgorithms + * @param null|array $contentEncryptionAlgorithms * @param null|array $compressionMethods * @param array $jws_serializers * @param array $signatureAlgorithms */ public function create( array $jwe_serializers, - array $keyEncryptionAlgorithms, - array $contentEncryptionAlgorithms, + array $encryptionAlgorithms, + null|array $contentEncryptionAlgorithms, null|array $compressionMethods, array $jws_serializers, array $signatureAlgorithms ): NestedTokenBuilder { - $jweBuilder = $this->jweBuilderFactory->create( - $keyEncryptionAlgorithms, - $contentEncryptionAlgorithms, - $compressionMethods - ); + if ($contentEncryptionAlgorithms !== null) { + $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); + } + $jweBuilder = $this->jweBuilderFactory->create($encryptionAlgorithms, null, $compressionMethods); $jweSerializerManager = $this->jweSerializerManagerFactory->create($jwe_serializers); $jwsBuilder = $this->jwsBuilderFactory->create($signatureAlgorithms); $jwsSerializerManager = $this->jwsSerializerManagerFactory->create($jws_serializers); diff --git a/tests/Bundle/JoseFramework/Functional/Encryption/JWEBuilderTest.php b/tests/Bundle/JoseFramework/Functional/Encryption/JWEBuilderTest.php index 9e8cf6786..f6ccb73b0 100644 --- a/tests/Bundle/JoseFramework/Functional/Encryption/JWEBuilderTest.php +++ b/tests/Bundle/JoseFramework/Functional/Encryption/JWEBuilderTest.php @@ -44,7 +44,7 @@ public static function theJWEBuilderFactoryCanCreateAJWEBuilder(): void $jweFactory = $container->get(JWEBuilderFactoryService::class); static::assertInstanceOf(JWEBuilderFactoryService::class, $jweFactory); - $jweFactory->create(['RSA1_5'], ['A256GCM'], ['DEF']); + $jweFactory->create(['RSA1_5', 'A256GCM']); } #[Test] diff --git a/tests/Bundle/JoseFramework/Functional/Encryption/JWEDecrypterTest.php b/tests/Bundle/JoseFramework/Functional/Encryption/JWEDecrypterTest.php index 651a70c46..d9581be3f 100644 --- a/tests/Bundle/JoseFramework/Functional/Encryption/JWEDecrypterTest.php +++ b/tests/Bundle/JoseFramework/Functional/Encryption/JWEDecrypterTest.php @@ -34,7 +34,7 @@ public static function theJWEDecrypterFactoryIsAvailable(): void } #[Test] - public static function theWEDecrypterFactoryCanCreateAJWEDecrypter(): void + public static function theJWEDecrypterFactoryCanCreateAJWEDecrypter(): void { static::ensureKernelShutdown(); $client = static::createClient(); @@ -44,7 +44,7 @@ public static function theWEDecrypterFactoryCanCreateAJWEDecrypter(): void $jweFactory = $container->get(JWEDecrypterFactoryService::class); static::assertInstanceOf(JWEDecrypterFactoryService::class, $jweFactory); - $jweFactory->create(['RSA1_5'], ['A256GCM'], ['DEF']); + $jweFactory->create(['RSA1_5', 'A256GCM']); } #[Test] diff --git a/tests/Bundle/JoseFramework/Functional/Encryption/JWELoaderTest.php b/tests/Bundle/JoseFramework/Functional/Encryption/JWELoaderTest.php index a2f51b62d..370400add 100644 --- a/tests/Bundle/JoseFramework/Functional/Encryption/JWELoaderTest.php +++ b/tests/Bundle/JoseFramework/Functional/Encryption/JWELoaderTest.php @@ -44,12 +44,11 @@ public static function theWELoaderFactoryCanCreateAJWELoader(): void $jweLoaderFactory = $container->get(JWELoaderFactoryAlias::class); static::assertInstanceOf(JWELoaderFactoryAlias::class, $jweLoaderFactory); - $jwe = $jweLoaderFactory->create(['jwe_compact'], ['RSA1_5'], ['A256GCM'], ['DEF']); + $jwe = $jweLoaderFactory->create(['jwe_compact'], ['RSA1_5'], ['A256GCM']); static::assertSame(['jwe_compact'], $jwe->getSerializerManager()->names()); static::assertSame(['RSA1_5'], $jwe->getJweDecrypter()->getKeyEncryptionAlgorithmManager()->list()); static::assertSame(['A256GCM'], $jwe->getJweDecrypter()->getContentEncryptionAlgorithmManager()->list()); - static::assertSame(['DEF'], $jwe->getJweDecrypter()->getCompressionMethodManager()->list()); } #[Test] diff --git a/tests/Bundle/JoseFramework/Functional/Encryption/JweBuilderConfigurationTest.php b/tests/Bundle/JoseFramework/Functional/Encryption/JweBuilderConfigurationTest.php index 87cd29245..db97ba94b 100644 --- a/tests/Bundle/JoseFramework/Functional/Encryption/JweBuilderConfigurationTest.php +++ b/tests/Bundle/JoseFramework/Functional/Encryption/JweBuilderConfigurationTest.php @@ -100,45 +100,6 @@ public function theConfigurationIsInvalidIfTheKeyEncryptionAlgorithmIsEmpty(): v ); } - #[Test] - public function theConfigurationIsInvalidIfNotContentEncryptionAlgorithmIsSet(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'jwe' => [ - 'builders' => [ - 'foo' => [ - 'key_encryption_algorithms' => ['A256GCMKW'], - ], - ], - ], - ], - ], - 'The child config "content_encryption_algorithms" under "jose.jwe.builders.foo" must be configured:' - ); - } - - #[Test] - public function theConfigurationIsInvalidIfTheContentEncryptionAlgorithmIsEmpty(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'jwe' => [ - 'builders' => [ - 'foo' => [ - 'key_encryption_algorithms' => ['A256GCMKW'], - 'content_encryption_algorithms' => [], - ], - ], - ], - ], - ], - 'The path "jose.jwe.builders.foo.content_encryption_algorithms" should have at least 1 element(s) defined.' - ); - } - protected function getConfiguration(): Configuration { return new Configuration('jose', [new CoreSource(), new EncryptionSource()]); diff --git a/tests/Bundle/JoseFramework/Functional/Encryption/JweDecrypterConfigurationTest.php b/tests/Bundle/JoseFramework/Functional/Encryption/JweDecrypterConfigurationTest.php index 8d5d1dd61..b04588aef 100644 --- a/tests/Bundle/JoseFramework/Functional/Encryption/JweDecrypterConfigurationTest.php +++ b/tests/Bundle/JoseFramework/Functional/Encryption/JweDecrypterConfigurationTest.php @@ -100,45 +100,6 @@ public function theConfigurationIsInvalidIfTheKeyEncryptionAlgorithmIsEmpty(): v ); } - #[Test] - public function theConfigurationIsInvalidIfNotContentEncryptionAlgorithmIsSet(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'jwe' => [ - 'decrypters' => [ - 'foo' => [ - 'key_encryption_algorithms' => ['A256GCMKW'], - ], - ], - ], - ], - ], - 'The child config "content_encryption_algorithms" under "jose.jwe.decrypters.foo" must be configured:' - ); - } - - #[Test] - public function theConfigurationIsInvalidIfTheContentEncryptionAlgorithmIsEmpty(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'jwe' => [ - 'decrypters' => [ - 'foo' => [ - 'key_encryption_algorithms' => ['A256GCMKW'], - 'content_encryption_algorithms' => [], - ], - ], - ], - ], - ], - 'The path "jose.jwe.decrypters.foo.content_encryption_algorithms" should have at least 1 element(s) defined.' - ); - } - protected function getConfiguration(): Configuration { return new Configuration('jose', [new CoreSource(), new EncryptionSource()]); diff --git a/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenBuilderConfigurationTest.php b/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenBuilderConfigurationTest.php index e89bb31c7..55d9e955a 100644 --- a/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenBuilderConfigurationTest.php +++ b/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenBuilderConfigurationTest.php @@ -103,26 +103,6 @@ public function theConfigurationIsInvalidIfNoKeyEncryptionAlgorithmIsSet(): void ); } - #[Test] - public function theConfigurationIsInvalidIfNoContentEncryptionAlgorithmIsSet(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'nested_token' => [ - 'builders' => [ - 'foo' => [ - 'signature_algorithms' => ['RS256'], - 'key_encryption_algorithms' => ['RSA-OAEP'], - ], - ], - ], - ], - ], - 'The child config "content_encryption_algorithms" under "jose.nested_token.builders.foo" must be configured:' - ); - } - #[Test] public function theConfigurationIsInvalidIfNoJwsSerializerIsSet(): void { diff --git a/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenLoaderConfigurationTest.php b/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenLoaderConfigurationTest.php index 303e1fa18..879fa5b8e 100644 --- a/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenLoaderConfigurationTest.php +++ b/tests/Bundle/JoseFramework/Functional/NestedToken/NestedTokenLoaderConfigurationTest.php @@ -103,26 +103,6 @@ public function theConfigurationIsInvalidIfNoKeyEncryptionAlgorithmIsSet(): void ); } - #[Test] - public function theConfigurationIsInvalidIfNoContentEncryptionAlgorithmIsSet(): void - { - $this->assertConfigurationIsInvalid( - [ - [ - 'nested_token' => [ - 'loaders' => [ - 'foo' => [ - 'signature_algorithms' => ['RS256'], - 'key_encryption_algorithms' => ['RSA-OAEP'], - ], - ], - ], - ], - ], - 'The child config "content_encryption_algorithms" under "jose.nested_token.loaders.foo" must be configured:' - ); - } - #[Test] public function theConfigurationIsInvalidIfNoJwsSerializerIsSet(): void { diff --git a/tests/Bundle/JoseFramework/Functional/Serializer/JWEEncoderTest.php b/tests/Bundle/JoseFramework/Functional/Serializer/JWEEncoderTest.php index 1354f2c9d..84ed622a5 100644 --- a/tests/Bundle/JoseFramework/Functional/Serializer/JWEEncoderTest.php +++ b/tests/Bundle/JoseFramework/Functional/Serializer/JWEEncoderTest.php @@ -227,7 +227,7 @@ private static function createJWE(): array $jweSerializerManager = $jweSerializerManagerFactory->create($jweSerializerManagerFactory->names()); static::assertInstanceOf(JWESerializerManager::class, $jweSerializerManager); - $builder = $jweFactory->create(['A256KW'], ['A256CBC-HS512'], []); + $builder = $jweFactory->create(['A256KW', 'A256CBC-HS512']); $jwk = new JWK([ 'kty' => 'oct', diff --git a/tests/Bundle/JoseFramework/Functional/Serializer/JWESerializerTest.php b/tests/Bundle/JoseFramework/Functional/Serializer/JWESerializerTest.php index 833a5c973..077a14f56 100644 --- a/tests/Bundle/JoseFramework/Functional/Serializer/JWESerializerTest.php +++ b/tests/Bundle/JoseFramework/Functional/Serializer/JWESerializerTest.php @@ -95,7 +95,7 @@ private function createJWE(): array $jweSerializerManager = $jweSerializerManagerFactory->create($jweSerializerManagerFactory->names()); static::assertInstanceOf(JWESerializerManager::class, $jweSerializerManager); - $builder = $jweFactory->create(['A256KW'], ['A256CBC-HS512'], []); + $builder = $jweFactory->create(['A256KW', 'A256CBC-HS512']); $jwk = new JWK([ 'kty' => 'oct', diff --git a/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php b/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php index 605b08661..551f536b0 100644 --- a/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php +++ b/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php @@ -44,8 +44,8 @@ public function prepend(ContainerBuilder $container): void true ); ConfigurationHelper::addJWSLoader($container, 'jws_loader2', ['jws_compact'], ['HS512'], [], true); - ConfigurationHelper::addJWEBuilder($container, 'builder2', ['RSA-OAEP-256'], ['A128GCM'], ['DEF'], true); - ConfigurationHelper::addJWEDecrypter($container, 'loader2', ['RSA-OAEP-256'], ['A128GCM'], ['DEF'], true); + ConfigurationHelper::addJWEBuilder($container, 'builder2', ['RSA-OAEP-256', 'A128GCM'], null, null, true); + ConfigurationHelper::addJWEDecrypter($container, 'loader2', ['RSA-OAEP-256', 'A128GCM'], null, null, true); ConfigurationHelper::addJWESerializer( $container, 'jwe_serializer2', @@ -56,9 +56,9 @@ public function prepend(ContainerBuilder $container): void $container, 'jwe_loader2', ['jwe_compact'], - ['RSA-OAEP-256'], - ['A128GCM'], - ['DEF'], + ['RSA-OAEP-256', 'A128GCM'], + null, + null, [], true ); @@ -66,9 +66,9 @@ public function prepend(ContainerBuilder $container): void $container, 'nested_token_loader_2', ['jwe_compact'], - ['RSA-OAEP'], - ['A128GCM'], - ['DEF'], + ['RSA-OAEP', 'A128GCM'], + null, + null, [], ['jws_compact'], ['PS256'], @@ -80,9 +80,9 @@ public function prepend(ContainerBuilder $container): void $container, 'nested_token_builder_2', ['jwe_compact'], - ['RSA-OAEP'], - ['A128GCM'], - ['DEF'], + ['RSA-OAEP', 'A128GCM'], + null, + null, ['jws_compact'], ['PS256'], true, diff --git a/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php b/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php index a86a02040..bc68dcd0b 100644 --- a/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php +++ b/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php @@ -34,9 +34,9 @@ public function a128CBCHS256EncryptAndDecrypt(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES+A128KW'], ['A128GCM'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A128KW'], ['A128GCM'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128GCM']); $jwt = $jweBuilder ->create() diff --git a/tests/Component/Encryption/EncrypterTest.php b/tests/Component/Encryption/EncrypterTest.php index 9173f8ece..368723ddf 100644 --- a/tests/Component/Encryption/EncrypterTest.php +++ b/tests/Component/Encryption/EncrypterTest.php @@ -20,9 +20,9 @@ final class EncrypterTest extends EncryptionTestCase public function encryptWithJWTInput(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -30,7 +30,6 @@ public function encryptWithJWTInput(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->withAAD('foo,bar,baz') ->addRecipient($this->getRSARecipientKey()) @@ -44,7 +43,6 @@ public function encryptWithJWTInput(): void static::assertSame('RSA-OAEP-256', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertSame('DEF', $loaded->getSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -55,10 +53,10 @@ public function encryptWithJWTInput(): void public function duplicatedHeader(): void { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('The header contains duplicated entries: zip.'); + $this->expectExceptionMessage('The header contains duplicated entries: alg.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweBuilder ->create() @@ -66,10 +64,9 @@ public function duplicatedHeader(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey(), [ - 'zip' => 'DEF', + 'alg' => 'RSA-OAEP-256', ]); } @@ -77,9 +74,9 @@ public function duplicatedHeader(): void public function createCompactJWEUsingFactory(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -87,7 +84,6 @@ public function createCompactJWEUsingFactory(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -99,7 +95,6 @@ public function createCompactJWEUsingFactory(): void static::assertSame('RSA-OAEP-256', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertSame('DEF', $loaded->getSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -111,9 +106,9 @@ public function createCompactJWEUsingFactory(): void public function createFlattenedJWEUsingFactory(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -121,7 +116,6 @@ public function createFlattenedJWEUsingFactory(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->withSharedHeader([ 'foo' => 'bar', @@ -139,7 +133,6 @@ public function createFlattenedJWEUsingFactory(): void static::assertSame('RSA-OAEP-256', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertSame('DEF', $loaded->getSharedProtectedHeaderParameter('zip')); static::assertSame('bar', $loaded->getSharedHeaderParameter('foo')); static::assertSame('A,B,C,D', $loaded->getAAD()); static::assertSame('ploc', $loaded->getRecipient(0)->getHeaderParameter('plic')); @@ -154,9 +147,9 @@ public function createFlattenedJWEUsingFactory(): void public function encryptAndLoadFlattenedWithAAD(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -164,7 +157,6 @@ public function encryptAndLoadFlattenedWithAAD(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->withAAD('foo,bar,baz') @@ -177,7 +169,6 @@ public function encryptAndLoadFlattenedWithAAD(): void static::assertSame('RSA-OAEP-256', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertSame('DEF', $loaded->getSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -188,30 +179,6 @@ public function encryptAndLoadFlattenedWithAAD(): void ); } - #[Test] - public function compressionAlgorithmNotSupported(): void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('The compression method "FIP" is not supported.'); - - $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); - - $jwe = $jweBuilder - ->create() - ->withPayload(json_encode($this->getKeyToEncrypt(), JSON_THROW_ON_ERROR)) - ->withSharedProtectedHeader([ - 'enc' => 'A256CBC-HS512', - 'alg' => 'RSA-OAEP-256', - 'zip' => 'FIP', - ]) - ->addRecipient($this->getRSARecipientKey()) - ->withAAD('foo,bar,baz') - ->build(); - $this->getJWESerializerManager() - ->serialize('jwe_json_flattened', $jwe, 0); - } - #[Test] public function foreignKeyManagementModeForbidden(): void { @@ -219,7 +186,7 @@ public function foreignKeyManagementModeForbidden(): void $this->expectExceptionMessage('Foreign key management mode forbidden.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['dir', 'ECDH-ES+A256KW'], ['A256CBC-HS512'], ['DEF']); + ->create(['dir', 'ECDH-ES+A256KW', 'A256CBC-HS512']); $jweBuilder ->create() @@ -245,7 +212,7 @@ public function operationNotAllowedForTheKey(): void $this->expectExceptionMessage('Key cannot be used to encrypt'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweBuilder ->create() @@ -253,7 +220,6 @@ public function operationNotAllowedForTheKey(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getSigningKey()) ->build(); @@ -266,7 +232,7 @@ public function algorithmNotAllowedForTheKey(): void $this->expectExceptionMessage('Key is only allowed for algorithm "RSA-OAEP".'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'A256CBC-HS512']); $jweBuilder ->create() @@ -274,7 +240,6 @@ public function algorithmNotAllowedForTheKey(): void ->withSharedProtectedHeader([ 'enc' => 'A256CBC-HS512', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKeyWithAlgorithm()) ->build(); @@ -284,9 +249,9 @@ public function algorithmNotAllowedForTheKey(): void public function encryptAndLoadFlattenedWithDeflateCompression(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA-OAEP-256', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA-OAEP-256', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() @@ -295,7 +260,6 @@ public function encryptAndLoadFlattenedWithDeflateCompression(): void 'kid' => '123456789', 'enc' => 'A128CBC-HS256', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -307,7 +271,6 @@ public function encryptAndLoadFlattenedWithDeflateCompression(): void static::assertSame('RSA-OAEP-256', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A128CBC-HS256', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertSame('DEF', $loaded->getSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -325,7 +288,7 @@ public function algParameterIsMissing(): void $this->expectExceptionMessage('Parameter "alg" is missing.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create([], ['A256CBC-HS512'], ['DEF']); + ->create(['A256CBC-HS512']); $jweBuilder ->create() @@ -333,7 +296,6 @@ public function algParameterIsMissing(): void ->withSharedProtectedHeader([ 'kid' => '123456789', 'enc' => 'A256CBC-HS512', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -346,7 +308,7 @@ public function encParameterIsMissing(): void $this->expectExceptionMessage('Parameter "enc" is missing.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], [], ['DEF']); + ->create(['RSA-OAEP-256']); $jweBuilder ->create() @@ -354,7 +316,6 @@ public function encParameterIsMissing(): void ->withSharedProtectedHeader([ 'kid' => '123456789', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -364,12 +325,10 @@ public function encParameterIsMissing(): void public function notAKeyEncryptionAlgorithm(): void { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - 'The key encryption algorithm "A256CBC-HS512" is not supported or not a key encryption algorithm instance.' - ); + $this->expectExceptionMessage('The algorithm "A256CBC-HS512" is not supported.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A256CBC-HS512'], ['A256CBC-HS512'], ['DEF']); + ->create(['A256CBC-HS512', 'A256CBC-HS512']); $jweBuilder ->create() @@ -378,7 +337,6 @@ public function notAKeyEncryptionAlgorithm(): void 'kid' => '123456789', 'enc' => 'A256CBC-HS512', 'alg' => 'A256CBC-HS512', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -388,12 +346,10 @@ public function notAKeyEncryptionAlgorithm(): void public function notAContentEncryptionAlgorithm(): void { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - 'The content encryption algorithm "RSA-OAEP-256" is not supported or not a content encryption algorithm instance.' - ); + $this->expectExceptionMessage('The algorithm "RSA-OAEP-256" is not supported.'); $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256'], ['RSA-OAEP-256'], ['DEF']); + ->create(['RSA-OAEP-256', 'RSA-OAEP-256']); $jweBuilder ->create() @@ -402,7 +358,6 @@ public function notAContentEncryptionAlgorithm(): void 'kid' => '123456789', 'enc' => 'RSA-OAEP-256', 'alg' => 'RSA-OAEP-256', - 'zip' => 'DEF', ]) ->addRecipient($this->getRSARecipientKey()) ->build(); @@ -412,9 +367,9 @@ public function notAContentEncryptionAlgorithm(): void public function encryptAndLoadCompactWithDirectKeyEncryption(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['dir'], ['A192CBC-HS384'], ['DEF']); + ->create(['dir', 'A192CBC-HS384']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['dir'], ['A192CBC-HS384'], ['DEF']); + ->create(['dir', 'A192CBC-HS384']); $jwe = $jweBuilder ->create() @@ -434,7 +389,6 @@ public function encryptAndLoadCompactWithDirectKeyEncryption(): void static::assertSame('dir', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A192CBC-HS384', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertFalse($loaded->hasSharedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getSymmetricKeySet(), 0)); @@ -449,9 +403,9 @@ public function encryptAndLoadCompactWithDirectKeyEncryption(): void public function encryptAndLoadCompactKeyAgreement(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES'], ['A192CBC-HS384'], ['DEF']); + ->create(['ECDH-ES', 'A192CBC-HS384']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES'], ['A192CBC-HS384'], ['DEF']); + ->create(['ECDH-ES', 'A192CBC-HS384']); $payload = json_encode([ 'user_id' => '1234', @@ -475,7 +429,6 @@ public function encryptAndLoadCompactKeyAgreement(): void static::assertSame('ECDH-ES', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A192CBC-HS384', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertFalse($loaded->hasSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -487,9 +440,9 @@ public function encryptAndLoadCompactKeyAgreement(): void public function encryptAndLoadCompactKeyAgreementWithWrappingCompact(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES+A256KW'], ['A256CBC-HS512'], ['DEF']); + ->create(['ECDH-ES+A256KW', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A256KW'], ['A256CBC-HS512'], ['DEF']); + ->create(['ECDH-ES+A256KW', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -509,8 +462,6 @@ public function encryptAndLoadCompactKeyAgreementWithWrappingCompact(): void static::assertSame('ECDH-ES+A256KW', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertFalse($loaded->hasSharedProtectedHeaderParameter('zip')); - static::assertFalse($loaded->hasSharedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -523,9 +474,9 @@ public function encryptAndLoadCompactKeyAgreementWithWrappingCompact(): void public function encryptAndLoadWithGCMAndAAD(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES+A256KW'], ['A256GCM'], ['DEF']); + ->create(['ECDH-ES+A256KW', 'A256GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A256KW'], ['A256GCM'], ['DEF']); + ->create(['ECDH-ES+A256KW', 'A256GCM']); $jwe = $jweBuilder ->create() @@ -546,8 +497,6 @@ public function encryptAndLoadWithGCMAndAAD(): void static::assertSame('ECDH-ES+A256KW', $loaded->getSharedProtectedHeaderParameter('alg')); static::assertSame('A256GCM', $loaded->getSharedProtectedHeaderParameter('enc')); - static::assertFalse($loaded->hasSharedProtectedHeaderParameter('zip')); - static::assertFalse($loaded->hasSharedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); @@ -560,9 +509,9 @@ public function encryptAndLoadWithGCMAndAAD(): void public function encryptAndLoadCompactKeyAgreementWithWrapping(): void { $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP-256', 'ECDH-ES+A256KW'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'ECDH-ES+A256KW', 'A256CBC-HS512']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP-256', 'ECDH-ES+A256KW'], ['A256CBC-HS512'], ['DEF']); + ->create(['RSA-OAEP-256', 'ECDH-ES+A256KW', 'A256CBC-HS512']); $jwe = $jweBuilder ->create() @@ -591,8 +540,6 @@ public function encryptAndLoadCompactKeyAgreementWithWrapping(): void static::assertSame('A256CBC-HS512', $loaded->getSharedProtectedHeaderParameter('enc')); static::assertSame('ECDH-ES+A256KW', $loaded->getRecipient(0)->getHeaderParameter('alg')); static::assertSame('RSA-OAEP-256', $loaded->getRecipient(1)->getHeaderParameter('alg')); - static::assertFalse($loaded->hasSharedHeaderParameter('zip')); - static::assertFalse($loaded->hasSharedProtectedHeaderParameter('zip')); static::assertNull($loaded->getPayload()); static::assertTrue($jweDecrypter->decryptUsingKeySet($loaded, $this->getPrivateKeySet(), 0)); diff --git a/tests/Component/Encryption/InvalidCurveAttackTest.php b/tests/Component/Encryption/InvalidCurveAttackTest.php index 640313487..2f32fb662 100644 --- a/tests/Component/Encryption/InvalidCurveAttackTest.php +++ b/tests/Component/Encryption/InvalidCurveAttackTest.php @@ -18,7 +18,7 @@ public function curveCheckNegativeP256AttackPt1(): void $maliciousJWE = 'eyJhbGciOiJFQ0RILUVTK0ExMjhLVyIsImVuYyI6IkExMjhDQkMtSFMyNTYiLCJlcGsiOnsia3R5IjoiRUMiLCJ4IjoiZ1RsaTY1ZVRRN3otQmgxNDdmZjhLM203azJVaURpRzJMcFlrV0FhRkpDYyIsInkiOiJjTEFuakthNGJ6akQ3REpWUHdhOUVQclJ6TUc3ck9OZ3NpVUQta2YzMEZzIiwiY3J2IjoiUC0yNTYifX0.qGAdxtEnrV_3zbIxU2ZKrMWcejNltjA_dtefBFnRh9A2z9cNIqYRWg.pEA5kX304PMCOmFSKX_cEg.a9fwUrx2JXi1OnWEMOmZhXd94-bEGCH9xxRwqcGuG2AMo-AwHoljdsH5C_kcTqlXS5p51OB1tvgQcMwB5rpTxg.72CHiYFecyDvuUa43KKT6w'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A128KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($maliciousJWE); @@ -38,7 +38,7 @@ public function curveCheckNegativeP256AttackPt2(): void // The malicious JWE contains a public key with order 2447 $maliciousJWE = 'eyJhbGciOiJFQ0RILUVTK0ExMjhLVyIsImVuYyI6IkExMjhDQkMtSFMyNTYiLCJlcGsiOnsia3R5IjoiRUMiLCJ4IjoiWE9YR1E5XzZRQ3ZCZzN1OHZDSS1VZEJ2SUNBRWNOTkJyZnFkN3RHN29RNCIsInkiOiJoUW9XTm90bk56S2x3aUNuZUprTElxRG5UTnc3SXNkQkM1M1ZVcVZqVkpjIiwiY3J2IjoiUC0yNTYifX0.UGb3hX3ePAvtFB9TCdWsNkFTv9QWxSr3MpYNiSBdW630uRXRBT3sxw.6VpU84oMob16DxOR98YTRw.y1UslvtkoWdl9HpugfP0rSAkTw1xhm_LbK1iRXzGdpYqNwIG5VU33UBpKAtKFBoA1Kk_sYtfnHYAvn-aes4FTg.UZPN8h7FcvA5MIOq-Pkj8A'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A128KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($maliciousJWE); diff --git a/tests/Component/Encryption/JWEFlattenedTest.php b/tests/Component/Encryption/JWEFlattenedTest.php index fd4e21a3e..c21c45909 100644 --- a/tests/Component/Encryption/JWEFlattenedTest.php +++ b/tests/Component/Encryption/JWEFlattenedTest.php @@ -20,7 +20,7 @@ final class JWEFlattenedTest extends EncryptionTestCase public function loadFlattenedJWE(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['A128KW', 'A128CBC-HS256']); $loaded = $this->getJWESerializerManager() ->unserialize( diff --git a/tests/Component/Encryption/JWELoaderTest.php b/tests/Component/Encryption/JWELoaderTest.php index 754e25928..a6f3b3a4e 100644 --- a/tests/Component/Encryption/JWELoaderTest.php +++ b/tests/Component/Encryption/JWELoaderTest.php @@ -101,7 +101,7 @@ private function getJWELoader(): JWELoader { if ($this->jweLoader === null) { $this->jweLoader = $this->getJWELoaderFactory() - ->create(['jwe_compact'], ['A128KW'], ['A128GCM'], ['DEF']); + ->create(['jwe_compact'], ['A128KW'], ['A128GCM']); } return $this->jweLoader; diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php index fae1ff622..ef018f35f 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php @@ -49,7 +49,7 @@ public function a128KWAndA128GCMEncryptionProtectedContentOnly(): void $expected_tag = 'e2m0Vm7JvjK2VpCKXS-kyg'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $loaded_flattened_json = $this->getJWESerializerManager() ->unserialize($expected_flattened_json); @@ -111,9 +111,9 @@ public function a128KWAndA128GCMEncryptionProtectedContentOnlyBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php index 5a42d8e81..e8e5d5894 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php @@ -48,7 +48,7 @@ public function a128KWAndA128GCMEncryption(): void $expected_tag = 'ER7MWJZ1FBI_NKvn7Zb1Lw'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -120,9 +120,9 @@ public function a128KWAndA128GCMEncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php index e0dbc1766..afe6a5dc9 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php @@ -48,7 +48,7 @@ public function a128KWAndA128GCMEncryptionWithAdditionalAuthenticatedData(): voi $expected_tag = 'vOaH_Rajnpy_3hOtqvZHRA'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $loaded_flattened_json = $this->getJWESerializerManager() ->unserialize($expected_flattened_json); @@ -108,9 +108,9 @@ public function a128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataBis(): ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php index 5311b9fe9..f8b1175f9 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php @@ -49,7 +49,7 @@ public function a128KWAndA128GCMEncryptionWithCompression(): void $expected_tag = 'VILuUwuIxaLVmh5X-T7kmA'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM'], null, ['DEF']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -118,13 +118,12 @@ public function a128KWAndA128GCMEncryptionWithCompressionBis(): void 'alg' => 'A128KW', 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', 'enc' => 'A128GCM', - 'zip' => 'DEF', ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php index e62dd5494..281d10259 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php @@ -50,7 +50,7 @@ public function a128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValues(): v $expected_tag = 'fNYLqpUe84KD45lvDiaBAQ'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $loaded_flattened_json = $this->getJWESerializerManager() ->unserialize($expected_flattened_json); @@ -113,9 +113,9 @@ public function a128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesBis() ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128GCM'], ['DEF']); + ->create(['A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php index 8858445e1..a069e51f2 100644 --- a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php @@ -56,7 +56,7 @@ public function a256GCMKWAndA128CBCHS256Encryption(): void $expected_tag = 'DKW7jrb4WaRSNfbXVPlT5g'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['A256GCMKW', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -128,9 +128,9 @@ public function a256GCMKWAndA128CBCHS256EncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['A256GCMKW', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['A256GCMKW', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php index 9c98d0118..556c4bc9b 100644 --- a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php @@ -46,7 +46,7 @@ public function dirAndA128GCMEncryption(): void $expected_tag = 'vbb32Xvllea2OtmHAdccRQ'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['dir'], ['A128GCM'], ['DEF']); + ->create(['dir', 'A128GCM']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -93,9 +93,9 @@ public function dirAndA128GCMEncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['dir'], ['A128GCM'], ['DEF']); + ->create(['dir', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['dir'], ['A128GCM'], ['DEF']); + ->create(['dir', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php index 0ac5faf70..6d1324ab3 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php @@ -56,7 +56,7 @@ public function eCDHESA128KWAndA128GCMEncryption(): void $expected_tag = 'WuGzxmcreYjpHGJoa17EBg'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A128KW'], ['A128GCM'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128GCM']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -139,9 +139,9 @@ public function eCDHESA128KWAndA128GCMEncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES+A128KW'], ['A128GCM'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES+A128KW'], ['A128GCM'], ['DEF']); + ->create(['ECDH-ES+A128KW', 'A128GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php index 045db225e..13649d14e 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php @@ -54,7 +54,7 @@ public function eCDHESAndA128CBCHS256Encryption(): void $expected_tag = 'WCCkNa-x4BeB9hIDIfFuhg'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES'], ['A128CBC-HS256'], ['DEF']); + ->create(['ECDH-ES', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -113,9 +113,9 @@ public function eCDHESAndA128CBCHS256EncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['ECDH-ES'], ['A128CBC-HS256'], ['DEF']); + ->create(['ECDH-ES', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['ECDH-ES'], ['A128CBC-HS256'], ['DEF']); + ->create(['ECDH-ES', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php index eae257f36..f07db246d 100644 --- a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php @@ -98,7 +98,7 @@ public function multipleRecipientEncryption(): void $expected_tag = 'BESYyFN7T09KY7i8zKs5_g'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW', 'A128CBC-HS256']); $loaded_json = $this->getJWESerializerManager() ->unserialize($expected_json); @@ -209,9 +209,9 @@ public function multipleRecipientEncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'ECDH-ES+A256KW', 'A256GCMKW', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() @@ -295,7 +295,7 @@ public function multipleRecipientEncryptionWithDifferentContentEncryptionAlgorit ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA1_5', 'A256GCMKW'], ['A128CBC-HS256', 'A128GCM'], ['DEF']); + ->create(['RSA1_5', 'A256GCMKW', 'A128CBC-HS256', 'A128GCM']); $jweBuilder ->create() ->withPayload($expected_payload) diff --git a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php index fe8c16a2b..de912c4f7 100644 --- a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php @@ -71,7 +71,7 @@ public function pBES2HS512A256KWAndA128CBCHS256Encryption(): void $expected_tag = '0HlwodAhOCILG5SQ2LQ9dg'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['PBES2-HS512+A256KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['PBES2-HS512+A256KW', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -172,9 +172,9 @@ public function pBES2HS512A256KWAndA128CBCHS256EncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['PBES2-HS512+A256KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['PBES2-HS512+A256KW', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['PBES2-HS512+A256KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['PBES2-HS512+A256KW', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php index 8c8796809..1537fde18 100644 --- a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php @@ -54,7 +54,7 @@ public function rSA15AndA128CBCHS256Encryption(): void $expected_tag = 'kvKuFBXHe5mQr4lqgobAUg'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128CBC-HS256']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -132,9 +132,9 @@ public function rSA15AndA128CBCHS256EncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA1_5'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128CBC-HS256']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128CBC-HS256']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php index 1a8491304..d9217fb97 100644 --- a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php @@ -55,7 +55,7 @@ public function rSAOAEPAndA256GCMEncryption(): void $expected_tag = 'UCGiqJxhBI3IFVdPalHHvA'; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP'], ['A256GCM'], ['DEF']); + ->create(['RSA-OAEP', 'A256GCM']); $loaded_compact_json = $this->getJWESerializerManager() ->unserialize($expected_compact_json); @@ -134,9 +134,9 @@ public function rSAOAEPAndA256GCMEncryptionBis(): void ]; $jweBuilder = $this->getJWEBuilderFactory() - ->create(['RSA-OAEP'], ['A256GCM'], ['DEF']); + ->create(['RSA-OAEP', 'A256GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP'], ['A256GCM'], ['DEF']); + ->create(['RSA-OAEP', 'A256GCM']); $jwe = $jweBuilder ->create() diff --git a/tests/Component/Encryption/RSAEncryptionTest.php b/tests/Component/Encryption/RSAEncryptionTest.php index 2448a3013..f0e1c1ea5 100644 --- a/tests/Component/Encryption/RSAEncryptionTest.php +++ b/tests/Component/Encryption/RSAEncryptionTest.php @@ -19,7 +19,7 @@ final class RSAEncryptionTest extends EncryptionTestCase public function loadJWEFromRFC7516(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128CBC-HS256']); $loaded = $this->getJWESerializerManager() ->unserialize( @@ -40,7 +40,7 @@ public function loadJWEFromRFC7516(): void public function loadJWEJSONSerialization(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5', 'A128KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128KW', 'A128CBC-HS256']); $loaded = $this->getJWESerializerManager() ->unserialize( diff --git a/tests/Component/Encryption/RSAKeyEncryptionTest.php b/tests/Component/Encryption/RSAKeyEncryptionTest.php index c2006b3ec..f134d6e2e 100644 --- a/tests/Component/Encryption/RSAKeyEncryptionTest.php +++ b/tests/Component/Encryption/RSAKeyEncryptionTest.php @@ -252,7 +252,7 @@ public function rSAOAEP256EncryptionAndDecryption(): void public function loadJWK1(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP'], ['A256GCM'], ['DEF']); + ->create(['RSA-OAEP', 'A256GCM']); $loaded = $this->getJWESerializerManager() ->unserialize( @@ -273,7 +273,7 @@ public function loadJWK1(): void public function loadJWK2(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA1_5'], ['A128CBC-HS256'], ['DEF']); + ->create(['RSA1_5', 'A128CBC-HS256']); $loaded = $this->getJWESerializerManager() ->unserialize( @@ -292,7 +292,7 @@ public function loadJWK2(): void public function loadJWK3(): void { $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['A128KW'], ['A128CBC-HS256'], ['DEF']); + ->create(['A128KW', 'A128CBC-HS256']); $loaded = $this->getJWESerializerManager() ->unserialize( diff --git a/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php b/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php index a7b7fca2e..bdc60a203 100644 --- a/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php +++ b/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php @@ -27,9 +27,9 @@ public function encryptionAlgorithms(string $encryption_algorithm): void ]); $jweBuilder = $this->getJWEBuilderFactory() - ->create([$encryption_algorithm], ['A256GCM'], ['DEF']); + ->create([$encryption_algorithm, 'A256GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create([$encryption_algorithm], ['A256GCM'], ['DEF']); + ->create([$encryption_algorithm, 'A256GCM']); $jwt = $jweBuilder ->create() @@ -60,9 +60,9 @@ public function encryptionAlgorithmsWithMinimalRsaKey(string $encryption_algorit ]); $jweBuilder = $this->getJWEBuilderFactory() - ->create([$encryption_algorithm], ['A256GCM'], ['DEF']); + ->create([$encryption_algorithm, 'A256GCM']); $jweDecrypter = $this->getJWEDecrypterFactory() - ->create([$encryption_algorithm], ['A256GCM'], ['DEF']); + ->create([$encryption_algorithm, 'A256GCM']); $jwt = $jweBuilder ->create() diff --git a/tests/Component/NestedToken/NestingTest.php b/tests/Component/NestedToken/NestingTest.php index f1589ce29..e38ff16e7 100644 --- a/tests/Component/NestedToken/NestingTest.php +++ b/tests/Component/NestedToken/NestingTest.php @@ -41,7 +41,7 @@ public function decryption(): void ]; $jweDecrypter = $this->getJWEDecrypterFactory() - ->create(['RSA-OAEP'], ['A128GCM'], ['DEF']); + ->create(['RSA-OAEP', 'A128GCM']); $json_compact = 'eyJhbGciOiJSU0EtT0FFUCIsImN0eSI6IkpXVCIsImVuYyI6IkExMjhHQ00ifQ.a0JHRoITfpX4qRewImjlStn8m3CPxBV1ueYlVhjurCyrBg3I7YhCRYjphDOOS4E7rXbr2Fn6NyQq-A-gqT0FXqNjVOGrG-bi13mwy7RoYhjTkBEC6P7sMYMXXx4gzMedpiJHQVeyI-zkZV7A9matpgevAJWrXzOUysYGTtwoSN6gtUVtlLaivjvb21O0ul4YxSHV-ByK1kyeetRp_fuYJxHoKLQL9P424sKx2WGYb4zsBIPF4ssl_e5IR7nany-25_UmC2urosNkoFz9cQ82MypZP8gqbQJyPN-Fpp4Z-5o6yV64x6yzDUF_5JCIdl-Qv6H5dMVIY7q1eKpXcV1lWO_2FefEBqXxXvIjLeZivjNkzogCq3-IapSjVFnMjBxjpYLT8muaawo1yy1XXMuinIpNcOY3n4KKrXLrCcteX85m4IIHMZa38s1Hpr56fPPseMA-Jltmt-a9iEDtOzhtxz8AXy9tsCAZV2XBWNG8c3kJusAamBKOYwfk7JhLRDgOnJjlJLhn7TI4UxDp9dCmUXEN6z0v23W15qJIEXNJtqnblpymooeWAHCT4e_Owbim1g0AEpTHUdA2iiLNs9WTX_H_TXuPC8yDDhi1smxS_X_xpkIHkiIHWDOLx03BpqDTivpKkBYwqP2UZkcxqX2Fo_GnVrNwlK7Lgxw6FSQvDO0.GbX1i9kXz0sxXPmA.SZI4IvKHmwpazl_pJQXX3mHv1ANnOU4Wf9-utWYUcKrBNgCe2OFMf66cSJ8k2QkxaQD3_R60MGE9ofomwtky3GFxMeGRjtpMt9OAvVLsAXB0_UTCBGyBg3C2bWLXqZlfJAAoJRUPRk-BimYZY81zVBuIhc7HsQePCpu33SzMsFHjn4lP_idrJz_glZTNgKDt8zdnUPauKTKDNOH1DD4fuzvDYfDIAfqGPyL5sVRwbiXpXdGokEszM-9ChMPqW1QNhzuX_Zul3bvrJwr7nuGZs4cUScY3n8yE3AHCLurgls-A9mz1X38xEaulV18l4Fg9tLejdkAuQZjPbqeHQBJe4IwGD5Ee0dQ-Mtz4NnhkIWx-YKBb_Xo2zI3Q_1sYjKUuis7yWW-HTr_vqvFt0bj7WJf2vzB0TZ3dvsoGaTvPH2dyWwumUrlx4gmPUzBdwTO6ubfYSDUEEz5py0d_OtWeUSYcCYBKD-aM7tXg26qJo21gYjLfhn9zy-W19sOCZGuzgFjPhawXHpvnj_t-0_ES96kogjJLxS1IMU9Y5XmnwZMyNc9EIwnogsCg-hVuvzyP0sIruktmI94_SL1xgMl7o03phcTMxtlMizR88NKU1WkBsiXMCjy1Noue7MD-ShDp5dmM.KnIKEhN8U-3C9s4gtSpjSw'; $json_flattened = '{"encrypted_key": "a0JHRoITfpX4qRewImjlStn8m3CPxBV1ueYlVhjurCyrBg3I7YhCRYjphDOOS4E7rXbr2Fn6NyQq-A-gqT0FXqNjVOGrG-bi13mwy7RoYhjTkBEC6P7sMYMXXx4gzMedpiJHQVeyI-zkZV7A9matpgevAJWrXzOUysYGTtwoSN6gtUVtlLaivjvb21O0ul4YxSHV-ByK1kyeetRp_fuYJxHoKLQL9P424sKx2WGYb4zsBIPF4ssl_e5IR7nany-25_UmC2urosNkoFz9cQ82MypZP8gqbQJyPN-Fpp4Z-5o6yV64x6yzDUF_5JCIdl-Qv6H5dMVIY7q1eKpXcV1lWO_2FefEBqXxXvIjLeZivjNkzogCq3-IapSjVFnMjBxjpYLT8muaawo1yy1XXMuinIpNcOY3n4KKrXLrCcteX85m4IIHMZa38s1Hpr56fPPseMA-Jltmt-a9iEDtOzhtxz8AXy9tsCAZV2XBWNG8c3kJusAamBKOYwfk7JhLRDgOnJjlJLhn7TI4UxDp9dCmUXEN6z0v23W15qJIEXNJtqnblpymooeWAHCT4e_Owbim1g0AEpTHUdA2iiLNs9WTX_H_TXuPC8yDDhi1smxS_X_xpkIHkiIHWDOLx03BpqDTivpKkBYwqP2UZkcxqX2Fo_GnVrNwlK7Lgxw6FSQvDO0","protected": "eyJhbGciOiJSU0EtT0FFUCIsImN0eSI6IkpXVCIsImVuYyI6IkExMjhHQ00ifQ","iv": "GbX1i9kXz0sxXPmA","ciphertext": "SZI4IvKHmwpazl_pJQXX3mHv1ANnOU4Wf9-utWYUcKrBNgCe2OFMf66cSJ8k2QkxaQD3_R60MGE9ofomwtky3GFxMeGRjtpMt9OAvVLsAXB0_UTCBGyBg3C2bWLXqZlfJAAoJRUPRk-BimYZY81zVBuIhc7HsQePCpu33SzMsFHjn4lP_idrJz_glZTNgKDt8zdnUPauKTKDNOH1DD4fuzvDYfDIAfqGPyL5sVRwbiXpXdGokEszM-9ChMPqW1QNhzuX_Zul3bvrJwr7nuGZs4cUScY3n8yE3AHCLurgls-A9mz1X38xEaulV18l4Fg9tLejdkAuQZjPbqeHQBJe4IwGD5Ee0dQ-Mtz4NnhkIWx-YKBb_Xo2zI3Q_1sYjKUuis7yWW-HTr_vqvFt0bj7WJf2vzB0TZ3dvsoGaTvPH2dyWwumUrlx4gmPUzBdwTO6ubfYSDUEEz5py0d_OtWeUSYcCYBKD-aM7tXg26qJo21gYjLfhn9zy-W19sOCZGuzgFjPhawXHpvnj_t-0_ES96kogjJLxS1IMU9Y5XmnwZMyNc9EIwnogsCg-hVuvzyP0sIruktmI94_SL1xgMl7o03phcTMxtlMizR88NKU1WkBsiXMCjy1Noue7MD-ShDp5dmM","tag": "KnIKEhN8U-3C9s4gtSpjSw"}'; diff --git a/tests/Component/NestedToken/NestingTokenBuilderTest.php b/tests/Component/NestedToken/NestingTokenBuilderTest.php index 99661f2bc..53b6b19a7 100644 --- a/tests/Component/NestedToken/NestingTokenBuilderTest.php +++ b/tests/Component/NestedToken/NestingTokenBuilderTest.php @@ -88,7 +88,7 @@ public function decryption(): void ]); $nestedTokenBuilder = $this->getNestedTokenBuilderFactory() - ->create(['jwe_compact'], ['RSA-OAEP'], ['A128GCM'], ['DEF'], ['jws_compact'], ['PS256']); + ->create(['jwe_compact'], ['RSA-OAEP', 'A128GCM'], null, null, ['jws_compact'], ['PS256']); $nestedTokenBuilder->create( $payload,