Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
37 changes: 6 additions & 31 deletions lib/Authentication/Util/JWE/JWEUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -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(),
]);

Expand All @@ -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)) {
Expand Down
12 changes: 1 addition & 11 deletions lib/Authentication/Util/MLEUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down