diff --git a/composer.json b/composer.json index 2a60417a..6c663343 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "ext-mbstring": "*", "firebase/php-jwt": "^7.0.0", "monolog/monolog": ">=1.25.0", - "web-token/jwt-framework": "^2.2.11|^3.3.5", + "web-token/jwt-framework": "^2.2.11|^3.3.5|^4.0", "singpolyma/openpgp-php": "0.7.0", "ramsey/uuid": "^4.0" }, diff --git a/lib/Authentication/Util/JWE/JWEUtility.php b/lib/Authentication/Util/JWE/JWEUtility.php index 609290a6..60c92a39 100644 --- a/lib/Authentication/Util/JWE/JWEUtility.php +++ b/lib/Authentication/Util/JWE/JWEUtility.php @@ -9,8 +9,6 @@ use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256; -use Jose\Component\Encryption\Compression\CompressionMethodManager; -use Jose\Component\Encryption\Compression\Deflate; use Jose\Component\Encryption\JWEDecrypter; use Jose\Component\Encryption\Serializer\CompactSerializer; use Jose\Component\Encryption\Serializer\JWESerializerManager; @@ -54,27 +52,13 @@ public static function decryptJWEUsingPEM(MerchantConfiguration $merchantConfig, new CompactSerializer(), ]); - // The key encryption algorithm manager with RSA-OAEP and RSA-OAEP-256 algorithms. - $keyEncryptionAlgorithmManager = new AlgorithmManager([ + $algorithmManager = new AlgorithmManager([ new RSAOAEP(), - new RSAOAEP256() - ]); - - // The content encryption algorithm manager with the A256GCM algorithm. - $contentEncryptionAlgorithmManager = new AlgorithmManager([ + new RSAOAEP256(), new A256GCM(), ]); - // The compression method manager with the DEF (Deflate) method. - $compressionMethodManager = new CompressionMethodManager([ - new Deflate() - ]); - - $jweDecrypter = new JWEDecrypter( - $keyEncryptionAlgorithmManager, - $contentEncryptionAlgorithmManager, - $compressionMethodManager - ); + $jweDecrypter = new JWEDecrypter($algorithmManager); $jwe = $serializerManager->unserialize($jweBase64Data); if($jweDecrypter -> decryptUsingKey($jwe, $jweKey, 0)) { @@ -86,14 +70,9 @@ public static function decryptJWEUsingPEM(MerchantConfiguration $merchantConfig, public static function decryptJWEUsingPrivateKey(string $privateKey, string $encodedResponse) { $jwk = JWKFactory::createFromKey($privateKey); - // The key encryption algorithm manager with RSA-OAEP and RSA-OAEP-256 algorithms. - $keyEncryptionAlgorithmManager = new AlgorithmManager([ + $algorithmManager = new AlgorithmManager([ new RSAOAEP(), - new RSAOAEP256() - ]); - - // The content encryption algorithm manager with the A256CBC-HS256 algorithm. - $contentEncryptionAlgorithmManager = new AlgorithmManager([ + new RSAOAEP256(), new A256GCM(), ]); @@ -102,11 +81,7 @@ public static function decryptJWEUsingPrivateKey(string $privateKey, string $enc new CompactSerializer(), ]); - $jweDecrypter = new JWEDecrypter( - $keyEncryptionAlgorithmManager, - $contentEncryptionAlgorithmManager, - new CompressionMethodManager([new Deflate()]) - ); + $jweDecrypter = new JWEDecrypter($algorithmManager); $jwe = $serializerManager->unserialize($encodedResponse); if($jweDecrypter -> decryptUsingKey($jwe, $jwk, 0)) { diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 36e212fd..63c9035c 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -14,8 +14,6 @@ use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256; use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM; -use Jose\Component\Encryption\Compression\CompressionMethodManager; -use Jose\Component\Encryption\Compression\Deflate; use CyberSource\Authentication\Util\MLEException; use \CyberSource\Authentication\Util\JWE\JWEUtility; @@ -204,15 +202,7 @@ private static function generateToken($cert, $requestBody) new A256GCM() ]); - $compressionManager = new CompressionMethodManager([ - new Deflate() - ]); - - $jweBuilder = new JWEBuilder( - $algorithmManager, - $algorithmManager, - $compressionManager - ); + $jweBuilder = new JWEBuilder($algorithmManager); $jwe = $jweBuilder ->create()