diff --git a/composer.json b/composer.json index a687e7b9..d2e06c5f 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": ">=5.6.0", "ext-json": "*", "guzzlehttp/guzzle": "^6.2.1 || ^7.0.1", - "phpseclib/phpseclib": "^2.0.11", + "phpseclib/phpseclib": "^2.0.11 || ^3.0.0", "gree/jose": "^2.2.1" }, "autoload": { diff --git a/src/Hyperwallet/Util/HyperwalletEncryption.php b/src/Hyperwallet/Util/HyperwalletEncryption.php index 3cc5cbe6..a0f2a2fc 100644 --- a/src/Hyperwallet/Util/HyperwalletEncryption.php +++ b/src/Hyperwallet/Util/HyperwalletEncryption.php @@ -9,8 +9,8 @@ use Hyperwallet\Model\BaseModel; use Hyperwallet\Response\ErrorResponse; use Composer\Autoload\ClassLoader; -use phpseclib\Crypt\RSA; -use phpseclib\Math\BigInteger; +use phpseclib3\Crypt\RSA; +use phpseclib3\Math\BigInteger; use phpseclib\Crypt\Hash; use JOSE_URLSafeBase64; use JOSE_JWS; @@ -220,9 +220,10 @@ private function getPrivateKey($privateKeyData) { array_unshift($coefficients, "phoney"); unset($coefficients[0]); - $pemData = (new RSA())->_convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients); - $privateKey = new RSA(); + $pemData = RSA::_convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients); + $privateKey = RSA::loadKey($pemData); $privateKey->loadKey($pemData); + if ($privateKeyData['alg'] == 'RSA-OAEP-256') { $privateKey->setHash('sha256'); $privateKey->setMGFHash('sha256');